board-armadillo800eva.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  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/regulator/driver.h>
  31. #include <linux/pinctrl/machine.h>
  32. #include <linux/regulator/fixed.h>
  33. #include <linux/regulator/gpio-regulator.h>
  34. #include <linux/regulator/machine.h>
  35. #include <linux/sh_eth.h>
  36. #include <linux/videodev2.h>
  37. #include <linux/usb/renesas_usbhs.h>
  38. #include <linux/mfd/tmio.h>
  39. #include <linux/mmc/host.h>
  40. #include <linux/mmc/sh_mmcif.h>
  41. #include <linux/mmc/sh_mobile_sdhi.h>
  42. #include <linux/i2c-gpio.h>
  43. #include <mach/common.h>
  44. #include <mach/irqs.h>
  45. #include <mach/r8a7740.h>
  46. #include <media/mt9t112.h>
  47. #include <media/sh_mobile_ceu.h>
  48. #include <media/soc_camera.h>
  49. #include <asm/page.h>
  50. #include <asm/mach-types.h>
  51. #include <asm/mach/arch.h>
  52. #include <asm/mach/map.h>
  53. #include <asm/mach/time.h>
  54. #include <asm/hardware/cache-l2x0.h>
  55. #include <video/sh_mobile_lcdc.h>
  56. #include <video/sh_mobile_hdmi.h>
  57. #include <sound/sh_fsi.h>
  58. #include <sound/simple_card.h>
  59. #include "sh-gpio.h"
  60. /*
  61. * CON1 Camera Module
  62. * CON2 Extension Bus
  63. * CON3 HDMI Output
  64. * CON4 Composite Video Output
  65. * CON5 H-UDI JTAG
  66. * CON6 ARM JTAG
  67. * CON7 SD1
  68. * CON8 SD2
  69. * CON9 RTC BackUp
  70. * CON10 Monaural Mic Input
  71. * CON11 Stereo Headphone Output
  72. * CON12 Audio Line Output(L)
  73. * CON13 Audio Line Output(R)
  74. * CON14 AWL13 Module
  75. * CON15 Extension
  76. * CON16 LCD1
  77. * CON17 LCD2
  78. * CON19 Power Input
  79. * CON20 USB1
  80. * CON21 USB2
  81. * CON22 Serial
  82. * CON23 LAN
  83. * CON24 USB3
  84. * LED1 Camera LED(Yellow)
  85. * LED2 Power LED (Green)
  86. * ED3-LED6 User LED(Yellow)
  87. * LED7 LAN link LED(Green)
  88. * LED8 LAN activity LED(Yellow)
  89. */
  90. /*
  91. * DipSwitch
  92. *
  93. * SW1
  94. *
  95. * -12345678-+---------------+----------------------------
  96. * 1 | boot | hermit
  97. * 0 | boot | OS auto boot
  98. * -12345678-+---------------+----------------------------
  99. * 00 | boot device | eMMC
  100. * 10 | boot device | SDHI0 (CON7)
  101. * 01 | boot device | -
  102. * 11 | boot device | Extension Buss (CS0)
  103. * -12345678-+---------------+----------------------------
  104. * 0 | Extension Bus | D8-D15 disable, eMMC enable
  105. * 1 | Extension Bus | D8-D15 enable, eMMC disable
  106. * -12345678-+---------------+----------------------------
  107. * 0 | SDHI1 | COM8 disable, COM14 enable
  108. * 1 | SDHI1 | COM8 enable, COM14 disable
  109. * -12345678-+---------------+----------------------------
  110. * 0 | USB0 | COM20 enable, COM24 disable
  111. * 1 | USB0 | COM20 disable, COM24 enable
  112. * -12345678-+---------------+----------------------------
  113. * 00 | JTAG | SH-X2
  114. * 10 | JTAG | ARM
  115. * 01 | JTAG | -
  116. * 11 | JTAG | Boundary Scan
  117. *-----------+---------------+----------------------------
  118. */
  119. /*
  120. * FSI-WM8978
  121. *
  122. * this command is required when playback.
  123. *
  124. * # amixer set "Headphone" 50
  125. *
  126. * this command is required when capture.
  127. *
  128. * # amixer set "Input PGA" 15
  129. * # amixer set "Left Input Mixer MicP" on
  130. * # amixer set "Left Input Mixer MicN" on
  131. * # amixer set "Right Input Mixer MicN" on
  132. * # amixer set "Right Input Mixer MicP" on
  133. */
  134. /*
  135. * USB function
  136. *
  137. * When you use USB Function,
  138. * set SW1.6 ON, and connect cable to CN24.
  139. *
  140. * USBF needs workaround on R8A7740 chip.
  141. * These are a little bit complex.
  142. * see
  143. * usbhsf_power_ctrl()
  144. */
  145. #define IRQ7 irq_pin(7)
  146. #define USBCR1 IOMEM(0xe605810a)
  147. #define USBH 0xC6700000
  148. #define USBH_USBCTR 0x10834
  149. struct usbhsf_private {
  150. struct clk *phy;
  151. struct clk *usb24;
  152. struct clk *pci;
  153. struct clk *func;
  154. struct clk *host;
  155. void __iomem *usbh_base;
  156. struct renesas_usbhs_platform_info info;
  157. };
  158. #define usbhsf_get_priv(pdev) \
  159. container_of(renesas_usbhs_get_info(pdev), \
  160. struct usbhsf_private, info)
  161. static int usbhsf_get_id(struct platform_device *pdev)
  162. {
  163. return USBHS_GADGET;
  164. }
  165. static void usbhsf_power_ctrl(struct platform_device *pdev,
  166. void __iomem *base, int enable)
  167. {
  168. struct usbhsf_private *priv = usbhsf_get_priv(pdev);
  169. /*
  170. * Work around for USB Function.
  171. * It needs USB host clock, and settings
  172. */
  173. if (enable) {
  174. /*
  175. * enable all the related usb clocks
  176. * for usb workaround
  177. */
  178. clk_enable(priv->usb24);
  179. clk_enable(priv->pci);
  180. clk_enable(priv->host);
  181. clk_enable(priv->func);
  182. clk_enable(priv->phy);
  183. /*
  184. * set USBCR1
  185. *
  186. * Port1 is driven by USB function,
  187. * Port2 is driven by USB HOST
  188. * One HOST (Port1 or Port2 is HOST)
  189. * USB PLL input clock = 24MHz
  190. */
  191. __raw_writew(0xd750, USBCR1);
  192. mdelay(1);
  193. /*
  194. * start USB Host
  195. */
  196. __raw_writel(0x0000000c, priv->usbh_base + USBH_USBCTR);
  197. __raw_writel(0x00000008, priv->usbh_base + USBH_USBCTR);
  198. mdelay(10);
  199. /*
  200. * USB PHY Power ON
  201. */
  202. __raw_writew(0xd770, USBCR1);
  203. __raw_writew(0x4000, base + 0x102); /* USBF :: SUSPMODE */
  204. } else {
  205. __raw_writel(0x0000010f, priv->usbh_base + USBH_USBCTR);
  206. __raw_writew(0xd7c0, USBCR1); /* GPIO */
  207. clk_disable(priv->phy);
  208. clk_disable(priv->func); /* usb work around */
  209. clk_disable(priv->host); /* usb work around */
  210. clk_disable(priv->pci); /* usb work around */
  211. clk_disable(priv->usb24); /* usb work around */
  212. }
  213. }
  214. static int usbhsf_get_vbus(struct platform_device *pdev)
  215. {
  216. return gpio_get_value(209);
  217. }
  218. static irqreturn_t usbhsf_interrupt(int irq, void *data)
  219. {
  220. struct platform_device *pdev = data;
  221. renesas_usbhs_call_notify_hotplug(pdev);
  222. return IRQ_HANDLED;
  223. }
  224. static void usbhsf_hardware_exit(struct platform_device *pdev)
  225. {
  226. struct usbhsf_private *priv = usbhsf_get_priv(pdev);
  227. if (!IS_ERR(priv->phy))
  228. clk_put(priv->phy);
  229. if (!IS_ERR(priv->usb24))
  230. clk_put(priv->usb24);
  231. if (!IS_ERR(priv->pci))
  232. clk_put(priv->pci);
  233. if (!IS_ERR(priv->host))
  234. clk_put(priv->host);
  235. if (!IS_ERR(priv->func))
  236. clk_put(priv->func);
  237. if (priv->usbh_base)
  238. iounmap(priv->usbh_base);
  239. priv->phy = NULL;
  240. priv->usb24 = NULL;
  241. priv->pci = NULL;
  242. priv->host = NULL;
  243. priv->func = NULL;
  244. priv->usbh_base = NULL;
  245. free_irq(IRQ7, pdev);
  246. }
  247. static int usbhsf_hardware_init(struct platform_device *pdev)
  248. {
  249. struct usbhsf_private *priv = usbhsf_get_priv(pdev);
  250. int ret;
  251. priv->phy = clk_get(&pdev->dev, "phy");
  252. priv->usb24 = clk_get(&pdev->dev, "usb24");
  253. priv->pci = clk_get(&pdev->dev, "pci");
  254. priv->func = clk_get(&pdev->dev, "func");
  255. priv->host = clk_get(&pdev->dev, "host");
  256. priv->usbh_base = ioremap_nocache(USBH, 0x20000);
  257. if (IS_ERR(priv->phy) ||
  258. IS_ERR(priv->usb24) ||
  259. IS_ERR(priv->pci) ||
  260. IS_ERR(priv->host) ||
  261. IS_ERR(priv->func) ||
  262. !priv->usbh_base) {
  263. dev_err(&pdev->dev, "USB clock setting failed\n");
  264. usbhsf_hardware_exit(pdev);
  265. return -EIO;
  266. }
  267. ret = request_irq(IRQ7, usbhsf_interrupt, IRQF_TRIGGER_NONE,
  268. dev_name(&pdev->dev), pdev);
  269. if (ret) {
  270. dev_err(&pdev->dev, "request_irq err\n");
  271. return ret;
  272. }
  273. irq_set_irq_type(IRQ7, IRQ_TYPE_EDGE_BOTH);
  274. /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */
  275. clk_set_rate(priv->usb24,
  276. clk_get_rate(clk_get_parent(priv->usb24)));
  277. return 0;
  278. }
  279. static struct usbhsf_private usbhsf_private = {
  280. .info = {
  281. .platform_callback = {
  282. .get_id = usbhsf_get_id,
  283. .get_vbus = usbhsf_get_vbus,
  284. .hardware_init = usbhsf_hardware_init,
  285. .hardware_exit = usbhsf_hardware_exit,
  286. .power_ctrl = usbhsf_power_ctrl,
  287. },
  288. .driver_param = {
  289. .buswait_bwait = 5,
  290. .detection_delay = 5,
  291. .d0_rx_id = SHDMA_SLAVE_USBHS_RX,
  292. .d1_tx_id = SHDMA_SLAVE_USBHS_TX,
  293. },
  294. }
  295. };
  296. static struct resource usbhsf_resources[] = {
  297. {
  298. .name = "USBHS",
  299. .start = 0xe6890000,
  300. .end = 0xe6890104 - 1,
  301. .flags = IORESOURCE_MEM,
  302. },
  303. {
  304. .start = gic_spi(51),
  305. .flags = IORESOURCE_IRQ,
  306. },
  307. };
  308. static struct platform_device usbhsf_device = {
  309. .name = "renesas_usbhs",
  310. .dev = {
  311. .platform_data = &usbhsf_private.info,
  312. },
  313. .id = -1,
  314. .num_resources = ARRAY_SIZE(usbhsf_resources),
  315. .resource = usbhsf_resources,
  316. };
  317. /* Ether */
  318. static struct sh_eth_plat_data sh_eth_platdata = {
  319. .phy = 0x00, /* LAN8710A */
  320. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  321. .register_type = SH_ETH_REG_GIGABIT,
  322. .phy_interface = PHY_INTERFACE_MODE_MII,
  323. };
  324. static struct resource sh_eth_resources[] = {
  325. {
  326. .start = 0xe9a00000,
  327. .end = 0xe9a00800 - 1,
  328. .flags = IORESOURCE_MEM,
  329. }, {
  330. .start = 0xe9a01800,
  331. .end = 0xe9a02000 - 1,
  332. .flags = IORESOURCE_MEM,
  333. }, {
  334. .start = gic_spi(110),
  335. .flags = IORESOURCE_IRQ,
  336. },
  337. };
  338. static struct platform_device sh_eth_device = {
  339. .name = "sh-eth",
  340. .id = -1,
  341. .dev = {
  342. .platform_data = &sh_eth_platdata,
  343. },
  344. .resource = sh_eth_resources,
  345. .num_resources = ARRAY_SIZE(sh_eth_resources),
  346. };
  347. /* LCDC */
  348. static struct fb_videomode lcdc0_mode = {
  349. .name = "AMPIER/AM-800480",
  350. .xres = 800,
  351. .yres = 480,
  352. .left_margin = 88,
  353. .right_margin = 40,
  354. .hsync_len = 128,
  355. .upper_margin = 20,
  356. .lower_margin = 5,
  357. .vsync_len = 5,
  358. .sync = 0,
  359. };
  360. static struct sh_mobile_lcdc_info lcdc0_info = {
  361. .clock_source = LCDC_CLK_BUS,
  362. .ch[0] = {
  363. .chan = LCDC_CHAN_MAINLCD,
  364. .fourcc = V4L2_PIX_FMT_RGB565,
  365. .interface_type = RGB24,
  366. .clock_divider = 5,
  367. .flags = 0,
  368. .lcd_modes = &lcdc0_mode,
  369. .num_modes = 1,
  370. .panel_cfg = {
  371. .width = 111,
  372. .height = 68,
  373. },
  374. },
  375. };
  376. static struct resource lcdc0_resources[] = {
  377. [0] = {
  378. .name = "LCD0",
  379. .start = 0xfe940000,
  380. .end = 0xfe943fff,
  381. .flags = IORESOURCE_MEM,
  382. },
  383. [1] = {
  384. .start = gic_spi(177),
  385. .flags = IORESOURCE_IRQ,
  386. },
  387. };
  388. static struct platform_device lcdc0_device = {
  389. .name = "sh_mobile_lcdc_fb",
  390. .num_resources = ARRAY_SIZE(lcdc0_resources),
  391. .resource = lcdc0_resources,
  392. .id = 0,
  393. .dev = {
  394. .platform_data = &lcdc0_info,
  395. .coherent_dma_mask = ~0,
  396. },
  397. };
  398. /*
  399. * LCDC1/HDMI
  400. */
  401. static struct sh_mobile_hdmi_info hdmi_info = {
  402. .flags = HDMI_OUTPUT_PUSH_PULL |
  403. HDMI_OUTPUT_POLARITY_HI |
  404. HDMI_32BIT_REG |
  405. HDMI_HAS_HTOP1 |
  406. HDMI_SND_SRC_SPDIF,
  407. };
  408. static struct resource hdmi_resources[] = {
  409. [0] = {
  410. .name = "HDMI",
  411. .start = 0xe6be0000,
  412. .end = 0xe6be03ff,
  413. .flags = IORESOURCE_MEM,
  414. },
  415. [1] = {
  416. .start = gic_spi(131),
  417. .flags = IORESOURCE_IRQ,
  418. },
  419. [2] = {
  420. .name = "HDMI emma3pf",
  421. .start = 0xe6be4000,
  422. .end = 0xe6be43ff,
  423. .flags = IORESOURCE_MEM,
  424. },
  425. };
  426. static struct platform_device hdmi_device = {
  427. .name = "sh-mobile-hdmi",
  428. .num_resources = ARRAY_SIZE(hdmi_resources),
  429. .resource = hdmi_resources,
  430. .id = -1,
  431. .dev = {
  432. .platform_data = &hdmi_info,
  433. },
  434. };
  435. static const struct fb_videomode lcdc1_mode = {
  436. .name = "HDMI 720p",
  437. .xres = 1280,
  438. .yres = 720,
  439. .pixclock = 13468,
  440. .left_margin = 220,
  441. .right_margin = 110,
  442. .hsync_len = 40,
  443. .upper_margin = 20,
  444. .lower_margin = 5,
  445. .vsync_len = 5,
  446. .refresh = 60,
  447. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
  448. };
  449. static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
  450. .clock_source = LCDC_CLK_PERIPHERAL, /* HDMI clock */
  451. .ch[0] = {
  452. .chan = LCDC_CHAN_MAINLCD,
  453. .fourcc = V4L2_PIX_FMT_RGB565,
  454. .interface_type = RGB24,
  455. .clock_divider = 1,
  456. .flags = LCDC_FLAGS_DWPOL,
  457. .lcd_modes = &lcdc1_mode,
  458. .num_modes = 1,
  459. .tx_dev = &hdmi_device,
  460. .panel_cfg = {
  461. .width = 1280,
  462. .height = 720,
  463. },
  464. },
  465. };
  466. static struct resource hdmi_lcdc_resources[] = {
  467. [0] = {
  468. .name = "LCDC1",
  469. .start = 0xfe944000,
  470. .end = 0xfe948000 - 1,
  471. .flags = IORESOURCE_MEM,
  472. },
  473. [1] = {
  474. .start = gic_spi(178),
  475. .flags = IORESOURCE_IRQ,
  476. },
  477. };
  478. static struct platform_device hdmi_lcdc_device = {
  479. .name = "sh_mobile_lcdc_fb",
  480. .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
  481. .resource = hdmi_lcdc_resources,
  482. .id = 1,
  483. .dev = {
  484. .platform_data = &hdmi_lcdc_info,
  485. .coherent_dma_mask = ~0,
  486. },
  487. };
  488. /* GPIO KEY */
  489. #define GPIO_KEY(c, g, d, ...) \
  490. { .code = c, .gpio = g, .desc = d, .active_low = 1, __VA_ARGS__ }
  491. static struct gpio_keys_button gpio_buttons[] = {
  492. GPIO_KEY(KEY_POWER, 99, "SW3", .wakeup = 1),
  493. GPIO_KEY(KEY_BACK, 100, "SW4"),
  494. GPIO_KEY(KEY_MENU, 97, "SW5"),
  495. GPIO_KEY(KEY_HOME, 98, "SW6"),
  496. };
  497. static struct gpio_keys_platform_data gpio_key_info = {
  498. .buttons = gpio_buttons,
  499. .nbuttons = ARRAY_SIZE(gpio_buttons),
  500. };
  501. static struct platform_device gpio_keys_device = {
  502. .name = "gpio-keys",
  503. .id = -1,
  504. .dev = {
  505. .platform_data = &gpio_key_info,
  506. },
  507. };
  508. /* Fixed 3.3V regulator to be used by SDHI1, MMCIF */
  509. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  510. REGULATOR_SUPPLY("vmmc", "sh_mmcif"),
  511. REGULATOR_SUPPLY("vqmmc", "sh_mmcif"),
  512. };
  513. /* Fixed 3.3V regulator to be used by SDHI0 */
  514. static struct regulator_consumer_supply vcc_sdhi0_consumers[] = {
  515. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  516. };
  517. static struct regulator_init_data vcc_sdhi0_init_data = {
  518. .constraints = {
  519. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  520. },
  521. .num_consumer_supplies = ARRAY_SIZE(vcc_sdhi0_consumers),
  522. .consumer_supplies = vcc_sdhi0_consumers,
  523. };
  524. static struct fixed_voltage_config vcc_sdhi0_info = {
  525. .supply_name = "SDHI0 Vcc",
  526. .microvolts = 3300000,
  527. .gpio = GPIO_PORT75,
  528. .enable_high = 1,
  529. .init_data = &vcc_sdhi0_init_data,
  530. };
  531. static struct platform_device vcc_sdhi0 = {
  532. .name = "reg-fixed-voltage",
  533. .id = 1,
  534. .dev = {
  535. .platform_data = &vcc_sdhi0_info,
  536. },
  537. };
  538. /* 1.8 / 3.3V SDHI0 VccQ regulator */
  539. static struct regulator_consumer_supply vccq_sdhi0_consumers[] = {
  540. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  541. };
  542. static struct regulator_init_data vccq_sdhi0_init_data = {
  543. .constraints = {
  544. .input_uV = 3300000,
  545. .min_uV = 1800000,
  546. .max_uV = 3300000,
  547. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  548. REGULATOR_CHANGE_STATUS,
  549. },
  550. .num_consumer_supplies = ARRAY_SIZE(vccq_sdhi0_consumers),
  551. .consumer_supplies = vccq_sdhi0_consumers,
  552. };
  553. static struct gpio vccq_sdhi0_gpios[] = {
  554. {GPIO_PORT17, GPIOF_OUT_INIT_LOW, "vccq-sdhi0" },
  555. };
  556. static struct gpio_regulator_state vccq_sdhi0_states[] = {
  557. { .value = 3300000, .gpios = (0 << 0) },
  558. { .value = 1800000, .gpios = (1 << 0) },
  559. };
  560. static struct gpio_regulator_config vccq_sdhi0_info = {
  561. .supply_name = "vqmmc",
  562. .enable_gpio = GPIO_PORT74,
  563. .enable_high = 1,
  564. .enabled_at_boot = 0,
  565. .gpios = vccq_sdhi0_gpios,
  566. .nr_gpios = ARRAY_SIZE(vccq_sdhi0_gpios),
  567. .states = vccq_sdhi0_states,
  568. .nr_states = ARRAY_SIZE(vccq_sdhi0_states),
  569. .type = REGULATOR_VOLTAGE,
  570. .init_data = &vccq_sdhi0_init_data,
  571. };
  572. static struct platform_device vccq_sdhi0 = {
  573. .name = "gpio-regulator",
  574. .id = -1,
  575. .dev = {
  576. .platform_data = &vccq_sdhi0_info,
  577. },
  578. };
  579. /* Fixed 3.3V regulator to be used by SDHI1 */
  580. static struct regulator_consumer_supply vcc_sdhi1_consumers[] = {
  581. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
  582. };
  583. static struct regulator_init_data vcc_sdhi1_init_data = {
  584. .constraints = {
  585. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  586. },
  587. .num_consumer_supplies = ARRAY_SIZE(vcc_sdhi1_consumers),
  588. .consumer_supplies = vcc_sdhi1_consumers,
  589. };
  590. static struct fixed_voltage_config vcc_sdhi1_info = {
  591. .supply_name = "SDHI1 Vcc",
  592. .microvolts = 3300000,
  593. .gpio = GPIO_PORT16,
  594. .enable_high = 1,
  595. .init_data = &vcc_sdhi1_init_data,
  596. };
  597. static struct platform_device vcc_sdhi1 = {
  598. .name = "reg-fixed-voltage",
  599. .id = 2,
  600. .dev = {
  601. .platform_data = &vcc_sdhi1_info,
  602. },
  603. };
  604. /* SDHI0 */
  605. /*
  606. * FIXME
  607. *
  608. * It use polling mode here, since
  609. * CD (= Card Detect) pin is not connected to SDHI0_CD.
  610. * We can use IRQ31 as card detect irq,
  611. * but it needs chattering removal operation
  612. */
  613. #define IRQ31 irq_pin(31)
  614. static struct sh_mobile_sdhi_info sdhi0_info = {
  615. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  616. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  617. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  618. MMC_CAP_POWER_OFF_CARD,
  619. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_USE_GPIO_CD,
  620. .cd_gpio = GPIO_PORT167,
  621. };
  622. static struct resource sdhi0_resources[] = {
  623. {
  624. .name = "SDHI0",
  625. .start = 0xe6850000,
  626. .end = 0xe6850100 - 1,
  627. .flags = IORESOURCE_MEM,
  628. },
  629. /*
  630. * no SH_MOBILE_SDHI_IRQ_CARD_DETECT here
  631. */
  632. {
  633. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  634. .start = gic_spi(118),
  635. .flags = IORESOURCE_IRQ,
  636. },
  637. {
  638. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  639. .start = gic_spi(119),
  640. .flags = IORESOURCE_IRQ,
  641. },
  642. };
  643. static struct platform_device sdhi0_device = {
  644. .name = "sh_mobile_sdhi",
  645. .id = 0,
  646. .dev = {
  647. .platform_data = &sdhi0_info,
  648. },
  649. .num_resources = ARRAY_SIZE(sdhi0_resources),
  650. .resource = sdhi0_resources,
  651. };
  652. /* SDHI1 */
  653. static struct sh_mobile_sdhi_info sdhi1_info = {
  654. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  655. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  656. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  657. MMC_CAP_POWER_OFF_CARD,
  658. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_USE_GPIO_CD,
  659. /* Port72 cannot generate IRQs, will be used in polling mode. */
  660. .cd_gpio = GPIO_PORT72,
  661. };
  662. static struct resource sdhi1_resources[] = {
  663. [0] = {
  664. .name = "SDHI1",
  665. .start = 0xe6860000,
  666. .end = 0xe6860100 - 1,
  667. .flags = IORESOURCE_MEM,
  668. },
  669. [1] = {
  670. .start = gic_spi(121),
  671. .flags = IORESOURCE_IRQ,
  672. },
  673. [2] = {
  674. .start = gic_spi(122),
  675. .flags = IORESOURCE_IRQ,
  676. },
  677. [3] = {
  678. .start = gic_spi(123),
  679. .flags = IORESOURCE_IRQ,
  680. },
  681. };
  682. static struct platform_device sdhi1_device = {
  683. .name = "sh_mobile_sdhi",
  684. .id = 1,
  685. .dev = {
  686. .platform_data = &sdhi1_info,
  687. },
  688. .num_resources = ARRAY_SIZE(sdhi1_resources),
  689. .resource = sdhi1_resources,
  690. };
  691. static const struct pinctrl_map eva_sdhi1_pinctrl_map[] = {
  692. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  693. "sdhi1_data4", "sdhi1"),
  694. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  695. "sdhi1_ctrl", "sdhi1"),
  696. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  697. "sdhi1_cd", "sdhi1"),
  698. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  699. "sdhi1_wp", "sdhi1"),
  700. };
  701. /* MMCIF */
  702. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  703. .sup_pclk = 0,
  704. .caps = MMC_CAP_4_BIT_DATA |
  705. MMC_CAP_8_BIT_DATA |
  706. MMC_CAP_NONREMOVABLE,
  707. };
  708. static struct resource sh_mmcif_resources[] = {
  709. [0] = {
  710. .name = "MMCIF",
  711. .start = 0xe6bd0000,
  712. .end = 0xe6bd0100 - 1,
  713. .flags = IORESOURCE_MEM,
  714. },
  715. [1] = {
  716. /* MMC ERR */
  717. .start = gic_spi(56),
  718. .flags = IORESOURCE_IRQ,
  719. },
  720. [2] = {
  721. /* MMC NOR */
  722. .start = gic_spi(57),
  723. .flags = IORESOURCE_IRQ,
  724. },
  725. };
  726. static struct platform_device sh_mmcif_device = {
  727. .name = "sh_mmcif",
  728. .id = -1,
  729. .dev = {
  730. .platform_data = &sh_mmcif_plat,
  731. },
  732. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  733. .resource = sh_mmcif_resources,
  734. };
  735. /* Camera */
  736. static int mt9t111_power(struct device *dev, int mode)
  737. {
  738. struct clk *mclk = clk_get(NULL, "video1");
  739. if (IS_ERR(mclk)) {
  740. dev_err(dev, "can't get video1 clock\n");
  741. return -EINVAL;
  742. }
  743. if (mode) {
  744. /* video1 (= CON1 camera) expect 24MHz */
  745. clk_set_rate(mclk, clk_round_rate(mclk, 24000000));
  746. clk_enable(mclk);
  747. gpio_set_value(158, 1);
  748. } else {
  749. gpio_set_value(158, 0);
  750. clk_disable(mclk);
  751. }
  752. clk_put(mclk);
  753. return 0;
  754. }
  755. static struct i2c_board_info i2c_camera_mt9t111 = {
  756. I2C_BOARD_INFO("mt9t112", 0x3d),
  757. };
  758. static struct mt9t112_camera_info mt9t111_info = {
  759. .divider = { 16, 0, 0, 7, 0, 10, 14, 7, 7 },
  760. };
  761. static struct soc_camera_link mt9t111_link = {
  762. .i2c_adapter_id = 0,
  763. .bus_id = 0,
  764. .board_info = &i2c_camera_mt9t111,
  765. .power = mt9t111_power,
  766. .priv = &mt9t111_info,
  767. };
  768. static struct platform_device camera_device = {
  769. .name = "soc-camera-pdrv",
  770. .id = 0,
  771. .dev = {
  772. .platform_data = &mt9t111_link,
  773. },
  774. };
  775. /* CEU0 */
  776. static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
  777. .flags = SH_CEU_FLAG_LOWER_8BIT,
  778. };
  779. static struct resource ceu0_resources[] = {
  780. [0] = {
  781. .name = "CEU",
  782. .start = 0xfe910000,
  783. .end = 0xfe91009f,
  784. .flags = IORESOURCE_MEM,
  785. },
  786. [1] = {
  787. .start = gic_spi(160),
  788. .flags = IORESOURCE_IRQ,
  789. },
  790. [2] = {
  791. /* place holder for contiguous memory */
  792. },
  793. };
  794. static struct platform_device ceu0_device = {
  795. .name = "sh_mobile_ceu",
  796. .id = 0,
  797. .num_resources = ARRAY_SIZE(ceu0_resources),
  798. .resource = ceu0_resources,
  799. .dev = {
  800. .platform_data = &sh_mobile_ceu0_info,
  801. .coherent_dma_mask = 0xffffffff,
  802. },
  803. };
  804. /* FSI */
  805. static struct sh_fsi_platform_info fsi_info = {
  806. /* FSI-WM8978 */
  807. .port_a = {
  808. .tx_id = SHDMA_SLAVE_FSIA_TX,
  809. },
  810. /* FSI-HDMI */
  811. .port_b = {
  812. .flags = SH_FSI_FMT_SPDIF |
  813. SH_FSI_ENABLE_STREAM_MODE |
  814. SH_FSI_CLK_CPG,
  815. .tx_id = SHDMA_SLAVE_FSIB_TX,
  816. }
  817. };
  818. static struct resource fsi_resources[] = {
  819. [0] = {
  820. .name = "FSI",
  821. .start = 0xfe1f0000,
  822. .end = 0xfe1f8400 - 1,
  823. .flags = IORESOURCE_MEM,
  824. },
  825. [1] = {
  826. .start = gic_spi(9),
  827. .flags = IORESOURCE_IRQ,
  828. },
  829. };
  830. static struct platform_device fsi_device = {
  831. .name = "sh_fsi2",
  832. .id = -1,
  833. .num_resources = ARRAY_SIZE(fsi_resources),
  834. .resource = fsi_resources,
  835. .dev = {
  836. .platform_data = &fsi_info,
  837. },
  838. };
  839. /* FSI-WM8978 */
  840. static struct asoc_simple_card_info fsi_wm8978_info = {
  841. .name = "wm8978",
  842. .card = "FSI2A-WM8978",
  843. .codec = "wm8978.0-001a",
  844. .platform = "sh_fsi2",
  845. .daifmt = SND_SOC_DAIFMT_I2S,
  846. .cpu_dai = {
  847. .name = "fsia-dai",
  848. .fmt = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_IB_NF,
  849. },
  850. .codec_dai = {
  851. .name = "wm8978-hifi",
  852. .fmt = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_NB_NF,
  853. .sysclk = 12288000,
  854. },
  855. };
  856. static struct platform_device fsi_wm8978_device = {
  857. .name = "asoc-simple-card",
  858. .id = 0,
  859. .dev = {
  860. .platform_data = &fsi_wm8978_info,
  861. },
  862. };
  863. /* FSI-HDMI */
  864. static struct asoc_simple_card_info fsi2_hdmi_info = {
  865. .name = "HDMI",
  866. .card = "FSI2B-HDMI",
  867. .codec = "sh-mobile-hdmi",
  868. .platform = "sh_fsi2",
  869. .cpu_dai = {
  870. .name = "fsib-dai",
  871. .fmt = SND_SOC_DAIFMT_CBM_CFM,
  872. },
  873. .codec_dai = {
  874. .name = "sh_mobile_hdmi-hifi",
  875. },
  876. };
  877. static struct platform_device fsi_hdmi_device = {
  878. .name = "asoc-simple-card",
  879. .id = 1,
  880. .dev = {
  881. .platform_data = &fsi2_hdmi_info,
  882. },
  883. };
  884. /* RTC: RTC connects i2c-gpio. */
  885. static struct i2c_gpio_platform_data i2c_gpio_data = {
  886. .sda_pin = 208,
  887. .scl_pin = 91,
  888. .udelay = 5, /* 100 kHz */
  889. };
  890. static struct platform_device i2c_gpio_device = {
  891. .name = "i2c-gpio",
  892. .id = 2,
  893. .dev = {
  894. .platform_data = &i2c_gpio_data,
  895. },
  896. };
  897. /* I2C */
  898. static struct i2c_board_info i2c0_devices[] = {
  899. {
  900. I2C_BOARD_INFO("st1232-ts", 0x55),
  901. .irq = irq_pin(10),
  902. },
  903. {
  904. I2C_BOARD_INFO("wm8978", 0x1a),
  905. },
  906. };
  907. static struct i2c_board_info i2c2_devices[] = {
  908. {
  909. I2C_BOARD_INFO("s35390a", 0x30),
  910. .type = "s35390a",
  911. },
  912. };
  913. /*
  914. * board devices
  915. */
  916. static struct platform_device *eva_devices[] __initdata = {
  917. &lcdc0_device,
  918. &gpio_keys_device,
  919. &sh_eth_device,
  920. &vcc_sdhi0,
  921. &vccq_sdhi0,
  922. &sdhi0_device,
  923. &sh_mmcif_device,
  924. &hdmi_device,
  925. &hdmi_lcdc_device,
  926. &camera_device,
  927. &ceu0_device,
  928. &fsi_device,
  929. &fsi_wm8978_device,
  930. &fsi_hdmi_device,
  931. &i2c_gpio_device,
  932. };
  933. static const struct pinctrl_map eva_pinctrl_map[] = {
  934. /* LCD0 */
  935. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
  936. "lcd0_data24_0", "lcd0"),
  937. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
  938. "lcd0_lclk_1", "lcd0"),
  939. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
  940. "lcd0_sync", "lcd0"),
  941. /* MMCIF */
  942. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a7740",
  943. "mmc0_data8_1", "mmc0"),
  944. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a7740",
  945. "mmc0_ctrl_1", "mmc0"),
  946. /* SDHI0 */
  947. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7740",
  948. "sdhi0_data4", "sdhi0"),
  949. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7740",
  950. "sdhi0_ctrl", "sdhi0"),
  951. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7740",
  952. "sdhi0_wp", "sdhi0"),
  953. };
  954. static void __init eva_clock_init(void)
  955. {
  956. struct clk *system = clk_get(NULL, "system_clk");
  957. struct clk *xtal1 = clk_get(NULL, "extal1");
  958. struct clk *usb24s = clk_get(NULL, "usb24s");
  959. struct clk *fsibck = clk_get(NULL, "fsibck");
  960. if (IS_ERR(system) ||
  961. IS_ERR(xtal1) ||
  962. IS_ERR(usb24s) ||
  963. IS_ERR(fsibck)) {
  964. pr_err("armadillo800eva board clock init failed\n");
  965. goto clock_error;
  966. }
  967. /* armadillo 800 eva extal1 is 24MHz */
  968. clk_set_rate(xtal1, 24000000);
  969. /* usb24s use extal1 (= system) clock (= 24MHz) */
  970. clk_set_parent(usb24s, system);
  971. /* FSIBCK is 12.288MHz, and it is parent of FSI-B */
  972. clk_set_rate(fsibck, 12288000);
  973. clock_error:
  974. if (!IS_ERR(system))
  975. clk_put(system);
  976. if (!IS_ERR(xtal1))
  977. clk_put(xtal1);
  978. if (!IS_ERR(usb24s))
  979. clk_put(usb24s);
  980. if (!IS_ERR(fsibck))
  981. clk_put(fsibck);
  982. }
  983. /*
  984. * board init
  985. */
  986. #define GPIO_PORT7CR IOMEM(0xe6050007)
  987. #define GPIO_PORT8CR IOMEM(0xe6050008)
  988. static void __init eva_init(void)
  989. {
  990. struct platform_device *usb = NULL;
  991. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  992. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  993. pinctrl_register_mappings(eva_pinctrl_map, ARRAY_SIZE(eva_pinctrl_map));
  994. r8a7740_pinmux_init();
  995. r8a7740_meram_workaround();
  996. /* SCIFA1 */
  997. gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
  998. gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
  999. /* LCDC0 */
  1000. gpio_request(GPIO_FN_LCDC0_SELECT, NULL);
  1001. gpio_request_one(61, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
  1002. gpio_request_one(202, GPIOF_OUT_INIT_LOW, NULL); /* LCD0_LED_CONT */
  1003. /* Touchscreen */
  1004. gpio_request(GPIO_FN_IRQ10, NULL); /* TP_INT */
  1005. gpio_request_one(166, GPIOF_OUT_INIT_HIGH, NULL); /* TP_RST_B */
  1006. /* GETHER */
  1007. gpio_request(GPIO_FN_ET_CRS, NULL);
  1008. gpio_request(GPIO_FN_ET_MDC, NULL);
  1009. gpio_request(GPIO_FN_ET_MDIO, NULL);
  1010. gpio_request(GPIO_FN_ET_TX_ER, NULL);
  1011. gpio_request(GPIO_FN_ET_RX_ER, NULL);
  1012. gpio_request(GPIO_FN_ET_ERXD0, NULL);
  1013. gpio_request(GPIO_FN_ET_ERXD1, NULL);
  1014. gpio_request(GPIO_FN_ET_ERXD2, NULL);
  1015. gpio_request(GPIO_FN_ET_ERXD3, NULL);
  1016. gpio_request(GPIO_FN_ET_TX_CLK, NULL);
  1017. gpio_request(GPIO_FN_ET_TX_EN, NULL);
  1018. gpio_request(GPIO_FN_ET_ETXD0, NULL);
  1019. gpio_request(GPIO_FN_ET_ETXD1, NULL);
  1020. gpio_request(GPIO_FN_ET_ETXD2, NULL);
  1021. gpio_request(GPIO_FN_ET_ETXD3, NULL);
  1022. gpio_request(GPIO_FN_ET_PHY_INT, NULL);
  1023. gpio_request(GPIO_FN_ET_COL, NULL);
  1024. gpio_request(GPIO_FN_ET_RX_DV, NULL);
  1025. gpio_request(GPIO_FN_ET_RX_CLK, NULL);
  1026. gpio_request_one(18, GPIOF_OUT_INIT_HIGH, NULL); /* PHY_RST */
  1027. /* USB */
  1028. gpio_request_one(159, GPIOF_IN, NULL); /* USB_DEVICE_MODE */
  1029. if (gpio_get_value(159)) {
  1030. /* USB Host */
  1031. } else {
  1032. /* USB Func */
  1033. /*
  1034. * A1 chip has 2 IRQ7 pin and it was controled by MSEL register.
  1035. * OTOH, usbhs interrupt needs its value (HI/LOW) to decide
  1036. * USB connection/disconnection (usbhsf_get_vbus()).
  1037. * This means we needs to select GPIO_FN_IRQ7_PORT209 first,
  1038. * and select GPIO 209 here
  1039. */
  1040. gpio_request(GPIO_FN_IRQ7_PORT209, NULL);
  1041. gpio_request_one(209, GPIOF_IN, NULL);
  1042. platform_device_register(&usbhsf_device);
  1043. usb = &usbhsf_device;
  1044. }
  1045. /* CEU0 */
  1046. gpio_request(GPIO_FN_VIO0_D7, NULL);
  1047. gpio_request(GPIO_FN_VIO0_D6, NULL);
  1048. gpio_request(GPIO_FN_VIO0_D5, NULL);
  1049. gpio_request(GPIO_FN_VIO0_D4, NULL);
  1050. gpio_request(GPIO_FN_VIO0_D3, NULL);
  1051. gpio_request(GPIO_FN_VIO0_D2, NULL);
  1052. gpio_request(GPIO_FN_VIO0_D1, NULL);
  1053. gpio_request(GPIO_FN_VIO0_D0, NULL);
  1054. gpio_request(GPIO_FN_VIO0_CLK, NULL);
  1055. gpio_request(GPIO_FN_VIO0_HD, NULL);
  1056. gpio_request(GPIO_FN_VIO0_VD, NULL);
  1057. gpio_request(GPIO_FN_VIO0_FIELD, NULL);
  1058. gpio_request(GPIO_FN_VIO_CKO, NULL);
  1059. /* CON1/CON15 Camera */
  1060. gpio_request_one(173, GPIOF_OUT_INIT_LOW, NULL); /* STANDBY */
  1061. gpio_request_one(172, GPIOF_OUT_INIT_HIGH, NULL); /* RST */
  1062. /* see mt9t111_power() */
  1063. gpio_request_one(158, GPIOF_OUT_INIT_LOW, NULL); /* CAM_PON */
  1064. /* FSI-WM8978 */
  1065. gpio_request(GPIO_FN_FSIAIBT, NULL);
  1066. gpio_request(GPIO_FN_FSIAILR, NULL);
  1067. gpio_request(GPIO_FN_FSIAOMC, NULL);
  1068. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  1069. gpio_request(GPIO_FN_FSIAISLD_PORT5, NULL);
  1070. gpio_request(7, NULL);
  1071. gpio_request(8, NULL);
  1072. gpio_direction_none(GPIO_PORT7CR); /* FSIAOBT needs no direction */
  1073. gpio_direction_none(GPIO_PORT8CR); /* FSIAOLR needs no direction */
  1074. /* FSI-HDMI */
  1075. gpio_request(GPIO_FN_FSIBCK, NULL);
  1076. /* HDMI */
  1077. gpio_request(GPIO_FN_HDMI_HPD, NULL);
  1078. gpio_request(GPIO_FN_HDMI_CEC, NULL);
  1079. /*
  1080. * CAUTION
  1081. *
  1082. * DBGMD/LCDC0/FSIA MUX
  1083. * DBGMD_SELECT_B should be set after setting PFC Function.
  1084. */
  1085. gpio_request_one(176, GPIOF_OUT_INIT_HIGH, NULL);
  1086. /*
  1087. * We can switch CON8/CON14 by SW1.5,
  1088. * but it needs after DBGMD_SELECT_B
  1089. */
  1090. gpio_request_one(6, GPIOF_IN, NULL);
  1091. if (gpio_get_value(6)) {
  1092. /* CON14 enable */
  1093. } else {
  1094. /* CON8 (SDHI1) enable */
  1095. pinctrl_register_mappings(eva_sdhi1_pinctrl_map,
  1096. ARRAY_SIZE(eva_sdhi1_pinctrl_map));
  1097. platform_device_register(&vcc_sdhi1);
  1098. platform_device_register(&sdhi1_device);
  1099. }
  1100. #ifdef CONFIG_CACHE_L2X0
  1101. /* Early BRESP enable, Shared attribute override enable, 32K*8way */
  1102. l2x0_init(IOMEM(0xf0002000), 0x40440000, 0x82000fff);
  1103. #endif
  1104. i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
  1105. i2c_register_board_info(2, i2c2_devices, ARRAY_SIZE(i2c2_devices));
  1106. r8a7740_add_standard_devices();
  1107. platform_add_devices(eva_devices,
  1108. ARRAY_SIZE(eva_devices));
  1109. rmobile_add_device_to_domain("A4LC", &lcdc0_device);
  1110. rmobile_add_device_to_domain("A4LC", &hdmi_lcdc_device);
  1111. if (usb)
  1112. rmobile_add_device_to_domain("A3SP", usb);
  1113. r8a7740_pm_init();
  1114. }
  1115. static void __init eva_earlytimer_init(void)
  1116. {
  1117. r8a7740_clock_init(MD_CK0 | MD_CK2);
  1118. shmobile_earlytimer_init();
  1119. /* the rate of extal1 clock must be set before late_time_init */
  1120. eva_clock_init();
  1121. }
  1122. static void __init eva_add_early_devices(void)
  1123. {
  1124. r8a7740_add_early_devices();
  1125. }
  1126. #define RESCNT2 IOMEM(0xe6188020)
  1127. static void eva_restart(char mode, const char *cmd)
  1128. {
  1129. /* Do soft power on reset */
  1130. writel((1 << 31), RESCNT2);
  1131. }
  1132. static const char *eva_boards_compat_dt[] __initdata = {
  1133. "renesas,armadillo800eva",
  1134. NULL,
  1135. };
  1136. DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva")
  1137. .map_io = r8a7740_map_io,
  1138. .init_early = eva_add_early_devices,
  1139. .init_irq = r8a7740_init_irq,
  1140. .init_machine = eva_init,
  1141. .init_late = shmobile_init_late,
  1142. .init_time = eva_earlytimer_init,
  1143. .dt_compat = eva_boards_compat_dt,
  1144. .restart = eva_restart,
  1145. MACHINE_END