board-kota2.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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/platform_data/leds-renesas-tpu.h>
  36. #include <linux/mmc/host.h>
  37. #include <linux/mmc/sh_mmcif.h>
  38. #include <linux/mfd/tmio.h>
  39. #include <linux/mmc/sh_mobile_sdhi.h>
  40. #include <mach/hardware.h>
  41. #include <mach/irqs.h>
  42. #include <mach/sh73a0.h>
  43. #include <mach/common.h>
  44. #include <asm/mach-types.h>
  45. #include <asm/mach/arch.h>
  46. #include <asm/mach/time.h>
  47. #include <asm/hardware/gic.h>
  48. #include <asm/hardware/cache-l2x0.h>
  49. #include <asm/traps.h>
  50. /* SMSC 9220 */
  51. static struct resource smsc9220_resources[] = {
  52. [0] = {
  53. .start = 0x14000000, /* CS5A */
  54. .end = 0x140000ff, /* A1->A7 */
  55. .flags = IORESOURCE_MEM,
  56. },
  57. [1] = {
  58. .start = SH73A0_PINT0_IRQ(2), /* PINTA2 */
  59. .flags = IORESOURCE_IRQ,
  60. },
  61. };
  62. static struct smsc911x_platform_config smsc9220_platdata = {
  63. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  64. .phy_interface = PHY_INTERFACE_MODE_MII,
  65. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  66. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  67. };
  68. static struct platform_device eth_device = {
  69. .name = "smsc911x",
  70. .id = 0,
  71. .dev = {
  72. .platform_data = &smsc9220_platdata,
  73. },
  74. .resource = smsc9220_resources,
  75. .num_resources = ARRAY_SIZE(smsc9220_resources),
  76. };
  77. /* KEYSC */
  78. static struct sh_keysc_info keysc_platdata = {
  79. .mode = SH_KEYSC_MODE_6,
  80. .scan_timing = 3,
  81. .delay = 100,
  82. .keycodes = {
  83. KEY_NUMERIC_STAR, KEY_NUMERIC_0, KEY_NUMERIC_POUND,
  84. 0, 0, 0, 0, 0,
  85. KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9,
  86. 0, KEY_DOWN, 0, 0, 0,
  87. KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6,
  88. KEY_LEFT, KEY_ENTER, KEY_RIGHT, 0, 0,
  89. KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3,
  90. 0, KEY_UP, 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. 0, 0, 0, 0, 0, 0, 0, 0,
  95. },
  96. };
  97. static struct resource keysc_resources[] = {
  98. [0] = {
  99. .name = "KEYSC",
  100. .start = 0xe61b0000,
  101. .end = 0xe61b0098 - 1,
  102. .flags = IORESOURCE_MEM,
  103. },
  104. [1] = {
  105. .start = gic_spi(71),
  106. .flags = IORESOURCE_IRQ,
  107. },
  108. };
  109. static struct platform_device keysc_device = {
  110. .name = "sh_keysc",
  111. .id = 0,
  112. .num_resources = ARRAY_SIZE(keysc_resources),
  113. .resource = keysc_resources,
  114. .dev = {
  115. .platform_data = &keysc_platdata,
  116. },
  117. };
  118. /* GPIO KEY */
  119. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  120. static struct gpio_keys_button gpio_buttons[] = {
  121. GPIO_KEY(KEY_VOLUMEUP, GPIO_PORT56, "+"), /* S2: VOL+ [IRQ9] */
  122. GPIO_KEY(KEY_VOLUMEDOWN, GPIO_PORT54, "-"), /* S3: VOL- [IRQ10] */
  123. GPIO_KEY(KEY_MENU, GPIO_PORT27, "Menu"), /* S4: MENU [IRQ30] */
  124. GPIO_KEY(KEY_HOMEPAGE, GPIO_PORT26, "Home"), /* S5: HOME [IRQ31] */
  125. GPIO_KEY(KEY_BACK, GPIO_PORT11, "Back"), /* S6: BACK [IRQ0] */
  126. GPIO_KEY(KEY_PHONE, GPIO_PORT238, "Tel"), /* S7: TEL [IRQ11] */
  127. GPIO_KEY(KEY_POWER, GPIO_PORT239, "C1"), /* S8: CAM [IRQ13] */
  128. GPIO_KEY(KEY_MAIL, GPIO_PORT224, "Mail"), /* S9: MAIL [IRQ3] */
  129. /* Omitted button "C3?": GPIO_PORT223 - S10: CUST [IRQ8] */
  130. GPIO_KEY(KEY_CAMERA, GPIO_PORT164, "C2"), /* S11: CAM_HALF [IRQ25] */
  131. /* Omitted button "?": GPIO_PORT152 - S12: CAM_FULL [No IRQ] */
  132. };
  133. static struct gpio_keys_platform_data gpio_key_info = {
  134. .buttons = gpio_buttons,
  135. .nbuttons = ARRAY_SIZE(gpio_buttons),
  136. };
  137. static struct platform_device gpio_keys_device = {
  138. .name = "gpio-keys",
  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("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. /* TPU LED */
  163. static struct led_renesas_tpu_config led_renesas_tpu12_pdata = {
  164. .name = "V2513",
  165. .pin_gpio_fn = GPIO_FN_TPU1TO2,
  166. .pin_gpio = GPIO_PORT153,
  167. .channel_offset = 0x90,
  168. .timer_bit = 2,
  169. .max_brightness = 1000,
  170. };
  171. static struct resource tpu12_resources[] = {
  172. [0] = {
  173. .name = "TPU12",
  174. .start = 0xe6610090,
  175. .end = 0xe66100b5,
  176. .flags = IORESOURCE_MEM,
  177. },
  178. };
  179. static struct platform_device leds_tpu12_device = {
  180. .name = "leds-renesas-tpu",
  181. .id = 12,
  182. .dev = {
  183. .platform_data = &led_renesas_tpu12_pdata,
  184. },
  185. .num_resources = ARRAY_SIZE(tpu12_resources),
  186. .resource = tpu12_resources,
  187. };
  188. static struct led_renesas_tpu_config led_renesas_tpu41_pdata = {
  189. .name = "V2514",
  190. .pin_gpio_fn = GPIO_FN_TPU4TO1,
  191. .pin_gpio = GPIO_PORT199,
  192. .channel_offset = 0x50,
  193. .timer_bit = 1,
  194. .max_brightness = 1000,
  195. };
  196. static struct resource tpu41_resources[] = {
  197. [0] = {
  198. .name = "TPU41",
  199. .start = 0xe6640050,
  200. .end = 0xe6640075,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. };
  204. static struct platform_device leds_tpu41_device = {
  205. .name = "leds-renesas-tpu",
  206. .id = 41,
  207. .dev = {
  208. .platform_data = &led_renesas_tpu41_pdata,
  209. },
  210. .num_resources = ARRAY_SIZE(tpu41_resources),
  211. .resource = tpu41_resources,
  212. };
  213. static struct led_renesas_tpu_config led_renesas_tpu21_pdata = {
  214. .name = "V2515",
  215. .pin_gpio_fn = GPIO_FN_TPU2TO1,
  216. .pin_gpio = GPIO_PORT197,
  217. .channel_offset = 0x50,
  218. .timer_bit = 1,
  219. .max_brightness = 1000,
  220. };
  221. static struct resource tpu21_resources[] = {
  222. [0] = {
  223. .name = "TPU21",
  224. .start = 0xe6620050,
  225. .end = 0xe6620075,
  226. .flags = IORESOURCE_MEM,
  227. },
  228. };
  229. static struct platform_device leds_tpu21_device = {
  230. .name = "leds-renesas-tpu",
  231. .id = 21,
  232. .dev = {
  233. .platform_data = &led_renesas_tpu21_pdata,
  234. },
  235. .num_resources = ARRAY_SIZE(tpu21_resources),
  236. .resource = tpu21_resources,
  237. };
  238. static struct led_renesas_tpu_config led_renesas_tpu30_pdata = {
  239. .name = "KEYLED",
  240. .pin_gpio_fn = GPIO_FN_TPU3TO0,
  241. .pin_gpio = GPIO_PORT163,
  242. .channel_offset = 0x10,
  243. .timer_bit = 0,
  244. .max_brightness = 1000,
  245. };
  246. static struct resource tpu30_resources[] = {
  247. [0] = {
  248. .name = "TPU30",
  249. .start = 0xe6630010,
  250. .end = 0xe6630035,
  251. .flags = IORESOURCE_MEM,
  252. },
  253. };
  254. static struct platform_device leds_tpu30_device = {
  255. .name = "leds-renesas-tpu",
  256. .id = 30,
  257. .dev = {
  258. .platform_data = &led_renesas_tpu30_pdata,
  259. },
  260. .num_resources = ARRAY_SIZE(tpu30_resources),
  261. .resource = tpu30_resources,
  262. };
  263. /* MMCIF */
  264. static struct resource mmcif_resources[] = {
  265. [0] = {
  266. .name = "MMCIF",
  267. .start = 0xe6bd0000,
  268. .end = 0xe6bd00ff,
  269. .flags = IORESOURCE_MEM,
  270. },
  271. [1] = {
  272. .start = gic_spi(140),
  273. .flags = IORESOURCE_IRQ,
  274. },
  275. [2] = {
  276. .start = gic_spi(141),
  277. .flags = IORESOURCE_IRQ,
  278. },
  279. };
  280. static struct sh_mmcif_plat_data mmcif_info = {
  281. .ocr = MMC_VDD_165_195,
  282. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  283. };
  284. static struct platform_device mmcif_device = {
  285. .name = "sh_mmcif",
  286. .id = 0,
  287. .dev = {
  288. .platform_data = &mmcif_info,
  289. },
  290. .num_resources = ARRAY_SIZE(mmcif_resources),
  291. .resource = mmcif_resources,
  292. };
  293. /* SDHI0 */
  294. static struct sh_mobile_sdhi_info sdhi0_info = {
  295. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  296. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  297. };
  298. static struct resource sdhi0_resources[] = {
  299. [0] = {
  300. .name = "SDHI0",
  301. .start = 0xee100000,
  302. .end = 0xee1000ff,
  303. .flags = IORESOURCE_MEM,
  304. },
  305. [1] = {
  306. .start = gic_spi(83),
  307. .flags = IORESOURCE_IRQ,
  308. },
  309. [2] = {
  310. .start = gic_spi(84),
  311. .flags = IORESOURCE_IRQ,
  312. },
  313. [3] = {
  314. .start = gic_spi(85),
  315. .flags = IORESOURCE_IRQ,
  316. },
  317. };
  318. static struct platform_device sdhi0_device = {
  319. .name = "sh_mobile_sdhi",
  320. .id = 0,
  321. .num_resources = ARRAY_SIZE(sdhi0_resources),
  322. .resource = sdhi0_resources,
  323. .dev = {
  324. .platform_data = &sdhi0_info,
  325. },
  326. };
  327. /* SDHI1 */
  328. static struct sh_mobile_sdhi_info sdhi1_info = {
  329. .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
  330. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  331. };
  332. static struct resource sdhi1_resources[] = {
  333. [0] = {
  334. .name = "SDHI1",
  335. .start = 0xee120000,
  336. .end = 0xee1200ff,
  337. .flags = IORESOURCE_MEM,
  338. },
  339. [1] = {
  340. .start = gic_spi(87),
  341. .flags = IORESOURCE_IRQ,
  342. },
  343. [2] = {
  344. .start = gic_spi(88),
  345. .flags = IORESOURCE_IRQ,
  346. },
  347. [3] = {
  348. .start = gic_spi(89),
  349. .flags = IORESOURCE_IRQ,
  350. },
  351. };
  352. static struct platform_device sdhi1_device = {
  353. .name = "sh_mobile_sdhi",
  354. .id = 1,
  355. .num_resources = ARRAY_SIZE(sdhi1_resources),
  356. .resource = sdhi1_resources,
  357. .dev = {
  358. .platform_data = &sdhi1_info,
  359. },
  360. };
  361. static struct platform_device *kota2_devices[] __initdata = {
  362. &eth_device,
  363. &keysc_device,
  364. &gpio_keys_device,
  365. &gpio_leds_device,
  366. &leds_tpu12_device,
  367. &leds_tpu41_device,
  368. &leds_tpu21_device,
  369. &leds_tpu30_device,
  370. &mmcif_device,
  371. &sdhi0_device,
  372. &sdhi1_device,
  373. };
  374. static void __init kota2_init(void)
  375. {
  376. sh73a0_pinmux_init();
  377. /* SCIFA2 (UART2) */
  378. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  379. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  380. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  381. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  382. /* SCIFA4 (UART1) */
  383. gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
  384. gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
  385. gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
  386. gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
  387. /* SMSC911X */
  388. gpio_request(GPIO_FN_D0_NAF0, NULL);
  389. gpio_request(GPIO_FN_D1_NAF1, NULL);
  390. gpio_request(GPIO_FN_D2_NAF2, NULL);
  391. gpio_request(GPIO_FN_D3_NAF3, NULL);
  392. gpio_request(GPIO_FN_D4_NAF4, NULL);
  393. gpio_request(GPIO_FN_D5_NAF5, NULL);
  394. gpio_request(GPIO_FN_D6_NAF6, NULL);
  395. gpio_request(GPIO_FN_D7_NAF7, NULL);
  396. gpio_request(GPIO_FN_D8_NAF8, NULL);
  397. gpio_request(GPIO_FN_D9_NAF9, NULL);
  398. gpio_request(GPIO_FN_D10_NAF10, NULL);
  399. gpio_request(GPIO_FN_D11_NAF11, NULL);
  400. gpio_request(GPIO_FN_D12_NAF12, NULL);
  401. gpio_request(GPIO_FN_D13_NAF13, NULL);
  402. gpio_request(GPIO_FN_D14_NAF14, NULL);
  403. gpio_request(GPIO_FN_D15_NAF15, NULL);
  404. gpio_request(GPIO_FN_CS5A_, NULL);
  405. gpio_request(GPIO_FN_WE0__FWE, NULL);
  406. gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
  407. gpio_direction_input(GPIO_PORT144);
  408. gpio_request(GPIO_PORT145, NULL); /* RESET */
  409. gpio_direction_output(GPIO_PORT145, 1);
  410. /* KEYSC */
  411. gpio_request(GPIO_FN_KEYIN0_PU, NULL);
  412. gpio_request(GPIO_FN_KEYIN1_PU, NULL);
  413. gpio_request(GPIO_FN_KEYIN2_PU, NULL);
  414. gpio_request(GPIO_FN_KEYIN3_PU, NULL);
  415. gpio_request(GPIO_FN_KEYIN4_PU, NULL);
  416. gpio_request(GPIO_FN_KEYIN5_PU, NULL);
  417. gpio_request(GPIO_FN_KEYIN6_PU, NULL);
  418. gpio_request(GPIO_FN_KEYIN7_PU, NULL);
  419. gpio_request(GPIO_FN_KEYOUT0, NULL);
  420. gpio_request(GPIO_FN_KEYOUT1, NULL);
  421. gpio_request(GPIO_FN_KEYOUT2, NULL);
  422. gpio_request(GPIO_FN_KEYOUT3, NULL);
  423. gpio_request(GPIO_FN_KEYOUT4, NULL);
  424. gpio_request(GPIO_FN_KEYOUT5, NULL);
  425. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  426. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  427. gpio_request(GPIO_FN_KEYOUT8, NULL);
  428. /* MMCIF */
  429. gpio_request(GPIO_FN_MMCCLK0, NULL);
  430. gpio_request(GPIO_FN_MMCD0_0, NULL);
  431. gpio_request(GPIO_FN_MMCD0_1, NULL);
  432. gpio_request(GPIO_FN_MMCD0_2, NULL);
  433. gpio_request(GPIO_FN_MMCD0_3, NULL);
  434. gpio_request(GPIO_FN_MMCD0_4, NULL);
  435. gpio_request(GPIO_FN_MMCD0_5, NULL);
  436. gpio_request(GPIO_FN_MMCD0_6, NULL);
  437. gpio_request(GPIO_FN_MMCD0_7, NULL);
  438. gpio_request(GPIO_FN_MMCCMD0, NULL);
  439. gpio_request(GPIO_PORT208, NULL); /* Reset */
  440. gpio_direction_output(GPIO_PORT208, 1);
  441. /* SDHI0 (microSD) */
  442. gpio_request(GPIO_FN_SDHICD0_PU, NULL);
  443. gpio_request(GPIO_FN_SDHICMD0_PU, NULL);
  444. gpio_request(GPIO_FN_SDHICLK0, NULL);
  445. gpio_request(GPIO_FN_SDHID0_3_PU, NULL);
  446. gpio_request(GPIO_FN_SDHID0_2_PU, NULL);
  447. gpio_request(GPIO_FN_SDHID0_1_PU, NULL);
  448. gpio_request(GPIO_FN_SDHID0_0_PU, NULL);
  449. /* SCIFB (BT) */
  450. gpio_request(GPIO_FN_PORT159_SCIFB_SCK, NULL);
  451. gpio_request(GPIO_FN_PORT160_SCIFB_TXD, NULL);
  452. gpio_request(GPIO_FN_PORT161_SCIFB_CTS_, NULL);
  453. gpio_request(GPIO_FN_PORT162_SCIFB_RXD, NULL);
  454. gpio_request(GPIO_FN_PORT163_SCIFB_RTS_, NULL);
  455. /* SDHI1 (BCM4330) */
  456. gpio_request(GPIO_FN_SDHICLK1, NULL);
  457. gpio_request(GPIO_FN_SDHICMD1_PU, NULL);
  458. gpio_request(GPIO_FN_SDHID1_3_PU, NULL);
  459. gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
  460. gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
  461. gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
  462. #ifdef CONFIG_CACHE_L2X0
  463. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  464. l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
  465. #endif
  466. sh73a0_add_standard_devices();
  467. platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
  468. }
  469. MACHINE_START(KOTA2, "kota2")
  470. .map_io = sh73a0_map_io,
  471. .init_early = sh73a0_add_early_devices,
  472. .nr_irqs = NR_IRQS_LEGACY,
  473. .init_irq = sh73a0_init_irq,
  474. .handle_irq = gic_handle_irq,
  475. .init_machine = kota2_init,
  476. .timer = &shmobile_timer,
  477. MACHINE_END