board-armadillo800eva.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322
  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. };
  384. static struct platform_device pwm_backlight_device = {
  385. .name = "pwm-backlight",
  386. .dev = {
  387. .platform_data = &pwm_backlight_data,
  388. },
  389. };
  390. static struct fb_videomode lcdc0_mode = {
  391. .name = "AMPIER/AM-800480",
  392. .xres = 800,
  393. .yres = 480,
  394. .left_margin = 88,
  395. .right_margin = 40,
  396. .hsync_len = 128,
  397. .upper_margin = 20,
  398. .lower_margin = 5,
  399. .vsync_len = 5,
  400. .sync = 0,
  401. };
  402. static struct sh_mobile_lcdc_info lcdc0_info = {
  403. .clock_source = LCDC_CLK_BUS,
  404. .ch[0] = {
  405. .chan = LCDC_CHAN_MAINLCD,
  406. .fourcc = V4L2_PIX_FMT_RGB565,
  407. .interface_type = RGB24,
  408. .clock_divider = 5,
  409. .flags = 0,
  410. .lcd_modes = &lcdc0_mode,
  411. .num_modes = 1,
  412. .panel_cfg = {
  413. .width = 111,
  414. .height = 68,
  415. },
  416. },
  417. };
  418. static struct resource lcdc0_resources[] = {
  419. [0] = {
  420. .name = "LCD0",
  421. .start = 0xfe940000,
  422. .end = 0xfe943fff,
  423. .flags = IORESOURCE_MEM,
  424. },
  425. [1] = {
  426. .start = gic_spi(177),
  427. .flags = IORESOURCE_IRQ,
  428. },
  429. };
  430. static struct platform_device lcdc0_device = {
  431. .name = "sh_mobile_lcdc_fb",
  432. .num_resources = ARRAY_SIZE(lcdc0_resources),
  433. .resource = lcdc0_resources,
  434. .id = 0,
  435. .dev = {
  436. .platform_data = &lcdc0_info,
  437. .coherent_dma_mask = ~0,
  438. },
  439. };
  440. /*
  441. * LCDC1/HDMI
  442. */
  443. static struct sh_mobile_hdmi_info hdmi_info = {
  444. .flags = HDMI_OUTPUT_PUSH_PULL |
  445. HDMI_OUTPUT_POLARITY_HI |
  446. HDMI_32BIT_REG |
  447. HDMI_HAS_HTOP1 |
  448. HDMI_SND_SRC_SPDIF,
  449. };
  450. static struct resource hdmi_resources[] = {
  451. [0] = {
  452. .name = "HDMI",
  453. .start = 0xe6be0000,
  454. .end = 0xe6be03ff,
  455. .flags = IORESOURCE_MEM,
  456. },
  457. [1] = {
  458. .start = gic_spi(131),
  459. .flags = IORESOURCE_IRQ,
  460. },
  461. [2] = {
  462. .name = "HDMI emma3pf",
  463. .start = 0xe6be4000,
  464. .end = 0xe6be43ff,
  465. .flags = IORESOURCE_MEM,
  466. },
  467. };
  468. static struct platform_device hdmi_device = {
  469. .name = "sh-mobile-hdmi",
  470. .num_resources = ARRAY_SIZE(hdmi_resources),
  471. .resource = hdmi_resources,
  472. .id = -1,
  473. .dev = {
  474. .platform_data = &hdmi_info,
  475. },
  476. };
  477. static const struct fb_videomode lcdc1_mode = {
  478. .name = "HDMI 720p",
  479. .xres = 1280,
  480. .yres = 720,
  481. .pixclock = 13468,
  482. .left_margin = 220,
  483. .right_margin = 110,
  484. .hsync_len = 40,
  485. .upper_margin = 20,
  486. .lower_margin = 5,
  487. .vsync_len = 5,
  488. .refresh = 60,
  489. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
  490. };
  491. static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
  492. .clock_source = LCDC_CLK_PERIPHERAL, /* HDMI clock */
  493. .ch[0] = {
  494. .chan = LCDC_CHAN_MAINLCD,
  495. .fourcc = V4L2_PIX_FMT_RGB565,
  496. .interface_type = RGB24,
  497. .clock_divider = 1,
  498. .flags = LCDC_FLAGS_DWPOL,
  499. .lcd_modes = &lcdc1_mode,
  500. .num_modes = 1,
  501. .tx_dev = &hdmi_device,
  502. .panel_cfg = {
  503. .width = 1280,
  504. .height = 720,
  505. },
  506. },
  507. };
  508. static struct resource hdmi_lcdc_resources[] = {
  509. [0] = {
  510. .name = "LCDC1",
  511. .start = 0xfe944000,
  512. .end = 0xfe948000 - 1,
  513. .flags = IORESOURCE_MEM,
  514. },
  515. [1] = {
  516. .start = gic_spi(178),
  517. .flags = IORESOURCE_IRQ,
  518. },
  519. };
  520. static struct platform_device hdmi_lcdc_device = {
  521. .name = "sh_mobile_lcdc_fb",
  522. .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
  523. .resource = hdmi_lcdc_resources,
  524. .id = 1,
  525. .dev = {
  526. .platform_data = &hdmi_lcdc_info,
  527. .coherent_dma_mask = ~0,
  528. },
  529. };
  530. /* GPIO KEY */
  531. #define GPIO_KEY(c, g, d, ...) \
  532. { .code = c, .gpio = g, .desc = d, .active_low = 1, __VA_ARGS__ }
  533. static struct gpio_keys_button gpio_buttons[] = {
  534. GPIO_KEY(KEY_POWER, 99, "SW3", .wakeup = 1),
  535. GPIO_KEY(KEY_BACK, 100, "SW4"),
  536. GPIO_KEY(KEY_MENU, 97, "SW5"),
  537. GPIO_KEY(KEY_HOME, 98, "SW6"),
  538. };
  539. static struct gpio_keys_platform_data gpio_key_info = {
  540. .buttons = gpio_buttons,
  541. .nbuttons = ARRAY_SIZE(gpio_buttons),
  542. };
  543. static struct platform_device gpio_keys_device = {
  544. .name = "gpio-keys",
  545. .id = -1,
  546. .dev = {
  547. .platform_data = &gpio_key_info,
  548. },
  549. };
  550. /* Fixed 3.3V regulator to be used by SDHI1, MMCIF */
  551. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  552. REGULATOR_SUPPLY("vmmc", "sh_mmcif"),
  553. REGULATOR_SUPPLY("vqmmc", "sh_mmcif"),
  554. };
  555. /* Fixed 3.3V regulator to be used by SDHI0 */
  556. static struct regulator_consumer_supply vcc_sdhi0_consumers[] = {
  557. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  558. };
  559. static struct regulator_init_data vcc_sdhi0_init_data = {
  560. .constraints = {
  561. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  562. },
  563. .num_consumer_supplies = ARRAY_SIZE(vcc_sdhi0_consumers),
  564. .consumer_supplies = vcc_sdhi0_consumers,
  565. };
  566. static struct fixed_voltage_config vcc_sdhi0_info = {
  567. .supply_name = "SDHI0 Vcc",
  568. .microvolts = 3300000,
  569. .gpio = 75,
  570. .enable_high = 1,
  571. .init_data = &vcc_sdhi0_init_data,
  572. };
  573. static struct platform_device vcc_sdhi0 = {
  574. .name = "reg-fixed-voltage",
  575. .id = 1,
  576. .dev = {
  577. .platform_data = &vcc_sdhi0_info,
  578. },
  579. };
  580. /* 1.8 / 3.3V SDHI0 VccQ regulator */
  581. static struct regulator_consumer_supply vccq_sdhi0_consumers[] = {
  582. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  583. };
  584. static struct regulator_init_data vccq_sdhi0_init_data = {
  585. .constraints = {
  586. .input_uV = 3300000,
  587. .min_uV = 1800000,
  588. .max_uV = 3300000,
  589. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  590. REGULATOR_CHANGE_STATUS,
  591. },
  592. .num_consumer_supplies = ARRAY_SIZE(vccq_sdhi0_consumers),
  593. .consumer_supplies = vccq_sdhi0_consumers,
  594. };
  595. static struct gpio vccq_sdhi0_gpios[] = {
  596. {17, GPIOF_OUT_INIT_LOW, "vccq-sdhi0" },
  597. };
  598. static struct gpio_regulator_state vccq_sdhi0_states[] = {
  599. { .value = 3300000, .gpios = (0 << 0) },
  600. { .value = 1800000, .gpios = (1 << 0) },
  601. };
  602. static struct gpio_regulator_config vccq_sdhi0_info = {
  603. .supply_name = "vqmmc",
  604. .enable_gpio = 74,
  605. .enable_high = 1,
  606. .enabled_at_boot = 0,
  607. .gpios = vccq_sdhi0_gpios,
  608. .nr_gpios = ARRAY_SIZE(vccq_sdhi0_gpios),
  609. .states = vccq_sdhi0_states,
  610. .nr_states = ARRAY_SIZE(vccq_sdhi0_states),
  611. .type = REGULATOR_VOLTAGE,
  612. .init_data = &vccq_sdhi0_init_data,
  613. };
  614. static struct platform_device vccq_sdhi0 = {
  615. .name = "gpio-regulator",
  616. .id = -1,
  617. .dev = {
  618. .platform_data = &vccq_sdhi0_info,
  619. },
  620. };
  621. /* Fixed 3.3V regulator to be used by SDHI1 */
  622. static struct regulator_consumer_supply vcc_sdhi1_consumers[] = {
  623. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
  624. };
  625. static struct regulator_init_data vcc_sdhi1_init_data = {
  626. .constraints = {
  627. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  628. },
  629. .num_consumer_supplies = ARRAY_SIZE(vcc_sdhi1_consumers),
  630. .consumer_supplies = vcc_sdhi1_consumers,
  631. };
  632. static struct fixed_voltage_config vcc_sdhi1_info = {
  633. .supply_name = "SDHI1 Vcc",
  634. .microvolts = 3300000,
  635. .gpio = 16,
  636. .enable_high = 1,
  637. .init_data = &vcc_sdhi1_init_data,
  638. };
  639. static struct platform_device vcc_sdhi1 = {
  640. .name = "reg-fixed-voltage",
  641. .id = 2,
  642. .dev = {
  643. .platform_data = &vcc_sdhi1_info,
  644. },
  645. };
  646. /* SDHI0 */
  647. static struct sh_mobile_sdhi_info sdhi0_info = {
  648. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  649. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  650. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  651. MMC_CAP_POWER_OFF_CARD,
  652. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_USE_GPIO_CD,
  653. .cd_gpio = 167,
  654. };
  655. static struct resource sdhi0_resources[] = {
  656. {
  657. .name = "SDHI0",
  658. .start = 0xe6850000,
  659. .end = 0xe6850100 - 1,
  660. .flags = IORESOURCE_MEM,
  661. },
  662. /*
  663. * no SH_MOBILE_SDHI_IRQ_CARD_DETECT here
  664. */
  665. {
  666. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  667. .start = gic_spi(118),
  668. .flags = IORESOURCE_IRQ,
  669. },
  670. {
  671. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  672. .start = gic_spi(119),
  673. .flags = IORESOURCE_IRQ,
  674. },
  675. };
  676. static struct platform_device sdhi0_device = {
  677. .name = "sh_mobile_sdhi",
  678. .id = 0,
  679. .dev = {
  680. .platform_data = &sdhi0_info,
  681. },
  682. .num_resources = ARRAY_SIZE(sdhi0_resources),
  683. .resource = sdhi0_resources,
  684. };
  685. /* SDHI1 */
  686. static struct sh_mobile_sdhi_info sdhi1_info = {
  687. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  688. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  689. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  690. MMC_CAP_POWER_OFF_CARD,
  691. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_USE_GPIO_CD,
  692. /* Port72 cannot generate IRQs, will be used in polling mode. */
  693. .cd_gpio = 72,
  694. };
  695. static struct resource sdhi1_resources[] = {
  696. [0] = {
  697. .name = "SDHI1",
  698. .start = 0xe6860000,
  699. .end = 0xe6860100 - 1,
  700. .flags = IORESOURCE_MEM,
  701. },
  702. [1] = {
  703. .start = gic_spi(121),
  704. .flags = IORESOURCE_IRQ,
  705. },
  706. [2] = {
  707. .start = gic_spi(122),
  708. .flags = IORESOURCE_IRQ,
  709. },
  710. [3] = {
  711. .start = gic_spi(123),
  712. .flags = IORESOURCE_IRQ,
  713. },
  714. };
  715. static struct platform_device sdhi1_device = {
  716. .name = "sh_mobile_sdhi",
  717. .id = 1,
  718. .dev = {
  719. .platform_data = &sdhi1_info,
  720. },
  721. .num_resources = ARRAY_SIZE(sdhi1_resources),
  722. .resource = sdhi1_resources,
  723. };
  724. static const struct pinctrl_map eva_sdhi1_pinctrl_map[] = {
  725. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  726. "sdhi1_data4", "sdhi1"),
  727. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  728. "sdhi1_ctrl", "sdhi1"),
  729. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  730. "sdhi1_cd", "sdhi1"),
  731. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  732. "sdhi1_wp", "sdhi1"),
  733. };
  734. /* MMCIF */
  735. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  736. .sup_pclk = 0,
  737. .caps = MMC_CAP_4_BIT_DATA |
  738. MMC_CAP_8_BIT_DATA |
  739. MMC_CAP_NONREMOVABLE,
  740. .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
  741. .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
  742. };
  743. static struct resource sh_mmcif_resources[] = {
  744. [0] = {
  745. .name = "MMCIF",
  746. .start = 0xe6bd0000,
  747. .end = 0xe6bd0100 - 1,
  748. .flags = IORESOURCE_MEM,
  749. },
  750. [1] = {
  751. /* MMC ERR */
  752. .start = gic_spi(56),
  753. .flags = IORESOURCE_IRQ,
  754. },
  755. [2] = {
  756. /* MMC NOR */
  757. .start = gic_spi(57),
  758. .flags = IORESOURCE_IRQ,
  759. },
  760. };
  761. static struct platform_device sh_mmcif_device = {
  762. .name = "sh_mmcif",
  763. .id = -1,
  764. .dev = {
  765. .platform_data = &sh_mmcif_plat,
  766. },
  767. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  768. .resource = sh_mmcif_resources,
  769. };
  770. /* Camera */
  771. static int mt9t111_power(struct device *dev, int mode)
  772. {
  773. struct clk *mclk = clk_get(NULL, "video1");
  774. if (IS_ERR(mclk)) {
  775. dev_err(dev, "can't get video1 clock\n");
  776. return -EINVAL;
  777. }
  778. if (mode) {
  779. /* video1 (= CON1 camera) expect 24MHz */
  780. clk_set_rate(mclk, clk_round_rate(mclk, 24000000));
  781. clk_enable(mclk);
  782. gpio_set_value(158, 1);
  783. } else {
  784. gpio_set_value(158, 0);
  785. clk_disable(mclk);
  786. }
  787. clk_put(mclk);
  788. return 0;
  789. }
  790. static struct i2c_board_info i2c_camera_mt9t111 = {
  791. I2C_BOARD_INFO("mt9t112", 0x3d),
  792. };
  793. static struct mt9t112_camera_info mt9t111_info = {
  794. .divider = { 16, 0, 0, 7, 0, 10, 14, 7, 7 },
  795. };
  796. static struct soc_camera_link mt9t111_link = {
  797. .i2c_adapter_id = 0,
  798. .bus_id = 0,
  799. .board_info = &i2c_camera_mt9t111,
  800. .power = mt9t111_power,
  801. .priv = &mt9t111_info,
  802. };
  803. static struct platform_device camera_device = {
  804. .name = "soc-camera-pdrv",
  805. .id = 0,
  806. .dev = {
  807. .platform_data = &mt9t111_link,
  808. },
  809. };
  810. /* CEU0 */
  811. static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
  812. .flags = SH_CEU_FLAG_LOWER_8BIT,
  813. };
  814. static struct resource ceu0_resources[] = {
  815. [0] = {
  816. .name = "CEU",
  817. .start = 0xfe910000,
  818. .end = 0xfe91009f,
  819. .flags = IORESOURCE_MEM,
  820. },
  821. [1] = {
  822. .start = gic_spi(160),
  823. .flags = IORESOURCE_IRQ,
  824. },
  825. [2] = {
  826. /* place holder for contiguous memory */
  827. },
  828. };
  829. static struct platform_device ceu0_device = {
  830. .name = "sh_mobile_ceu",
  831. .id = 0,
  832. .num_resources = ARRAY_SIZE(ceu0_resources),
  833. .resource = ceu0_resources,
  834. .dev = {
  835. .platform_data = &sh_mobile_ceu0_info,
  836. .coherent_dma_mask = 0xffffffff,
  837. },
  838. };
  839. /* FSI */
  840. static struct sh_fsi_platform_info fsi_info = {
  841. /* FSI-WM8978 */
  842. .port_a = {
  843. .tx_id = SHDMA_SLAVE_FSIA_TX,
  844. },
  845. /* FSI-HDMI */
  846. .port_b = {
  847. .flags = SH_FSI_FMT_SPDIF |
  848. SH_FSI_ENABLE_STREAM_MODE |
  849. SH_FSI_CLK_CPG,
  850. .tx_id = SHDMA_SLAVE_FSIB_TX,
  851. }
  852. };
  853. static struct resource fsi_resources[] = {
  854. [0] = {
  855. .name = "FSI",
  856. .start = 0xfe1f0000,
  857. .end = 0xfe1f8400 - 1,
  858. .flags = IORESOURCE_MEM,
  859. },
  860. [1] = {
  861. .start = gic_spi(9),
  862. .flags = IORESOURCE_IRQ,
  863. },
  864. };
  865. static struct platform_device fsi_device = {
  866. .name = "sh_fsi2",
  867. .id = -1,
  868. .num_resources = ARRAY_SIZE(fsi_resources),
  869. .resource = fsi_resources,
  870. .dev = {
  871. .platform_data = &fsi_info,
  872. },
  873. };
  874. /* FSI-WM8978 */
  875. static struct asoc_simple_card_info fsi_wm8978_info = {
  876. .name = "wm8978",
  877. .card = "FSI2A-WM8978",
  878. .codec = "wm8978.0-001a",
  879. .platform = "sh_fsi2",
  880. .daifmt = SND_SOC_DAIFMT_I2S,
  881. .cpu_dai = {
  882. .name = "fsia-dai",
  883. .fmt = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_IB_NF,
  884. },
  885. .codec_dai = {
  886. .name = "wm8978-hifi",
  887. .fmt = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_NB_NF,
  888. .sysclk = 12288000,
  889. },
  890. };
  891. static struct platform_device fsi_wm8978_device = {
  892. .name = "asoc-simple-card",
  893. .id = 0,
  894. .dev = {
  895. .platform_data = &fsi_wm8978_info,
  896. },
  897. };
  898. /* FSI-HDMI */
  899. static struct asoc_simple_card_info fsi2_hdmi_info = {
  900. .name = "HDMI",
  901. .card = "FSI2B-HDMI",
  902. .codec = "sh-mobile-hdmi",
  903. .platform = "sh_fsi2",
  904. .cpu_dai = {
  905. .name = "fsib-dai",
  906. .fmt = SND_SOC_DAIFMT_CBM_CFM,
  907. },
  908. .codec_dai = {
  909. .name = "sh_mobile_hdmi-hifi",
  910. },
  911. };
  912. static struct platform_device fsi_hdmi_device = {
  913. .name = "asoc-simple-card",
  914. .id = 1,
  915. .dev = {
  916. .platform_data = &fsi2_hdmi_info,
  917. },
  918. };
  919. /* RTC: RTC connects i2c-gpio. */
  920. static struct i2c_gpio_platform_data i2c_gpio_data = {
  921. .sda_pin = 208,
  922. .scl_pin = 91,
  923. .udelay = 5, /* 100 kHz */
  924. };
  925. static struct platform_device i2c_gpio_device = {
  926. .name = "i2c-gpio",
  927. .id = 2,
  928. .dev = {
  929. .platform_data = &i2c_gpio_data,
  930. },
  931. };
  932. /* I2C */
  933. static struct st1232_pdata st1232_i2c0_pdata = {
  934. .reset_gpio = 166,
  935. };
  936. static struct i2c_board_info i2c0_devices[] = {
  937. {
  938. I2C_BOARD_INFO("st1232-ts", 0x55),
  939. .irq = irq_pin(10),
  940. .platform_data = &st1232_i2c0_pdata,
  941. },
  942. {
  943. I2C_BOARD_INFO("wm8978", 0x1a),
  944. },
  945. };
  946. static struct i2c_board_info i2c2_devices[] = {
  947. {
  948. I2C_BOARD_INFO("s35390a", 0x30),
  949. .type = "s35390a",
  950. },
  951. };
  952. /*
  953. * board devices
  954. */
  955. static struct platform_device *eva_devices[] __initdata = {
  956. &lcdc0_device,
  957. &pwm_device,
  958. &pwm_backlight_device,
  959. &gpio_keys_device,
  960. &sh_eth_device,
  961. &vcc_sdhi0,
  962. &vccq_sdhi0,
  963. &sdhi0_device,
  964. &sh_mmcif_device,
  965. &hdmi_device,
  966. &hdmi_lcdc_device,
  967. &camera_device,
  968. &ceu0_device,
  969. &fsi_device,
  970. &fsi_wm8978_device,
  971. &fsi_hdmi_device,
  972. &i2c_gpio_device,
  973. };
  974. static const struct pinctrl_map eva_pinctrl_map[] = {
  975. /* CEU0 */
  976. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-r8a7740",
  977. "ceu0_data_0_7", "ceu0"),
  978. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-r8a7740",
  979. "ceu0_clk_0", "ceu0"),
  980. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-r8a7740",
  981. "ceu0_sync", "ceu0"),
  982. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-r8a7740",
  983. "ceu0_field", "ceu0"),
  984. /* FSIA */
  985. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-r8a7740",
  986. "fsia_sclk_in", "fsia"),
  987. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-r8a7740",
  988. "fsia_mclk_out", "fsia"),
  989. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-r8a7740",
  990. "fsia_data_in_1", "fsia"),
  991. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-r8a7740",
  992. "fsia_data_out_0", "fsia"),
  993. /* FSIB */
  994. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.1", "pfc-r8a7740",
  995. "fsib_mclk_in", "fsib"),
  996. /* GETHER */
  997. PIN_MAP_MUX_GROUP_DEFAULT("sh-eth", "pfc-r8a7740",
  998. "gether_mii", "gether"),
  999. PIN_MAP_MUX_GROUP_DEFAULT("sh-eth", "pfc-r8a7740",
  1000. "gether_int", "gether"),
  1001. /* HDMI */
  1002. PIN_MAP_MUX_GROUP_DEFAULT("sh-mobile-hdmi", "pfc-r8a7740",
  1003. "hdmi", "hdmi"),
  1004. /* LCD0 */
  1005. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
  1006. "lcd0_data24_0", "lcd0"),
  1007. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
  1008. "lcd0_lclk_1", "lcd0"),
  1009. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
  1010. "lcd0_sync", "lcd0"),
  1011. /* MMCIF */
  1012. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a7740",
  1013. "mmc0_data8_1", "mmc0"),
  1014. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a7740",
  1015. "mmc0_ctrl_1", "mmc0"),
  1016. /* SCIFA1 */
  1017. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.1", "pfc-r8a7740",
  1018. "scifa1_data", "scifa1"),
  1019. /* SDHI0 */
  1020. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7740",
  1021. "sdhi0_data4", "sdhi0"),
  1022. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7740",
  1023. "sdhi0_ctrl", "sdhi0"),
  1024. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7740",
  1025. "sdhi0_wp", "sdhi0"),
  1026. /* ST1232 */
  1027. PIN_MAP_MUX_GROUP_DEFAULT("0-0055", "pfc-r8a7740",
  1028. "intc_irq10", "intc"),
  1029. /* TPU0 */
  1030. PIN_MAP_MUX_GROUP_DEFAULT("renesas-tpu-pwm", "pfc-r8a7740",
  1031. "tpu0_to2_1", "tpu0"),
  1032. /* USBHS */
  1033. PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7740",
  1034. "intc_irq7_1", "intc"),
  1035. };
  1036. static void __init eva_clock_init(void)
  1037. {
  1038. struct clk *system = clk_get(NULL, "system_clk");
  1039. struct clk *xtal1 = clk_get(NULL, "extal1");
  1040. struct clk *usb24s = clk_get(NULL, "usb24s");
  1041. struct clk *fsibck = clk_get(NULL, "fsibck");
  1042. if (IS_ERR(system) ||
  1043. IS_ERR(xtal1) ||
  1044. IS_ERR(usb24s) ||
  1045. IS_ERR(fsibck)) {
  1046. pr_err("armadillo800eva board clock init failed\n");
  1047. goto clock_error;
  1048. }
  1049. /* armadillo 800 eva extal1 is 24MHz */
  1050. clk_set_rate(xtal1, 24000000);
  1051. /* usb24s use extal1 (= system) clock (= 24MHz) */
  1052. clk_set_parent(usb24s, system);
  1053. /* FSIBCK is 12.288MHz, and it is parent of FSI-B */
  1054. clk_set_rate(fsibck, 12288000);
  1055. clock_error:
  1056. if (!IS_ERR(system))
  1057. clk_put(system);
  1058. if (!IS_ERR(xtal1))
  1059. clk_put(xtal1);
  1060. if (!IS_ERR(usb24s))
  1061. clk_put(usb24s);
  1062. if (!IS_ERR(fsibck))
  1063. clk_put(fsibck);
  1064. }
  1065. /*
  1066. * board init
  1067. */
  1068. #define GPIO_PORT7CR IOMEM(0xe6050007)
  1069. #define GPIO_PORT8CR IOMEM(0xe6050008)
  1070. static void __init eva_init(void)
  1071. {
  1072. struct platform_device *usb = NULL;
  1073. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  1074. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  1075. pinctrl_register_mappings(eva_pinctrl_map, ARRAY_SIZE(eva_pinctrl_map));
  1076. pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
  1077. r8a7740_pinmux_init();
  1078. r8a7740_meram_workaround();
  1079. /* LCDC0 */
  1080. gpio_request_one(61, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
  1081. /* GETHER */
  1082. gpio_request_one(18, GPIOF_OUT_INIT_HIGH, NULL); /* PHY_RST */
  1083. /* USB */
  1084. gpio_request_one(159, GPIOF_IN, NULL); /* USB_DEVICE_MODE */
  1085. if (gpio_get_value(159)) {
  1086. /* USB Host */
  1087. } else {
  1088. /* USB Func */
  1089. /*
  1090. * The USBHS interrupt handlers needs to read the IRQ pin value
  1091. * (HI/LOW) to diffentiate USB connection and disconnection
  1092. * events (usbhsf_get_vbus()). We thus need to select both the
  1093. * intc_irq7_1 pin group and GPIO 209 here.
  1094. */
  1095. gpio_request_one(209, GPIOF_IN, NULL);
  1096. platform_device_register(&usbhsf_device);
  1097. usb = &usbhsf_device;
  1098. }
  1099. /* CON1/CON15 Camera */
  1100. gpio_request_one(173, GPIOF_OUT_INIT_LOW, NULL); /* STANDBY */
  1101. gpio_request_one(172, GPIOF_OUT_INIT_HIGH, NULL); /* RST */
  1102. /* see mt9t111_power() */
  1103. gpio_request_one(158, GPIOF_OUT_INIT_LOW, NULL); /* CAM_PON */
  1104. /* FSI-WM8978 */
  1105. gpio_request(7, NULL);
  1106. gpio_request(8, NULL);
  1107. gpio_direction_none(GPIO_PORT7CR); /* FSIAOBT needs no direction */
  1108. gpio_direction_none(GPIO_PORT8CR); /* FSIAOLR needs no direction */
  1109. /*
  1110. * CAUTION
  1111. *
  1112. * DBGMD/LCDC0/FSIA MUX
  1113. * DBGMD_SELECT_B should be set after setting PFC Function.
  1114. */
  1115. gpio_request_one(176, GPIOF_OUT_INIT_HIGH, NULL);
  1116. /*
  1117. * We can switch CON8/CON14 by SW1.5,
  1118. * but it needs after DBGMD_SELECT_B
  1119. */
  1120. gpio_request_one(6, GPIOF_IN, NULL);
  1121. if (gpio_get_value(6)) {
  1122. /* CON14 enable */
  1123. } else {
  1124. /* CON8 (SDHI1) enable */
  1125. pinctrl_register_mappings(eva_sdhi1_pinctrl_map,
  1126. ARRAY_SIZE(eva_sdhi1_pinctrl_map));
  1127. platform_device_register(&vcc_sdhi1);
  1128. platform_device_register(&sdhi1_device);
  1129. }
  1130. #ifdef CONFIG_CACHE_L2X0
  1131. /* Early BRESP enable, Shared attribute override enable, 32K*8way */
  1132. l2x0_init(IOMEM(0xf0002000), 0x40440000, 0x82000fff);
  1133. #endif
  1134. i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
  1135. i2c_register_board_info(2, i2c2_devices, ARRAY_SIZE(i2c2_devices));
  1136. r8a7740_add_standard_devices();
  1137. platform_add_devices(eva_devices,
  1138. ARRAY_SIZE(eva_devices));
  1139. rmobile_add_device_to_domain("A4LC", &lcdc0_device);
  1140. rmobile_add_device_to_domain("A4LC", &hdmi_lcdc_device);
  1141. if (usb)
  1142. rmobile_add_device_to_domain("A3SP", usb);
  1143. r8a7740_pm_init();
  1144. }
  1145. static void __init eva_earlytimer_init(void)
  1146. {
  1147. r8a7740_clock_init(MD_CK0 | MD_CK2);
  1148. shmobile_earlytimer_init();
  1149. /* the rate of extal1 clock must be set before late_time_init */
  1150. eva_clock_init();
  1151. }
  1152. static void __init eva_add_early_devices(void)
  1153. {
  1154. r8a7740_add_early_devices();
  1155. }
  1156. #define RESCNT2 IOMEM(0xe6188020)
  1157. static void eva_restart(enum reboot_mode mode, const char *cmd)
  1158. {
  1159. /* Do soft power on reset */
  1160. writel((1 << 31), RESCNT2);
  1161. }
  1162. static const char *eva_boards_compat_dt[] __initdata = {
  1163. "renesas,armadillo800eva",
  1164. NULL,
  1165. };
  1166. DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva")
  1167. .map_io = r8a7740_map_io,
  1168. .init_early = eva_add_early_devices,
  1169. .init_irq = r8a7740_init_irq_of,
  1170. .init_machine = eva_init,
  1171. .init_late = shmobile_init_late,
  1172. .init_time = eva_earlytimer_init,
  1173. .dt_compat = eva_boards_compat_dt,
  1174. .restart = eva_restart,
  1175. MACHINE_END