mach-anubis.c 10 KB

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