board-armadillo800eva.c 31 KB

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