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 <net/ax88796.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/irq.h>
29 #include <asm/arch/bast-map.h>
30 #include <asm/arch/bast-irq.h>
31 #include <asm/arch/bast-cpld.h>
33 #include <asm/hardware.h>
36 #include <asm/mach-types.h>
38 //#include <asm/debug-ll.h>
39 #include <asm/plat-s3c/regs-serial.h>
40 #include <asm/arch/regs-gpio.h>
41 #include <asm/arch/regs-mem.h>
42 #include <asm/arch/regs-lcd.h>
44 #include <asm/plat-s3c/nand.h>
45 #include <asm/plat-s3c/iic.h>
46 #include <asm/arch/fb.h>
48 #include <linux/mtd/mtd.h>
49 #include <linux/mtd/nand.h>
50 #include <linux/mtd/nand_ecc.h>
51 #include <linux/mtd/partitions.h>
53 #include <linux/serial_8250.h>
55 #include <asm/plat-s3c24xx/clock.h>
56 #include <asm/plat-s3c24xx/devs.h>
57 #include <asm/plat-s3c24xx/cpu.h>
58 #include "usb-simtec.h"
60 #define COPYRIGHT ", (c) 2004-2005 Simtec Electronics"
62 /* macros for virtual address mods for the io space entries */
63 #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
64 #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
65 #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
66 #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
68 /* macros to modify the physical addresses for io space */
70 #define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
71 #define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
72 #define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
73 #define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
75 static struct map_desc bast_iodesc
[] __initdata
= {
78 .virtual = (u32
)S3C24XX_VA_ISA_BYTE
,
79 .pfn
= PA_CS2(BAST_PA_ISAIO
),
83 .virtual = (u32
)S3C24XX_VA_ISA_WORD
,
84 .pfn
= PA_CS3(BAST_PA_ISAIO
),
88 /* bast CPLD control registers, and external interrupt controls */
90 .virtual = (u32
)BAST_VA_CTRL1
,
91 .pfn
= __phys_to_pfn(BAST_PA_CTRL1
),
95 .virtual = (u32
)BAST_VA_CTRL2
,
96 .pfn
= __phys_to_pfn(BAST_PA_CTRL2
),
100 .virtual = (u32
)BAST_VA_CTRL3
,
101 .pfn
= __phys_to_pfn(BAST_PA_CTRL3
),
105 .virtual = (u32
)BAST_VA_CTRL4
,
106 .pfn
= __phys_to_pfn(BAST_PA_CTRL4
),
112 .virtual = (u32
)BAST_VA_PC104_IRQREQ
,
113 .pfn
= __phys_to_pfn(BAST_PA_PC104_IRQREQ
),
117 .virtual = (u32
)BAST_VA_PC104_IRQRAW
,
118 .pfn
= __phys_to_pfn(BAST_PA_PC104_IRQRAW
),
122 .virtual = (u32
)BAST_VA_PC104_IRQMASK
,
123 .pfn
= __phys_to_pfn(BAST_PA_PC104_IRQMASK
),
128 /* peripheral space... one for each of fast/slow/byte/16bit */
129 /* note, ide is only decoded in word space, even though some registers
133 { VA_C2(BAST_VA_ISAIO
), PA_CS2(BAST_PA_ISAIO
), SZ_16M
, MT_DEVICE
},
134 { VA_C2(BAST_VA_ISAMEM
), PA_CS2(BAST_PA_ISAMEM
), SZ_16M
, MT_DEVICE
},
135 { VA_C2(BAST_VA_SUPERIO
), PA_CS2(BAST_PA_SUPERIO
), SZ_1M
, MT_DEVICE
},
136 { VA_C2(BAST_VA_IDEPRI
), PA_CS3(BAST_PA_IDEPRI
), SZ_1M
, MT_DEVICE
},
137 { VA_C2(BAST_VA_IDESEC
), PA_CS3(BAST_PA_IDESEC
), SZ_1M
, MT_DEVICE
},
138 { VA_C2(BAST_VA_IDEPRIAUX
), PA_CS3(BAST_PA_IDEPRIAUX
), SZ_1M
, MT_DEVICE
},
139 { VA_C2(BAST_VA_IDESECAUX
), PA_CS3(BAST_PA_IDESECAUX
), SZ_1M
, MT_DEVICE
},
142 { VA_C3(BAST_VA_ISAIO
), PA_CS3(BAST_PA_ISAIO
), SZ_16M
, MT_DEVICE
},
143 { VA_C3(BAST_VA_ISAMEM
), PA_CS3(BAST_PA_ISAMEM
), SZ_16M
, MT_DEVICE
},
144 { VA_C3(BAST_VA_SUPERIO
), PA_CS3(BAST_PA_SUPERIO
), SZ_1M
, MT_DEVICE
},
145 { VA_C3(BAST_VA_IDEPRI
), PA_CS3(BAST_PA_IDEPRI
), SZ_1M
, MT_DEVICE
},
146 { VA_C3(BAST_VA_IDESEC
), PA_CS3(BAST_PA_IDESEC
), SZ_1M
, MT_DEVICE
},
147 { VA_C3(BAST_VA_IDEPRIAUX
), PA_CS3(BAST_PA_IDEPRIAUX
), SZ_1M
, MT_DEVICE
},
148 { VA_C3(BAST_VA_IDESECAUX
), PA_CS3(BAST_PA_IDESECAUX
), SZ_1M
, MT_DEVICE
},
151 { VA_C4(BAST_VA_ISAIO
), PA_CS4(BAST_PA_ISAIO
), SZ_16M
, MT_DEVICE
},
152 { VA_C4(BAST_VA_ISAMEM
), PA_CS4(BAST_PA_ISAMEM
), SZ_16M
, MT_DEVICE
},
153 { VA_C4(BAST_VA_SUPERIO
), PA_CS4(BAST_PA_SUPERIO
), SZ_1M
, MT_DEVICE
},
154 { VA_C4(BAST_VA_IDEPRI
), PA_CS5(BAST_PA_IDEPRI
), SZ_1M
, MT_DEVICE
},
155 { VA_C4(BAST_VA_IDESEC
), PA_CS5(BAST_PA_IDESEC
), SZ_1M
, MT_DEVICE
},
156 { VA_C4(BAST_VA_IDEPRIAUX
), PA_CS5(BAST_PA_IDEPRIAUX
), SZ_1M
, MT_DEVICE
},
157 { VA_C4(BAST_VA_IDESECAUX
), PA_CS5(BAST_PA_IDESECAUX
), SZ_1M
, MT_DEVICE
},
160 { VA_C5(BAST_VA_ISAIO
), PA_CS5(BAST_PA_ISAIO
), SZ_16M
, MT_DEVICE
},
161 { VA_C5(BAST_VA_ISAMEM
), PA_CS5(BAST_PA_ISAMEM
), SZ_16M
, MT_DEVICE
},
162 { VA_C5(BAST_VA_SUPERIO
), PA_CS5(BAST_PA_SUPERIO
), SZ_1M
, MT_DEVICE
},
163 { VA_C5(BAST_VA_IDEPRI
), PA_CS5(BAST_PA_IDEPRI
), SZ_1M
, MT_DEVICE
},
164 { VA_C5(BAST_VA_IDESEC
), PA_CS5(BAST_PA_IDESEC
), SZ_1M
, MT_DEVICE
},
165 { VA_C5(BAST_VA_IDEPRIAUX
), PA_CS5(BAST_PA_IDEPRIAUX
), SZ_1M
, MT_DEVICE
},
166 { VA_C5(BAST_VA_IDESECAUX
), PA_CS5(BAST_PA_IDESECAUX
), SZ_1M
, MT_DEVICE
},
169 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
170 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
171 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
173 static struct s3c24xx_uart_clksrc bast_serial_clocks
[] = {
189 static struct s3c2410_uartcfg bast_uartcfgs
[] __initdata
= {
196 .clocks
= bast_serial_clocks
,
197 .clocks_size
= ARRAY_SIZE(bast_serial_clocks
),
205 .clocks
= bast_serial_clocks
,
206 .clocks_size
= ARRAY_SIZE(bast_serial_clocks
),
208 /* port 2 is not actually used */
215 .clocks
= bast_serial_clocks
,
216 .clocks_size
= ARRAY_SIZE(bast_serial_clocks
),
220 /* NOR Flash on BAST board */
222 static struct resource bast_nor_resource
[] = {
224 .start
= S3C2410_CS1
+ 0x4000000,
225 .end
= S3C2410_CS1
+ 0x4000000 + (32*1024*1024) - 1,
226 .flags
= IORESOURCE_MEM
,
230 static struct platform_device bast_device_nor
= {
233 .num_resources
= ARRAY_SIZE(bast_nor_resource
),
234 .resource
= bast_nor_resource
,
237 /* NAND Flash on BAST board */
240 static int smartmedia_map
[] = { 0 };
241 static int chip0_map
[] = { 1 };
242 static int chip1_map
[] = { 2 };
243 static int chip2_map
[] = { 3 };
245 static struct mtd_partition bast_default_nand_part
[] = {
247 .name
= "Boot Agent",
253 .size
= SZ_4M
- SZ_16K
,
259 .size
= MTDPART_SIZ_FULL
,
263 /* the bast has 4 selectable slots for nand-flash, the three
264 * on-board chip areas, as well as the external SmartMedia
267 * Note, there is no current hot-plug support for the SmartMedia
271 static struct s3c2410_nand_set bast_nand_sets
[] = {
273 .name
= "SmartMedia",
275 .nr_map
= smartmedia_map
,
276 .nr_partitions
= ARRAY_SIZE(bast_default_nand_part
),
277 .partitions
= bast_default_nand_part
,
283 .nr_partitions
= ARRAY_SIZE(bast_default_nand_part
),
284 .partitions
= bast_default_nand_part
,
290 .nr_partitions
= ARRAY_SIZE(bast_default_nand_part
),
291 .partitions
= bast_default_nand_part
,
297 .nr_partitions
= ARRAY_SIZE(bast_default_nand_part
),
298 .partitions
= bast_default_nand_part
,
302 static void bast_nand_select(struct s3c2410_nand_set
*set
, int slot
)
306 slot
= set
->nr_map
[slot
] & 3;
308 pr_debug("bast_nand: selecting slot %d (set %p,%p)\n",
309 slot
, set
, set
->nr_map
);
311 tmp
= __raw_readb(BAST_VA_CTRL2
);
312 tmp
&= BAST_CPLD_CTLR2_IDERST
;
314 tmp
|= BAST_CPLD_CTRL2_WNAND
;
316 pr_debug("bast_nand: ctrl2 now %02x\n", tmp
);
318 __raw_writeb(tmp
, BAST_VA_CTRL2
);
321 static struct s3c2410_platform_nand bast_nand_info
= {
325 .nr_sets
= ARRAY_SIZE(bast_nand_sets
),
326 .sets
= bast_nand_sets
,
327 .select_chip
= bast_nand_select
,
332 static struct resource bast_dm9k_resource
[] = {
334 .start
= S3C2410_CS5
+ BAST_PA_DM9000
,
335 .end
= S3C2410_CS5
+ BAST_PA_DM9000
+ 3,
336 .flags
= IORESOURCE_MEM
,
339 .start
= S3C2410_CS5
+ BAST_PA_DM9000
+ 0x40,
340 .end
= S3C2410_CS5
+ BAST_PA_DM9000
+ 0x40 + 0x3f,
341 .flags
= IORESOURCE_MEM
,
346 .flags
= IORESOURCE_IRQ
,
351 /* for the moment we limit ourselves to 16bit IO until some
352 * better IO routines can be written and tested
355 static struct dm9000_plat_data bast_dm9k_platdata
= {
356 .flags
= DM9000_PLATF_16BITONLY
,
359 static struct platform_device bast_device_dm9k
= {
362 .num_resources
= ARRAY_SIZE(bast_dm9k_resource
),
363 .resource
= bast_dm9k_resource
,
365 .platform_data
= &bast_dm9k_platdata
,
371 #define SERIAL_BASE (S3C2410_CS2 + BAST_PA_SUPERIO)
372 #define SERIAL_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ)
373 #define SERIAL_CLK (1843200)
375 static struct plat_serial8250_port bast_sio_data
[] = {
377 .mapbase
= SERIAL_BASE
+ 0x2f8,
378 .irq
= IRQ_PCSERIAL1
,
379 .flags
= SERIAL_FLAGS
,
382 .uartclk
= SERIAL_CLK
,
385 .mapbase
= SERIAL_BASE
+ 0x3f8,
386 .irq
= IRQ_PCSERIAL2
,
387 .flags
= SERIAL_FLAGS
,
390 .uartclk
= SERIAL_CLK
,
395 static struct platform_device bast_sio
= {
396 .name
= "serial8250",
397 .id
= PLAT8250_DEV_PLATFORM
,
399 .platform_data
= &bast_sio_data
,
403 /* we have devices on the bus which cannot work much over the
404 * standard 100KHz i2c bus frequency
407 static struct s3c2410_platform_i2c bast_i2c_info
= {
410 .bus_freq
= 100*1000,
411 .max_freq
= 130*1000,
414 /* Asix AX88796 10/100 ethernet controller */
416 static struct ax_plat_data bast_asix_platdata
= {
417 .flags
= AXFLG_MAC_FROMDEV
,
423 static struct resource bast_asix_resource
[] = {
425 .start
= S3C2410_CS5
+ BAST_PA_ASIXNET
,
426 .end
= S3C2410_CS5
+ BAST_PA_ASIXNET
+ (0x18 * 0x20) - 1,
427 .flags
= IORESOURCE_MEM
,
430 .start
= S3C2410_CS5
+ BAST_PA_ASIXNET
+ (0x1f * 0x20),
431 .end
= S3C2410_CS5
+ BAST_PA_ASIXNET
+ (0x1f * 0x20),
432 .flags
= IORESOURCE_MEM
,
437 .flags
= IORESOURCE_IRQ
441 static struct platform_device bast_device_asix
= {
444 .num_resources
= ARRAY_SIZE(bast_asix_resource
),
445 .resource
= bast_asix_resource
,
447 .platform_data
= &bast_asix_platdata
451 /* Asix AX88796 10/100 ethernet controller parallel port */
453 static struct resource bast_asixpp_resource
[] = {
455 .start
= S3C2410_CS5
+ BAST_PA_ASIXNET
+ (0x18 * 0x20),
456 .end
= S3C2410_CS5
+ BAST_PA_ASIXNET
+ (0x1b * 0x20) - 1,
457 .flags
= IORESOURCE_MEM
,
461 static struct platform_device bast_device_axpp
= {
462 .name
= "ax88796-pp",
464 .num_resources
= ARRAY_SIZE(bast_asixpp_resource
),
465 .resource
= bast_asixpp_resource
,
468 /* LCD/VGA controller */
470 static struct s3c2410fb_display __initdata bast_lcd_info
[] = {
472 .type
= S3C2410_LCDCON1_TFT
,
487 .lcdcon5
= 0x00014b02,
490 .type
= S3C2410_LCDCON1_TFT
,
505 .lcdcon5
= 0x00014b02,
508 .type
= S3C2410_LCDCON1_TFT
,
523 .lcdcon5
= 0x00014b02,
527 /* LCD/VGA controller */
529 static struct s3c2410fb_mach_info __initdata bast_fb_info
= {
531 .displays
= bast_lcd_info
,
532 .num_displays
= ARRAY_SIZE(bast_lcd_info
),
533 .default_display
= 1,
536 /* Standard BAST devices */
538 static struct platform_device
*bast_devices
[] __initdata
= {
552 static struct clk
*bast_clocks
[] = {
560 static void __init
bast_map_io(void)
562 /* initialise the clocks */
564 s3c24xx_dclk0
.parent
= NULL
;
565 s3c24xx_dclk0
.rate
= 12*1000*1000;
567 s3c24xx_dclk1
.parent
= NULL
;
568 s3c24xx_dclk1
.rate
= 24*1000*1000;
570 s3c24xx_clkout0
.parent
= &s3c24xx_dclk0
;
571 s3c24xx_clkout1
.parent
= &s3c24xx_dclk1
;
573 s3c24xx_uclk
.parent
= &s3c24xx_clkout1
;
575 s3c24xx_register_clocks(bast_clocks
, ARRAY_SIZE(bast_clocks
));
577 s3c_device_nand
.dev
.platform_data
= &bast_nand_info
;
578 s3c_device_i2c
.dev
.platform_data
= &bast_i2c_info
;
580 s3c24xx_init_io(bast_iodesc
, ARRAY_SIZE(bast_iodesc
));
581 s3c24xx_init_clocks(0);
582 s3c24xx_init_uarts(bast_uartcfgs
, ARRAY_SIZE(bast_uartcfgs
));
587 static void __init
bast_init(void)
589 s3c24xx_fb_set_platdata(&bast_fb_info
);
590 platform_add_devices(bast_devices
, ARRAY_SIZE(bast_devices
));
593 MACHINE_START(BAST
, "Simtec-BAST")
594 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
595 .phys_io
= S3C2410_PA_UART
,
596 .io_pg_offst
= (((u32
)S3C24XX_VA_UART
) >> 18) & 0xfffc,
597 .boot_params
= S3C2410_SDRAM_PA
+ 0x100,
598 .map_io
= bast_map_io
,
599 .init_irq
= s3c24xx_init_irq
,
600 .init_machine
= bast_init
,
601 .timer
= &s3c24xx_timer
,