1 /* linux/arch/arm/mach-s3c2410/mach-bast.c
3 * Copyright (c) 2003-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * http://www.simtec.co.uk/products/EB2410ITX/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/interrupt.h>
16 #include <linux/list.h>
17 #include <linux/timer.h>
18 #include <linux/init.h>
19 #include <linux/serial_core.h>
20 #include <linux/platform_device.h>
21 #include <linux/dm9000.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/map.h>
25 #include <asm/mach/irq.h>
27 #include <asm/arch/bast-map.h>
28 #include <asm/arch/bast-irq.h>
29 #include <asm/arch/bast-cpld.h>
31 #include <asm/hardware.h>
34 #include <asm/mach-types.h>
36 //#include <asm/debug-ll.h>
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>
42 #include <asm/arch/nand.h>
43 #include <asm/arch/iic.h>
44 #include <asm/arch/fb.h>
46 #include <linux/mtd/mtd.h>
47 #include <linux/mtd/nand.h>
48 #include <linux/mtd/nand_ecc.h>
49 #include <linux/mtd/partitions.h>
51 #include <linux/serial_8250.h>
53 #include <asm/plat-s3c24xx/clock.h>
54 #include <asm/plat-s3c24xx/devs.h>
55 #include <asm/plat-s3c24xx/cpu.h>
56 #include "usb-simtec.h"
58 #define COPYRIGHT ", (c) 2004-2005 Simtec Electronics"
60 /* macros for virtual address mods for the io space entries */
61 #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
62 #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
63 #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
64 #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
66 /* macros to modify the physical addresses for io space */
68 #define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
69 #define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
70 #define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
71 #define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
73 static struct map_desc bast_iodesc[] __initdata = {
76 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
77 .pfn = PA_CS2(BAST_PA_ISAIO),
81 .virtual = (u32)S3C24XX_VA_ISA_WORD,
82 .pfn = PA_CS3(BAST_PA_ISAIO),
86 /* bast CPLD control registers, and external interrupt controls */
88 .virtual = (u32)BAST_VA_CTRL1,
89 .pfn = __phys_to_pfn(BAST_PA_CTRL1),
93 .virtual = (u32)BAST_VA_CTRL2,
94 .pfn = __phys_to_pfn(BAST_PA_CTRL2),
98 .virtual = (u32)BAST_VA_CTRL3,
99 .pfn = __phys_to_pfn(BAST_PA_CTRL3),
103 .virtual = (u32)BAST_VA_CTRL4,
104 .pfn = __phys_to_pfn(BAST_PA_CTRL4),
110 .virtual = (u32)BAST_VA_PC104_IRQREQ,
111 .pfn = __phys_to_pfn(BAST_PA_PC104_IRQREQ),
115 .virtual = (u32)BAST_VA_PC104_IRQRAW,
116 .pfn = __phys_to_pfn(BAST_PA_PC104_IRQRAW),
120 .virtual = (u32)BAST_VA_PC104_IRQMASK,
121 .pfn = __phys_to_pfn(BAST_PA_PC104_IRQMASK),
126 /* peripheral space... one for each of fast/slow/byte/16bit */
127 /* note, ide is only decoded in word space, even though some registers
131 { VA_C2(BAST_VA_ISAIO), PA_CS2(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
132 { VA_C2(BAST_VA_ISAMEM), PA_CS2(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
133 { VA_C2(BAST_VA_SUPERIO), PA_CS2(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
134 { VA_C2(BAST_VA_IDEPRI), PA_CS3(BAST_PA_IDEPRI), SZ_1M, MT_DEVICE },
135 { VA_C2(BAST_VA_IDESEC), PA_CS3(BAST_PA_IDESEC), SZ_1M, MT_DEVICE },
136 { VA_C2(BAST_VA_IDEPRIAUX), PA_CS3(BAST_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
137 { VA_C2(BAST_VA_IDESECAUX), PA_CS3(BAST_PA_IDESECAUX), SZ_1M, MT_DEVICE },
140 { VA_C3(BAST_VA_ISAIO), PA_CS3(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
141 { VA_C3(BAST_VA_ISAMEM), PA_CS3(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
142 { VA_C3(BAST_VA_SUPERIO), PA_CS3(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
143 { VA_C3(BAST_VA_IDEPRI), PA_CS3(BAST_PA_IDEPRI), SZ_1M, MT_DEVICE },
144 { VA_C3(BAST_VA_IDESEC), PA_CS3(BAST_PA_IDESEC), SZ_1M, MT_DEVICE },
145 { VA_C3(BAST_VA_IDEPRIAUX), PA_CS3(BAST_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
146 { VA_C3(BAST_VA_IDESECAUX), PA_CS3(BAST_PA_IDESECAUX), SZ_1M, MT_DEVICE },
149 { VA_C4(BAST_VA_ISAIO), PA_CS4(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
150 { VA_C4(BAST_VA_ISAMEM), PA_CS4(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
151 { VA_C4(BAST_VA_SUPERIO), PA_CS4(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
152 { VA_C4(BAST_VA_IDEPRI), PA_CS5(BAST_PA_IDEPRI), SZ_1M, MT_DEVICE },
153 { VA_C4(BAST_VA_IDESEC), PA_CS5(BAST_PA_IDESEC), SZ_1M, MT_DEVICE },
154 { VA_C4(BAST_VA_IDEPRIAUX), PA_CS5(BAST_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
155 { VA_C4(BAST_VA_IDESECAUX), PA_CS5(BAST_PA_IDESECAUX), SZ_1M, MT_DEVICE },
158 { VA_C5(BAST_VA_ISAIO), PA_CS5(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
159 { VA_C5(BAST_VA_ISAMEM), PA_CS5(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
160 { VA_C5(BAST_VA_SUPERIO), PA_CS5(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
161 { VA_C5(BAST_VA_IDEPRI), PA_CS5(BAST_PA_IDEPRI), SZ_1M, MT_DEVICE },
162 { VA_C5(BAST_VA_IDESEC), PA_CS5(BAST_PA_IDESEC), SZ_1M, MT_DEVICE },
163 { VA_C5(BAST_VA_IDEPRIAUX), PA_CS5(BAST_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
164 { VA_C5(BAST_VA_IDESECAUX), PA_CS5(BAST_PA_IDESECAUX), SZ_1M, MT_DEVICE },
167 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
168 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
169 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
171 static struct s3c24xx_uart_clksrc bast_serial_clocks[] = {
187 static struct s3c2410_uartcfg bast_uartcfgs[] __initdata = {
194 .clocks = bast_serial_clocks,
195 .clocks_size = ARRAY_SIZE(bast_serial_clocks),
203 .clocks = bast_serial_clocks,
204 .clocks_size = ARRAY_SIZE(bast_serial_clocks),
206 /* port 2 is not actually used */
213 .clocks = bast_serial_clocks,
214 .clocks_size = ARRAY_SIZE(bast_serial_clocks),
218 /* NOR Flash on BAST board */
220 static struct resource bast_nor_resource[] = {
222 .start = S3C2410_CS1 + 0x4000000,
223 .end = S3C2410_CS1 + 0x4000000 + (32*1024*1024) - 1,
224 .flags = IORESOURCE_MEM,
228 static struct platform_device bast_device_nor = {
231 .num_resources = ARRAY_SIZE(bast_nor_resource),
232 .resource = bast_nor_resource,
235 /* NAND Flash on BAST board */
238 static int smartmedia_map[] = { 0 };
239 static int chip0_map[] = { 1 };
240 static int chip1_map[] = { 2 };
241 static int chip2_map[] = { 3 };
243 static struct mtd_partition bast_default_nand_part[] = {
245 .name = "Boot Agent",
251 .size = SZ_4M - SZ_16K,
257 .size = MTDPART_SIZ_FULL,
261 /* the bast has 4 selectable slots for nand-flash, the three
262 * on-board chip areas, as well as the external SmartMedia
265 * Note, there is no current hot-plug support for the SmartMedia
269 static struct s3c2410_nand_set bast_nand_sets[] = {
271 .name = "SmartMedia",
273 .nr_map = smartmedia_map,
274 .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
275 .partitions = bast_default_nand_part,
281 .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
282 .partitions = bast_default_nand_part,
288 .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
289 .partitions = bast_default_nand_part,
295 .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
296 .partitions = bast_default_nand_part,
300 static void bast_nand_select(struct s3c2410_nand_set *set, int slot)
304 slot = set->nr_map[slot] & 3;
306 pr_debug("bast_nand: selecting slot %d (set %p,%p)\n",
307 slot, set, set->nr_map);
309 tmp = __raw_readb(BAST_VA_CTRL2);
310 tmp &= BAST_CPLD_CTLR2_IDERST;
312 tmp |= BAST_CPLD_CTRL2_WNAND;
314 pr_debug("bast_nand: ctrl2 now %02x\n", tmp);
316 __raw_writeb(tmp, BAST_VA_CTRL2);
319 static struct s3c2410_platform_nand bast_nand_info = {
323 .nr_sets = ARRAY_SIZE(bast_nand_sets),
324 .sets = bast_nand_sets,
325 .select_chip = bast_nand_select,
330 static struct resource bast_dm9k_resource[] = {
332 .start = S3C2410_CS5 + BAST_PA_DM9000,
333 .end = S3C2410_CS5 + BAST_PA_DM9000 + 3,
334 .flags = IORESOURCE_MEM,
337 .start = S3C2410_CS5 + BAST_PA_DM9000 + 0x40,
338 .end = S3C2410_CS5 + BAST_PA_DM9000 + 0x40 + 0x3f,
339 .flags = IORESOURCE_MEM,
344 .flags = IORESOURCE_IRQ,
349 /* for the moment we limit ourselves to 16bit IO until some
350 * better IO routines can be written and tested
353 static struct dm9000_plat_data bast_dm9k_platdata = {
354 .flags = DM9000_PLATF_16BITONLY,
357 static struct platform_device bast_device_dm9k = {
360 .num_resources = ARRAY_SIZE(bast_dm9k_resource),
361 .resource = bast_dm9k_resource,
363 .platform_data = &bast_dm9k_platdata,
369 #define SERIAL_BASE (S3C2410_CS2 + BAST_PA_SUPERIO)
370 #define SERIAL_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ)
371 #define SERIAL_CLK (1843200)
373 static struct plat_serial8250_port bast_sio_data[] = {
375 .mapbase = SERIAL_BASE + 0x2f8,
376 .irq = IRQ_PCSERIAL1,
377 .flags = SERIAL_FLAGS,
380 .uartclk = SERIAL_CLK,
383 .mapbase = SERIAL_BASE + 0x3f8,
384 .irq = IRQ_PCSERIAL2,
385 .flags = SERIAL_FLAGS,
388 .uartclk = SERIAL_CLK,
393 static struct platform_device bast_sio = {
394 .name = "serial8250",
395 .id = PLAT8250_DEV_PLATFORM,
397 .platform_data = &bast_sio_data,
401 /* we have devices on the bus which cannot work much over the
402 * standard 100KHz i2c bus frequency
405 static struct s3c2410_platform_i2c bast_i2c_info = {
408 .bus_freq = 100*1000,
409 .max_freq = 130*1000,
413 static struct s3c2410fb_mach_info __initdata bast_lcd_info = {
436 .lcdcon1 = 0x00000176,
437 .lcdcon2 = 0x1d77c7c2,
438 .lcdcon3 = 0x013a7f13,
439 .lcdcon4 = 0x00000057,
440 .lcdcon5 = 0x00014b02,
444 /* Standard BAST devices */
446 static struct platform_device *bast_devices[] __initdata = {
459 static struct clk *bast_clocks[] = {
467 static struct s3c24xx_board bast_board __initdata = {
468 .devices = bast_devices,
469 .devices_count = ARRAY_SIZE(bast_devices),
470 .clocks = bast_clocks,
471 .clocks_count = ARRAY_SIZE(bast_clocks),
474 static void __init bast_map_io(void)
476 /* initialise the clocks */
478 s3c24xx_dclk0.parent = NULL;
479 s3c24xx_dclk0.rate = 12*1000*1000;
481 s3c24xx_dclk1.parent = NULL;
482 s3c24xx_dclk1.rate = 24*1000*1000;
484 s3c24xx_clkout0.parent = &s3c24xx_dclk0;
485 s3c24xx_clkout1.parent = &s3c24xx_dclk1;
487 s3c24xx_uclk.parent = &s3c24xx_clkout1;
489 s3c_device_nand.dev.platform_data = &bast_nand_info;
490 s3c_device_i2c.dev.platform_data = &bast_i2c_info;
492 s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
493 s3c24xx_init_clocks(0);
494 s3c24xx_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));
495 s3c24xx_set_board(&bast_board);
499 static void __init bast_init(void)
501 s3c24xx_fb_set_platdata(&bast_lcd_info);
504 MACHINE_START(BAST, "Simtec-BAST")
505 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
506 .phys_io = S3C2410_PA_UART,
507 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
508 .boot_params = S3C2410_SDRAM_PA + 0x100,
509 .map_io = bast_map_io,
510 .init_irq = s3c24xx_init_irq,
511 .init_machine = bast_init,
512 .timer = &s3c24xx_timer,