mach-anubis.c 11 KB

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