board-armadillo800eva.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  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. .dev = {
  297. .platform_data = &sh_eth_platdata,
  298. },
  299. .resource = sh_eth_resources,
  300. .num_resources = ARRAY_SIZE(sh_eth_resources),
  301. };
  302. /* LCDC */
  303. static struct fb_videomode lcdc0_mode = {
  304. .name = "AMPIER/AM-800480",
  305. .xres = 800,
  306. .yres = 480,
  307. .left_margin = 88,
  308. .right_margin = 40,
  309. .hsync_len = 128,
  310. .upper_margin = 20,
  311. .lower_margin = 5,
  312. .vsync_len = 5,
  313. .sync = 0,
  314. };
  315. static struct sh_mobile_lcdc_info lcdc0_info = {
  316. .clock_source = LCDC_CLK_BUS,
  317. .ch[0] = {
  318. .chan = LCDC_CHAN_MAINLCD,
  319. .fourcc = V4L2_PIX_FMT_RGB565,
  320. .interface_type = RGB24,
  321. .clock_divider = 5,
  322. .flags = 0,
  323. .lcd_modes = &lcdc0_mode,
  324. .num_modes = 1,
  325. .panel_cfg = {
  326. .width = 111,
  327. .height = 68,
  328. },
  329. },
  330. };
  331. static struct resource lcdc0_resources[] = {
  332. [0] = {
  333. .name = "LCD0",
  334. .start = 0xfe940000,
  335. .end = 0xfe943fff,
  336. .flags = IORESOURCE_MEM,
  337. },
  338. [1] = {
  339. .start = intcs_evt2irq(0x580),
  340. .flags = IORESOURCE_IRQ,
  341. },
  342. };
  343. static struct platform_device lcdc0_device = {
  344. .name = "sh_mobile_lcdc_fb",
  345. .num_resources = ARRAY_SIZE(lcdc0_resources),
  346. .resource = lcdc0_resources,
  347. .id = 0,
  348. .dev = {
  349. .platform_data = &lcdc0_info,
  350. .coherent_dma_mask = ~0,
  351. },
  352. };
  353. /* GPIO KEY */
  354. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  355. static struct gpio_keys_button gpio_buttons[] = {
  356. GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW1"),
  357. GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW2"),
  358. GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW3"),
  359. GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW4"),
  360. };
  361. static struct gpio_keys_platform_data gpio_key_info = {
  362. .buttons = gpio_buttons,
  363. .nbuttons = ARRAY_SIZE(gpio_buttons),
  364. };
  365. static struct platform_device gpio_keys_device = {
  366. .name = "gpio-keys",
  367. .id = -1,
  368. .dev = {
  369. .platform_data = &gpio_key_info,
  370. },
  371. };
  372. /* SDHI0 */
  373. /*
  374. * FIXME
  375. *
  376. * It use polling mode here, since
  377. * CD (= Card Detect) pin is not connected to SDHI0_CD.
  378. * We can use IRQ31 as card detect irq,
  379. * but it needs chattering removal operation
  380. */
  381. #define IRQ31 evt2irq(0x33E0)
  382. static struct sh_mobile_sdhi_info sdhi0_info = {
  383. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |\
  384. MMC_CAP_NEEDS_POLL,
  385. .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  386. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  387. };
  388. static struct resource sdhi0_resources[] = {
  389. {
  390. .name = "SDHI0",
  391. .start = 0xe6850000,
  392. .end = 0xe6850100 - 1,
  393. .flags = IORESOURCE_MEM,
  394. },
  395. /*
  396. * no SH_MOBILE_SDHI_IRQ_CARD_DETECT here
  397. */
  398. {
  399. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  400. .start = evt2irq(0x0E20),
  401. .flags = IORESOURCE_IRQ,
  402. },
  403. {
  404. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  405. .start = evt2irq(0x0E40),
  406. .flags = IORESOURCE_IRQ,
  407. },
  408. };
  409. static struct platform_device sdhi0_device = {
  410. .name = "sh_mobile_sdhi",
  411. .id = 0,
  412. .dev = {
  413. .platform_data = &sdhi0_info,
  414. },
  415. .num_resources = ARRAY_SIZE(sdhi0_resources),
  416. .resource = sdhi0_resources,
  417. };
  418. /* SDHI1 */
  419. static struct sh_mobile_sdhi_info sdhi1_info = {
  420. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
  421. .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  422. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  423. };
  424. static struct resource sdhi1_resources[] = {
  425. [0] = {
  426. .name = "SDHI1",
  427. .start = 0xe6860000,
  428. .end = 0xe6860100 - 1,
  429. .flags = IORESOURCE_MEM,
  430. },
  431. [1] = {
  432. .start = evt2irq(0x0E80),
  433. .flags = IORESOURCE_IRQ,
  434. },
  435. [2] = {
  436. .start = evt2irq(0x0EA0),
  437. .flags = IORESOURCE_IRQ,
  438. },
  439. [3] = {
  440. .start = evt2irq(0x0EC0),
  441. .flags = IORESOURCE_IRQ,
  442. },
  443. };
  444. static struct platform_device sdhi1_device = {
  445. .name = "sh_mobile_sdhi",
  446. .id = 1,
  447. .dev = {
  448. .platform_data = &sdhi1_info,
  449. },
  450. .num_resources = ARRAY_SIZE(sdhi1_resources),
  451. .resource = sdhi1_resources,
  452. };
  453. /* MMCIF */
  454. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  455. .sup_pclk = 0,
  456. .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  457. .caps = MMC_CAP_4_BIT_DATA |
  458. MMC_CAP_8_BIT_DATA |
  459. MMC_CAP_NONREMOVABLE,
  460. };
  461. static struct resource sh_mmcif_resources[] = {
  462. [0] = {
  463. .name = "MMCIF",
  464. .start = 0xe6bd0000,
  465. .end = 0xe6bd0100 - 1,
  466. .flags = IORESOURCE_MEM,
  467. },
  468. [1] = {
  469. /* MMC ERR */
  470. .start = evt2irq(0x1AC0),
  471. .flags = IORESOURCE_IRQ,
  472. },
  473. [2] = {
  474. /* MMC NOR */
  475. .start = evt2irq(0x1AE0),
  476. .flags = IORESOURCE_IRQ,
  477. },
  478. };
  479. static struct platform_device sh_mmcif_device = {
  480. .name = "sh_mmcif",
  481. .id = -1,
  482. .dev = {
  483. .platform_data = &sh_mmcif_plat,
  484. },
  485. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  486. .resource = sh_mmcif_resources,
  487. };
  488. /* I2C */
  489. static struct i2c_board_info i2c0_devices[] = {
  490. {
  491. I2C_BOARD_INFO("st1232-ts", 0x55),
  492. .irq = evt2irq(0x0340),
  493. },
  494. };
  495. /*
  496. * board devices
  497. */
  498. static struct platform_device *eva_devices[] __initdata = {
  499. &lcdc0_device,
  500. &gpio_keys_device,
  501. &sh_eth_device,
  502. &sdhi0_device,
  503. &sh_mmcif_device,
  504. };
  505. static void __init eva_clock_init(void)
  506. {
  507. struct clk *system = clk_get(NULL, "system_clk");
  508. struct clk *xtal1 = clk_get(NULL, "extal1");
  509. struct clk *usb24s = clk_get(NULL, "usb24s");
  510. if (IS_ERR(system) ||
  511. IS_ERR(xtal1) ||
  512. IS_ERR(usb24s)) {
  513. pr_err("armadillo800eva board clock init failed\n");
  514. goto clock_error;
  515. }
  516. /* armadillo 800 eva extal1 is 24MHz */
  517. clk_set_rate(xtal1, 24000000);
  518. /* usb24s use extal1 (= system) clock (= 24MHz) */
  519. clk_set_parent(usb24s, system);
  520. clock_error:
  521. if (!IS_ERR(system))
  522. clk_put(system);
  523. if (!IS_ERR(xtal1))
  524. clk_put(xtal1);
  525. if (!IS_ERR(usb24s))
  526. clk_put(usb24s);
  527. }
  528. /*
  529. * board init
  530. */
  531. static void __init eva_init(void)
  532. {
  533. eva_clock_init();
  534. r8a7740_pinmux_init();
  535. /* SCIFA1 */
  536. gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
  537. gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
  538. /* LCDC0 */
  539. gpio_request(GPIO_FN_LCDC0_SELECT, NULL);
  540. gpio_request(GPIO_FN_LCD0_D0, NULL);
  541. gpio_request(GPIO_FN_LCD0_D1, NULL);
  542. gpio_request(GPIO_FN_LCD0_D2, NULL);
  543. gpio_request(GPIO_FN_LCD0_D3, NULL);
  544. gpio_request(GPIO_FN_LCD0_D4, NULL);
  545. gpio_request(GPIO_FN_LCD0_D5, NULL);
  546. gpio_request(GPIO_FN_LCD0_D6, NULL);
  547. gpio_request(GPIO_FN_LCD0_D7, NULL);
  548. gpio_request(GPIO_FN_LCD0_D8, NULL);
  549. gpio_request(GPIO_FN_LCD0_D9, NULL);
  550. gpio_request(GPIO_FN_LCD0_D10, NULL);
  551. gpio_request(GPIO_FN_LCD0_D11, NULL);
  552. gpio_request(GPIO_FN_LCD0_D12, NULL);
  553. gpio_request(GPIO_FN_LCD0_D13, NULL);
  554. gpio_request(GPIO_FN_LCD0_D14, NULL);
  555. gpio_request(GPIO_FN_LCD0_D15, NULL);
  556. gpio_request(GPIO_FN_LCD0_D16, NULL);
  557. gpio_request(GPIO_FN_LCD0_D17, NULL);
  558. gpio_request(GPIO_FN_LCD0_D18_PORT40, NULL);
  559. gpio_request(GPIO_FN_LCD0_D19_PORT4, NULL);
  560. gpio_request(GPIO_FN_LCD0_D20_PORT3, NULL);
  561. gpio_request(GPIO_FN_LCD0_D21_PORT2, NULL);
  562. gpio_request(GPIO_FN_LCD0_D22_PORT0, NULL);
  563. gpio_request(GPIO_FN_LCD0_D23_PORT1, NULL);
  564. gpio_request(GPIO_FN_LCD0_DCK, NULL);
  565. gpio_request(GPIO_FN_LCD0_VSYN, NULL);
  566. gpio_request(GPIO_FN_LCD0_HSYN, NULL);
  567. gpio_request(GPIO_FN_LCD0_DISP, NULL);
  568. gpio_request(GPIO_FN_LCD0_LCLK_PORT165, NULL);
  569. gpio_request(GPIO_PORT61, NULL); /* LCDDON */
  570. gpio_direction_output(GPIO_PORT61, 1);
  571. gpio_request(GPIO_PORT202, NULL); /* LCD0_LED_CONT */
  572. gpio_direction_output(GPIO_PORT202, 0);
  573. /* Touchscreen */
  574. gpio_request(GPIO_FN_IRQ10, NULL); /* TP_INT */
  575. gpio_request(GPIO_PORT166, NULL); /* TP_RST_B */
  576. gpio_direction_output(GPIO_PORT166, 1);
  577. /* GETHER */
  578. gpio_request(GPIO_FN_ET_CRS, NULL);
  579. gpio_request(GPIO_FN_ET_MDC, NULL);
  580. gpio_request(GPIO_FN_ET_MDIO, NULL);
  581. gpio_request(GPIO_FN_ET_TX_ER, NULL);
  582. gpio_request(GPIO_FN_ET_RX_ER, NULL);
  583. gpio_request(GPIO_FN_ET_ERXD0, NULL);
  584. gpio_request(GPIO_FN_ET_ERXD1, NULL);
  585. gpio_request(GPIO_FN_ET_ERXD2, NULL);
  586. gpio_request(GPIO_FN_ET_ERXD3, NULL);
  587. gpio_request(GPIO_FN_ET_TX_CLK, NULL);
  588. gpio_request(GPIO_FN_ET_TX_EN, NULL);
  589. gpio_request(GPIO_FN_ET_ETXD0, NULL);
  590. gpio_request(GPIO_FN_ET_ETXD1, NULL);
  591. gpio_request(GPIO_FN_ET_ETXD2, NULL);
  592. gpio_request(GPIO_FN_ET_ETXD3, NULL);
  593. gpio_request(GPIO_FN_ET_PHY_INT, NULL);
  594. gpio_request(GPIO_FN_ET_COL, NULL);
  595. gpio_request(GPIO_FN_ET_RX_DV, NULL);
  596. gpio_request(GPIO_FN_ET_RX_CLK, NULL);
  597. gpio_request(GPIO_PORT18, NULL); /* PHY_RST */
  598. gpio_direction_output(GPIO_PORT18, 1);
  599. /* USB */
  600. gpio_request(GPIO_PORT159, NULL); /* USB_DEVICE_MODE */
  601. gpio_direction_input(GPIO_PORT159);
  602. if (gpio_get_value(GPIO_PORT159)) {
  603. /* USB Host */
  604. } else {
  605. /* USB Func */
  606. gpio_request(GPIO_FN_VBUS, NULL);
  607. platform_device_register(&usbhsf_device);
  608. }
  609. /* SDHI0 */
  610. gpio_request(GPIO_FN_SDHI0_CMD, NULL);
  611. gpio_request(GPIO_FN_SDHI0_CLK, NULL);
  612. gpio_request(GPIO_FN_SDHI0_D0, NULL);
  613. gpio_request(GPIO_FN_SDHI0_D1, NULL);
  614. gpio_request(GPIO_FN_SDHI0_D2, NULL);
  615. gpio_request(GPIO_FN_SDHI0_D3, NULL);
  616. gpio_request(GPIO_FN_SDHI0_WP, NULL);
  617. gpio_request(GPIO_PORT17, NULL); /* SDHI0_18/33_B */
  618. gpio_request(GPIO_PORT74, NULL); /* SDHI0_PON */
  619. gpio_request(GPIO_PORT75, NULL); /* SDSLOT1_PON */
  620. gpio_direction_output(GPIO_PORT17, 0);
  621. gpio_direction_output(GPIO_PORT74, 1);
  622. gpio_direction_output(GPIO_PORT75, 1);
  623. /* we can use GPIO_FN_IRQ31_PORT167 here for SDHI0 CD irq */
  624. /*
  625. * MMCIF
  626. *
  627. * Here doesn't care SW1.4 status,
  628. * since CON2 is not mounted.
  629. */
  630. gpio_request(GPIO_FN_MMC1_CLK_PORT103, NULL);
  631. gpio_request(GPIO_FN_MMC1_CMD_PORT104, NULL);
  632. gpio_request(GPIO_FN_MMC1_D0_PORT149, NULL);
  633. gpio_request(GPIO_FN_MMC1_D1_PORT148, NULL);
  634. gpio_request(GPIO_FN_MMC1_D2_PORT147, NULL);
  635. gpio_request(GPIO_FN_MMC1_D3_PORT146, NULL);
  636. gpio_request(GPIO_FN_MMC1_D4_PORT145, NULL);
  637. gpio_request(GPIO_FN_MMC1_D5_PORT144, NULL);
  638. gpio_request(GPIO_FN_MMC1_D6_PORT143, NULL);
  639. gpio_request(GPIO_FN_MMC1_D7_PORT142, NULL);
  640. /*
  641. * CAUTION
  642. *
  643. * DBGMD/LCDC0/FSIA MUX
  644. * DBGMD_SELECT_B should be set after setting PFC Function.
  645. */
  646. gpio_request(GPIO_PORT176, NULL);
  647. gpio_direction_output(GPIO_PORT176, 1);
  648. /*
  649. * We can switch CON8/CON14 by SW1.5,
  650. * but it needs after DBGMD_SELECT_B
  651. */
  652. gpio_request(GPIO_PORT6, NULL);
  653. gpio_direction_input(GPIO_PORT6);
  654. if (gpio_get_value(GPIO_PORT6)) {
  655. /* CON14 enable */
  656. } else {
  657. /* CON8 (SDHI1) enable */
  658. gpio_request(GPIO_FN_SDHI1_CLK, NULL);
  659. gpio_request(GPIO_FN_SDHI1_CMD, NULL);
  660. gpio_request(GPIO_FN_SDHI1_D0, NULL);
  661. gpio_request(GPIO_FN_SDHI1_D1, NULL);
  662. gpio_request(GPIO_FN_SDHI1_D2, NULL);
  663. gpio_request(GPIO_FN_SDHI1_D3, NULL);
  664. gpio_request(GPIO_FN_SDHI1_CD, NULL);
  665. gpio_request(GPIO_FN_SDHI1_WP, NULL);
  666. gpio_request(GPIO_PORT16, NULL); /* SDSLOT2_PON */
  667. gpio_direction_output(GPIO_PORT16, 1);
  668. platform_device_register(&sdhi1_device);
  669. }
  670. #ifdef CONFIG_CACHE_L2X0
  671. /* Early BRESP enable, Shared attribute override enable, 32K*8way */
  672. l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff);
  673. #endif
  674. i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
  675. r8a7740_add_standard_devices();
  676. platform_add_devices(eva_devices,
  677. ARRAY_SIZE(eva_devices));
  678. }
  679. static void __init eva_earlytimer_init(void)
  680. {
  681. r8a7740_clock_init(MD_CK0 | MD_CK2);
  682. shmobile_earlytimer_init();
  683. }
  684. static void __init eva_add_early_devices(void)
  685. {
  686. r8a7740_add_early_devices();
  687. /* override timer setup with board-specific code */
  688. shmobile_timer.init = eva_earlytimer_init;
  689. }
  690. MACHINE_START(ARMADILLO800EVA, "armadillo800eva")
  691. .map_io = r8a7740_map_io,
  692. .init_early = eva_add_early_devices,
  693. .init_irq = r8a7740_init_irq,
  694. .handle_irq = shmobile_handle_irq_intc,
  695. .init_machine = eva_init,
  696. .timer = &shmobile_timer,
  697. MACHINE_END