board-kzm9g.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. /*
  2. * KZM-A9-GT board support
  3. *
  4. * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include <linux/delay.h>
  20. #include <linux/gpio.h>
  21. #include <linux/gpio_keys.h>
  22. #include <linux/io.h>
  23. #include <linux/irq.h>
  24. #include <linux/i2c.h>
  25. #include <linux/i2c/pcf857x.h>
  26. #include <linux/input.h>
  27. #include <linux/mmc/host.h>
  28. #include <linux/mmc/sh_mmcif.h>
  29. #include <linux/mmc/sh_mobile_sdhi.h>
  30. #include <linux/mfd/tmio.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/smsc911x.h>
  33. #include <linux/usb/r8a66597.h>
  34. #include <linux/usb/renesas_usbhs.h>
  35. #include <linux/videodev2.h>
  36. #include <sound/sh_fsi.h>
  37. #include <sound/simple_card.h>
  38. #include <mach/irqs.h>
  39. #include <mach/sh73a0.h>
  40. #include <mach/common.h>
  41. #include <asm/hardware/cache-l2x0.h>
  42. #include <asm/hardware/gic.h>
  43. #include <asm/mach-types.h>
  44. #include <asm/mach/arch.h>
  45. #include <video/sh_mobile_lcdc.h>
  46. /*
  47. * external GPIO
  48. */
  49. #define GPIO_PCF8575_BASE (GPIO_NR)
  50. #define GPIO_PCF8575_PORT10 (GPIO_NR + 8)
  51. #define GPIO_PCF8575_PORT11 (GPIO_NR + 9)
  52. #define GPIO_PCF8575_PORT12 (GPIO_NR + 10)
  53. #define GPIO_PCF8575_PORT13 (GPIO_NR + 11)
  54. #define GPIO_PCF8575_PORT14 (GPIO_NR + 12)
  55. #define GPIO_PCF8575_PORT15 (GPIO_NR + 13)
  56. #define GPIO_PCF8575_PORT16 (GPIO_NR + 14)
  57. /*
  58. * FSI-AK4648
  59. *
  60. * this command is required when playback.
  61. *
  62. * # amixer set "LINEOUT Mixer DACL" on
  63. */
  64. /* SMSC 9221 */
  65. static struct resource smsc9221_resources[] = {
  66. [0] = {
  67. .start = 0x10000000, /* CS4 */
  68. .end = 0x100000ff,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. [1] = {
  72. .start = intcs_evt2irq(0x260), /* IRQ3 */
  73. .flags = IORESOURCE_IRQ,
  74. },
  75. };
  76. static struct smsc911x_platform_config smsc9221_platdata = {
  77. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  78. .phy_interface = PHY_INTERFACE_MODE_MII,
  79. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  80. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  81. };
  82. static struct platform_device smsc_device = {
  83. .name = "smsc911x",
  84. .dev = {
  85. .platform_data = &smsc9221_platdata,
  86. },
  87. .resource = smsc9221_resources,
  88. .num_resources = ARRAY_SIZE(smsc9221_resources),
  89. };
  90. /* USB external chip */
  91. static struct r8a66597_platdata usb_host_data = {
  92. .on_chip = 0,
  93. .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
  94. };
  95. static struct resource usb_resources[] = {
  96. [0] = {
  97. .start = 0x10010000,
  98. .end = 0x1001ffff - 1,
  99. .flags = IORESOURCE_MEM,
  100. },
  101. [1] = {
  102. .start = intcs_evt2irq(0x220), /* IRQ1 */
  103. .flags = IORESOURCE_IRQ,
  104. },
  105. };
  106. static struct platform_device usb_host_device = {
  107. .name = "r8a66597_hcd",
  108. .dev = {
  109. .platform_data = &usb_host_data,
  110. .dma_mask = NULL,
  111. .coherent_dma_mask = 0xffffffff,
  112. },
  113. .num_resources = ARRAY_SIZE(usb_resources),
  114. .resource = usb_resources,
  115. };
  116. /* USB Func CN17 */
  117. struct usbhs_private {
  118. unsigned int phy;
  119. unsigned int cr2;
  120. struct renesas_usbhs_platform_info info;
  121. };
  122. #define IRQ15 intcs_evt2irq(0x03e0)
  123. #define USB_PHY_MODE (1 << 4)
  124. #define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
  125. #define USB_PHY_ON (1 << 1)
  126. #define USB_PHY_OFF (1 << 0)
  127. #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
  128. #define usbhs_get_priv(pdev) \
  129. container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
  130. static int usbhs_get_vbus(struct platform_device *pdev)
  131. {
  132. struct usbhs_private *priv = usbhs_get_priv(pdev);
  133. return !((1 << 7) & __raw_readw(priv->cr2));
  134. }
  135. static void usbhs_phy_reset(struct platform_device *pdev)
  136. {
  137. struct usbhs_private *priv = usbhs_get_priv(pdev);
  138. /* init phy */
  139. __raw_writew(0x8a0a, priv->cr2);
  140. }
  141. static int usbhs_get_id(struct platform_device *pdev)
  142. {
  143. return USBHS_GADGET;
  144. }
  145. static irqreturn_t usbhs_interrupt(int irq, void *data)
  146. {
  147. struct platform_device *pdev = data;
  148. struct usbhs_private *priv = usbhs_get_priv(pdev);
  149. renesas_usbhs_call_notify_hotplug(pdev);
  150. /* clear status */
  151. __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy);
  152. return IRQ_HANDLED;
  153. }
  154. static int usbhs_hardware_init(struct platform_device *pdev)
  155. {
  156. struct usbhs_private *priv = usbhs_get_priv(pdev);
  157. int ret;
  158. /* clear interrupt status */
  159. __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
  160. ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH,
  161. dev_name(&pdev->dev), pdev);
  162. if (ret) {
  163. dev_err(&pdev->dev, "request_irq err\n");
  164. return ret;
  165. }
  166. /* enable USB phy interrupt */
  167. __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy);
  168. return 0;
  169. }
  170. static void usbhs_hardware_exit(struct platform_device *pdev)
  171. {
  172. struct usbhs_private *priv = usbhs_get_priv(pdev);
  173. /* clear interrupt status */
  174. __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
  175. free_irq(IRQ15, pdev);
  176. }
  177. static u32 usbhs_pipe_cfg[] = {
  178. USB_ENDPOINT_XFER_CONTROL,
  179. USB_ENDPOINT_XFER_ISOC,
  180. USB_ENDPOINT_XFER_ISOC,
  181. USB_ENDPOINT_XFER_BULK,
  182. USB_ENDPOINT_XFER_BULK,
  183. USB_ENDPOINT_XFER_BULK,
  184. USB_ENDPOINT_XFER_INT,
  185. USB_ENDPOINT_XFER_INT,
  186. USB_ENDPOINT_XFER_INT,
  187. USB_ENDPOINT_XFER_BULK,
  188. USB_ENDPOINT_XFER_BULK,
  189. USB_ENDPOINT_XFER_BULK,
  190. USB_ENDPOINT_XFER_BULK,
  191. USB_ENDPOINT_XFER_BULK,
  192. USB_ENDPOINT_XFER_BULK,
  193. USB_ENDPOINT_XFER_BULK,
  194. };
  195. static struct usbhs_private usbhs_private = {
  196. .phy = 0xe60781e0, /* USBPHYINT */
  197. .cr2 = 0xe605810c, /* USBCR2 */
  198. .info = {
  199. .platform_callback = {
  200. .hardware_init = usbhs_hardware_init,
  201. .hardware_exit = usbhs_hardware_exit,
  202. .get_id = usbhs_get_id,
  203. .phy_reset = usbhs_phy_reset,
  204. .get_vbus = usbhs_get_vbus,
  205. },
  206. .driver_param = {
  207. .buswait_bwait = 4,
  208. .has_otg = 1,
  209. .pipe_type = usbhs_pipe_cfg,
  210. .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
  211. },
  212. },
  213. };
  214. static struct resource usbhs_resources[] = {
  215. [0] = {
  216. .start = 0xE6890000,
  217. .end = 0xE68900e6 - 1,
  218. .flags = IORESOURCE_MEM,
  219. },
  220. [1] = {
  221. .start = gic_spi(62),
  222. .end = gic_spi(62),
  223. .flags = IORESOURCE_IRQ,
  224. },
  225. };
  226. static struct platform_device usbhs_device = {
  227. .name = "renesas_usbhs",
  228. .id = -1,
  229. .dev = {
  230. .dma_mask = NULL,
  231. .coherent_dma_mask = 0xffffffff,
  232. .platform_data = &usbhs_private.info,
  233. },
  234. .num_resources = ARRAY_SIZE(usbhs_resources),
  235. .resource = usbhs_resources,
  236. };
  237. /* LCDC */
  238. static struct fb_videomode kzm_lcdc_mode = {
  239. .name = "WVGA Panel",
  240. .xres = 800,
  241. .yres = 480,
  242. .left_margin = 220,
  243. .right_margin = 110,
  244. .hsync_len = 70,
  245. .upper_margin = 20,
  246. .lower_margin = 5,
  247. .vsync_len = 5,
  248. .sync = 0,
  249. };
  250. static struct sh_mobile_lcdc_info lcdc_info = {
  251. .clock_source = LCDC_CLK_BUS,
  252. .ch[0] = {
  253. .chan = LCDC_CHAN_MAINLCD,
  254. .fourcc = V4L2_PIX_FMT_RGB565,
  255. .interface_type = RGB24,
  256. .lcd_modes = &kzm_lcdc_mode,
  257. .num_modes = 1,
  258. .clock_divider = 5,
  259. .flags = 0,
  260. .panel_cfg = {
  261. .width = 152,
  262. .height = 91,
  263. },
  264. }
  265. };
  266. static struct resource lcdc_resources[] = {
  267. [0] = {
  268. .name = "LCDC",
  269. .start = 0xfe940000,
  270. .end = 0xfe943fff,
  271. .flags = IORESOURCE_MEM,
  272. },
  273. [1] = {
  274. .start = intcs_evt2irq(0x580),
  275. .flags = IORESOURCE_IRQ,
  276. },
  277. };
  278. static struct platform_device lcdc_device = {
  279. .name = "sh_mobile_lcdc_fb",
  280. .num_resources = ARRAY_SIZE(lcdc_resources),
  281. .resource = lcdc_resources,
  282. .dev = {
  283. .platform_data = &lcdc_info,
  284. .coherent_dma_mask = ~0,
  285. },
  286. };
  287. /* MMCIF */
  288. static struct resource sh_mmcif_resources[] = {
  289. [0] = {
  290. .name = "MMCIF",
  291. .start = 0xe6bd0000,
  292. .end = 0xe6bd00ff,
  293. .flags = IORESOURCE_MEM,
  294. },
  295. [1] = {
  296. .start = gic_spi(141),
  297. .flags = IORESOURCE_IRQ,
  298. },
  299. [2] = {
  300. .start = gic_spi(140),
  301. .flags = IORESOURCE_IRQ,
  302. },
  303. };
  304. static struct sh_mmcif_plat_data sh_mmcif_platdata = {
  305. .ocr = MMC_VDD_165_195,
  306. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  307. };
  308. static struct platform_device mmc_device = {
  309. .name = "sh_mmcif",
  310. .dev = {
  311. .dma_mask = NULL,
  312. .coherent_dma_mask = 0xffffffff,
  313. .platform_data = &sh_mmcif_platdata,
  314. },
  315. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  316. .resource = sh_mmcif_resources,
  317. };
  318. /* SDHI */
  319. static struct sh_mobile_sdhi_info sdhi0_info = {
  320. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  321. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  322. .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
  323. };
  324. static struct resource sdhi0_resources[] = {
  325. [0] = {
  326. .name = "SDHI0",
  327. .start = 0xee100000,
  328. .end = 0xee1000ff,
  329. .flags = IORESOURCE_MEM,
  330. },
  331. [1] = {
  332. .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
  333. .start = gic_spi(83),
  334. .flags = IORESOURCE_IRQ,
  335. },
  336. [2] = {
  337. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  338. .start = gic_spi(84),
  339. .flags = IORESOURCE_IRQ,
  340. },
  341. [3] = {
  342. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  343. .start = gic_spi(85),
  344. .flags = IORESOURCE_IRQ,
  345. },
  346. };
  347. static struct platform_device sdhi0_device = {
  348. .name = "sh_mobile_sdhi",
  349. .num_resources = ARRAY_SIZE(sdhi0_resources),
  350. .resource = sdhi0_resources,
  351. .dev = {
  352. .platform_data = &sdhi0_info,
  353. },
  354. };
  355. /* KEY */
  356. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  357. static struct gpio_keys_button gpio_buttons[] = {
  358. GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
  359. GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
  360. GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
  361. GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
  362. GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
  363. GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
  364. GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
  365. };
  366. static struct gpio_keys_platform_data gpio_key_info = {
  367. .buttons = gpio_buttons,
  368. .nbuttons = ARRAY_SIZE(gpio_buttons),
  369. .poll_interval = 250, /* poling at this point */
  370. };
  371. static struct platform_device gpio_keys_device = {
  372. /* gpio-pcf857x.c driver doesn't support gpio_to_irq() */
  373. .name = "gpio-keys-polled",
  374. .dev = {
  375. .platform_data = &gpio_key_info,
  376. },
  377. };
  378. /* FSI-AK4648 */
  379. static struct sh_fsi_platform_info fsi_info = {
  380. .port_a = {
  381. },
  382. };
  383. static struct resource fsi_resources[] = {
  384. [0] = {
  385. .name = "FSI",
  386. .start = 0xEC230000,
  387. .end = 0xEC230400 - 1,
  388. .flags = IORESOURCE_MEM,
  389. },
  390. [1] = {
  391. .start = gic_spi(146),
  392. .flags = IORESOURCE_IRQ,
  393. },
  394. };
  395. static struct platform_device fsi_device = {
  396. .name = "sh_fsi2",
  397. .id = -1,
  398. .num_resources = ARRAY_SIZE(fsi_resources),
  399. .resource = fsi_resources,
  400. .dev = {
  401. .platform_data = &fsi_info,
  402. },
  403. };
  404. static struct asoc_simple_dai_init_info fsi2_ak4648_init_info = {
  405. .fmt = SND_SOC_DAIFMT_LEFT_J,
  406. .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM,
  407. .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS,
  408. .sysclk = 11289600,
  409. };
  410. static struct asoc_simple_card_info fsi2_ak4648_info = {
  411. .name = "AK4648",
  412. .card = "FSI2A-AK4648",
  413. .cpu_dai = "fsia-dai",
  414. .codec = "ak4642-codec.0-0012",
  415. .platform = "sh_fsi2",
  416. .codec_dai = "ak4642-hifi",
  417. .init = &fsi2_ak4648_init_info,
  418. };
  419. static struct platform_device fsi_ak4648_device = {
  420. .name = "asoc-simple-card",
  421. .dev = {
  422. .platform_data = &fsi2_ak4648_info,
  423. },
  424. };
  425. /* I2C */
  426. static struct pcf857x_platform_data pcf8575_pdata = {
  427. .gpio_base = GPIO_PCF8575_BASE,
  428. };
  429. static struct i2c_board_info i2c0_devices[] = {
  430. {
  431. I2C_BOARD_INFO("ak4648", 0x12),
  432. },
  433. {
  434. I2C_BOARD_INFO("r2025sd", 0x32),
  435. }
  436. };
  437. static struct i2c_board_info i2c1_devices[] = {
  438. {
  439. I2C_BOARD_INFO("st1232-ts", 0x55),
  440. .irq = intcs_evt2irq(0x300), /* IRQ8 */
  441. },
  442. };
  443. static struct i2c_board_info i2c3_devices[] = {
  444. {
  445. I2C_BOARD_INFO("pcf8575", 0x20),
  446. .platform_data = &pcf8575_pdata,
  447. },
  448. };
  449. static struct platform_device *kzm_devices[] __initdata = {
  450. &smsc_device,
  451. &usb_host_device,
  452. &usbhs_device,
  453. &lcdc_device,
  454. &mmc_device,
  455. &sdhi0_device,
  456. &gpio_keys_device,
  457. &fsi_device,
  458. &fsi_ak4648_device,
  459. };
  460. /*
  461. * FIXME
  462. *
  463. * This is quick hack for enabling LCDC backlight
  464. */
  465. static int __init as3711_enable_lcdc_backlight(void)
  466. {
  467. struct i2c_adapter *a = i2c_get_adapter(0);
  468. struct i2c_msg msg;
  469. int i, ret;
  470. __u8 magic[] = {
  471. 0x40, 0x2a,
  472. 0x43, 0x3c,
  473. 0x44, 0x3c,
  474. 0x45, 0x3c,
  475. 0x54, 0x03,
  476. 0x51, 0x00,
  477. 0x51, 0x01,
  478. 0xff, 0x00, /* wait */
  479. 0x43, 0xf0,
  480. 0x44, 0xf0,
  481. 0x45, 0xf0,
  482. };
  483. if (!machine_is_kzm9g())
  484. return 0;
  485. if (!a)
  486. return 0;
  487. msg.addr = 0x40;
  488. msg.len = 2;
  489. msg.flags = 0;
  490. for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
  491. msg.buf = magic + i;
  492. if (0xff == msg.buf[0]) {
  493. udelay(500);
  494. continue;
  495. }
  496. ret = i2c_transfer(a, &msg, 1);
  497. if (ret < 0) {
  498. pr_err("i2c transfer fail\n");
  499. break;
  500. }
  501. }
  502. return 0;
  503. }
  504. device_initcall(as3711_enable_lcdc_backlight);
  505. static void __init kzm_init(void)
  506. {
  507. sh73a0_pinmux_init();
  508. /* enable SCIFA4 */
  509. gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
  510. gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
  511. gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
  512. gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
  513. /* CS4 for SMSC/USB */
  514. gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
  515. /* SMSC */
  516. gpio_request(GPIO_PORT224, NULL); /* IRQ3 */
  517. gpio_direction_input(GPIO_PORT224);
  518. /* LCDC */
  519. gpio_request(GPIO_FN_LCDD23, NULL);
  520. gpio_request(GPIO_FN_LCDD22, NULL);
  521. gpio_request(GPIO_FN_LCDD21, NULL);
  522. gpio_request(GPIO_FN_LCDD20, NULL);
  523. gpio_request(GPIO_FN_LCDD19, NULL);
  524. gpio_request(GPIO_FN_LCDD18, NULL);
  525. gpio_request(GPIO_FN_LCDD17, NULL);
  526. gpio_request(GPIO_FN_LCDD16, NULL);
  527. gpio_request(GPIO_FN_LCDD15, NULL);
  528. gpio_request(GPIO_FN_LCDD14, NULL);
  529. gpio_request(GPIO_FN_LCDD13, NULL);
  530. gpio_request(GPIO_FN_LCDD12, NULL);
  531. gpio_request(GPIO_FN_LCDD11, NULL);
  532. gpio_request(GPIO_FN_LCDD10, NULL);
  533. gpio_request(GPIO_FN_LCDD9, NULL);
  534. gpio_request(GPIO_FN_LCDD8, NULL);
  535. gpio_request(GPIO_FN_LCDD7, NULL);
  536. gpio_request(GPIO_FN_LCDD6, NULL);
  537. gpio_request(GPIO_FN_LCDD5, NULL);
  538. gpio_request(GPIO_FN_LCDD4, NULL);
  539. gpio_request(GPIO_FN_LCDD3, NULL);
  540. gpio_request(GPIO_FN_LCDD2, NULL);
  541. gpio_request(GPIO_FN_LCDD1, NULL);
  542. gpio_request(GPIO_FN_LCDD0, NULL);
  543. gpio_request(GPIO_FN_LCDDISP, NULL);
  544. gpio_request(GPIO_FN_LCDDCK, NULL);
  545. gpio_request(GPIO_PORT222, NULL); /* LCDCDON */
  546. gpio_request(GPIO_PORT226, NULL); /* SC */
  547. gpio_direction_output(GPIO_PORT222, 1);
  548. gpio_direction_output(GPIO_PORT226, 1);
  549. /* Touchscreen */
  550. gpio_request(GPIO_PORT223, NULL); /* IRQ8 */
  551. gpio_direction_input(GPIO_PORT223);
  552. /* enable MMCIF */
  553. gpio_request(GPIO_FN_MMCCLK0, NULL);
  554. gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
  555. gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
  556. gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
  557. gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
  558. gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
  559. gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
  560. gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
  561. gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
  562. gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
  563. /* enable SD */
  564. gpio_request(GPIO_FN_SDHIWP0, NULL);
  565. gpio_request(GPIO_FN_SDHICD0, NULL);
  566. gpio_request(GPIO_FN_SDHICMD0, NULL);
  567. gpio_request(GPIO_FN_SDHICLK0, NULL);
  568. gpio_request(GPIO_FN_SDHID0_3, NULL);
  569. gpio_request(GPIO_FN_SDHID0_2, NULL);
  570. gpio_request(GPIO_FN_SDHID0_1, NULL);
  571. gpio_request(GPIO_FN_SDHID0_0, NULL);
  572. gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL);
  573. gpio_request(GPIO_PORT15, NULL);
  574. gpio_direction_output(GPIO_PORT15, 1); /* power */
  575. /* I2C 3 */
  576. gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
  577. gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
  578. /* enable FSI2 port A (ak4648) */
  579. gpio_request(GPIO_FN_FSIACK, NULL);
  580. gpio_request(GPIO_FN_FSIAILR, NULL);
  581. gpio_request(GPIO_FN_FSIAIBT, NULL);
  582. gpio_request(GPIO_FN_FSIAISLD, NULL);
  583. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  584. /* enable USB */
  585. gpio_request(GPIO_FN_VBUS_0, NULL);
  586. #ifdef CONFIG_CACHE_L2X0
  587. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  588. l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
  589. #endif
  590. i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
  591. i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
  592. i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
  593. sh73a0_add_standard_devices();
  594. platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
  595. }
  596. static const char *kzm9g_boards_compat_dt[] __initdata = {
  597. "renesas,kzm9g",
  598. NULL,
  599. };
  600. DT_MACHINE_START(KZM9G_DT, "kzm9g")
  601. .map_io = sh73a0_map_io,
  602. .init_early = sh73a0_add_early_devices,
  603. .nr_irqs = NR_IRQS_LEGACY,
  604. .init_irq = sh73a0_init_irq,
  605. .handle_irq = gic_handle_irq,
  606. .init_machine = kzm_init,
  607. .timer = &shmobile_timer,
  608. .dt_compat = kzm9g_boards_compat_dt,
  609. MACHINE_END