board-armadillo800eva.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  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. /*
  610. * FIXME
  611. *
  612. * It use polling mode here, since
  613. * CD (= Card Detect) pin is not connected to SDHI0_CD.
  614. * We can use IRQ31 as card detect irq,
  615. * but it needs chattering removal operation
  616. */
  617. #define IRQ31 irq_pin(31)
  618. static struct sh_mobile_sdhi_info sdhi0_info = {
  619. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  620. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  621. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  622. MMC_CAP_POWER_OFF_CARD,
  623. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_USE_GPIO_CD,
  624. .cd_gpio = 167,
  625. };
  626. static struct resource sdhi0_resources[] = {
  627. {
  628. .name = "SDHI0",
  629. .start = 0xe6850000,
  630. .end = 0xe6850100 - 1,
  631. .flags = IORESOURCE_MEM,
  632. },
  633. /*
  634. * no SH_MOBILE_SDHI_IRQ_CARD_DETECT here
  635. */
  636. {
  637. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  638. .start = gic_spi(118),
  639. .flags = IORESOURCE_IRQ,
  640. },
  641. {
  642. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  643. .start = gic_spi(119),
  644. .flags = IORESOURCE_IRQ,
  645. },
  646. };
  647. static struct platform_device sdhi0_device = {
  648. .name = "sh_mobile_sdhi",
  649. .id = 0,
  650. .dev = {
  651. .platform_data = &sdhi0_info,
  652. },
  653. .num_resources = ARRAY_SIZE(sdhi0_resources),
  654. .resource = sdhi0_resources,
  655. };
  656. /* SDHI1 */
  657. static struct sh_mobile_sdhi_info sdhi1_info = {
  658. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  659. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  660. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  661. MMC_CAP_POWER_OFF_CARD,
  662. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_USE_GPIO_CD,
  663. /* Port72 cannot generate IRQs, will be used in polling mode. */
  664. .cd_gpio = 72,
  665. };
  666. static struct resource sdhi1_resources[] = {
  667. [0] = {
  668. .name = "SDHI1",
  669. .start = 0xe6860000,
  670. .end = 0xe6860100 - 1,
  671. .flags = IORESOURCE_MEM,
  672. },
  673. [1] = {
  674. .start = gic_spi(121),
  675. .flags = IORESOURCE_IRQ,
  676. },
  677. [2] = {
  678. .start = gic_spi(122),
  679. .flags = IORESOURCE_IRQ,
  680. },
  681. [3] = {
  682. .start = gic_spi(123),
  683. .flags = IORESOURCE_IRQ,
  684. },
  685. };
  686. static struct platform_device sdhi1_device = {
  687. .name = "sh_mobile_sdhi",
  688. .id = 1,
  689. .dev = {
  690. .platform_data = &sdhi1_info,
  691. },
  692. .num_resources = ARRAY_SIZE(sdhi1_resources),
  693. .resource = sdhi1_resources,
  694. };
  695. static const struct pinctrl_map eva_sdhi1_pinctrl_map[] = {
  696. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  697. "sdhi1_data4", "sdhi1"),
  698. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  699. "sdhi1_ctrl", "sdhi1"),
  700. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  701. "sdhi1_cd", "sdhi1"),
  702. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7740",
  703. "sdhi1_wp", "sdhi1"),
  704. };
  705. /* MMCIF */
  706. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  707. .sup_pclk = 0,
  708. .caps = MMC_CAP_4_BIT_DATA |
  709. MMC_CAP_8_BIT_DATA |
  710. MMC_CAP_NONREMOVABLE,
  711. };
  712. static struct resource sh_mmcif_resources[] = {
  713. [0] = {
  714. .name = "MMCIF",
  715. .start = 0xe6bd0000,
  716. .end = 0xe6bd0100 - 1,
  717. .flags = IORESOURCE_MEM,
  718. },
  719. [1] = {
  720. /* MMC ERR */
  721. .start = gic_spi(56),
  722. .flags = IORESOURCE_IRQ,
  723. },
  724. [2] = {
  725. /* MMC NOR */
  726. .start = gic_spi(57),
  727. .flags = IORESOURCE_IRQ,
  728. },
  729. };
  730. static struct platform_device sh_mmcif_device = {
  731. .name = "sh_mmcif",
  732. .id = -1,
  733. .dev = {
  734. .platform_data = &sh_mmcif_plat,
  735. },
  736. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  737. .resource = sh_mmcif_resources,
  738. };
  739. /* Camera */
  740. static int mt9t111_power(struct device *dev, int mode)
  741. {
  742. struct clk *mclk = clk_get(NULL, "video1");
  743. if (IS_ERR(mclk)) {
  744. dev_err(dev, "can't get video1 clock\n");
  745. return -EINVAL;
  746. }
  747. if (mode) {
  748. /* video1 (= CON1 camera) expect 24MHz */
  749. clk_set_rate(mclk, clk_round_rate(mclk, 24000000));
  750. clk_enable(mclk);
  751. gpio_set_value(158, 1);
  752. } else {
  753. gpio_set_value(158, 0);
  754. clk_disable(mclk);
  755. }
  756. clk_put(mclk);
  757. return 0;
  758. }
  759. static struct i2c_board_info i2c_camera_mt9t111 = {
  760. I2C_BOARD_INFO("mt9t112", 0x3d),
  761. };
  762. static struct mt9t112_camera_info mt9t111_info = {
  763. .divider = { 16, 0, 0, 7, 0, 10, 14, 7, 7 },
  764. };
  765. static struct soc_camera_link mt9t111_link = {
  766. .i2c_adapter_id = 0,
  767. .bus_id = 0,
  768. .board_info = &i2c_camera_mt9t111,
  769. .power = mt9t111_power,
  770. .priv = &mt9t111_info,
  771. };
  772. static struct platform_device camera_device = {
  773. .name = "soc-camera-pdrv",
  774. .id = 0,
  775. .dev = {
  776. .platform_data = &mt9t111_link,
  777. },
  778. };
  779. /* CEU0 */
  780. static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
  781. .flags = SH_CEU_FLAG_LOWER_8BIT,
  782. };
  783. static struct resource ceu0_resources[] = {
  784. [0] = {
  785. .name = "CEU",
  786. .start = 0xfe910000,
  787. .end = 0xfe91009f,
  788. .flags = IORESOURCE_MEM,
  789. },
  790. [1] = {
  791. .start = gic_spi(160),
  792. .flags = IORESOURCE_IRQ,
  793. },
  794. [2] = {
  795. /* place holder for contiguous memory */
  796. },
  797. };
  798. static struct platform_device ceu0_device = {
  799. .name = "sh_mobile_ceu",
  800. .id = 0,
  801. .num_resources = ARRAY_SIZE(ceu0_resources),
  802. .resource = ceu0_resources,
  803. .dev = {
  804. .platform_data = &sh_mobile_ceu0_info,
  805. .coherent_dma_mask = 0xffffffff,
  806. },
  807. };
  808. /* FSI */
  809. static struct sh_fsi_platform_info fsi_info = {
  810. /* FSI-WM8978 */
  811. .port_a = {
  812. .tx_id = SHDMA_SLAVE_FSIA_TX,
  813. },
  814. /* FSI-HDMI */
  815. .port_b = {
  816. .flags = SH_FSI_FMT_SPDIF |
  817. SH_FSI_ENABLE_STREAM_MODE |
  818. SH_FSI_CLK_CPG,
  819. .tx_id = SHDMA_SLAVE_FSIB_TX,
  820. }
  821. };
  822. static struct resource fsi_resources[] = {
  823. [0] = {
  824. .name = "FSI",
  825. .start = 0xfe1f0000,
  826. .end = 0xfe1f8400 - 1,
  827. .flags = IORESOURCE_MEM,
  828. },
  829. [1] = {
  830. .start = gic_spi(9),
  831. .flags = IORESOURCE_IRQ,
  832. },
  833. };
  834. static struct platform_device fsi_device = {
  835. .name = "sh_fsi2",
  836. .id = -1,
  837. .num_resources = ARRAY_SIZE(fsi_resources),
  838. .resource = fsi_resources,
  839. .dev = {
  840. .platform_data = &fsi_info,
  841. },
  842. };
  843. /* FSI-WM8978 */
  844. static struct asoc_simple_card_info fsi_wm8978_info = {
  845. .name = "wm8978",
  846. .card = "FSI2A-WM8978",
  847. .codec = "wm8978.0-001a",
  848. .platform = "sh_fsi2",
  849. .daifmt = SND_SOC_DAIFMT_I2S,
  850. .cpu_dai = {
  851. .name = "fsia-dai",
  852. .fmt = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_IB_NF,
  853. },
  854. .codec_dai = {
  855. .name = "wm8978-hifi",
  856. .fmt = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_NB_NF,
  857. .sysclk = 12288000,
  858. },
  859. };
  860. static struct platform_device fsi_wm8978_device = {
  861. .name = "asoc-simple-card",
  862. .id = 0,
  863. .dev = {
  864. .platform_data = &fsi_wm8978_info,
  865. },
  866. };
  867. /* FSI-HDMI */
  868. static struct asoc_simple_card_info fsi2_hdmi_info = {
  869. .name = "HDMI",
  870. .card = "FSI2B-HDMI",
  871. .codec = "sh-mobile-hdmi",
  872. .platform = "sh_fsi2",
  873. .cpu_dai = {
  874. .name = "fsib-dai",
  875. .fmt = SND_SOC_DAIFMT_CBM_CFM,
  876. },
  877. .codec_dai = {
  878. .name = "sh_mobile_hdmi-hifi",
  879. },
  880. };
  881. static struct platform_device fsi_hdmi_device = {
  882. .name = "asoc-simple-card",
  883. .id = 1,
  884. .dev = {
  885. .platform_data = &fsi2_hdmi_info,
  886. },
  887. };
  888. /* RTC: RTC connects i2c-gpio. */
  889. static struct i2c_gpio_platform_data i2c_gpio_data = {
  890. .sda_pin = 208,
  891. .scl_pin = 91,
  892. .udelay = 5, /* 100 kHz */
  893. };
  894. static struct platform_device i2c_gpio_device = {
  895. .name = "i2c-gpio",
  896. .id = 2,
  897. .dev = {
  898. .platform_data = &i2c_gpio_data,
  899. },
  900. };
  901. /* I2C */
  902. static struct st1232_pdata st1232_i2c0_pdata = {
  903. .reset_gpio = 166,
  904. };
  905. static struct i2c_board_info i2c0_devices[] = {
  906. {
  907. I2C_BOARD_INFO("st1232-ts", 0x55),
  908. .irq = irq_pin(10),
  909. .platform_data = &st1232_i2c0_pdata,
  910. },
  911. {
  912. I2C_BOARD_INFO("wm8978", 0x1a),
  913. },
  914. };
  915. static struct i2c_board_info i2c2_devices[] = {
  916. {
  917. I2C_BOARD_INFO("s35390a", 0x30),
  918. .type = "s35390a",
  919. },
  920. };
  921. /*
  922. * board devices
  923. */
  924. static struct platform_device *eva_devices[] __initdata = {
  925. &lcdc0_device,
  926. &gpio_keys_device,
  927. &sh_eth_device,
  928. &vcc_sdhi0,
  929. &vccq_sdhi0,
  930. &sdhi0_device,
  931. &sh_mmcif_device,
  932. &hdmi_device,
  933. &hdmi_lcdc_device,
  934. &camera_device,
  935. &ceu0_device,
  936. &fsi_device,
  937. &fsi_wm8978_device,
  938. &fsi_hdmi_device,
  939. &i2c_gpio_device,
  940. };
  941. static const struct pinctrl_map eva_pinctrl_map[] = {
  942. /* CEU0 */
  943. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-r8a7740",
  944. "ceu0_data_0_7", "ceu0"),
  945. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-r8a7740",
  946. "ceu0_clk_0", "ceu0"),
  947. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-r8a7740",
  948. "ceu0_sync", "ceu0"),
  949. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-r8a7740",
  950. "ceu0_field", "ceu0"),
  951. /* FSIA */
  952. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-r8a7740",
  953. "fsia_sclk_in", "fsia"),
  954. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-r8a7740",
  955. "fsia_mclk_out", "fsia"),
  956. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-r8a7740",
  957. "fsia_data_in_1", "fsia"),
  958. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-r8a7740",
  959. "fsia_data_out_0", "fsia"),
  960. /* FSIB */
  961. PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.1", "pfc-r8a7740",
  962. "fsib_mclk_in", "fsib"),
  963. /* GETHER */
  964. PIN_MAP_MUX_GROUP_DEFAULT("sh-eth", "pfc-r8a7740",
  965. "gether_mii", "gether"),
  966. PIN_MAP_MUX_GROUP_DEFAULT("sh-eth", "pfc-r8a7740",
  967. "gether_int", "gether"),
  968. /* HDMI */
  969. PIN_MAP_MUX_GROUP_DEFAULT("sh-mobile-hdmi", "pfc-r8a7740",
  970. "hdmi", "hdmi"),
  971. /* LCD0 */
  972. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
  973. "lcd0_data24_0", "lcd0"),
  974. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
  975. "lcd0_lclk_1", "lcd0"),
  976. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
  977. "lcd0_sync", "lcd0"),
  978. /* MMCIF */
  979. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a7740",
  980. "mmc0_data8_1", "mmc0"),
  981. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a7740",
  982. "mmc0_ctrl_1", "mmc0"),
  983. /* SCIFA1 */
  984. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.1", "pfc-r8a7740",
  985. "scifa1_data", "scifa1"),
  986. /* SDHI0 */
  987. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7740",
  988. "sdhi0_data4", "sdhi0"),
  989. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7740",
  990. "sdhi0_ctrl", "sdhi0"),
  991. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7740",
  992. "sdhi0_wp", "sdhi0"),
  993. /* ST1232 */
  994. PIN_MAP_MUX_GROUP_DEFAULT("0-0055", "pfc-r8a7740",
  995. "intc_irq10", "intc"),
  996. /* USBHS */
  997. PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7740",
  998. "intc_irq7_1", "intc"),
  999. };
  1000. static void __init eva_clock_init(void)
  1001. {
  1002. struct clk *system = clk_get(NULL, "system_clk");
  1003. struct clk *xtal1 = clk_get(NULL, "extal1");
  1004. struct clk *usb24s = clk_get(NULL, "usb24s");
  1005. struct clk *fsibck = clk_get(NULL, "fsibck");
  1006. if (IS_ERR(system) ||
  1007. IS_ERR(xtal1) ||
  1008. IS_ERR(usb24s) ||
  1009. IS_ERR(fsibck)) {
  1010. pr_err("armadillo800eva board clock init failed\n");
  1011. goto clock_error;
  1012. }
  1013. /* armadillo 800 eva extal1 is 24MHz */
  1014. clk_set_rate(xtal1, 24000000);
  1015. /* usb24s use extal1 (= system) clock (= 24MHz) */
  1016. clk_set_parent(usb24s, system);
  1017. /* FSIBCK is 12.288MHz, and it is parent of FSI-B */
  1018. clk_set_rate(fsibck, 12288000);
  1019. clock_error:
  1020. if (!IS_ERR(system))
  1021. clk_put(system);
  1022. if (!IS_ERR(xtal1))
  1023. clk_put(xtal1);
  1024. if (!IS_ERR(usb24s))
  1025. clk_put(usb24s);
  1026. if (!IS_ERR(fsibck))
  1027. clk_put(fsibck);
  1028. }
  1029. /*
  1030. * board init
  1031. */
  1032. #define GPIO_PORT7CR IOMEM(0xe6050007)
  1033. #define GPIO_PORT8CR IOMEM(0xe6050008)
  1034. static void __init eva_init(void)
  1035. {
  1036. struct platform_device *usb = NULL;
  1037. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  1038. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  1039. pinctrl_register_mappings(eva_pinctrl_map, ARRAY_SIZE(eva_pinctrl_map));
  1040. r8a7740_pinmux_init();
  1041. r8a7740_meram_workaround();
  1042. /* LCDC0 */
  1043. gpio_request_one(61, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
  1044. gpio_request_one(202, GPIOF_OUT_INIT_LOW, NULL); /* LCD0_LED_CONT */
  1045. /* Touchscreen */
  1046. gpio_request_one(166, GPIOF_OUT_INIT_HIGH, NULL); /* TP_RST_B */
  1047. /* GETHER */
  1048. gpio_request_one(18, GPIOF_OUT_INIT_HIGH, NULL); /* PHY_RST */
  1049. /* USB */
  1050. gpio_request_one(159, GPIOF_IN, NULL); /* USB_DEVICE_MODE */
  1051. if (gpio_get_value(159)) {
  1052. /* USB Host */
  1053. } else {
  1054. /* USB Func */
  1055. /*
  1056. * The USBHS interrupt handlers needs to read the IRQ pin value
  1057. * (HI/LOW) to diffentiate USB connection and disconnection
  1058. * events (usbhsf_get_vbus()). We thus need to select both the
  1059. * intc_irq7_1 pin group and GPIO 209 here.
  1060. */
  1061. gpio_request_one(209, GPIOF_IN, NULL);
  1062. platform_device_register(&usbhsf_device);
  1063. usb = &usbhsf_device;
  1064. }
  1065. /* CON1/CON15 Camera */
  1066. gpio_request_one(173, GPIOF_OUT_INIT_LOW, NULL); /* STANDBY */
  1067. gpio_request_one(172, GPIOF_OUT_INIT_HIGH, NULL); /* RST */
  1068. /* see mt9t111_power() */
  1069. gpio_request_one(158, GPIOF_OUT_INIT_LOW, NULL); /* CAM_PON */
  1070. /* FSI-WM8978 */
  1071. gpio_request(7, NULL);
  1072. gpio_request(8, NULL);
  1073. gpio_direction_none(GPIO_PORT7CR); /* FSIAOBT needs no direction */
  1074. gpio_direction_none(GPIO_PORT8CR); /* FSIAOLR needs no direction */
  1075. /*
  1076. * CAUTION
  1077. *
  1078. * DBGMD/LCDC0/FSIA MUX
  1079. * DBGMD_SELECT_B should be set after setting PFC Function.
  1080. */
  1081. gpio_request_one(176, GPIOF_OUT_INIT_HIGH, NULL);
  1082. /*
  1083. * We can switch CON8/CON14 by SW1.5,
  1084. * but it needs after DBGMD_SELECT_B
  1085. */
  1086. gpio_request_one(6, GPIOF_IN, NULL);
  1087. if (gpio_get_value(6)) {
  1088. /* CON14 enable */
  1089. } else {
  1090. /* CON8 (SDHI1) enable */
  1091. pinctrl_register_mappings(eva_sdhi1_pinctrl_map,
  1092. ARRAY_SIZE(eva_sdhi1_pinctrl_map));
  1093. platform_device_register(&vcc_sdhi1);
  1094. platform_device_register(&sdhi1_device);
  1095. }
  1096. #ifdef CONFIG_CACHE_L2X0
  1097. /* Early BRESP enable, Shared attribute override enable, 32K*8way */
  1098. l2x0_init(IOMEM(0xf0002000), 0x40440000, 0x82000fff);
  1099. #endif
  1100. i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
  1101. i2c_register_board_info(2, i2c2_devices, ARRAY_SIZE(i2c2_devices));
  1102. r8a7740_add_standard_devices();
  1103. platform_add_devices(eva_devices,
  1104. ARRAY_SIZE(eva_devices));
  1105. rmobile_add_device_to_domain("A4LC", &lcdc0_device);
  1106. rmobile_add_device_to_domain("A4LC", &hdmi_lcdc_device);
  1107. if (usb)
  1108. rmobile_add_device_to_domain("A3SP", usb);
  1109. r8a7740_pm_init();
  1110. }
  1111. static void __init eva_earlytimer_init(void)
  1112. {
  1113. r8a7740_clock_init(MD_CK0 | MD_CK2);
  1114. shmobile_earlytimer_init();
  1115. /* the rate of extal1 clock must be set before late_time_init */
  1116. eva_clock_init();
  1117. }
  1118. static void __init eva_add_early_devices(void)
  1119. {
  1120. r8a7740_add_early_devices();
  1121. }
  1122. #define RESCNT2 IOMEM(0xe6188020)
  1123. static void eva_restart(enum reboot_mode mode, const char *cmd)
  1124. {
  1125. /* Do soft power on reset */
  1126. writel((1 << 31), RESCNT2);
  1127. }
  1128. static const char *eva_boards_compat_dt[] __initdata = {
  1129. "renesas,armadillo800eva",
  1130. NULL,
  1131. };
  1132. DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva")
  1133. .map_io = r8a7740_map_io,
  1134. .init_early = eva_add_early_devices,
  1135. .init_irq = r8a7740_init_irq,
  1136. .init_machine = eva_init,
  1137. .init_late = shmobile_init_late,
  1138. .init_time = eva_earlytimer_init,
  1139. .dt_compat = eva_boards_compat_dt,
  1140. .restart = eva_restart,
  1141. MACHINE_END