blob: 0a5a7e4a24ad6171889642a9335ea0edf1f5c73e [file] [log] [blame]
Ben Dooks7efb8332005-09-07 11:49:23 +01001/* linux/arch/arm/mach-s3c2410/mach-anubis.c
2 *
3 * Copyright (c) 2003-2005 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * Modifications:
14 * 02-May-2005 BJD Copied from mach-bast.c
Ben Dooks5fe10ab2005-09-20 17:24:33 +010015 * 20-Sep-2005 BJD Added static to non-exported items
Ben Dooks7efb8332005-09-07 11:49:23 +010016*/
17
18#include <linux/kernel.h>
19#include <linux/types.h>
20#include <linux/interrupt.h>
21#include <linux/list.h>
22#include <linux/timer.h>
23#include <linux/init.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010024#include <linux/platform_device.h>
Ben Dooks7efb8332005-09-07 11:49:23 +010025
26#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28#include <asm/mach/irq.h>
29
30#include <asm/arch/anubis-map.h>
31#include <asm/arch/anubis-irq.h>
32#include <asm/arch/anubis-cpld.h>
33
34#include <asm/hardware.h>
35#include <asm/io.h>
36#include <asm/irq.h>
37#include <asm/mach-types.h>
38
39#include <asm/arch/regs-serial.h>
40#include <asm/arch/regs-gpio.h>
41#include <asm/arch/regs-mem.h>
42#include <asm/arch/regs-lcd.h>
43#include <asm/arch/nand.h>
44
45#include <linux/mtd/mtd.h>
46#include <linux/mtd/nand.h>
47#include <linux/mtd/nand_ecc.h>
48#include <linux/mtd/partitions.h>
49
50#include "clock.h"
51#include "devs.h"
52#include "cpu.h"
53
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 }, {
84 .virtual = (u32)ANUBIS_VA_CTRL2,
85 .pfn = __phys_to_pfn(ANUBIS_PA_CTRL2),
86 .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 /* IDE drives */
91
Ben Dooks8dd52312005-11-09 14:05:30 +000092 {
93 .virtual = (u32)ANUBIS_IDEPRI,
94 .pfn = __phys_to_pfn(S3C2410_CS3),
95 .length = SZ_1M,
96 .type = MT_DEVICE
97 }, {
98 .virtual = (u32)ANUBIS_IDEPRIAUX,
99 .pfn = __phys_to_pfn(S3C2410_CS3+(1<<26)),
100 .length = SZ_1M,
101 .type = MT_DEVICE
102 }, {
103 .virtual = (u32)ANUBIS_IDESEC,
104 .pfn = __phys_to_pfn(S3C2410_CS4),
105 .length = SZ_1M,
106 .type = MT_DEVICE
107 }, {
108 .virtual = (u32)ANUBIS_IDESECAUX,
109 .pfn = __phys_to_pfn(S3C2410_CS4+(1<<26)),
110 .length = SZ_1M,
111 .type = MT_DEVICE
112 },
Ben Dooks7efb8332005-09-07 11:49:23 +0100113};
114
115#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
116#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
117#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
118
119static struct s3c24xx_uart_clksrc anubis_serial_clocks[] = {
120 [0] = {
121 .name = "uclk",
122 .divisor = 1,
123 .min_baud = 0,
124 .max_baud = 0,
125 },
126 [1] = {
127 .name = "pclk",
128 .divisor = 1,
129 .min_baud = 0,
Ben Dooks705630d2006-07-26 20:16:39 +0100130 .max_baud = 0,
Ben Dooks7efb8332005-09-07 11:49:23 +0100131 }
132};
133
134
Ben Dooks66a9b492006-06-18 23:04:05 +0100135static struct s3c2410_uartcfg anubis_uartcfgs[] __initdata = {
Ben Dooks7efb8332005-09-07 11:49:23 +0100136 [0] = {
137 .hwport = 0,
138 .flags = 0,
139 .ucon = UCON,
140 .ulcon = ULCON,
141 .ufcon = UFCON,
142 .clocks = anubis_serial_clocks,
Ben Dooks705630d2006-07-26 20:16:39 +0100143 .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
Ben Dooks7efb8332005-09-07 11:49:23 +0100144 },
145 [1] = {
146 .hwport = 2,
147 .flags = 0,
148 .ucon = UCON,
149 .ulcon = ULCON,
150 .ufcon = UFCON,
151 .clocks = anubis_serial_clocks,
Ben Dooks705630d2006-07-26 20:16:39 +0100152 .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
Ben Dooks7efb8332005-09-07 11:49:23 +0100153 },
154};
155
156/* NAND Flash on Anubis board */
157
158static int external_map[] = { 2 };
159static int chip0_map[] = { 0 };
160static int chip1_map[] = { 1 };
161
Ben Dooks9f693d72005-10-12 19:58:07 +0100162static struct mtd_partition anubis_default_nand_part[] = {
Ben Dooks7efb8332005-09-07 11:49:23 +0100163 [0] = {
164 .name = "Boot Agent",
165 .size = SZ_16K,
Ben Dooks705630d2006-07-26 20:16:39 +0100166 .offset = 0,
Ben Dooks7efb8332005-09-07 11:49:23 +0100167 },
168 [1] = {
169 .name = "/boot",
170 .size = SZ_4M - SZ_16K,
171 .offset = SZ_16K,
172 },
173 [2] = {
174 .name = "user1",
175 .offset = SZ_4M,
176 .size = SZ_32M - SZ_4M,
177 },
178 [3] = {
179 .name = "user2",
180 .offset = SZ_32M,
181 .size = MTDPART_SIZ_FULL,
182 }
183};
184
185/* the Anubis has 3 selectable slots for nand-flash, the two
186 * on-board chip areas, as well as the external slot.
187 *
188 * Note, there is no current hot-plug support for the External
189 * socket.
190*/
191
192static struct s3c2410_nand_set anubis_nand_sets[] = {
193 [1] = {
194 .name = "External",
195 .nr_chips = 1,
196 .nr_map = external_map,
197 .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
Ben Dooks705630d2006-07-26 20:16:39 +0100198 .partitions = anubis_default_nand_part,
Ben Dooks7efb8332005-09-07 11:49:23 +0100199 },
200 [0] = {
201 .name = "chip0",
202 .nr_chips = 1,
203 .nr_map = chip0_map,
204 .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
Ben Dooks705630d2006-07-26 20:16:39 +0100205 .partitions = anubis_default_nand_part,
Ben Dooks7efb8332005-09-07 11:49:23 +0100206 },
207 [2] = {
208 .name = "chip1",
209 .nr_chips = 1,
210 .nr_map = chip1_map,
211 .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
Ben Dooks705630d2006-07-26 20:16:39 +0100212 .partitions = anubis_default_nand_part,
Ben Dooks7efb8332005-09-07 11:49:23 +0100213 },
214};
215
216static void anubis_nand_select(struct s3c2410_nand_set *set, int slot)
217{
218 unsigned int tmp;
219
220 slot = set->nr_map[slot] & 3;
221
222 pr_debug("anubis_nand: selecting slot %d (set %p,%p)\n",
223 slot, set, set->nr_map);
224
225 tmp = __raw_readb(ANUBIS_VA_CTRL1);
226 tmp &= ~ANUBIS_CTRL1_NANDSEL;
227 tmp |= slot;
228
229 pr_debug("anubis_nand: ctrl1 now %02x\n", tmp);
230
231 __raw_writeb(tmp, ANUBIS_VA_CTRL1);
232}
233
234static struct s3c2410_platform_nand anubis_nand_info = {
235 .tacls = 25,
Ben Dooks661e6ac2006-04-02 10:32:46 +0100236 .twrph0 = 55,
237 .twrph1 = 40,
Ben Dooks7efb8332005-09-07 11:49:23 +0100238 .nr_sets = ARRAY_SIZE(anubis_nand_sets),
239 .sets = anubis_nand_sets,
240 .select_chip = anubis_nand_select,
241};
242
Ben Dooksbf1c56a2006-06-19 18:30:04 +0100243/* IDE channels */
244
245static struct resource anubis_ide0_resource[] = {
246 {
247 .start = S3C2410_CS3,
248 .end = S3C2410_CS3 + (8*32) - 1,
249 .flags = IORESOURCE_MEM,
250 }, {
251 .start = S3C2410_CS3 + (1<<26),
252 .end = S3C2410_CS3 + (1<<26) + (8*32) - 1,
253 .flags = IORESOURCE_MEM,
254 }, {
255 .start = IRQ_IDE0,
256 .end = IRQ_IDE0,
257 .flags = IORESOURCE_IRQ,
258 },
259};
260
261static struct platform_device anubis_device_ide0 = {
262 .name = "simtec-ide",
263 .id = 0,
264 .num_resources = ARRAY_SIZE(anubis_ide0_resource),
265 .resource = anubis_ide0_resource,
266};
267
268static struct resource anubis_ide1_resource[] = {
269 {
270 .start = S3C2410_CS4,
271 .end = S3C2410_CS4 + (8*32) - 1,
272 .flags = IORESOURCE_MEM,
273 }, {
274 .start = S3C2410_CS4 + (1<<26),
275 .end = S3C2410_CS4 + (1<<26) + (8*32) - 1,
276 .flags = IORESOURCE_MEM,
277 }, {
278 .start = IRQ_IDE0,
279 .end = IRQ_IDE0,
280 .flags = IORESOURCE_IRQ,
281 },
282};
283
284
285static struct platform_device anubis_device_ide1 = {
286 .name = "simtec-ide",
287 .id = 1,
288 .num_resources = ARRAY_SIZE(anubis_ide1_resource),
289 .resource = anubis_ide1_resource,
290};
Ben Dooks7efb8332005-09-07 11:49:23 +0100291
292/* Standard Anubis devices */
293
294static struct platform_device *anubis_devices[] __initdata = {
295 &s3c_device_usb,
296 &s3c_device_wdt,
297 &s3c_device_adc,
298 &s3c_device_i2c,
299 &s3c_device_rtc,
300 &s3c_device_nand,
Ben Dooksbf1c56a2006-06-19 18:30:04 +0100301 &anubis_device_ide0,
302 &anubis_device_ide1,
Ben Dooks7efb8332005-09-07 11:49:23 +0100303};
304
305static struct clk *anubis_clocks[] = {
306 &s3c24xx_dclk0,
307 &s3c24xx_dclk1,
308 &s3c24xx_clkout0,
309 &s3c24xx_clkout1,
310 &s3c24xx_uclk,
311};
312
313static struct s3c24xx_board anubis_board __initdata = {
314 .devices = anubis_devices,
315 .devices_count = ARRAY_SIZE(anubis_devices),
316 .clocks = anubis_clocks,
Ben Dooks705630d2006-07-26 20:16:39 +0100317 .clocks_count = ARRAY_SIZE(anubis_clocks),
Ben Dooks7efb8332005-09-07 11:49:23 +0100318};
319
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100320static void __init anubis_map_io(void)
Ben Dooks7efb8332005-09-07 11:49:23 +0100321{
322 /* initialise the clocks */
323
324 s3c24xx_dclk0.parent = NULL;
325 s3c24xx_dclk0.rate = 12*1000*1000;
326
327 s3c24xx_dclk1.parent = NULL;
328 s3c24xx_dclk1.rate = 24*1000*1000;
329
330 s3c24xx_clkout0.parent = &s3c24xx_dclk0;
331 s3c24xx_clkout1.parent = &s3c24xx_dclk1;
332
333 s3c24xx_uclk.parent = &s3c24xx_clkout1;
334
335 s3c_device_nand.dev.platform_data = &anubis_nand_info;
336
337 s3c24xx_init_io(anubis_iodesc, ARRAY_SIZE(anubis_iodesc));
338 s3c24xx_init_clocks(0);
339 s3c24xx_init_uarts(anubis_uartcfgs, ARRAY_SIZE(anubis_uartcfgs));
340 s3c24xx_set_board(&anubis_board);
341
342 /* ensure that the GPIO is setup */
343 s3c2410_gpio_setpin(S3C2410_GPA0, 1);
344}
345
346MACHINE_START(ANUBIS, "Simtec-Anubis")
347 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
Ben Dooks7efb8332005-09-07 11:49:23 +0100348 .phys_io = S3C2410_PA_UART,
349 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
350 .boot_params = S3C2410_SDRAM_PA + 0x100,
351 .map_io = anubis_map_io,
352 .init_irq = s3c24xx_init_irq,
353 .timer = &s3c24xx_timer,
354MACHINE_END