mach-anubis.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. /* linux/arch/arm/mach-s3c2440/mach-anubis.c
  2. *
  3. * Copyright (c) 2003-2005,2008 Simtec Electronics
  4. * http://armlinux.simtec.co.uk/
  5. * Ben Dooks <ben@simtec.co.uk>
  6. *
  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.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/list.h>
  15. #include <linux/timer.h>
  16. #include <linux/init.h>
  17. #include <linux/serial_core.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/ata_platform.h>
  20. #include <linux/i2c.h>
  21. #include <linux/io.h>
  22. #include <linux/sm501.h>
  23. #include <linux/sm501-regs.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/map.h>
  26. #include <asm/mach/irq.h>
  27. #include <mach/anubis-map.h>
  28. #include <mach/anubis-irq.h>
  29. #include <mach/anubis-cpld.h>
  30. #include <mach/hardware.h>
  31. #include <asm/irq.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/plat-s3c/regs-serial.h>
  34. #include <mach/regs-gpio.h>
  35. #include <mach/regs-mem.h>
  36. #include <mach/regs-lcd.h>
  37. #include <asm/plat-s3c/nand.h>
  38. #include <linux/mtd/mtd.h>
  39. #include <linux/mtd/nand.h>
  40. #include <linux/mtd/nand_ecc.h>
  41. #include <linux/mtd/partitions.h>
  42. #include <net/ax88796.h>
  43. #include <asm/plat-s3c24xx/clock.h>
  44. #include <asm/plat-s3c24xx/devs.h>
  45. #include <asm/plat-s3c24xx/cpu.h>
  46. #define COPYRIGHT ", (c) 2005 Simtec Electronics"
  47. static struct map_desc anubis_iodesc[] __initdata = {
  48. /* ISA IO areas */
  49. {
  50. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  51. .pfn = __phys_to_pfn(0x0),
  52. .length = SZ_4M,
  53. .type = MT_DEVICE,
  54. }, {
  55. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  56. .pfn = __phys_to_pfn(0x0),
  57. .length = SZ_4M,
  58. .type = MT_DEVICE,
  59. },
  60. /* we could possibly compress the next set down into a set of smaller tables
  61. * pagetables, but that would mean using an L2 section, and it still means
  62. * we cannot actually feed the same register to an LDR due to 16K spacing
  63. */
  64. /* CPLD control registers */
  65. {
  66. .virtual = (u32)ANUBIS_VA_CTRL1,
  67. .pfn = __phys_to_pfn(ANUBIS_PA_CTRL1),
  68. .length = SZ_4K,
  69. .type = MT_DEVICE,
  70. }, {
  71. .virtual = (u32)ANUBIS_VA_IDREG,
  72. .pfn = __phys_to_pfn(ANUBIS_PA_IDREG),
  73. .length = SZ_4K,
  74. .type = MT_DEVICE,
  75. },
  76. };
  77. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  78. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  79. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  80. static struct s3c24xx_uart_clksrc anubis_serial_clocks[] = {
  81. [0] = {
  82. .name = "uclk",
  83. .divisor = 1,
  84. .min_baud = 0,
  85. .max_baud = 0,
  86. },
  87. [1] = {
  88. .name = "pclk",
  89. .divisor = 1,
  90. .min_baud = 0,
  91. .max_baud = 0,
  92. }
  93. };
  94. static struct s3c2410_uartcfg anubis_uartcfgs[] __initdata = {
  95. [0] = {
  96. .hwport = 0,
  97. .flags = 0,
  98. .ucon = UCON,
  99. .ulcon = ULCON,
  100. .ufcon = UFCON,
  101. .clocks = anubis_serial_clocks,
  102. .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
  103. },
  104. [1] = {
  105. .hwport = 2,
  106. .flags = 0,
  107. .ucon = UCON,
  108. .ulcon = ULCON,
  109. .ufcon = UFCON,
  110. .clocks = anubis_serial_clocks,
  111. .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
  112. },
  113. };
  114. /* NAND Flash on Anubis board */
  115. static int external_map[] = { 2 };
  116. static int chip0_map[] = { 0 };
  117. static int chip1_map[] = { 1 };
  118. static struct mtd_partition anubis_default_nand_part[] = {
  119. [0] = {
  120. .name = "Boot Agent",
  121. .size = SZ_16K,
  122. .offset = 0,
  123. },
  124. [1] = {
  125. .name = "/boot",
  126. .size = SZ_4M - SZ_16K,
  127. .offset = SZ_16K,
  128. },
  129. [2] = {
  130. .name = "user1",
  131. .offset = SZ_4M,
  132. .size = SZ_32M - SZ_4M,
  133. },
  134. [3] = {
  135. .name = "user2",
  136. .offset = SZ_32M,
  137. .size = MTDPART_SIZ_FULL,
  138. }
  139. };
  140. static struct mtd_partition anubis_default_nand_part_large[] = {
  141. [0] = {
  142. .name = "Boot Agent",
  143. .size = SZ_128K,
  144. .offset = 0,
  145. },
  146. [1] = {
  147. .name = "/boot",
  148. .size = SZ_4M - SZ_128K,
  149. .offset = SZ_128K,
  150. },
  151. [2] = {
  152. .name = "user1",
  153. .offset = SZ_4M,
  154. .size = SZ_32M - SZ_4M,
  155. },
  156. [3] = {
  157. .name = "user2",
  158. .offset = SZ_32M,
  159. .size = MTDPART_SIZ_FULL,
  160. }
  161. };
  162. /* the Anubis has 3 selectable slots for nand-flash, the two
  163. * on-board chip areas, as well as the external slot.
  164. *
  165. * Note, there is no current hot-plug support for the External
  166. * socket.
  167. */
  168. static struct s3c2410_nand_set anubis_nand_sets[] = {
  169. [1] = {
  170. .name = "External",
  171. .nr_chips = 1,
  172. .nr_map = external_map,
  173. .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
  174. .partitions = anubis_default_nand_part,
  175. },
  176. [0] = {
  177. .name = "chip0",
  178. .nr_chips = 1,
  179. .nr_map = chip0_map,
  180. .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
  181. .partitions = anubis_default_nand_part,
  182. },
  183. [2] = {
  184. .name = "chip1",
  185. .nr_chips = 1,
  186. .nr_map = chip1_map,
  187. .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
  188. .partitions = anubis_default_nand_part,
  189. },
  190. };
  191. static void anubis_nand_select(struct s3c2410_nand_set *set, int slot)
  192. {
  193. unsigned int tmp;
  194. slot = set->nr_map[slot] & 3;
  195. pr_debug("anubis_nand: selecting slot %d (set %p,%p)\n",
  196. slot, set, set->nr_map);
  197. tmp = __raw_readb(ANUBIS_VA_CTRL1);
  198. tmp &= ~ANUBIS_CTRL1_NANDSEL;
  199. tmp |= slot;
  200. pr_debug("anubis_nand: ctrl1 now %02x\n", tmp);
  201. __raw_writeb(tmp, ANUBIS_VA_CTRL1);
  202. }
  203. static struct s3c2410_platform_nand anubis_nand_info = {
  204. .tacls = 25,
  205. .twrph0 = 55,
  206. .twrph1 = 40,
  207. .nr_sets = ARRAY_SIZE(anubis_nand_sets),
  208. .sets = anubis_nand_sets,
  209. .select_chip = anubis_nand_select,
  210. };
  211. /* IDE channels */
  212. struct pata_platform_info anubis_ide_platdata = {
  213. .ioport_shift = 5,
  214. };
  215. static struct resource anubis_ide0_resource[] = {
  216. {
  217. .start = S3C2410_CS3,
  218. .end = S3C2410_CS3 + (8*32) - 1,
  219. .flags = IORESOURCE_MEM,
  220. }, {
  221. .start = S3C2410_CS3 + (1<<26) + (6*32),
  222. .end = S3C2410_CS3 + (1<<26) + (7*32) - 1,
  223. .flags = IORESOURCE_MEM,
  224. }, {
  225. .start = IRQ_IDE0,
  226. .end = IRQ_IDE0,
  227. .flags = IORESOURCE_IRQ,
  228. },
  229. };
  230. static struct platform_device anubis_device_ide0 = {
  231. .name = "pata_platform",
  232. .id = 0,
  233. .num_resources = ARRAY_SIZE(anubis_ide0_resource),
  234. .resource = anubis_ide0_resource,
  235. .dev = {
  236. .platform_data = &anubis_ide_platdata,
  237. .coherent_dma_mask = ~0,
  238. },
  239. };
  240. static struct resource anubis_ide1_resource[] = {
  241. {
  242. .start = S3C2410_CS4,
  243. .end = S3C2410_CS4 + (8*32) - 1,
  244. .flags = IORESOURCE_MEM,
  245. }, {
  246. .start = S3C2410_CS4 + (1<<26) + (6*32),
  247. .end = S3C2410_CS4 + (1<<26) + (7*32) - 1,
  248. .flags = IORESOURCE_MEM,
  249. }, {
  250. .start = IRQ_IDE0,
  251. .end = IRQ_IDE0,
  252. .flags = IORESOURCE_IRQ,
  253. },
  254. };
  255. static struct platform_device anubis_device_ide1 = {
  256. .name = "pata_platform",
  257. .id = 1,
  258. .num_resources = ARRAY_SIZE(anubis_ide1_resource),
  259. .resource = anubis_ide1_resource,
  260. .dev = {
  261. .platform_data = &anubis_ide_platdata,
  262. .coherent_dma_mask = ~0,
  263. },
  264. };
  265. /* Asix AX88796 10/100 ethernet controller */
  266. static struct ax_plat_data anubis_asix_platdata = {
  267. .flags = AXFLG_MAC_FROMDEV,
  268. .wordlength = 2,
  269. .dcr_val = 0x48,
  270. .rcr_val = 0x40,
  271. };
  272. static struct resource anubis_asix_resource[] = {
  273. [0] = {
  274. .start = S3C2410_CS5,
  275. .end = S3C2410_CS5 + (0x20 * 0x20) -1,
  276. .flags = IORESOURCE_MEM
  277. },
  278. [1] = {
  279. .start = IRQ_ASIX,
  280. .end = IRQ_ASIX,
  281. .flags = IORESOURCE_IRQ
  282. }
  283. };
  284. static struct platform_device anubis_device_asix = {
  285. .name = "ax88796",
  286. .id = 0,
  287. .num_resources = ARRAY_SIZE(anubis_asix_resource),
  288. .resource = anubis_asix_resource,
  289. .dev = {
  290. .platform_data = &anubis_asix_platdata,
  291. }
  292. };
  293. /* SM501 */
  294. static struct resource anubis_sm501_resource[] = {
  295. [0] = {
  296. .start = S3C2410_CS2,
  297. .end = S3C2410_CS2 + SZ_8M,
  298. .flags = IORESOURCE_MEM,
  299. },
  300. [1] = {
  301. .start = S3C2410_CS2 + SZ_64M - SZ_2M,
  302. .end = S3C2410_CS2 + SZ_64M - 1,
  303. .flags = IORESOURCE_MEM,
  304. },
  305. [2] = {
  306. .start = IRQ_EINT0,
  307. .end = IRQ_EINT0,
  308. .flags = IORESOURCE_IRQ,
  309. },
  310. };
  311. static struct sm501_initdata anubis_sm501_initdata = {
  312. .gpio_high = {
  313. .set = 0x3F000000, /* 24bit panel */
  314. .mask = 0x0,
  315. },
  316. .misc_timing = {
  317. .set = 0x010100, /* SDRAM timing */
  318. .mask = 0x1F1F00,
  319. },
  320. .misc_control = {
  321. .set = SM501_MISC_PNL_24BIT,
  322. .mask = 0,
  323. },
  324. /* set the SDRAM and bus clocks */
  325. .mclk = 72 * MHZ,
  326. .m1xclk = 144 * MHZ,
  327. };
  328. static struct sm501_platdata_gpio_i2c anubis_sm501_gpio_i2c[] = {
  329. [0] = {
  330. .pin_scl = 44,
  331. .pin_sda = 45,
  332. },
  333. [1] = {
  334. .pin_scl = 40,
  335. .pin_sda = 41,
  336. },
  337. };
  338. static struct sm501_platdata anubis_sm501_platdata = {
  339. .init = &anubis_sm501_initdata,
  340. .gpio_i2c = anubis_sm501_gpio_i2c,
  341. .gpio_i2c_nr = ARRAY_SIZE(anubis_sm501_gpio_i2c),
  342. };
  343. static struct platform_device anubis_device_sm501 = {
  344. .name = "sm501",
  345. .id = 0,
  346. .num_resources = ARRAY_SIZE(anubis_sm501_resource),
  347. .resource = anubis_sm501_resource,
  348. .dev = {
  349. .platform_data = &anubis_sm501_platdata,
  350. },
  351. };
  352. /* Standard Anubis devices */
  353. static struct platform_device *anubis_devices[] __initdata = {
  354. &s3c_device_usb,
  355. &s3c_device_wdt,
  356. &s3c_device_adc,
  357. &s3c_device_i2c,
  358. &s3c_device_rtc,
  359. &s3c_device_nand,
  360. &anubis_device_ide0,
  361. &anubis_device_ide1,
  362. &anubis_device_asix,
  363. &anubis_device_sm501,
  364. };
  365. static struct clk *anubis_clocks[] __initdata = {
  366. &s3c24xx_dclk0,
  367. &s3c24xx_dclk1,
  368. &s3c24xx_clkout0,
  369. &s3c24xx_clkout1,
  370. &s3c24xx_uclk,
  371. };
  372. /* I2C devices. */
  373. static struct i2c_board_info anubis_i2c_devs[] __initdata = {
  374. {
  375. I2C_BOARD_INFO("tps65011", 0x48),
  376. .irq = IRQ_EINT20,
  377. }
  378. };
  379. static void __init anubis_map_io(void)
  380. {
  381. /* initialise the clocks */
  382. s3c24xx_dclk0.parent = &clk_upll;
  383. s3c24xx_dclk0.rate = 12*1000*1000;
  384. s3c24xx_dclk1.parent = &clk_upll;
  385. s3c24xx_dclk1.rate = 24*1000*1000;
  386. s3c24xx_clkout0.parent = &s3c24xx_dclk0;
  387. s3c24xx_clkout1.parent = &s3c24xx_dclk1;
  388. s3c24xx_uclk.parent = &s3c24xx_clkout1;
  389. s3c24xx_register_clocks(anubis_clocks, ARRAY_SIZE(anubis_clocks));
  390. s3c_device_nand.dev.platform_data = &anubis_nand_info;
  391. s3c24xx_init_io(anubis_iodesc, ARRAY_SIZE(anubis_iodesc));
  392. s3c24xx_init_clocks(0);
  393. s3c24xx_init_uarts(anubis_uartcfgs, ARRAY_SIZE(anubis_uartcfgs));
  394. /* check for the newer revision boards with large page nand */
  395. if ((__raw_readb(ANUBIS_VA_IDREG) & ANUBIS_IDREG_REVMASK) >= 4) {
  396. printk(KERN_INFO "ANUBIS-B detected (revision %d)\n",
  397. __raw_readb(ANUBIS_VA_IDREG) & ANUBIS_IDREG_REVMASK);
  398. anubis_nand_sets[0].partitions = anubis_default_nand_part_large;
  399. anubis_nand_sets[0].nr_partitions = ARRAY_SIZE(anubis_default_nand_part_large);
  400. } else {
  401. /* ensure that the GPIO is setup */
  402. s3c2410_gpio_setpin(S3C2410_GPA0, 1);
  403. }
  404. }
  405. static void __init anubis_init(void)
  406. {
  407. platform_add_devices(anubis_devices, ARRAY_SIZE(anubis_devices));
  408. i2c_register_board_info(0, anubis_i2c_devs,
  409. ARRAY_SIZE(anubis_i2c_devs));
  410. }
  411. MACHINE_START(ANUBIS, "Simtec-Anubis")
  412. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  413. .phys_io = S3C2410_PA_UART,
  414. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  415. .boot_params = S3C2410_SDRAM_PA + 0x100,
  416. .map_io = anubis_map_io,
  417. .init_machine = anubis_init,
  418. .init_irq = s3c24xx_init_irq,
  419. .timer = &s3c24xx_timer,
  420. MACHINE_END