board-kota2.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /*
  2. * kota2 board support
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Magnus Damm
  6. * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com>
  7. * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; version 2 of the License.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/irq.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/delay.h>
  28. #include <linux/io.h>
  29. #include <linux/smsc911x.h>
  30. #include <linux/gpio.h>
  31. #include <linux/input.h>
  32. #include <linux/input/sh_keysc.h>
  33. #include <linux/gpio_keys.h>
  34. #include <linux/leds.h>
  35. #include <linux/mmc/host.h>
  36. #include <linux/mmc/sh_mmcif.h>
  37. #include <linux/mfd/tmio.h>
  38. #include <linux/mmc/sh_mobile_sdhi.h>
  39. #include <mach/hardware.h>
  40. #include <mach/sh73a0.h>
  41. #include <mach/common.h>
  42. #include <asm/mach-types.h>
  43. #include <asm/mach/arch.h>
  44. #include <asm/mach/map.h>
  45. #include <asm/mach/time.h>
  46. #include <asm/hardware/gic.h>
  47. #include <asm/hardware/cache-l2x0.h>
  48. #include <asm/traps.h>
  49. /* SMSC 9220 */
  50. static struct resource smsc9220_resources[] = {
  51. [0] = {
  52. .start = 0x14000000, /* CS5A */
  53. .end = 0x140000ff, /* A1->A7 */
  54. .flags = IORESOURCE_MEM,
  55. },
  56. [1] = {
  57. .start = gic_spi(33), /* PINTA2 @ PORT144 */
  58. .flags = IORESOURCE_IRQ,
  59. },
  60. };
  61. static struct smsc911x_platform_config smsc9220_platdata = {
  62. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  63. .phy_interface = PHY_INTERFACE_MODE_MII,
  64. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  65. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  66. };
  67. static struct platform_device eth_device = {
  68. .name = "smsc911x",
  69. .id = 0,
  70. .dev = {
  71. .platform_data = &smsc9220_platdata,
  72. },
  73. .resource = smsc9220_resources,
  74. .num_resources = ARRAY_SIZE(smsc9220_resources),
  75. };
  76. /* KEYSC */
  77. static struct sh_keysc_info keysc_platdata = {
  78. .mode = SH_KEYSC_MODE_6,
  79. .scan_timing = 3,
  80. .delay = 100,
  81. .keycodes = {
  82. KEY_NUMERIC_STAR, KEY_NUMERIC_0, KEY_NUMERIC_POUND,
  83. 0, 0, 0, 0, 0,
  84. KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9,
  85. 0, KEY_DOWN, 0, 0, 0,
  86. KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6,
  87. KEY_LEFT, KEY_ENTER, KEY_RIGHT, 0, 0,
  88. KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3,
  89. 0, KEY_UP, 0, 0, 0,
  90. 0, 0, 0, 0, 0, 0, 0, 0,
  91. 0, 0, 0, 0, 0, 0, 0, 0,
  92. 0, 0, 0, 0, 0, 0, 0, 0,
  93. 0, 0, 0, 0, 0, 0, 0, 0,
  94. },
  95. };
  96. static struct resource keysc_resources[] = {
  97. [0] = {
  98. .name = "KEYSC",
  99. .start = 0xe61b0000,
  100. .end = 0xe61b0098 - 1,
  101. .flags = IORESOURCE_MEM,
  102. },
  103. [1] = {
  104. .start = gic_spi(71),
  105. .flags = IORESOURCE_IRQ,
  106. },
  107. };
  108. static struct platform_device keysc_device = {
  109. .name = "sh_keysc",
  110. .id = 0,
  111. .num_resources = ARRAY_SIZE(keysc_resources),
  112. .resource = keysc_resources,
  113. .dev = {
  114. .platform_data = &keysc_platdata,
  115. },
  116. };
  117. /* GPIO KEY */
  118. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  119. static struct gpio_keys_button gpio_buttons[] = {
  120. GPIO_KEY(KEY_VOLUMEUP, GPIO_PORT56, "+"), /* S2: VOL+ [IRQ9] */
  121. GPIO_KEY(KEY_VOLUMEDOWN, GPIO_PORT54, "-"), /* S3: VOL- [IRQ10] */
  122. GPIO_KEY(KEY_MENU, GPIO_PORT27, "Menu"), /* S4: MENU [IRQ30] */
  123. GPIO_KEY(KEY_HOMEPAGE, GPIO_PORT26, "Home"), /* S5: HOME [IRQ31] */
  124. GPIO_KEY(KEY_BACK, GPIO_PORT11, "Back"), /* S6: BACK [IRQ0] */
  125. GPIO_KEY(KEY_PHONE, GPIO_PORT238, "Tel"), /* S7: TEL [IRQ11] */
  126. GPIO_KEY(KEY_POWER, GPIO_PORT239, "C1"), /* S8: CAM [IRQ13] */
  127. GPIO_KEY(KEY_MAIL, GPIO_PORT224, "Mail"), /* S9: MAIL [IRQ3] */
  128. /* Omitted button "C3?": GPIO_PORT223 - S10: CUST [IRQ8] */
  129. GPIO_KEY(KEY_CAMERA, GPIO_PORT164, "C2"), /* S11: CAM_HALF [IRQ25] */
  130. /* Omitted button "?": GPIO_PORT152 - S12: CAM_FULL [No IRQ] */
  131. };
  132. static struct gpio_keys_platform_data gpio_key_info = {
  133. .buttons = gpio_buttons,
  134. .nbuttons = ARRAY_SIZE(gpio_buttons),
  135. .poll_interval = 250, /* polled for now */
  136. };
  137. static struct platform_device gpio_keys_device = {
  138. .name = "gpio-keys-polled", /* polled for now */
  139. .id = -1,
  140. .dev = {
  141. .platform_data = &gpio_key_info,
  142. },
  143. };
  144. /* GPIO LED */
  145. #define GPIO_LED(n, g) { .name = n, .gpio = g }
  146. static struct gpio_led gpio_leds[] = {
  147. GPIO_LED("V2513", GPIO_PORT153), /* PORT153 [TPU1T02] -> V2513 */
  148. GPIO_LED("V2514", GPIO_PORT199), /* PORT199 [TPU4TO1] -> V2514 */
  149. GPIO_LED("V2515", GPIO_PORT197), /* PORT197 [TPU2TO1] -> V2515 */
  150. GPIO_LED("KEYLED", GPIO_PORT163), /* PORT163 [TPU3TO0] -> KEYLED */
  151. GPIO_LED("G", GPIO_PORT20), /* PORT20 [GPO0] -> LED7 -> "G" */
  152. GPIO_LED("H", GPIO_PORT21), /* PORT21 [GPO1] -> LED8 -> "H" */
  153. GPIO_LED("J", GPIO_PORT22), /* PORT22 [GPO2] -> LED9 -> "J" */
  154. };
  155. static struct gpio_led_platform_data gpio_leds_info = {
  156. .leds = gpio_leds,
  157. .num_leds = ARRAY_SIZE(gpio_leds),
  158. };
  159. static struct platform_device gpio_leds_device = {
  160. .name = "leds-gpio",
  161. .id = -1,
  162. .dev = {
  163. .platform_data = &gpio_leds_info,
  164. },
  165. };
  166. /* MMCIF */
  167. static struct resource mmcif_resources[] = {
  168. [0] = {
  169. .name = "MMCIF",
  170. .start = 0xe6bd0000,
  171. .end = 0xe6bd00ff,
  172. .flags = IORESOURCE_MEM,
  173. },
  174. [1] = {
  175. .start = gic_spi(140),
  176. .flags = IORESOURCE_IRQ,
  177. },
  178. [2] = {
  179. .start = gic_spi(141),
  180. .flags = IORESOURCE_IRQ,
  181. },
  182. };
  183. static struct sh_mmcif_plat_data mmcif_info = {
  184. .ocr = MMC_VDD_165_195,
  185. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  186. };
  187. static struct platform_device mmcif_device = {
  188. .name = "sh_mmcif",
  189. .id = 0,
  190. .dev = {
  191. .platform_data = &mmcif_info,
  192. },
  193. .num_resources = ARRAY_SIZE(mmcif_resources),
  194. .resource = mmcif_resources,
  195. };
  196. /* SDHI0 */
  197. static struct sh_mobile_sdhi_info sdhi0_info = {
  198. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  199. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  200. };
  201. static struct resource sdhi0_resources[] = {
  202. [0] = {
  203. .name = "SDHI0",
  204. .start = 0xee100000,
  205. .end = 0xee1000ff,
  206. .flags = IORESOURCE_MEM,
  207. },
  208. [1] = {
  209. .start = gic_spi(83),
  210. .flags = IORESOURCE_IRQ,
  211. },
  212. [2] = {
  213. .start = gic_spi(84),
  214. .flags = IORESOURCE_IRQ,
  215. },
  216. [3] = {
  217. .start = gic_spi(85),
  218. .flags = IORESOURCE_IRQ,
  219. },
  220. };
  221. static struct platform_device sdhi0_device = {
  222. .name = "sh_mobile_sdhi",
  223. .id = 0,
  224. .num_resources = ARRAY_SIZE(sdhi0_resources),
  225. .resource = sdhi0_resources,
  226. .dev = {
  227. .platform_data = &sdhi0_info,
  228. },
  229. };
  230. /* SDHI1 */
  231. static struct sh_mobile_sdhi_info sdhi1_info = {
  232. .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
  233. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  234. };
  235. static struct resource sdhi1_resources[] = {
  236. [0] = {
  237. .name = "SDHI1",
  238. .start = 0xee120000,
  239. .end = 0xee1200ff,
  240. .flags = IORESOURCE_MEM,
  241. },
  242. [1] = {
  243. .start = gic_spi(87),
  244. .flags = IORESOURCE_IRQ,
  245. },
  246. [2] = {
  247. .start = gic_spi(88),
  248. .flags = IORESOURCE_IRQ,
  249. },
  250. [3] = {
  251. .start = gic_spi(89),
  252. .flags = IORESOURCE_IRQ,
  253. },
  254. };
  255. static struct platform_device sdhi1_device = {
  256. .name = "sh_mobile_sdhi",
  257. .id = 1,
  258. .num_resources = ARRAY_SIZE(sdhi1_resources),
  259. .resource = sdhi1_resources,
  260. .dev = {
  261. .platform_data = &sdhi1_info,
  262. },
  263. };
  264. static struct platform_device *kota2_devices[] __initdata = {
  265. &eth_device,
  266. &keysc_device,
  267. &gpio_keys_device,
  268. &gpio_leds_device,
  269. &mmcif_device,
  270. &sdhi0_device,
  271. &sdhi1_device,
  272. };
  273. static struct map_desc kota2_io_desc[] __initdata = {
  274. /* create a 1:1 entity map for 0xe6xxxxxx
  275. * used by CPGA, INTC and PFC.
  276. */
  277. {
  278. .virtual = 0xe6000000,
  279. .pfn = __phys_to_pfn(0xe6000000),
  280. .length = 256 << 20,
  281. .type = MT_DEVICE_NONSHARED
  282. },
  283. };
  284. static void __init kota2_map_io(void)
  285. {
  286. iotable_init(kota2_io_desc, ARRAY_SIZE(kota2_io_desc));
  287. /* setup early devices and console here as well */
  288. sh73a0_add_early_devices();
  289. shmobile_setup_console();
  290. }
  291. #define PINTER0A 0xe69000a0
  292. #define PINTCR0A 0xe69000b0
  293. void __init kota2_init_irq(void)
  294. {
  295. sh73a0_init_irq();
  296. /* setup PINT: enable PINTA2 as active low */
  297. __raw_writel(1 << 29, PINTER0A);
  298. __raw_writew(2 << 10, PINTCR0A);
  299. }
  300. static void __init kota2_init(void)
  301. {
  302. sh73a0_pinmux_init();
  303. /* SCIFA2 (UART2) */
  304. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  305. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  306. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  307. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  308. /* SCIFA4 (UART1) */
  309. gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
  310. gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
  311. gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
  312. gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
  313. /* SMSC911X */
  314. gpio_request(GPIO_FN_D0_NAF0, NULL);
  315. gpio_request(GPIO_FN_D1_NAF1, NULL);
  316. gpio_request(GPIO_FN_D2_NAF2, NULL);
  317. gpio_request(GPIO_FN_D3_NAF3, NULL);
  318. gpio_request(GPIO_FN_D4_NAF4, NULL);
  319. gpio_request(GPIO_FN_D5_NAF5, NULL);
  320. gpio_request(GPIO_FN_D6_NAF6, NULL);
  321. gpio_request(GPIO_FN_D7_NAF7, NULL);
  322. gpio_request(GPIO_FN_D8_NAF8, NULL);
  323. gpio_request(GPIO_FN_D9_NAF9, NULL);
  324. gpio_request(GPIO_FN_D10_NAF10, NULL);
  325. gpio_request(GPIO_FN_D11_NAF11, NULL);
  326. gpio_request(GPIO_FN_D12_NAF12, NULL);
  327. gpio_request(GPIO_FN_D13_NAF13, NULL);
  328. gpio_request(GPIO_FN_D14_NAF14, NULL);
  329. gpio_request(GPIO_FN_D15_NAF15, NULL);
  330. gpio_request(GPIO_FN_CS5A_, NULL);
  331. gpio_request(GPIO_FN_WE0__FWE, NULL);
  332. gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
  333. gpio_direction_input(GPIO_PORT144);
  334. gpio_request(GPIO_PORT145, NULL); /* RESET */
  335. gpio_direction_output(GPIO_PORT145, 1);
  336. /* KEYSC */
  337. gpio_request(GPIO_FN_KEYIN0_PU, NULL);
  338. gpio_request(GPIO_FN_KEYIN1_PU, NULL);
  339. gpio_request(GPIO_FN_KEYIN2_PU, NULL);
  340. gpio_request(GPIO_FN_KEYIN3_PU, NULL);
  341. gpio_request(GPIO_FN_KEYIN4_PU, NULL);
  342. gpio_request(GPIO_FN_KEYIN5_PU, NULL);
  343. gpio_request(GPIO_FN_KEYIN6_PU, NULL);
  344. gpio_request(GPIO_FN_KEYIN7_PU, NULL);
  345. gpio_request(GPIO_FN_KEYOUT0, NULL);
  346. gpio_request(GPIO_FN_KEYOUT1, NULL);
  347. gpio_request(GPIO_FN_KEYOUT2, NULL);
  348. gpio_request(GPIO_FN_KEYOUT3, NULL);
  349. gpio_request(GPIO_FN_KEYOUT4, NULL);
  350. gpio_request(GPIO_FN_KEYOUT5, NULL);
  351. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  352. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  353. gpio_request(GPIO_FN_KEYOUT8, NULL);
  354. /* MMCIF */
  355. gpio_request(GPIO_FN_MMCCLK0, NULL);
  356. gpio_request(GPIO_FN_MMCD0_0, NULL);
  357. gpio_request(GPIO_FN_MMCD0_1, NULL);
  358. gpio_request(GPIO_FN_MMCD0_2, NULL);
  359. gpio_request(GPIO_FN_MMCD0_3, NULL);
  360. gpio_request(GPIO_FN_MMCD0_4, NULL);
  361. gpio_request(GPIO_FN_MMCD0_5, NULL);
  362. gpio_request(GPIO_FN_MMCD0_6, NULL);
  363. gpio_request(GPIO_FN_MMCD0_7, NULL);
  364. gpio_request(GPIO_FN_MMCCMD0, NULL);
  365. gpio_request(GPIO_PORT208, NULL); /* Reset */
  366. gpio_direction_output(GPIO_PORT208, 1);
  367. /* SDHI0 (microSD) */
  368. gpio_request(GPIO_FN_SDHICD0_PU, NULL);
  369. gpio_request(GPIO_FN_SDHICMD0_PU, NULL);
  370. gpio_request(GPIO_FN_SDHICLK0, NULL);
  371. gpio_request(GPIO_FN_SDHID0_3_PU, NULL);
  372. gpio_request(GPIO_FN_SDHID0_2_PU, NULL);
  373. gpio_request(GPIO_FN_SDHID0_1_PU, NULL);
  374. gpio_request(GPIO_FN_SDHID0_0_PU, NULL);
  375. /* SCIFB (BT) */
  376. gpio_request(GPIO_FN_PORT159_SCIFB_SCK, NULL);
  377. gpio_request(GPIO_FN_PORT160_SCIFB_TXD, NULL);
  378. gpio_request(GPIO_FN_PORT161_SCIFB_CTS_, NULL);
  379. gpio_request(GPIO_FN_PORT162_SCIFB_RXD, NULL);
  380. gpio_request(GPIO_FN_PORT163_SCIFB_RTS_, NULL);
  381. /* SDHI1 (BCM4330) */
  382. gpio_request(GPIO_FN_SDHICLK1, NULL);
  383. gpio_request(GPIO_FN_SDHICMD1_PU, NULL);
  384. gpio_request(GPIO_FN_SDHID1_3_PU, NULL);
  385. gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
  386. gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
  387. gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
  388. #ifdef CONFIG_CACHE_L2X0
  389. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  390. l2x0_init(__io(0xf0100000), 0x40460000, 0x82000fff);
  391. #endif
  392. sh73a0_add_standard_devices();
  393. platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
  394. }
  395. static void __init kota2_timer_init(void)
  396. {
  397. sh73a0_clock_init();
  398. shmobile_timer.init();
  399. return;
  400. }
  401. struct sys_timer kota2_timer = {
  402. .init = kota2_timer_init,
  403. };
  404. MACHINE_START(KOTA2, "kota2")
  405. .map_io = kota2_map_io,
  406. .init_irq = kota2_init_irq,
  407. .handle_irq = shmobile_handle_irq_gic,
  408. .init_machine = kota2_init,
  409. .timer = &kota2_timer,
  410. MACHINE_END