board-armadillo800eva.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. /*
  2. * armadillo 800 eva board support
  3. *
  4. * Copyright (C) 2012 Renesas Solutions Corp.
  5. * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  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 as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #include <linux/clk.h>
  22. #include <linux/delay.h>
  23. #include <linux/err.h>
  24. #include <linux/kernel.h>
  25. #include <linux/input.h>
  26. #include <linux/irq.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/gpio.h>
  29. #include <linux/gpio_keys.h>
  30. #include <linux/sh_eth.h>
  31. #include <linux/videodev2.h>
  32. #include <linux/usb/renesas_usbhs.h>
  33. #include <linux/mfd/tmio.h>
  34. #include <linux/mmc/host.h>
  35. #include <linux/mmc/sh_mmcif.h>
  36. #include <linux/mmc/sh_mobile_sdhi.h>
  37. #include <mach/common.h>
  38. #include <mach/irqs.h>
  39. #include <asm/page.h>
  40. #include <asm/mach-types.h>
  41. #include <asm/mach/arch.h>
  42. #include <asm/mach/map.h>
  43. #include <asm/mach/time.h>
  44. #include <asm/hardware/cache-l2x0.h>
  45. #include <mach/r8a7740.h>
  46. #include <video/sh_mobile_lcdc.h>
  47. /*
  48. * CON1 Camera Module
  49. * CON2 Extension Bus
  50. * CON3 HDMI Output
  51. * CON4 Composite Video Output
  52. * CON5 H-UDI JTAG
  53. * CON6 ARM JTAG
  54. * CON7 SD1
  55. * CON8 SD2
  56. * CON9 RTC BackUp
  57. * CON10 Monaural Mic Input
  58. * CON11 Stereo Headphone Output
  59. * CON12 Audio Line Output(L)
  60. * CON13 Audio Line Output(R)
  61. * CON14 AWL13 Module
  62. * CON15 Extension
  63. * CON16 LCD1
  64. * CON17 LCD2
  65. * CON19 Power Input
  66. * CON20 USB1
  67. * CON21 USB2
  68. * CON22 Serial
  69. * CON23 LAN
  70. * CON24 USB3
  71. * LED1 Camera LED(Yellow)
  72. * LED2 Power LED (Green)
  73. * ED3-LED6 User LED(Yellow)
  74. * LED7 LAN link LED(Green)
  75. * LED8 LAN activity LED(Yellow)
  76. */
  77. /*
  78. * DipSwitch
  79. *
  80. * SW1
  81. *
  82. * -12345678-+---------------+----------------------------
  83. * 1 | boot | hermit
  84. * 0 | boot | OS auto boot
  85. * -12345678-+---------------+----------------------------
  86. * 00 | boot device | eMMC
  87. * 10 | boot device | SDHI0 (CON7)
  88. * 01 | boot device | -
  89. * 11 | boot device | Extension Buss (CS0)
  90. * -12345678-+---------------+----------------------------
  91. * 0 | Extension Bus | D8-D15 disable, eMMC enable
  92. * 1 | Extension Bus | D8-D15 enable, eMMC disable
  93. * -12345678-+---------------+----------------------------
  94. * 0 | SDHI1 | COM8 disable, COM14 enable
  95. * 1 | SDHI1 | COM8 enable, COM14 disable
  96. * -12345678-+---------------+----------------------------
  97. * 0 | USB0 | COM20 enable, COM24 disable
  98. * 1 | USB0 | COM20 disable, COM24 enable
  99. * -12345678-+---------------+----------------------------
  100. * 00 | JTAG | SH-X2
  101. * 10 | JTAG | ARM
  102. * 01 | JTAG | -
  103. * 11 | JTAG | Boundary Scan
  104. *-----------+---------------+----------------------------
  105. */
  106. /*
  107. * USB function
  108. *
  109. * When you use USB Function,
  110. * set SW1.6 ON, and connect cable to CN24.
  111. *
  112. * USBF needs workaround on R8A7740 chip.
  113. * These are a little bit complex.
  114. * see
  115. * usbhsf_power_ctrl()
  116. *
  117. * CAUTION
  118. *
  119. * It uses autonomy mode for USB hotplug at this point
  120. * (= usbhs_private.platform_callback.get_vbus is NULL),
  121. * since we don't know what's happen on PM control
  122. * on this workaround.
  123. */
  124. #define USBCR1 0xe605810a
  125. #define USBH 0xC6700000
  126. #define USBH_USBCTR 0x10834
  127. struct usbhsf_private {
  128. struct clk *phy;
  129. struct clk *usb24;
  130. struct clk *pci;
  131. struct clk *func;
  132. struct clk *host;
  133. void __iomem *usbh_base;
  134. struct renesas_usbhs_platform_info info;
  135. };
  136. #define usbhsf_get_priv(pdev) \
  137. container_of(renesas_usbhs_get_info(pdev), \
  138. struct usbhsf_private, info)
  139. static int usbhsf_get_id(struct platform_device *pdev)
  140. {
  141. return USBHS_GADGET;
  142. }
  143. static void usbhsf_power_ctrl(struct platform_device *pdev,
  144. void __iomem *base, int enable)
  145. {
  146. struct usbhsf_private *priv = usbhsf_get_priv(pdev);
  147. /*
  148. * Work around for USB Function.
  149. * It needs USB host clock, and settings
  150. */
  151. if (enable) {
  152. /*
  153. * enable all the related usb clocks
  154. * for usb workaround
  155. */
  156. clk_enable(priv->usb24);
  157. clk_enable(priv->pci);
  158. clk_enable(priv->host);
  159. clk_enable(priv->func);
  160. clk_enable(priv->phy);
  161. /*
  162. * set USBCR1
  163. *
  164. * Port1 is driven by USB function,
  165. * Port2 is driven by USB HOST
  166. * One HOST (Port1 or Port2 is HOST)
  167. * USB PLL input clock = 24MHz
  168. */
  169. __raw_writew(0xd750, USBCR1);
  170. mdelay(1);
  171. /*
  172. * start USB Host
  173. */
  174. __raw_writel(0x0000000c, priv->usbh_base + USBH_USBCTR);
  175. __raw_writel(0x00000008, priv->usbh_base + USBH_USBCTR);
  176. mdelay(10);
  177. /*
  178. * USB PHY Power ON
  179. */
  180. __raw_writew(0xd770, USBCR1);
  181. __raw_writew(0x4000, base + 0x102); /* USBF :: SUSPMODE */
  182. } else {
  183. __raw_writel(0x0000010f, priv->usbh_base + USBH_USBCTR);
  184. __raw_writew(0xd7c0, USBCR1); /* GPIO */
  185. clk_disable(priv->phy);
  186. clk_disable(priv->func); /* usb work around */
  187. clk_disable(priv->host); /* usb work around */
  188. clk_disable(priv->pci); /* usb work around */
  189. clk_disable(priv->usb24); /* usb work around */
  190. }
  191. }
  192. static void usbhsf_hardware_exit(struct platform_device *pdev)
  193. {
  194. struct usbhsf_private *priv = usbhsf_get_priv(pdev);
  195. if (!IS_ERR(priv->phy))
  196. clk_put(priv->phy);
  197. if (!IS_ERR(priv->usb24))
  198. clk_put(priv->usb24);
  199. if (!IS_ERR(priv->pci))
  200. clk_put(priv->pci);
  201. if (!IS_ERR(priv->host))
  202. clk_put(priv->host);
  203. if (!IS_ERR(priv->func))
  204. clk_put(priv->func);
  205. if (priv->usbh_base)
  206. iounmap(priv->usbh_base);
  207. priv->phy = NULL;
  208. priv->usb24 = NULL;
  209. priv->pci = NULL;
  210. priv->host = NULL;
  211. priv->func = NULL;
  212. priv->usbh_base = NULL;
  213. }
  214. static int usbhsf_hardware_init(struct platform_device *pdev)
  215. {
  216. struct usbhsf_private *priv = usbhsf_get_priv(pdev);
  217. priv->phy = clk_get(&pdev->dev, "phy");
  218. priv->usb24 = clk_get(&pdev->dev, "usb24");
  219. priv->pci = clk_get(&pdev->dev, "pci");
  220. priv->func = clk_get(&pdev->dev, "func");
  221. priv->host = clk_get(&pdev->dev, "host");
  222. priv->usbh_base = ioremap_nocache(USBH, 0x20000);
  223. if (IS_ERR(priv->phy) ||
  224. IS_ERR(priv->usb24) ||
  225. IS_ERR(priv->pci) ||
  226. IS_ERR(priv->host) ||
  227. IS_ERR(priv->func) ||
  228. !priv->usbh_base) {
  229. dev_err(&pdev->dev, "USB clock setting failed\n");
  230. usbhsf_hardware_exit(pdev);
  231. return -EIO;
  232. }
  233. /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */
  234. clk_set_rate(priv->usb24,
  235. clk_get_rate(clk_get_parent(priv->usb24)));
  236. return 0;
  237. }
  238. static struct usbhsf_private usbhsf_private = {
  239. .info = {
  240. .platform_callback = {
  241. .get_id = usbhsf_get_id,
  242. .hardware_init = usbhsf_hardware_init,
  243. .hardware_exit = usbhsf_hardware_exit,
  244. .power_ctrl = usbhsf_power_ctrl,
  245. },
  246. .driver_param = {
  247. .buswait_bwait = 5,
  248. .detection_delay = 5,
  249. },
  250. }
  251. };
  252. static struct resource usbhsf_resources[] = {
  253. {
  254. .name = "USBHS",
  255. .start = 0xe6890000,
  256. .end = 0xe6890104 - 1,
  257. .flags = IORESOURCE_MEM,
  258. },
  259. {
  260. .start = evt2irq(0x0A20),
  261. .flags = IORESOURCE_IRQ,
  262. },
  263. };
  264. static struct platform_device usbhsf_device = {
  265. .name = "renesas_usbhs",
  266. .dev = {
  267. .platform_data = &usbhsf_private.info,
  268. },
  269. .id = -1,
  270. .num_resources = ARRAY_SIZE(usbhsf_resources),
  271. .resource = usbhsf_resources,
  272. };
  273. /* Ether */
  274. static struct sh_eth_plat_data sh_eth_platdata = {
  275. .phy = 0x00, /* LAN8710A */
  276. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  277. .register_type = SH_ETH_REG_GIGABIT,
  278. .phy_interface = PHY_INTERFACE_MODE_MII,
  279. };
  280. static struct resource sh_eth_resources[] = {
  281. {
  282. .start = 0xe9a00000,
  283. .end = 0xe9a00800 - 1,
  284. .flags = IORESOURCE_MEM,
  285. }, {
  286. .start = 0xe9a01800,
  287. .end = 0xe9a02000 - 1,
  288. .flags = IORESOURCE_MEM,
  289. }, {
  290. .start = evt2irq(0x0500),
  291. .flags = IORESOURCE_IRQ,
  292. },
  293. };
  294. static struct platform_device sh_eth_device = {
  295. .name = "sh-eth",
  296. .id = -1,
  297. .dev = {
  298. .platform_data = &sh_eth_platdata,
  299. },
  300. .resource = sh_eth_resources,
  301. .num_resources = ARRAY_SIZE(sh_eth_resources),
  302. };
  303. /* LCDC */
  304. static struct fb_videomode lcdc0_mode = {
  305. .name = "AMPIER/AM-800480",
  306. .xres = 800,
  307. .yres = 480,
  308. .left_margin = 88,
  309. .right_margin = 40,
  310. .hsync_len = 128,
  311. .upper_margin = 20,
  312. .lower_margin = 5,
  313. .vsync_len = 5,
  314. .sync = 0,
  315. };
  316. static struct sh_mobile_lcdc_info lcdc0_info = {
  317. .clock_source = LCDC_CLK_BUS,
  318. .ch[0] = {
  319. .chan = LCDC_CHAN_MAINLCD,
  320. .fourcc = V4L2_PIX_FMT_RGB565,
  321. .interface_type = RGB24,
  322. .clock_divider = 5,
  323. .flags = 0,
  324. .lcd_modes = &lcdc0_mode,
  325. .num_modes = 1,
  326. .panel_cfg = {
  327. .width = 111,
  328. .height = 68,
  329. },
  330. },
  331. };
  332. static struct resource lcdc0_resources[] = {
  333. [0] = {
  334. .name = "LCD0",
  335. .start = 0xfe940000,
  336. .end = 0xfe943fff,
  337. .flags = IORESOURCE_MEM,
  338. },
  339. [1] = {
  340. .start = intcs_evt2irq(0x580),
  341. .flags = IORESOURCE_IRQ,
  342. },
  343. };
  344. static struct platform_device lcdc0_device = {
  345. .name = "sh_mobile_lcdc_fb",
  346. .num_resources = ARRAY_SIZE(lcdc0_resources),
  347. .resource = lcdc0_resources,
  348. .id = 0,
  349. .dev = {
  350. .platform_data = &lcdc0_info,
  351. .coherent_dma_mask = ~0,
  352. },
  353. };
  354. /* GPIO KEY */
  355. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  356. static struct gpio_keys_button gpio_buttons[] = {
  357. GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW1"),
  358. GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW2"),
  359. GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW3"),
  360. GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW4"),
  361. };
  362. static struct gpio_keys_platform_data gpio_key_info = {
  363. .buttons = gpio_buttons,
  364. .nbuttons = ARRAY_SIZE(gpio_buttons),
  365. };
  366. static struct platform_device gpio_keys_device = {
  367. .name = "gpio-keys",
  368. .id = -1,
  369. .dev = {
  370. .platform_data = &gpio_key_info,
  371. },
  372. };
  373. /* SDHI0 */
  374. /*
  375. * FIXME
  376. *
  377. * It use polling mode here, since
  378. * CD (= Card Detect) pin is not connected to SDHI0_CD.
  379. * We can use IRQ31 as card detect irq,
  380. * but it needs chattering removal operation
  381. */
  382. #define IRQ31 evt2irq(0x33E0)
  383. static struct sh_mobile_sdhi_info sdhi0_info = {
  384. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |\
  385. MMC_CAP_NEEDS_POLL,
  386. .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  387. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  388. };
  389. static struct resource sdhi0_resources[] = {
  390. {
  391. .name = "SDHI0",
  392. .start = 0xe6850000,
  393. .end = 0xe6850100 - 1,
  394. .flags = IORESOURCE_MEM,
  395. },
  396. /*
  397. * no SH_MOBILE_SDHI_IRQ_CARD_DETECT here
  398. */
  399. {
  400. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  401. .start = evt2irq(0x0E20),
  402. .flags = IORESOURCE_IRQ,
  403. },
  404. {
  405. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  406. .start = evt2irq(0x0E40),
  407. .flags = IORESOURCE_IRQ,
  408. },
  409. };
  410. static struct platform_device sdhi0_device = {
  411. .name = "sh_mobile_sdhi",
  412. .id = 0,
  413. .dev = {
  414. .platform_data = &sdhi0_info,
  415. },
  416. .num_resources = ARRAY_SIZE(sdhi0_resources),
  417. .resource = sdhi0_resources,
  418. };
  419. /* SDHI1 */
  420. static struct sh_mobile_sdhi_info sdhi1_info = {
  421. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
  422. .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  423. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  424. };
  425. static struct resource sdhi1_resources[] = {
  426. [0] = {
  427. .name = "SDHI1",
  428. .start = 0xe6860000,
  429. .end = 0xe6860100 - 1,
  430. .flags = IORESOURCE_MEM,
  431. },
  432. [1] = {
  433. .start = evt2irq(0x0E80),
  434. .flags = IORESOURCE_IRQ,
  435. },
  436. [2] = {
  437. .start = evt2irq(0x0EA0),
  438. .flags = IORESOURCE_IRQ,
  439. },
  440. [3] = {
  441. .start = evt2irq(0x0EC0),
  442. .flags = IORESOURCE_IRQ,
  443. },
  444. };
  445. static struct platform_device sdhi1_device = {
  446. .name = "sh_mobile_sdhi",
  447. .id = 1,
  448. .dev = {
  449. .platform_data = &sdhi1_info,
  450. },
  451. .num_resources = ARRAY_SIZE(sdhi1_resources),
  452. .resource = sdhi1_resources,
  453. };
  454. /* MMCIF */
  455. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  456. .sup_pclk = 0,
  457. .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  458. .caps = MMC_CAP_4_BIT_DATA |
  459. MMC_CAP_8_BIT_DATA |
  460. MMC_CAP_NONREMOVABLE,
  461. };
  462. static struct resource sh_mmcif_resources[] = {
  463. [0] = {
  464. .name = "MMCIF",
  465. .start = 0xe6bd0000,
  466. .end = 0xe6bd0100 - 1,
  467. .flags = IORESOURCE_MEM,
  468. },
  469. [1] = {
  470. /* MMC ERR */
  471. .start = evt2irq(0x1AC0),
  472. .flags = IORESOURCE_IRQ,
  473. },
  474. [2] = {
  475. /* MMC NOR */
  476. .start = evt2irq(0x1AE0),
  477. .flags = IORESOURCE_IRQ,
  478. },
  479. };
  480. static struct platform_device sh_mmcif_device = {
  481. .name = "sh_mmcif",
  482. .id = -1,
  483. .dev = {
  484. .platform_data = &sh_mmcif_plat,
  485. },
  486. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  487. .resource = sh_mmcif_resources,
  488. };
  489. /* I2C */
  490. static struct i2c_board_info i2c0_devices[] = {
  491. {
  492. I2C_BOARD_INFO("st1232-ts", 0x55),
  493. .irq = evt2irq(0x0340),
  494. },
  495. };
  496. /*
  497. * board devices
  498. */
  499. static struct platform_device *eva_devices[] __initdata = {
  500. &lcdc0_device,
  501. &gpio_keys_device,
  502. &sh_eth_device,
  503. &sdhi0_device,
  504. &sh_mmcif_device,
  505. };
  506. static void __init eva_clock_init(void)
  507. {
  508. struct clk *system = clk_get(NULL, "system_clk");
  509. struct clk *xtal1 = clk_get(NULL, "extal1");
  510. struct clk *usb24s = clk_get(NULL, "usb24s");
  511. if (IS_ERR(system) ||
  512. IS_ERR(xtal1) ||
  513. IS_ERR(usb24s)) {
  514. pr_err("armadillo800eva board clock init failed\n");
  515. goto clock_error;
  516. }
  517. /* armadillo 800 eva extal1 is 24MHz */
  518. clk_set_rate(xtal1, 24000000);
  519. /* usb24s use extal1 (= system) clock (= 24MHz) */
  520. clk_set_parent(usb24s, system);
  521. clock_error:
  522. if (!IS_ERR(system))
  523. clk_put(system);
  524. if (!IS_ERR(xtal1))
  525. clk_put(xtal1);
  526. if (!IS_ERR(usb24s))
  527. clk_put(usb24s);
  528. }
  529. /*
  530. * board init
  531. */
  532. static void __init eva_init(void)
  533. {
  534. eva_clock_init();
  535. r8a7740_pinmux_init();
  536. /* SCIFA1 */
  537. gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
  538. gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
  539. /* LCDC0 */
  540. gpio_request(GPIO_FN_LCDC0_SELECT, NULL);
  541. gpio_request(GPIO_FN_LCD0_D0, NULL);
  542. gpio_request(GPIO_FN_LCD0_D1, NULL);
  543. gpio_request(GPIO_FN_LCD0_D2, NULL);
  544. gpio_request(GPIO_FN_LCD0_D3, NULL);
  545. gpio_request(GPIO_FN_LCD0_D4, NULL);
  546. gpio_request(GPIO_FN_LCD0_D5, NULL);
  547. gpio_request(GPIO_FN_LCD0_D6, NULL);
  548. gpio_request(GPIO_FN_LCD0_D7, NULL);
  549. gpio_request(GPIO_FN_LCD0_D8, NULL);
  550. gpio_request(GPIO_FN_LCD0_D9, NULL);
  551. gpio_request(GPIO_FN_LCD0_D10, NULL);
  552. gpio_request(GPIO_FN_LCD0_D11, NULL);
  553. gpio_request(GPIO_FN_LCD0_D12, NULL);
  554. gpio_request(GPIO_FN_LCD0_D13, NULL);
  555. gpio_request(GPIO_FN_LCD0_D14, NULL);
  556. gpio_request(GPIO_FN_LCD0_D15, NULL);
  557. gpio_request(GPIO_FN_LCD0_D16, NULL);
  558. gpio_request(GPIO_FN_LCD0_D17, NULL);
  559. gpio_request(GPIO_FN_LCD0_D18_PORT40, NULL);
  560. gpio_request(GPIO_FN_LCD0_D19_PORT4, NULL);
  561. gpio_request(GPIO_FN_LCD0_D20_PORT3, NULL);
  562. gpio_request(GPIO_FN_LCD0_D21_PORT2, NULL);
  563. gpio_request(GPIO_FN_LCD0_D22_PORT0, NULL);
  564. gpio_request(GPIO_FN_LCD0_D23_PORT1, NULL);
  565. gpio_request(GPIO_FN_LCD0_DCK, NULL);
  566. gpio_request(GPIO_FN_LCD0_VSYN, NULL);
  567. gpio_request(GPIO_FN_LCD0_HSYN, NULL);
  568. gpio_request(GPIO_FN_LCD0_DISP, NULL);
  569. gpio_request(GPIO_FN_LCD0_LCLK_PORT165, NULL);
  570. gpio_request(GPIO_PORT61, NULL); /* LCDDON */
  571. gpio_direction_output(GPIO_PORT61, 1);
  572. gpio_request(GPIO_PORT202, NULL); /* LCD0_LED_CONT */
  573. gpio_direction_output(GPIO_PORT202, 0);
  574. /* Touchscreen */
  575. gpio_request(GPIO_FN_IRQ10, NULL); /* TP_INT */
  576. gpio_request(GPIO_PORT166, NULL); /* TP_RST_B */
  577. gpio_direction_output(GPIO_PORT166, 1);
  578. /* GETHER */
  579. gpio_request(GPIO_FN_ET_CRS, NULL);
  580. gpio_request(GPIO_FN_ET_MDC, NULL);
  581. gpio_request(GPIO_FN_ET_MDIO, NULL);
  582. gpio_request(GPIO_FN_ET_TX_ER, NULL);
  583. gpio_request(GPIO_FN_ET_RX_ER, NULL);
  584. gpio_request(GPIO_FN_ET_ERXD0, NULL);
  585. gpio_request(GPIO_FN_ET_ERXD1, NULL);
  586. gpio_request(GPIO_FN_ET_ERXD2, NULL);
  587. gpio_request(GPIO_FN_ET_ERXD3, NULL);
  588. gpio_request(GPIO_FN_ET_TX_CLK, NULL);
  589. gpio_request(GPIO_FN_ET_TX_EN, NULL);
  590. gpio_request(GPIO_FN_ET_ETXD0, NULL);
  591. gpio_request(GPIO_FN_ET_ETXD1, NULL);
  592. gpio_request(GPIO_FN_ET_ETXD2, NULL);
  593. gpio_request(GPIO_FN_ET_ETXD3, NULL);
  594. gpio_request(GPIO_FN_ET_PHY_INT, NULL);
  595. gpio_request(GPIO_FN_ET_COL, NULL);
  596. gpio_request(GPIO_FN_ET_RX_DV, NULL);
  597. gpio_request(GPIO_FN_ET_RX_CLK, NULL);
  598. gpio_request(GPIO_PORT18, NULL); /* PHY_RST */
  599. gpio_direction_output(GPIO_PORT18, 1);
  600. /* USB */
  601. gpio_request(GPIO_PORT159, NULL); /* USB_DEVICE_MODE */
  602. gpio_direction_input(GPIO_PORT159);
  603. if (gpio_get_value(GPIO_PORT159)) {
  604. /* USB Host */
  605. } else {
  606. /* USB Func */
  607. gpio_request(GPIO_FN_VBUS, NULL);
  608. platform_device_register(&usbhsf_device);
  609. }
  610. /* SDHI0 */
  611. gpio_request(GPIO_FN_SDHI0_CMD, NULL);
  612. gpio_request(GPIO_FN_SDHI0_CLK, NULL);
  613. gpio_request(GPIO_FN_SDHI0_D0, NULL);
  614. gpio_request(GPIO_FN_SDHI0_D1, NULL);
  615. gpio_request(GPIO_FN_SDHI0_D2, NULL);
  616. gpio_request(GPIO_FN_SDHI0_D3, NULL);
  617. gpio_request(GPIO_FN_SDHI0_WP, NULL);
  618. gpio_request(GPIO_PORT17, NULL); /* SDHI0_18/33_B */
  619. gpio_request(GPIO_PORT74, NULL); /* SDHI0_PON */
  620. gpio_request(GPIO_PORT75, NULL); /* SDSLOT1_PON */
  621. gpio_direction_output(GPIO_PORT17, 0);
  622. gpio_direction_output(GPIO_PORT74, 1);
  623. gpio_direction_output(GPIO_PORT75, 1);
  624. /* we can use GPIO_FN_IRQ31_PORT167 here for SDHI0 CD irq */
  625. /*
  626. * MMCIF
  627. *
  628. * Here doesn't care SW1.4 status,
  629. * since CON2 is not mounted.
  630. */
  631. gpio_request(GPIO_FN_MMC1_CLK_PORT103, NULL);
  632. gpio_request(GPIO_FN_MMC1_CMD_PORT104, NULL);
  633. gpio_request(GPIO_FN_MMC1_D0_PORT149, NULL);
  634. gpio_request(GPIO_FN_MMC1_D1_PORT148, NULL);
  635. gpio_request(GPIO_FN_MMC1_D2_PORT147, NULL);
  636. gpio_request(GPIO_FN_MMC1_D3_PORT146, NULL);
  637. gpio_request(GPIO_FN_MMC1_D4_PORT145, NULL);
  638. gpio_request(GPIO_FN_MMC1_D5_PORT144, NULL);
  639. gpio_request(GPIO_FN_MMC1_D6_PORT143, NULL);
  640. gpio_request(GPIO_FN_MMC1_D7_PORT142, NULL);
  641. /*
  642. * CAUTION
  643. *
  644. * DBGMD/LCDC0/FSIA MUX
  645. * DBGMD_SELECT_B should be set after setting PFC Function.
  646. */
  647. gpio_request(GPIO_PORT176, NULL);
  648. gpio_direction_output(GPIO_PORT176, 1);
  649. /*
  650. * We can switch CON8/CON14 by SW1.5,
  651. * but it needs after DBGMD_SELECT_B
  652. */
  653. gpio_request(GPIO_PORT6, NULL);
  654. gpio_direction_input(GPIO_PORT6);
  655. if (gpio_get_value(GPIO_PORT6)) {
  656. /* CON14 enable */
  657. } else {
  658. /* CON8 (SDHI1) enable */
  659. gpio_request(GPIO_FN_SDHI1_CLK, NULL);
  660. gpio_request(GPIO_FN_SDHI1_CMD, NULL);
  661. gpio_request(GPIO_FN_SDHI1_D0, NULL);
  662. gpio_request(GPIO_FN_SDHI1_D1, NULL);
  663. gpio_request(GPIO_FN_SDHI1_D2, NULL);
  664. gpio_request(GPIO_FN_SDHI1_D3, NULL);
  665. gpio_request(GPIO_FN_SDHI1_CD, NULL);
  666. gpio_request(GPIO_FN_SDHI1_WP, NULL);
  667. gpio_request(GPIO_PORT16, NULL); /* SDSLOT2_PON */
  668. gpio_direction_output(GPIO_PORT16, 1);
  669. platform_device_register(&sdhi1_device);
  670. }
  671. #ifdef CONFIG_CACHE_L2X0
  672. /* Early BRESP enable, Shared attribute override enable, 32K*8way */
  673. l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff);
  674. #endif
  675. i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
  676. r8a7740_add_standard_devices();
  677. platform_add_devices(eva_devices,
  678. ARRAY_SIZE(eva_devices));
  679. }
  680. static void __init eva_earlytimer_init(void)
  681. {
  682. r8a7740_clock_init(MD_CK0 | MD_CK2);
  683. shmobile_earlytimer_init();
  684. }
  685. static void __init eva_add_early_devices(void)
  686. {
  687. r8a7740_add_early_devices();
  688. /* override timer setup with board-specific code */
  689. shmobile_timer.init = eva_earlytimer_init;
  690. }
  691. static const char *eva_boards_compat_dt[] __initdata = {
  692. "renesas,armadillo800eva",
  693. NULL,
  694. };
  695. DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva")
  696. .map_io = r8a7740_map_io,
  697. .init_early = eva_add_early_devices,
  698. .init_irq = r8a7740_init_irq,
  699. .handle_irq = shmobile_handle_irq_intc,
  700. .init_machine = eva_init,
  701. .timer = &shmobile_timer,
  702. .dt_compat = eva_boards_compat_dt,
  703. MACHINE_END