mach-anubis.c 10 KB

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