board-armadillo800eva.c 32 KB

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