board-armadillo800eva.c 32 KB

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