board-armadillo800eva.c 30 KB

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