blob: 64456f9a0f6d052ed7f769ecba05ec4c836338cc [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
21#include <asm/mach/arch.h>
22#include <asm/mach/map.h>
23#include <asm/mach/irq.h>
24
25#include <asm/arch/anubis-map.h>
26#include <asm/arch/anubis-irq.h>
27#include <asm/arch/anubis-cpld.h>
28
29#include <asm/hardware.h>
30#include <asm/io.h>
31#include <asm/irq.h>
32#include <asm/mach-types.h>
33
34#include <asm/arch/regs-serial.h>
35#include <asm/arch/regs-gpio.h>
36#include <asm/arch/regs-mem.h>
37#include <asm/arch/regs-lcd.h>
38#include <asm/arch/nand.h>
39
40#include <linux/mtd/mtd.h>
41#include <linux/mtd/nand.h>
42#include <linux/mtd/nand_ecc.h>
43#include <linux/mtd/partitions.h>
44
Ben Dookseac1d8d2007-07-11 10:14:53 +010045#include <net/ax88796.h>
46
Ben Dooksa21765a2007-02-11 18:31:01 +010047#include <asm/plat-s3c24xx/clock.h>
48#include <asm/plat-s3c24xx/devs.h>
49#include <asm/plat-s3c24xx/cpu.h>
Ben Dooks7efb8332005-09-07 11:49:23 +010050
51#define COPYRIGHT ", (c) 2005 Simtec Electronics"
52
53static struct map_desc anubis_iodesc[] __initdata = {
54 /* ISA IO areas */
55
Ben Dooks8dd52312005-11-09 14:05:30 +000056 {
57 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
58 .pfn = __phys_to_pfn(0x0),
59 .length = SZ_4M,
Ben Dooks705630d2006-07-26 20:16:39 +010060 .type = MT_DEVICE,
Ben Dooks8dd52312005-11-09 14:05:30 +000061 }, {
62 .virtual = (u32)S3C24XX_VA_ISA_WORD,
63 .pfn = __phys_to_pfn(0x0),
Ben Dooks705630d2006-07-26 20:16:39 +010064 .length = SZ_4M,
65 .type = MT_DEVICE,
Ben Dooks8dd52312005-11-09 14:05:30 +000066 },
Ben Dooks7efb8332005-09-07 11:49:23 +010067
68 /* we could possibly compress the next set down into a set of smaller tables
69 * pagetables, but that would mean using an L2 section, and it still means
70 * we cannot actually feed the same register to an LDR due to 16K spacing
71 */
72
73 /* CPLD control registers */
74
Ben Dooks8dd52312005-11-09 14:05:30 +000075 {
76 .virtual = (u32)ANUBIS_VA_CTRL1,
77 .pfn = __phys_to_pfn(ANUBIS_PA_CTRL1),
78 .length = SZ_4K,
Ben Dooks705630d2006-07-26 20:16:39 +010079 .type = MT_DEVICE,
Ben Dooks8dd52312005-11-09 14:05:30 +000080 }, {
Ben Dooks6c1640d2007-06-06 10:01:04 +010081 .virtual = (u32)ANUBIS_VA_IDREG,
82 .pfn = __phys_to_pfn(ANUBIS_PA_IDREG),
Ben Dooks8dd52312005-11-09 14:05:30 +000083 .length = SZ_4K,
Ben Dooks705630d2006-07-26 20:16:39 +010084 .type = MT_DEVICE,
Ben Dooks8dd52312005-11-09 14:05:30 +000085 },
Ben Dooks7efb8332005-09-07 11:49:23 +010086};
87
88#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
89#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
90#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
91
92static struct s3c24xx_uart_clksrc anubis_serial_clocks[] = {
93 [0] = {
94 .name = "uclk",
95 .divisor = 1,
96 .min_baud = 0,
97 .max_baud = 0,
98 },
99 [1] = {
100 .name = "pclk",
101 .divisor = 1,
102 .min_baud = 0,
Ben Dooks705630d2006-07-26 20:16:39 +0100103 .max_baud = 0,
Ben Dooks7efb8332005-09-07 11:49:23 +0100104 }
105};
106
107
Ben Dooks66a9b492006-06-18 23:04:05 +0100108static struct s3c2410_uartcfg anubis_uartcfgs[] __initdata = {
Ben Dooks7efb8332005-09-07 11:49:23 +0100109 [0] = {
110 .hwport = 0,
111 .flags = 0,
112 .ucon = UCON,
113 .ulcon = ULCON,
114 .ufcon = UFCON,
115 .clocks = anubis_serial_clocks,
Ben Dooks705630d2006-07-26 20:16:39 +0100116 .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
Ben Dooks7efb8332005-09-07 11:49:23 +0100117 },
118 [1] = {
119 .hwport = 2,
120 .flags = 0,
121 .ucon = UCON,
122 .ulcon = ULCON,
123 .ufcon = UFCON,
124 .clocks = anubis_serial_clocks,
Ben Dooks705630d2006-07-26 20:16:39 +0100125 .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
Ben Dooks7efb8332005-09-07 11:49:23 +0100126 },
127};
128
129/* NAND Flash on Anubis board */
130
131static int external_map[] = { 2 };
132static int chip0_map[] = { 0 };
133static int chip1_map[] = { 1 };
134
Ben Dooks9f693d72005-10-12 19:58:07 +0100135static struct mtd_partition anubis_default_nand_part[] = {
Ben Dooks7efb8332005-09-07 11:49:23 +0100136 [0] = {
137 .name = "Boot Agent",
138 .size = SZ_16K,
Ben Dooks705630d2006-07-26 20:16:39 +0100139 .offset = 0,
Ben Dooks7efb8332005-09-07 11:49:23 +0100140 },
141 [1] = {
142 .name = "/boot",
143 .size = SZ_4M - SZ_16K,
144 .offset = SZ_16K,
145 },
146 [2] = {
147 .name = "user1",
148 .offset = SZ_4M,
149 .size = SZ_32M - SZ_4M,
150 },
151 [3] = {
152 .name = "user2",
153 .offset = SZ_32M,
154 .size = MTDPART_SIZ_FULL,
155 }
156};
157
158/* the Anubis has 3 selectable slots for nand-flash, the two
159 * on-board chip areas, as well as the external slot.
160 *
161 * Note, there is no current hot-plug support for the External
162 * socket.
163*/
164
165static struct s3c2410_nand_set anubis_nand_sets[] = {
166 [1] = {
167 .name = "External",
168 .nr_chips = 1,
169 .nr_map = external_map,
170 .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
Ben Dooks705630d2006-07-26 20:16:39 +0100171 .partitions = anubis_default_nand_part,
Ben Dooks7efb8332005-09-07 11:49:23 +0100172 },
173 [0] = {
174 .name = "chip0",
175 .nr_chips = 1,
176 .nr_map = chip0_map,
177 .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
Ben Dooks705630d2006-07-26 20:16:39 +0100178 .partitions = anubis_default_nand_part,
Ben Dooks7efb8332005-09-07 11:49:23 +0100179 },
180 [2] = {
181 .name = "chip1",
182 .nr_chips = 1,
183 .nr_map = chip1_map,
184 .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
Ben Dooks705630d2006-07-26 20:16:39 +0100185 .partitions = anubis_default_nand_part,
Ben Dooks7efb8332005-09-07 11:49:23 +0100186 },
187};
188
189static void anubis_nand_select(struct s3c2410_nand_set *set, int slot)
190{
191 unsigned int tmp;
192
193 slot = set->nr_map[slot] & 3;
194
195 pr_debug("anubis_nand: selecting slot %d (set %p,%p)\n",
196 slot, set, set->nr_map);
197
198 tmp = __raw_readb(ANUBIS_VA_CTRL1);
199 tmp &= ~ANUBIS_CTRL1_NANDSEL;
200 tmp |= slot;
201
202 pr_debug("anubis_nand: ctrl1 now %02x\n", tmp);
203
204 __raw_writeb(tmp, ANUBIS_VA_CTRL1);
205}
206
207static struct s3c2410_platform_nand anubis_nand_info = {
208 .tacls = 25,
Ben Dooks661e6ac2006-04-02 10:32:46 +0100209 .twrph0 = 55,
210 .twrph1 = 40,
Ben Dooks7efb8332005-09-07 11:49:23 +0100211 .nr_sets = ARRAY_SIZE(anubis_nand_sets),
212 .sets = anubis_nand_sets,
213 .select_chip = anubis_nand_select,
214};
215
Ben Dooksbf1c56a2006-06-19 18:30:04 +0100216/* IDE channels */
217
218static struct resource anubis_ide0_resource[] = {
219 {
220 .start = S3C2410_CS3,
221 .end = S3C2410_CS3 + (8*32) - 1,
222 .flags = IORESOURCE_MEM,
223 }, {
224 .start = S3C2410_CS3 + (1<<26),
225 .end = S3C2410_CS3 + (1<<26) + (8*32) - 1,
226 .flags = IORESOURCE_MEM,
227 }, {
228 .start = IRQ_IDE0,
229 .end = IRQ_IDE0,
230 .flags = IORESOURCE_IRQ,
231 },
232};
233
234static struct platform_device anubis_device_ide0 = {
235 .name = "simtec-ide",
236 .id = 0,
237 .num_resources = ARRAY_SIZE(anubis_ide0_resource),
238 .resource = anubis_ide0_resource,
239};
240
241static struct resource anubis_ide1_resource[] = {
242 {
243 .start = S3C2410_CS4,
244 .end = S3C2410_CS4 + (8*32) - 1,
245 .flags = IORESOURCE_MEM,
246 }, {
247 .start = S3C2410_CS4 + (1<<26),
248 .end = S3C2410_CS4 + (1<<26) + (8*32) - 1,
249 .flags = IORESOURCE_MEM,
250 }, {
251 .start = IRQ_IDE0,
252 .end = IRQ_IDE0,
253 .flags = IORESOURCE_IRQ,
254 },
255};
256
257
258static struct platform_device anubis_device_ide1 = {
259 .name = "simtec-ide",
260 .id = 1,
261 .num_resources = ARRAY_SIZE(anubis_ide1_resource),
262 .resource = anubis_ide1_resource,
263};
Ben Dooks7efb8332005-09-07 11:49:23 +0100264
Ben Dookseac1d8d2007-07-11 10:14:53 +0100265/* Asix AX88796 10/100 ethernet controller */
266
267static struct ax_plat_data anubis_asix_platdata = {
268 .flags = AXFLG_MAC_FROMDEV,
269 .wordlength = 2,
270 .dcr_val = 0x48,
271 .rcr_val = 0x40,
272};
273
274static struct resource anubis_asix_resource[] = {
275 [0] = {
276 .start = S3C2410_CS5,
277 .end = S3C2410_CS5 + (0x20 * 0x20) -1,
278 .flags = IORESOURCE_MEM
279 },
280 [1] = {
281 .start = IRQ_ASIX,
282 .end = IRQ_ASIX,
283 .flags = IORESOURCE_IRQ
284 }
285};
286
287static struct platform_device anubis_device_asix = {
288 .name = "ax88796",
289 .id = 0,
290 .num_resources = ARRAY_SIZE(anubis_asix_resource),
291 .resource = anubis_asix_resource,
292 .dev = {
293 .platform_data = &anubis_asix_platdata,
294 }
295};
296
Ben Dooks7efb8332005-09-07 11:49:23 +0100297/* Standard Anubis devices */
298
299static struct platform_device *anubis_devices[] __initdata = {
300 &s3c_device_usb,
301 &s3c_device_wdt,
302 &s3c_device_adc,
303 &s3c_device_i2c,
304 &s3c_device_rtc,
305 &s3c_device_nand,
Ben Dooksbf1c56a2006-06-19 18:30:04 +0100306 &anubis_device_ide0,
307 &anubis_device_ide1,
Ben Dookseac1d8d2007-07-11 10:14:53 +0100308 &anubis_device_asix,
Ben Dooks7efb8332005-09-07 11:49:23 +0100309};
310
311static struct clk *anubis_clocks[] = {
312 &s3c24xx_dclk0,
313 &s3c24xx_dclk1,
314 &s3c24xx_clkout0,
315 &s3c24xx_clkout1,
316 &s3c24xx_uclk,
317};
318
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100319static void __init anubis_map_io(void)
Ben Dooks7efb8332005-09-07 11:49:23 +0100320{
321 /* initialise the clocks */
322
323 s3c24xx_dclk0.parent = NULL;
324 s3c24xx_dclk0.rate = 12*1000*1000;
325
326 s3c24xx_dclk1.parent = NULL;
327 s3c24xx_dclk1.rate = 24*1000*1000;
328
329 s3c24xx_clkout0.parent = &s3c24xx_dclk0;
330 s3c24xx_clkout1.parent = &s3c24xx_dclk1;
331
332 s3c24xx_uclk.parent = &s3c24xx_clkout1;
333
Ben Dooksce89c202007-04-20 11:15:27 +0100334 s3c24xx_register_clocks(anubis_clocks, ARRAY_SIZE(anubis_clocks));
335
Ben Dooks7efb8332005-09-07 11:49:23 +0100336 s3c_device_nand.dev.platform_data = &anubis_nand_info;
337
338 s3c24xx_init_io(anubis_iodesc, ARRAY_SIZE(anubis_iodesc));
339 s3c24xx_init_clocks(0);
340 s3c24xx_init_uarts(anubis_uartcfgs, ARRAY_SIZE(anubis_uartcfgs));
Ben Dooks7efb8332005-09-07 11:49:23 +0100341
342 /* ensure that the GPIO is setup */
343 s3c2410_gpio_setpin(S3C2410_GPA0, 1);
344}
345
Ben Dooks57e51712007-04-20 11:19:16 +0100346static void __init anubis_init(void)
347{
348 platform_add_devices(anubis_devices, ARRAY_SIZE(anubis_devices));
349}
350
351
Ben Dooks7efb8332005-09-07 11:49:23 +0100352MACHINE_START(ANUBIS, "Simtec-Anubis")
353 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
Ben Dooks7efb8332005-09-07 11:49:23 +0100354 .phys_io = S3C2410_PA_UART,
355 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
356 .boot_params = S3C2410_SDRAM_PA + 0x100,
357 .map_io = anubis_map_io,
Ben Dooks57e51712007-04-20 11:19:16 +0100358 .init_machine = anubis_init,
Ben Dooks7efb8332005-09-07 11:49:23 +0100359 .init_irq = s3c24xx_init_irq,
360 .timer = &s3c24xx_timer,
361MACHINE_END