mach-anubis.c 11 KB

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