blob: 53675aa516f30b208ee5afcc6897273f69436c58 [file] [log] [blame]
Ben Dooksa21765a2007-02-11 18:31:01 +01001/* linux/arch/arm/mach-s3c2440/mach-anubis.c
Ben Dooks7efb8332005-09-07 11:49:23 +01002 *
3 * Copyright (c) 2003-2005 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
Ben Dooks7efb8332005-09-07 11:49:23 +01007 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
Ben Dooks7efb8332005-09-07 11:49:23 +010010*/
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/interrupt.h>
15#include <linux/list.h>
16#include <linux/timer.h>
17#include <linux/init.h>
Ben Dooksb6d1f542006-12-17 23:22:26 +010018#include <linux/serial_core.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010019#include <linux/platform_device.h>
Ben Dooks7efb8332005-09-07 11:49:23 +010020
Ben Dooks8a9ccb72007-07-12 10:47:35 +010021#include <linux/sm501.h>
22#include <linux/sm501-regs.h>
23
Ben Dooks7efb8332005-09-07 11:49:23 +010024#include <asm/mach/arch.h>
25#include <asm/mach/map.h>
26#include <asm/mach/irq.h>
27
28#include <asm/arch/anubis-map.h>
29#include <asm/arch/anubis-irq.h>
30#include <asm/arch/anubis-cpld.h>
31
32#include <asm/hardware.h>
33#include <asm/io.h>
34#include <asm/irq.h>
35#include <asm/mach-types.h>
36
37#include <asm/arch/regs-serial.h>
38#include <asm/arch/regs-gpio.h>
39#include <asm/arch/regs-mem.h>
40#include <asm/arch/regs-lcd.h>
41#include <asm/arch/nand.h>
42
43#include <linux/mtd/mtd.h>
44#include <linux/mtd/nand.h>
45#include <linux/mtd/nand_ecc.h>
46#include <linux/mtd/partitions.h>
47
Ben Dookseac1d8d2007-07-11 10:14:53 +010048#include <net/ax88796.h>
49
Ben Dooksa21765a2007-02-11 18:31:01 +010050#include <asm/plat-s3c24xx/clock.h>
51#include <asm/plat-s3c24xx/devs.h>
52#include <asm/plat-s3c24xx/cpu.h>
Ben Dooks7efb8332005-09-07 11:49:23 +010053
54#define COPYRIGHT ", (c) 2005 Simtec Electronics"
55
56static struct map_desc anubis_iodesc[] __initdata = {
57 /* ISA IO areas */
58
Ben Dooks8dd52312005-11-09 14:05:30 +000059 {
60 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
61 .pfn = __phys_to_pfn(0x0),
62 .length = SZ_4M,
Ben Dooks705630d2006-07-26 20:16:39 +010063 .type = MT_DEVICE,
Ben Dooks8dd52312005-11-09 14:05:30 +000064 }, {
65 .virtual = (u32)S3C24XX_VA_ISA_WORD,
66 .pfn = __phys_to_pfn(0x0),
Ben Dooks705630d2006-07-26 20:16:39 +010067 .length = SZ_4M,
68 .type = MT_DEVICE,
Ben Dooks8dd52312005-11-09 14:05:30 +000069 },
Ben Dooks7efb8332005-09-07 11:49:23 +010070
71 /* we could possibly compress the next set down into a set of smaller tables
72 * pagetables, but that would mean using an L2 section, and it still means
73 * we cannot actually feed the same register to an LDR due to 16K spacing
74 */
75
76 /* CPLD control registers */
77
Ben Dooks8dd52312005-11-09 14:05:30 +000078 {
79 .virtual = (u32)ANUBIS_VA_CTRL1,
80 .pfn = __phys_to_pfn(ANUBIS_PA_CTRL1),
81 .length = SZ_4K,
Ben Dooks705630d2006-07-26 20:16:39 +010082 .type = MT_DEVICE,
Ben Dooks8dd52312005-11-09 14:05:30 +000083 }, {
Ben Dooks6c1640d2007-06-06 10:01:04 +010084 .virtual = (u32)ANUBIS_VA_IDREG,
85 .pfn = __phys_to_pfn(ANUBIS_PA_IDREG),
Ben Dooks8dd52312005-11-09 14:05:30 +000086 .length = SZ_4K,
Ben Dooks705630d2006-07-26 20:16:39 +010087 .type = MT_DEVICE,
Ben Dooks8dd52312005-11-09 14:05:30 +000088 },
Ben Dooks7efb8332005-09-07 11:49:23 +010089};
90
91#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
92#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
93#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
94
95static struct s3c24xx_uart_clksrc anubis_serial_clocks[] = {
96 [0] = {
97 .name = "uclk",
98 .divisor = 1,
99 .min_baud = 0,
100 .max_baud = 0,
101 },
102 [1] = {
103 .name = "pclk",
104 .divisor = 1,
105 .min_baud = 0,
Ben Dooks705630d2006-07-26 20:16:39 +0100106 .max_baud = 0,
Ben Dooks7efb8332005-09-07 11:49:23 +0100107 }
108};
109
110
Ben Dooks66a9b492006-06-18 23:04:05 +0100111static struct s3c2410_uartcfg anubis_uartcfgs[] __initdata = {
Ben Dooks7efb8332005-09-07 11:49:23 +0100112 [0] = {
113 .hwport = 0,
114 .flags = 0,
115 .ucon = UCON,
116 .ulcon = ULCON,
117 .ufcon = UFCON,
118 .clocks = anubis_serial_clocks,
Ben Dooks705630d2006-07-26 20:16:39 +0100119 .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
Ben Dooks7efb8332005-09-07 11:49:23 +0100120 },
121 [1] = {
122 .hwport = 2,
123 .flags = 0,
124 .ucon = UCON,
125 .ulcon = ULCON,
126 .ufcon = UFCON,
127 .clocks = anubis_serial_clocks,
Ben Dooks705630d2006-07-26 20:16:39 +0100128 .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
Ben Dooks7efb8332005-09-07 11:49:23 +0100129 },
130};
131
132/* NAND Flash on Anubis board */
133
134static int external_map[] = { 2 };
135static int chip0_map[] = { 0 };
136static int chip1_map[] = { 1 };
137
Ben Dooks9f693d72005-10-12 19:58:07 +0100138static struct mtd_partition anubis_default_nand_part[] = {
Ben Dooks7efb8332005-09-07 11:49:23 +0100139 [0] = {
140 .name = "Boot Agent",
141 .size = SZ_16K,
Ben Dooks705630d2006-07-26 20:16:39 +0100142 .offset = 0,
Ben Dooks7efb8332005-09-07 11:49:23 +0100143 },
144 [1] = {
145 .name = "/boot",
146 .size = SZ_4M - SZ_16K,
147 .offset = SZ_16K,
148 },
149 [2] = {
150 .name = "user1",
151 .offset = SZ_4M,
152 .size = SZ_32M - SZ_4M,
153 },
154 [3] = {
155 .name = "user2",
156 .offset = SZ_32M,
157 .size = MTDPART_SIZ_FULL,
158 }
159};
160
161/* the Anubis has 3 selectable slots for nand-flash, the two
162 * on-board chip areas, as well as the external slot.
163 *
164 * Note, there is no current hot-plug support for the External
165 * socket.
166*/
167
168static struct s3c2410_nand_set anubis_nand_sets[] = {
169 [1] = {
170 .name = "External",
171 .nr_chips = 1,
172 .nr_map = external_map,
173 .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
Ben Dooks705630d2006-07-26 20:16:39 +0100174 .partitions = anubis_default_nand_part,
Ben Dooks7efb8332005-09-07 11:49:23 +0100175 },
176 [0] = {
177 .name = "chip0",
178 .nr_chips = 1,
179 .nr_map = chip0_map,
180 .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
Ben Dooks705630d2006-07-26 20:16:39 +0100181 .partitions = anubis_default_nand_part,
Ben Dooks7efb8332005-09-07 11:49:23 +0100182 },
183 [2] = {
184 .name = "chip1",
185 .nr_chips = 1,
186 .nr_map = chip1_map,
187 .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
Ben Dooks705630d2006-07-26 20:16:39 +0100188 .partitions = anubis_default_nand_part,
Ben Dooks7efb8332005-09-07 11:49:23 +0100189 },
190};
191
192static void anubis_nand_select(struct s3c2410_nand_set *set, int slot)
193{
194 unsigned int tmp;
195
196 slot = set->nr_map[slot] & 3;
197
198 pr_debug("anubis_nand: selecting slot %d (set %p,%p)\n",
199 slot, set, set->nr_map);
200
201 tmp = __raw_readb(ANUBIS_VA_CTRL1);
202 tmp &= ~ANUBIS_CTRL1_NANDSEL;
203 tmp |= slot;
204
205 pr_debug("anubis_nand: ctrl1 now %02x\n", tmp);
206
207 __raw_writeb(tmp, ANUBIS_VA_CTRL1);
208}
209
210static struct s3c2410_platform_nand anubis_nand_info = {
211 .tacls = 25,
Ben Dooks661e6ac2006-04-02 10:32:46 +0100212 .twrph0 = 55,
213 .twrph1 = 40,
Ben Dooks7efb8332005-09-07 11:49:23 +0100214 .nr_sets = ARRAY_SIZE(anubis_nand_sets),
215 .sets = anubis_nand_sets,
216 .select_chip = anubis_nand_select,
217};
218
Ben Dooksbf1c56a2006-06-19 18:30:04 +0100219/* IDE channels */
220
221static struct resource anubis_ide0_resource[] = {
222 {
223 .start = S3C2410_CS3,
224 .end = S3C2410_CS3 + (8*32) - 1,
225 .flags = IORESOURCE_MEM,
226 }, {
227 .start = S3C2410_CS3 + (1<<26),
228 .end = S3C2410_CS3 + (1<<26) + (8*32) - 1,
229 .flags = IORESOURCE_MEM,
230 }, {
231 .start = IRQ_IDE0,
232 .end = IRQ_IDE0,
233 .flags = IORESOURCE_IRQ,
234 },
235};
236
237static struct platform_device anubis_device_ide0 = {
238 .name = "simtec-ide",
239 .id = 0,
240 .num_resources = ARRAY_SIZE(anubis_ide0_resource),
241 .resource = anubis_ide0_resource,
242};
243
244static struct resource anubis_ide1_resource[] = {
245 {
246 .start = S3C2410_CS4,
247 .end = S3C2410_CS4 + (8*32) - 1,
248 .flags = IORESOURCE_MEM,
249 }, {
250 .start = S3C2410_CS4 + (1<<26),
251 .end = S3C2410_CS4 + (1<<26) + (8*32) - 1,
252 .flags = IORESOURCE_MEM,
253 }, {
254 .start = IRQ_IDE0,
255 .end = IRQ_IDE0,
256 .flags = IORESOURCE_IRQ,
257 },
258};
259
260
261static struct platform_device anubis_device_ide1 = {
262 .name = "simtec-ide",
263 .id = 1,
264 .num_resources = ARRAY_SIZE(anubis_ide1_resource),
265 .resource = anubis_ide1_resource,
266};
Ben Dooks7efb8332005-09-07 11:49:23 +0100267
Ben Dookseac1d8d2007-07-11 10:14:53 +0100268/* Asix AX88796 10/100 ethernet controller */
269
270static struct ax_plat_data anubis_asix_platdata = {
271 .flags = AXFLG_MAC_FROMDEV,
272 .wordlength = 2,
273 .dcr_val = 0x48,
274 .rcr_val = 0x40,
275};
276
277static struct resource anubis_asix_resource[] = {
278 [0] = {
279 .start = S3C2410_CS5,
280 .end = S3C2410_CS5 + (0x20 * 0x20) -1,
281 .flags = IORESOURCE_MEM
282 },
283 [1] = {
284 .start = IRQ_ASIX,
285 .end = IRQ_ASIX,
286 .flags = IORESOURCE_IRQ
287 }
288};
289
290static struct platform_device anubis_device_asix = {
291 .name = "ax88796",
292 .id = 0,
293 .num_resources = ARRAY_SIZE(anubis_asix_resource),
294 .resource = anubis_asix_resource,
295 .dev = {
296 .platform_data = &anubis_asix_platdata,
297 }
298};
299
Ben Dooks8a9ccb72007-07-12 10:47:35 +0100300/* SM501 */
301
302static struct resource anubis_sm501_resource[] = {
303 [0] = {
304 .start = S3C2410_CS2,
305 .end = S3C2410_CS2 + SZ_8M,
306 .flags = IORESOURCE_MEM,
307 },
308 [1] = {
309 .start = S3C2410_CS2 + SZ_64M - SZ_2M,
310 .end = S3C2410_CS2 + SZ_64M - 1,
311 .flags = IORESOURCE_MEM,
312 },
313 [2] = {
314 .start = IRQ_EINT0,
315 .end = IRQ_EINT0,
316 .flags = IORESOURCE_IRQ,
317 },
318};
319
320static struct sm501_initdata anubis_sm501_initdata = {
321 .gpio_high = {
322 .set = 0x3F000000, /* 24bit panel */
323 .mask = 0x0,
324 },
325 .misc_timing = {
326 .set = 0x010100, /* SDRAM timing */
327 .mask = 0x1F1F00,
328 },
329 .misc_control = {
330 .set = SM501_MISC_PNL_24BIT,
331 .mask = 0,
332 },
333
334 /* set the SDRAM and bus clocks */
335 .mclk = 72 * MHZ,
336 .m1xclk = 144 * MHZ,
337};
338
339static struct sm501_platdata_gpio_i2c anubis_sm501_gpio_i2c[] = {
340 [0] = {
341 .pin_scl = 44,
342 .pin_sda = 45,
343 },
344 [1] = {
345 .pin_scl = 40,
346 .pin_sda = 41,
347 },
348};
349
350static struct sm501_platdata anubis_sm501_platdata = {
351 .init = &anubis_sm501_initdata,
352 .gpio_i2c = anubis_sm501_gpio_i2c,
353 .gpio_i2c_nr = ARRAY_SIZE(anubis_sm501_gpio_i2c),
354};
355
356static struct platform_device anubis_device_sm501 = {
357 .name = "sm501",
358 .id = 0,
359 .num_resources = ARRAY_SIZE(anubis_sm501_resource),
360 .resource = anubis_sm501_resource,
361 .dev = {
362 .platform_data = &anubis_sm501_platdata,
363 },
364};
365
Ben Dooks7efb8332005-09-07 11:49:23 +0100366/* Standard Anubis devices */
367
368static struct platform_device *anubis_devices[] __initdata = {
369 &s3c_device_usb,
370 &s3c_device_wdt,
371 &s3c_device_adc,
372 &s3c_device_i2c,
373 &s3c_device_rtc,
374 &s3c_device_nand,
Ben Dooksbf1c56a2006-06-19 18:30:04 +0100375 &anubis_device_ide0,
376 &anubis_device_ide1,
Ben Dookseac1d8d2007-07-11 10:14:53 +0100377 &anubis_device_asix,
Ben Dooks8a9ccb72007-07-12 10:47:35 +0100378 &anubis_device_sm501,
Ben Dooks7efb8332005-09-07 11:49:23 +0100379};
380
381static struct clk *anubis_clocks[] = {
382 &s3c24xx_dclk0,
383 &s3c24xx_dclk1,
384 &s3c24xx_clkout0,
385 &s3c24xx_clkout1,
386 &s3c24xx_uclk,
387};
388
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100389static void __init anubis_map_io(void)
Ben Dooks7efb8332005-09-07 11:49:23 +0100390{
391 /* initialise the clocks */
392
393 s3c24xx_dclk0.parent = NULL;
394 s3c24xx_dclk0.rate = 12*1000*1000;
395
396 s3c24xx_dclk1.parent = NULL;
397 s3c24xx_dclk1.rate = 24*1000*1000;
398
399 s3c24xx_clkout0.parent = &s3c24xx_dclk0;
400 s3c24xx_clkout1.parent = &s3c24xx_dclk1;
401
402 s3c24xx_uclk.parent = &s3c24xx_clkout1;
403
Ben Dooksce89c202007-04-20 11:15:27 +0100404 s3c24xx_register_clocks(anubis_clocks, ARRAY_SIZE(anubis_clocks));
405
Ben Dooks7efb8332005-09-07 11:49:23 +0100406 s3c_device_nand.dev.platform_data = &anubis_nand_info;
407
408 s3c24xx_init_io(anubis_iodesc, ARRAY_SIZE(anubis_iodesc));
409 s3c24xx_init_clocks(0);
410 s3c24xx_init_uarts(anubis_uartcfgs, ARRAY_SIZE(anubis_uartcfgs));
Ben Dooks7efb8332005-09-07 11:49:23 +0100411
412 /* ensure that the GPIO is setup */
413 s3c2410_gpio_setpin(S3C2410_GPA0, 1);
414}
415
Ben Dooks57e51712007-04-20 11:19:16 +0100416static void __init anubis_init(void)
417{
418 platform_add_devices(anubis_devices, ARRAY_SIZE(anubis_devices));
419}
420
421
Ben Dooks7efb8332005-09-07 11:49:23 +0100422MACHINE_START(ANUBIS, "Simtec-Anubis")
423 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
Ben Dooks7efb8332005-09-07 11:49:23 +0100424 .phys_io = S3C2410_PA_UART,
425 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
426 .boot_params = S3C2410_SDRAM_PA + 0x100,
427 .map_io = anubis_map_io,
Ben Dooks57e51712007-04-20 11:19:16 +0100428 .init_machine = anubis_init,
Ben Dooks7efb8332005-09-07 11:49:23 +0100429 .init_irq = s3c24xx_init_irq,
430 .timer = &s3c24xx_timer,
431MACHINE_END