Ben Dooks | a21765a | 2007-02-11 18:31:01 +0100 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c2440/mach-anubis.c |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 2 | * |
| 3 | * Copyright (c) 2003-2005 Simtec Electronics |
| 4 | * http://armlinux.simtec.co.uk/ |
| 5 | * Ben Dooks <ben@simtec.co.uk> |
| 6 | * |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 7 | * 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 Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 10 | */ |
| 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 Dooks | b6d1f54 | 2006-12-17 23:22:26 +0100 | [diff] [blame] | 18 | #include <linux/serial_core.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 19 | #include <linux/platform_device.h> |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 20 | |
| 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 Dooks | eac1d8d | 2007-07-11 10:14:53 +0100 | [diff] [blame^] | 45 | #include <net/ax88796.h> |
| 46 | |
Ben Dooks | a21765a | 2007-02-11 18:31:01 +0100 | [diff] [blame] | 47 | #include <asm/plat-s3c24xx/clock.h> |
| 48 | #include <asm/plat-s3c24xx/devs.h> |
| 49 | #include <asm/plat-s3c24xx/cpu.h> |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 50 | |
| 51 | #define COPYRIGHT ", (c) 2005 Simtec Electronics" |
| 52 | |
| 53 | static struct map_desc anubis_iodesc[] __initdata = { |
| 54 | /* ISA IO areas */ |
| 55 | |
Ben Dooks | 8dd5231 | 2005-11-09 14:05:30 +0000 | [diff] [blame] | 56 | { |
| 57 | .virtual = (u32)S3C24XX_VA_ISA_BYTE, |
| 58 | .pfn = __phys_to_pfn(0x0), |
| 59 | .length = SZ_4M, |
Ben Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 60 | .type = MT_DEVICE, |
Ben Dooks | 8dd5231 | 2005-11-09 14:05:30 +0000 | [diff] [blame] | 61 | }, { |
| 62 | .virtual = (u32)S3C24XX_VA_ISA_WORD, |
| 63 | .pfn = __phys_to_pfn(0x0), |
Ben Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 64 | .length = SZ_4M, |
| 65 | .type = MT_DEVICE, |
Ben Dooks | 8dd5231 | 2005-11-09 14:05:30 +0000 | [diff] [blame] | 66 | }, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 67 | |
| 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 Dooks | 8dd5231 | 2005-11-09 14:05:30 +0000 | [diff] [blame] | 75 | { |
| 76 | .virtual = (u32)ANUBIS_VA_CTRL1, |
| 77 | .pfn = __phys_to_pfn(ANUBIS_PA_CTRL1), |
| 78 | .length = SZ_4K, |
Ben Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 79 | .type = MT_DEVICE, |
Ben Dooks | 8dd5231 | 2005-11-09 14:05:30 +0000 | [diff] [blame] | 80 | }, { |
Ben Dooks | 6c1640d | 2007-06-06 10:01:04 +0100 | [diff] [blame] | 81 | .virtual = (u32)ANUBIS_VA_IDREG, |
| 82 | .pfn = __phys_to_pfn(ANUBIS_PA_IDREG), |
Ben Dooks | 8dd5231 | 2005-11-09 14:05:30 +0000 | [diff] [blame] | 83 | .length = SZ_4K, |
Ben Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 84 | .type = MT_DEVICE, |
Ben Dooks | 8dd5231 | 2005-11-09 14:05:30 +0000 | [diff] [blame] | 85 | }, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 86 | }; |
| 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 | |
| 92 | static 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 Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 103 | .max_baud = 0, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 104 | } |
| 105 | }; |
| 106 | |
| 107 | |
Ben Dooks | 66a9b49 | 2006-06-18 23:04:05 +0100 | [diff] [blame] | 108 | static struct s3c2410_uartcfg anubis_uartcfgs[] __initdata = { |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 109 | [0] = { |
| 110 | .hwport = 0, |
| 111 | .flags = 0, |
| 112 | .ucon = UCON, |
| 113 | .ulcon = ULCON, |
| 114 | .ufcon = UFCON, |
| 115 | .clocks = anubis_serial_clocks, |
Ben Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 116 | .clocks_size = ARRAY_SIZE(anubis_serial_clocks), |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 117 | }, |
| 118 | [1] = { |
| 119 | .hwport = 2, |
| 120 | .flags = 0, |
| 121 | .ucon = UCON, |
| 122 | .ulcon = ULCON, |
| 123 | .ufcon = UFCON, |
| 124 | .clocks = anubis_serial_clocks, |
Ben Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 125 | .clocks_size = ARRAY_SIZE(anubis_serial_clocks), |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 126 | }, |
| 127 | }; |
| 128 | |
| 129 | /* NAND Flash on Anubis board */ |
| 130 | |
| 131 | static int external_map[] = { 2 }; |
| 132 | static int chip0_map[] = { 0 }; |
| 133 | static int chip1_map[] = { 1 }; |
| 134 | |
Ben Dooks | 9f693d7 | 2005-10-12 19:58:07 +0100 | [diff] [blame] | 135 | static struct mtd_partition anubis_default_nand_part[] = { |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 136 | [0] = { |
| 137 | .name = "Boot Agent", |
| 138 | .size = SZ_16K, |
Ben Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 139 | .offset = 0, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 140 | }, |
| 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 | |
| 165 | static 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 Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 171 | .partitions = anubis_default_nand_part, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 172 | }, |
| 173 | [0] = { |
| 174 | .name = "chip0", |
| 175 | .nr_chips = 1, |
| 176 | .nr_map = chip0_map, |
| 177 | .nr_partitions = ARRAY_SIZE(anubis_default_nand_part), |
Ben Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 178 | .partitions = anubis_default_nand_part, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 179 | }, |
| 180 | [2] = { |
| 181 | .name = "chip1", |
| 182 | .nr_chips = 1, |
| 183 | .nr_map = chip1_map, |
| 184 | .nr_partitions = ARRAY_SIZE(anubis_default_nand_part), |
Ben Dooks | 705630d | 2006-07-26 20:16:39 +0100 | [diff] [blame] | 185 | .partitions = anubis_default_nand_part, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 186 | }, |
| 187 | }; |
| 188 | |
| 189 | static 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 | |
| 207 | static struct s3c2410_platform_nand anubis_nand_info = { |
| 208 | .tacls = 25, |
Ben Dooks | 661e6ac | 2006-04-02 10:32:46 +0100 | [diff] [blame] | 209 | .twrph0 = 55, |
| 210 | .twrph1 = 40, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 211 | .nr_sets = ARRAY_SIZE(anubis_nand_sets), |
| 212 | .sets = anubis_nand_sets, |
| 213 | .select_chip = anubis_nand_select, |
| 214 | }; |
| 215 | |
Ben Dooks | bf1c56a | 2006-06-19 18:30:04 +0100 | [diff] [blame] | 216 | /* IDE channels */ |
| 217 | |
| 218 | static 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 | |
| 234 | static 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 | |
| 241 | static 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 | |
| 258 | static 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 Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 264 | |
Ben Dooks | eac1d8d | 2007-07-11 10:14:53 +0100 | [diff] [blame^] | 265 | /* Asix AX88796 10/100 ethernet controller */ |
| 266 | |
| 267 | static 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 | |
| 274 | static 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 | |
| 287 | static 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 Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 297 | /* Standard Anubis devices */ |
| 298 | |
| 299 | static 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 Dooks | bf1c56a | 2006-06-19 18:30:04 +0100 | [diff] [blame] | 306 | &anubis_device_ide0, |
| 307 | &anubis_device_ide1, |
Ben Dooks | eac1d8d | 2007-07-11 10:14:53 +0100 | [diff] [blame^] | 308 | &anubis_device_asix, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 309 | }; |
| 310 | |
| 311 | static struct clk *anubis_clocks[] = { |
| 312 | &s3c24xx_dclk0, |
| 313 | &s3c24xx_dclk1, |
| 314 | &s3c24xx_clkout0, |
| 315 | &s3c24xx_clkout1, |
| 316 | &s3c24xx_uclk, |
| 317 | }; |
| 318 | |
Ben Dooks | 5fe10ab | 2005-09-20 17:24:33 +0100 | [diff] [blame] | 319 | static void __init anubis_map_io(void) |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 320 | { |
| 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 Dooks | ce89c20 | 2007-04-20 11:15:27 +0100 | [diff] [blame] | 334 | s3c24xx_register_clocks(anubis_clocks, ARRAY_SIZE(anubis_clocks)); |
| 335 | |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 336 | 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 Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 341 | |
| 342 | /* ensure that the GPIO is setup */ |
| 343 | s3c2410_gpio_setpin(S3C2410_GPA0, 1); |
| 344 | } |
| 345 | |
Ben Dooks | 57e5171 | 2007-04-20 11:19:16 +0100 | [diff] [blame] | 346 | static void __init anubis_init(void) |
| 347 | { |
| 348 | platform_add_devices(anubis_devices, ARRAY_SIZE(anubis_devices)); |
| 349 | } |
| 350 | |
| 351 | |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 352 | MACHINE_START(ANUBIS, "Simtec-Anubis") |
| 353 | /* Maintainer: Ben Dooks <ben@simtec.co.uk> */ |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 354 | .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 Dooks | 57e5171 | 2007-04-20 11:19:16 +0100 | [diff] [blame] | 358 | .init_machine = anubis_init, |
Ben Dooks | 7efb833 | 2005-09-07 11:49:23 +0100 | [diff] [blame] | 359 | .init_irq = s3c24xx_init_irq, |
| 360 | .timer = &s3c24xx_timer, |
| 361 | MACHINE_END |