board-armadillo800eva.c 31 KB

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