board-kota2.c 12 KB

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