board-armadillo800eva.c 30 KB

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