board-kota2.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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/sh73a0.h>
  42. #include <mach/common.h>
  43. #include <asm/mach-types.h>
  44. #include <asm/mach/arch.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 = SH73A0_PINT0_IRQ(2), /* PINTA2 */
  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. };
  136. static struct platform_device gpio_keys_device = {
  137. .name = "gpio-keys",
  138. .id = -1,
  139. .dev = {
  140. .platform_data = &gpio_key_info,
  141. },
  142. };
  143. /* GPIO LED */
  144. #define GPIO_LED(n, g) { .name = n, .gpio = g }
  145. static struct gpio_led gpio_leds[] = {
  146. GPIO_LED("G", GPIO_PORT20), /* PORT20 [GPO0] -> LED7 -> "G" */
  147. GPIO_LED("H", GPIO_PORT21), /* PORT21 [GPO1] -> LED8 -> "H" */
  148. GPIO_LED("J", GPIO_PORT22), /* PORT22 [GPO2] -> LED9 -> "J" */
  149. };
  150. static struct gpio_led_platform_data gpio_leds_info = {
  151. .leds = gpio_leds,
  152. .num_leds = ARRAY_SIZE(gpio_leds),
  153. };
  154. static struct platform_device gpio_leds_device = {
  155. .name = "leds-gpio",
  156. .id = -1,
  157. .dev = {
  158. .platform_data = &gpio_leds_info,
  159. },
  160. };
  161. /* TPU LED */
  162. static struct led_renesas_tpu_config led_renesas_tpu12_pdata = {
  163. .name = "V2513",
  164. .pin_gpio_fn = GPIO_FN_TPU1TO2,
  165. .pin_gpio = GPIO_PORT153,
  166. .channel_offset = 0x90,
  167. .timer_bit = 2,
  168. .max_brightness = 1000,
  169. };
  170. static struct resource tpu12_resources[] = {
  171. [0] = {
  172. .name = "TPU12",
  173. .start = 0xe6610090,
  174. .end = 0xe66100b5,
  175. .flags = IORESOURCE_MEM,
  176. },
  177. };
  178. static struct platform_device leds_tpu12_device = {
  179. .name = "leds-renesas-tpu",
  180. .id = 12,
  181. .dev = {
  182. .platform_data = &led_renesas_tpu12_pdata,
  183. },
  184. .num_resources = ARRAY_SIZE(tpu12_resources),
  185. .resource = tpu12_resources,
  186. };
  187. static struct led_renesas_tpu_config led_renesas_tpu41_pdata = {
  188. .name = "V2514",
  189. .pin_gpio_fn = GPIO_FN_TPU4TO1,
  190. .pin_gpio = GPIO_PORT199,
  191. .channel_offset = 0x50,
  192. .timer_bit = 1,
  193. .max_brightness = 1000,
  194. };
  195. static struct resource tpu41_resources[] = {
  196. [0] = {
  197. .name = "TPU41",
  198. .start = 0xe6640050,
  199. .end = 0xe6640075,
  200. .flags = IORESOURCE_MEM,
  201. },
  202. };
  203. static struct platform_device leds_tpu41_device = {
  204. .name = "leds-renesas-tpu",
  205. .id = 41,
  206. .dev = {
  207. .platform_data = &led_renesas_tpu41_pdata,
  208. },
  209. .num_resources = ARRAY_SIZE(tpu41_resources),
  210. .resource = tpu41_resources,
  211. };
  212. static struct led_renesas_tpu_config led_renesas_tpu21_pdata = {
  213. .name = "V2515",
  214. .pin_gpio_fn = GPIO_FN_TPU2TO1,
  215. .pin_gpio = GPIO_PORT197,
  216. .channel_offset = 0x50,
  217. .timer_bit = 1,
  218. .max_brightness = 1000,
  219. };
  220. static struct resource tpu21_resources[] = {
  221. [0] = {
  222. .name = "TPU21",
  223. .start = 0xe6620050,
  224. .end = 0xe6620075,
  225. .flags = IORESOURCE_MEM,
  226. },
  227. };
  228. static struct platform_device leds_tpu21_device = {
  229. .name = "leds-renesas-tpu",
  230. .id = 21,
  231. .dev = {
  232. .platform_data = &led_renesas_tpu21_pdata,
  233. },
  234. .num_resources = ARRAY_SIZE(tpu21_resources),
  235. .resource = tpu21_resources,
  236. };
  237. static struct led_renesas_tpu_config led_renesas_tpu30_pdata = {
  238. .name = "KEYLED",
  239. .pin_gpio_fn = GPIO_FN_TPU3TO0,
  240. .pin_gpio = GPIO_PORT163,
  241. .channel_offset = 0x10,
  242. .timer_bit = 0,
  243. .max_brightness = 1000,
  244. };
  245. static struct resource tpu30_resources[] = {
  246. [0] = {
  247. .name = "TPU30",
  248. .start = 0xe6630010,
  249. .end = 0xe6630035,
  250. .flags = IORESOURCE_MEM,
  251. },
  252. };
  253. static struct platform_device leds_tpu30_device = {
  254. .name = "leds-renesas-tpu",
  255. .id = 30,
  256. .dev = {
  257. .platform_data = &led_renesas_tpu30_pdata,
  258. },
  259. .num_resources = ARRAY_SIZE(tpu30_resources),
  260. .resource = tpu30_resources,
  261. };
  262. /* MMCIF */
  263. static struct resource mmcif_resources[] = {
  264. [0] = {
  265. .name = "MMCIF",
  266. .start = 0xe6bd0000,
  267. .end = 0xe6bd00ff,
  268. .flags = IORESOURCE_MEM,
  269. },
  270. [1] = {
  271. .start = gic_spi(140),
  272. .flags = IORESOURCE_IRQ,
  273. },
  274. [2] = {
  275. .start = gic_spi(141),
  276. .flags = IORESOURCE_IRQ,
  277. },
  278. };
  279. static struct sh_mmcif_plat_data mmcif_info = {
  280. .ocr = MMC_VDD_165_195,
  281. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  282. };
  283. static struct platform_device mmcif_device = {
  284. .name = "sh_mmcif",
  285. .id = 0,
  286. .dev = {
  287. .platform_data = &mmcif_info,
  288. },
  289. .num_resources = ARRAY_SIZE(mmcif_resources),
  290. .resource = mmcif_resources,
  291. };
  292. /* SDHI0 */
  293. static struct sh_mobile_sdhi_info sdhi0_info = {
  294. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  295. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  296. };
  297. static struct resource sdhi0_resources[] = {
  298. [0] = {
  299. .name = "SDHI0",
  300. .start = 0xee100000,
  301. .end = 0xee1000ff,
  302. .flags = IORESOURCE_MEM,
  303. },
  304. [1] = {
  305. .start = gic_spi(83),
  306. .flags = IORESOURCE_IRQ,
  307. },
  308. [2] = {
  309. .start = gic_spi(84),
  310. .flags = IORESOURCE_IRQ,
  311. },
  312. [3] = {
  313. .start = gic_spi(85),
  314. .flags = IORESOURCE_IRQ,
  315. },
  316. };
  317. static struct platform_device sdhi0_device = {
  318. .name = "sh_mobile_sdhi",
  319. .id = 0,
  320. .num_resources = ARRAY_SIZE(sdhi0_resources),
  321. .resource = sdhi0_resources,
  322. .dev = {
  323. .platform_data = &sdhi0_info,
  324. },
  325. };
  326. /* SDHI1 */
  327. static struct sh_mobile_sdhi_info sdhi1_info = {
  328. .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
  329. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  330. };
  331. static struct resource sdhi1_resources[] = {
  332. [0] = {
  333. .name = "SDHI1",
  334. .start = 0xee120000,
  335. .end = 0xee1200ff,
  336. .flags = IORESOURCE_MEM,
  337. },
  338. [1] = {
  339. .start = gic_spi(87),
  340. .flags = IORESOURCE_IRQ,
  341. },
  342. [2] = {
  343. .start = gic_spi(88),
  344. .flags = IORESOURCE_IRQ,
  345. },
  346. [3] = {
  347. .start = gic_spi(89),
  348. .flags = IORESOURCE_IRQ,
  349. },
  350. };
  351. static struct platform_device sdhi1_device = {
  352. .name = "sh_mobile_sdhi",
  353. .id = 1,
  354. .num_resources = ARRAY_SIZE(sdhi1_resources),
  355. .resource = sdhi1_resources,
  356. .dev = {
  357. .platform_data = &sdhi1_info,
  358. },
  359. };
  360. static struct platform_device *kota2_devices[] __initdata = {
  361. &eth_device,
  362. &keysc_device,
  363. &gpio_keys_device,
  364. &gpio_leds_device,
  365. &leds_tpu12_device,
  366. &leds_tpu41_device,
  367. &leds_tpu21_device,
  368. &leds_tpu30_device,
  369. &mmcif_device,
  370. &sdhi0_device,
  371. &sdhi1_device,
  372. };
  373. static void __init kota2_init(void)
  374. {
  375. sh73a0_pinmux_init();
  376. /* SCIFA2 (UART2) */
  377. gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
  378. gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
  379. gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
  380. gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
  381. /* SCIFA4 (UART1) */
  382. gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
  383. gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
  384. gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
  385. gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
  386. /* SMSC911X */
  387. gpio_request(GPIO_FN_D0_NAF0, NULL);
  388. gpio_request(GPIO_FN_D1_NAF1, NULL);
  389. gpio_request(GPIO_FN_D2_NAF2, NULL);
  390. gpio_request(GPIO_FN_D3_NAF3, NULL);
  391. gpio_request(GPIO_FN_D4_NAF4, NULL);
  392. gpio_request(GPIO_FN_D5_NAF5, NULL);
  393. gpio_request(GPIO_FN_D6_NAF6, NULL);
  394. gpio_request(GPIO_FN_D7_NAF7, NULL);
  395. gpio_request(GPIO_FN_D8_NAF8, NULL);
  396. gpio_request(GPIO_FN_D9_NAF9, NULL);
  397. gpio_request(GPIO_FN_D10_NAF10, NULL);
  398. gpio_request(GPIO_FN_D11_NAF11, NULL);
  399. gpio_request(GPIO_FN_D12_NAF12, NULL);
  400. gpio_request(GPIO_FN_D13_NAF13, NULL);
  401. gpio_request(GPIO_FN_D14_NAF14, NULL);
  402. gpio_request(GPIO_FN_D15_NAF15, NULL);
  403. gpio_request(GPIO_FN_CS5A_, NULL);
  404. gpio_request(GPIO_FN_WE0__FWE, NULL);
  405. gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
  406. gpio_direction_input(GPIO_PORT144);
  407. gpio_request(GPIO_PORT145, NULL); /* RESET */
  408. gpio_direction_output(GPIO_PORT145, 1);
  409. /* KEYSC */
  410. gpio_request(GPIO_FN_KEYIN0_PU, NULL);
  411. gpio_request(GPIO_FN_KEYIN1_PU, NULL);
  412. gpio_request(GPIO_FN_KEYIN2_PU, NULL);
  413. gpio_request(GPIO_FN_KEYIN3_PU, NULL);
  414. gpio_request(GPIO_FN_KEYIN4_PU, NULL);
  415. gpio_request(GPIO_FN_KEYIN5_PU, NULL);
  416. gpio_request(GPIO_FN_KEYIN6_PU, NULL);
  417. gpio_request(GPIO_FN_KEYIN7_PU, NULL);
  418. gpio_request(GPIO_FN_KEYOUT0, NULL);
  419. gpio_request(GPIO_FN_KEYOUT1, NULL);
  420. gpio_request(GPIO_FN_KEYOUT2, NULL);
  421. gpio_request(GPIO_FN_KEYOUT3, NULL);
  422. gpio_request(GPIO_FN_KEYOUT4, NULL);
  423. gpio_request(GPIO_FN_KEYOUT5, NULL);
  424. gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
  425. gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
  426. gpio_request(GPIO_FN_KEYOUT8, NULL);
  427. /* MMCIF */
  428. gpio_request(GPIO_FN_MMCCLK0, NULL);
  429. gpio_request(GPIO_FN_MMCD0_0, NULL);
  430. gpio_request(GPIO_FN_MMCD0_1, NULL);
  431. gpio_request(GPIO_FN_MMCD0_2, NULL);
  432. gpio_request(GPIO_FN_MMCD0_3, NULL);
  433. gpio_request(GPIO_FN_MMCD0_4, NULL);
  434. gpio_request(GPIO_FN_MMCD0_5, NULL);
  435. gpio_request(GPIO_FN_MMCD0_6, NULL);
  436. gpio_request(GPIO_FN_MMCD0_7, NULL);
  437. gpio_request(GPIO_FN_MMCCMD0, NULL);
  438. gpio_request(GPIO_PORT208, NULL); /* Reset */
  439. gpio_direction_output(GPIO_PORT208, 1);
  440. /* SDHI0 (microSD) */
  441. gpio_request(GPIO_FN_SDHICD0_PU, NULL);
  442. gpio_request(GPIO_FN_SDHICMD0_PU, NULL);
  443. gpio_request(GPIO_FN_SDHICLK0, NULL);
  444. gpio_request(GPIO_FN_SDHID0_3_PU, NULL);
  445. gpio_request(GPIO_FN_SDHID0_2_PU, NULL);
  446. gpio_request(GPIO_FN_SDHID0_1_PU, NULL);
  447. gpio_request(GPIO_FN_SDHID0_0_PU, NULL);
  448. /* SCIFB (BT) */
  449. gpio_request(GPIO_FN_PORT159_SCIFB_SCK, NULL);
  450. gpio_request(GPIO_FN_PORT160_SCIFB_TXD, NULL);
  451. gpio_request(GPIO_FN_PORT161_SCIFB_CTS_, NULL);
  452. gpio_request(GPIO_FN_PORT162_SCIFB_RXD, NULL);
  453. gpio_request(GPIO_FN_PORT163_SCIFB_RTS_, NULL);
  454. /* SDHI1 (BCM4330) */
  455. gpio_request(GPIO_FN_SDHICLK1, NULL);
  456. gpio_request(GPIO_FN_SDHICMD1_PU, NULL);
  457. gpio_request(GPIO_FN_SDHID1_3_PU, NULL);
  458. gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
  459. gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
  460. gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
  461. #ifdef CONFIG_CACHE_L2X0
  462. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  463. l2x0_init(__io(0xf0100000), 0x40460000, 0x82000fff);
  464. #endif
  465. sh73a0_add_standard_devices();
  466. platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
  467. }
  468. MACHINE_START(KOTA2, "kota2")
  469. .map_io = sh73a0_map_io,
  470. .init_early = sh73a0_add_early_devices,
  471. .nr_irqs = NR_IRQS_LEGACY,
  472. .init_irq = sh73a0_init_irq,
  473. .handle_irq = gic_handle_irq,
  474. .init_machine = kota2_init,
  475. .timer = &shmobile_timer,
  476. MACHINE_END