mach-anubis.c 11 KB

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