board-armadillo800eva.c 30 KB

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