board-kzm9g.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  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/irqchip/arm-gic.h>
  28. #include <linux/mmc/host.h>
  29. #include <linux/mmc/sh_mmcif.h>
  30. #include <linux/mmc/sh_mobile_sdhi.h>
  31. #include <linux/mfd/tmio.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/regulator/fixed.h>
  34. #include <linux/regulator/machine.h>
  35. #include <linux/smsc911x.h>
  36. #include <linux/usb/r8a66597.h>
  37. #include <linux/usb/renesas_usbhs.h>
  38. #include <linux/videodev2.h>
  39. #include <sound/sh_fsi.h>
  40. #include <sound/simple_card.h>
  41. #include <mach/irqs.h>
  42. #include <mach/sh73a0.h>
  43. #include <mach/common.h>
  44. #include <asm/hardware/cache-l2x0.h>
  45. #include <asm/mach-types.h>
  46. #include <asm/mach/arch.h>
  47. #include <video/sh_mobile_lcdc.h>
  48. /*
  49. * external GPIO
  50. */
  51. #define GPIO_PCF8575_BASE (GPIO_NR)
  52. #define GPIO_PCF8575_PORT10 (GPIO_NR + 8)
  53. #define GPIO_PCF8575_PORT11 (GPIO_NR + 9)
  54. #define GPIO_PCF8575_PORT12 (GPIO_NR + 10)
  55. #define GPIO_PCF8575_PORT13 (GPIO_NR + 11)
  56. #define GPIO_PCF8575_PORT14 (GPIO_NR + 12)
  57. #define GPIO_PCF8575_PORT15 (GPIO_NR + 13)
  58. #define GPIO_PCF8575_PORT16 (GPIO_NR + 14)
  59. /* Dummy supplies, where voltage doesn't matter */
  60. static struct regulator_consumer_supply dummy_supplies[] = {
  61. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  62. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  63. };
  64. /*
  65. * FSI-AK4648
  66. *
  67. * this command is required when playback.
  68. *
  69. * # amixer set "LINEOUT Mixer DACL" on
  70. */
  71. /* SMSC 9221 */
  72. static struct resource smsc9221_resources[] = {
  73. [0] = {
  74. .start = 0x10000000, /* CS4 */
  75. .end = 0x100000ff,
  76. .flags = IORESOURCE_MEM,
  77. },
  78. [1] = {
  79. .start = intcs_evt2irq(0x260), /* IRQ3 */
  80. .flags = IORESOURCE_IRQ,
  81. },
  82. };
  83. static struct smsc911x_platform_config smsc9221_platdata = {
  84. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  85. .phy_interface = PHY_INTERFACE_MODE_MII,
  86. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  87. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  88. };
  89. static struct platform_device smsc_device = {
  90. .name = "smsc911x",
  91. .dev = {
  92. .platform_data = &smsc9221_platdata,
  93. },
  94. .resource = smsc9221_resources,
  95. .num_resources = ARRAY_SIZE(smsc9221_resources),
  96. };
  97. /* USB external chip */
  98. static struct r8a66597_platdata usb_host_data = {
  99. .on_chip = 0,
  100. .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
  101. };
  102. static struct resource usb_resources[] = {
  103. [0] = {
  104. .start = 0x10010000,
  105. .end = 0x1001ffff - 1,
  106. .flags = IORESOURCE_MEM,
  107. },
  108. [1] = {
  109. .start = intcs_evt2irq(0x220), /* IRQ1 */
  110. .flags = IORESOURCE_IRQ,
  111. },
  112. };
  113. static struct platform_device usb_host_device = {
  114. .name = "r8a66597_hcd",
  115. .dev = {
  116. .platform_data = &usb_host_data,
  117. .dma_mask = NULL,
  118. .coherent_dma_mask = 0xffffffff,
  119. },
  120. .num_resources = ARRAY_SIZE(usb_resources),
  121. .resource = usb_resources,
  122. };
  123. /* USB Func CN17 */
  124. struct usbhs_private {
  125. void __iomem *phy;
  126. void __iomem *cr2;
  127. struct renesas_usbhs_platform_info info;
  128. };
  129. #define IRQ15 intcs_evt2irq(0x03e0)
  130. #define USB_PHY_MODE (1 << 4)
  131. #define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
  132. #define USB_PHY_ON (1 << 1)
  133. #define USB_PHY_OFF (1 << 0)
  134. #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
  135. #define usbhs_get_priv(pdev) \
  136. container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
  137. static int usbhs_get_vbus(struct platform_device *pdev)
  138. {
  139. struct usbhs_private *priv = usbhs_get_priv(pdev);
  140. return !((1 << 7) & __raw_readw(priv->cr2));
  141. }
  142. static void usbhs_phy_reset(struct platform_device *pdev)
  143. {
  144. struct usbhs_private *priv = usbhs_get_priv(pdev);
  145. /* init phy */
  146. __raw_writew(0x8a0a, priv->cr2);
  147. }
  148. static int usbhs_get_id(struct platform_device *pdev)
  149. {
  150. return USBHS_GADGET;
  151. }
  152. static irqreturn_t usbhs_interrupt(int irq, void *data)
  153. {
  154. struct platform_device *pdev = data;
  155. struct usbhs_private *priv = usbhs_get_priv(pdev);
  156. renesas_usbhs_call_notify_hotplug(pdev);
  157. /* clear status */
  158. __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy);
  159. return IRQ_HANDLED;
  160. }
  161. static int usbhs_hardware_init(struct platform_device *pdev)
  162. {
  163. struct usbhs_private *priv = usbhs_get_priv(pdev);
  164. int ret;
  165. /* clear interrupt status */
  166. __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
  167. ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH,
  168. dev_name(&pdev->dev), pdev);
  169. if (ret) {
  170. dev_err(&pdev->dev, "request_irq err\n");
  171. return ret;
  172. }
  173. /* enable USB phy interrupt */
  174. __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy);
  175. return 0;
  176. }
  177. static void usbhs_hardware_exit(struct platform_device *pdev)
  178. {
  179. struct usbhs_private *priv = usbhs_get_priv(pdev);
  180. /* clear interrupt status */
  181. __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
  182. free_irq(IRQ15, pdev);
  183. }
  184. static u32 usbhs_pipe_cfg[] = {
  185. USB_ENDPOINT_XFER_CONTROL,
  186. USB_ENDPOINT_XFER_ISOC,
  187. USB_ENDPOINT_XFER_ISOC,
  188. USB_ENDPOINT_XFER_BULK,
  189. USB_ENDPOINT_XFER_BULK,
  190. USB_ENDPOINT_XFER_BULK,
  191. USB_ENDPOINT_XFER_INT,
  192. USB_ENDPOINT_XFER_INT,
  193. USB_ENDPOINT_XFER_INT,
  194. USB_ENDPOINT_XFER_BULK,
  195. USB_ENDPOINT_XFER_BULK,
  196. USB_ENDPOINT_XFER_BULK,
  197. USB_ENDPOINT_XFER_BULK,
  198. USB_ENDPOINT_XFER_BULK,
  199. USB_ENDPOINT_XFER_BULK,
  200. USB_ENDPOINT_XFER_BULK,
  201. };
  202. static struct usbhs_private usbhs_private = {
  203. .phy = IOMEM(0xe60781e0), /* USBPHYINT */
  204. .cr2 = IOMEM(0xe605810c), /* USBCR2 */
  205. .info = {
  206. .platform_callback = {
  207. .hardware_init = usbhs_hardware_init,
  208. .hardware_exit = usbhs_hardware_exit,
  209. .get_id = usbhs_get_id,
  210. .phy_reset = usbhs_phy_reset,
  211. .get_vbus = usbhs_get_vbus,
  212. },
  213. .driver_param = {
  214. .buswait_bwait = 4,
  215. .has_otg = 1,
  216. .pipe_type = usbhs_pipe_cfg,
  217. .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
  218. },
  219. },
  220. };
  221. static struct resource usbhs_resources[] = {
  222. [0] = {
  223. .start = 0xE6890000,
  224. .end = 0xE68900e6 - 1,
  225. .flags = IORESOURCE_MEM,
  226. },
  227. [1] = {
  228. .start = gic_spi(62),
  229. .end = gic_spi(62),
  230. .flags = IORESOURCE_IRQ,
  231. },
  232. };
  233. static struct platform_device usbhs_device = {
  234. .name = "renesas_usbhs",
  235. .id = -1,
  236. .dev = {
  237. .dma_mask = NULL,
  238. .coherent_dma_mask = 0xffffffff,
  239. .platform_data = &usbhs_private.info,
  240. },
  241. .num_resources = ARRAY_SIZE(usbhs_resources),
  242. .resource = usbhs_resources,
  243. };
  244. /* LCDC */
  245. static struct fb_videomode kzm_lcdc_mode = {
  246. .name = "WVGA Panel",
  247. .xres = 800,
  248. .yres = 480,
  249. .left_margin = 220,
  250. .right_margin = 110,
  251. .hsync_len = 70,
  252. .upper_margin = 20,
  253. .lower_margin = 5,
  254. .vsync_len = 5,
  255. .sync = 0,
  256. };
  257. static struct sh_mobile_lcdc_info lcdc_info = {
  258. .clock_source = LCDC_CLK_BUS,
  259. .ch[0] = {
  260. .chan = LCDC_CHAN_MAINLCD,
  261. .fourcc = V4L2_PIX_FMT_RGB565,
  262. .interface_type = RGB24,
  263. .lcd_modes = &kzm_lcdc_mode,
  264. .num_modes = 1,
  265. .clock_divider = 5,
  266. .flags = 0,
  267. .panel_cfg = {
  268. .width = 152,
  269. .height = 91,
  270. },
  271. }
  272. };
  273. static struct resource lcdc_resources[] = {
  274. [0] = {
  275. .name = "LCDC",
  276. .start = 0xfe940000,
  277. .end = 0xfe943fff,
  278. .flags = IORESOURCE_MEM,
  279. },
  280. [1] = {
  281. .start = intcs_evt2irq(0x580),
  282. .flags = IORESOURCE_IRQ,
  283. },
  284. };
  285. static struct platform_device lcdc_device = {
  286. .name = "sh_mobile_lcdc_fb",
  287. .num_resources = ARRAY_SIZE(lcdc_resources),
  288. .resource = lcdc_resources,
  289. .dev = {
  290. .platform_data = &lcdc_info,
  291. .coherent_dma_mask = ~0,
  292. },
  293. };
  294. /* Fixed 1.8V regulator to be used by MMCIF */
  295. static struct regulator_consumer_supply fixed1v8_power_consumers[] =
  296. {
  297. REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
  298. REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
  299. };
  300. /* MMCIF */
  301. static struct resource sh_mmcif_resources[] = {
  302. [0] = {
  303. .name = "MMCIF",
  304. .start = 0xe6bd0000,
  305. .end = 0xe6bd00ff,
  306. .flags = IORESOURCE_MEM,
  307. },
  308. [1] = {
  309. .start = gic_spi(140),
  310. .flags = IORESOURCE_IRQ,
  311. },
  312. [2] = {
  313. .start = gic_spi(141),
  314. .flags = IORESOURCE_IRQ,
  315. },
  316. };
  317. static struct sh_mmcif_plat_data sh_mmcif_platdata = {
  318. .ocr = MMC_VDD_165_195,
  319. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  320. .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
  321. .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
  322. };
  323. static struct platform_device mmc_device = {
  324. .name = "sh_mmcif",
  325. .dev = {
  326. .dma_mask = NULL,
  327. .coherent_dma_mask = 0xffffffff,
  328. .platform_data = &sh_mmcif_platdata,
  329. },
  330. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  331. .resource = sh_mmcif_resources,
  332. };
  333. /* Fixed 2.8V regulators to be used by SDHI0 and SDHI2 */
  334. static struct regulator_consumer_supply fixed2v8_power_consumers[] =
  335. {
  336. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  337. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  338. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
  339. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
  340. };
  341. /* SDHI */
  342. static struct sh_mobile_sdhi_info sdhi0_info = {
  343. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  344. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  345. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  346. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  347. .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
  348. };
  349. static struct resource sdhi0_resources[] = {
  350. [0] = {
  351. .name = "SDHI0",
  352. .start = 0xee100000,
  353. .end = 0xee1000ff,
  354. .flags = IORESOURCE_MEM,
  355. },
  356. [1] = {
  357. .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
  358. .start = gic_spi(83),
  359. .flags = IORESOURCE_IRQ,
  360. },
  361. [2] = {
  362. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  363. .start = gic_spi(84),
  364. .flags = IORESOURCE_IRQ,
  365. },
  366. [3] = {
  367. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  368. .start = gic_spi(85),
  369. .flags = IORESOURCE_IRQ,
  370. },
  371. };
  372. static struct platform_device sdhi0_device = {
  373. .name = "sh_mobile_sdhi",
  374. .num_resources = ARRAY_SIZE(sdhi0_resources),
  375. .resource = sdhi0_resources,
  376. .dev = {
  377. .platform_data = &sdhi0_info,
  378. },
  379. };
  380. /* Micro SD */
  381. static struct sh_mobile_sdhi_info sdhi2_info = {
  382. .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
  383. .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
  384. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
  385. TMIO_MMC_USE_GPIO_CD |
  386. TMIO_MMC_WRPROTECT_DISABLE,
  387. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  388. .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
  389. .cd_gpio = GPIO_PORT13,
  390. };
  391. static struct resource sdhi2_resources[] = {
  392. [0] = {
  393. .name = "SDHI2",
  394. .start = 0xee140000,
  395. .end = 0xee1400ff,
  396. .flags = IORESOURCE_MEM,
  397. },
  398. [1] = {
  399. .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
  400. .start = gic_spi(103),
  401. .flags = IORESOURCE_IRQ,
  402. },
  403. [2] = {
  404. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  405. .start = gic_spi(104),
  406. .flags = IORESOURCE_IRQ,
  407. },
  408. [3] = {
  409. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  410. .start = gic_spi(105),
  411. .flags = IORESOURCE_IRQ,
  412. },
  413. };
  414. static struct platform_device sdhi2_device = {
  415. .name = "sh_mobile_sdhi",
  416. .id = 2,
  417. .num_resources = ARRAY_SIZE(sdhi2_resources),
  418. .resource = sdhi2_resources,
  419. .dev = {
  420. .platform_data = &sdhi2_info,
  421. },
  422. };
  423. /* KEY */
  424. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  425. static struct gpio_keys_button gpio_buttons[] = {
  426. GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
  427. GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
  428. GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
  429. GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
  430. GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
  431. GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
  432. GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
  433. };
  434. static struct gpio_keys_platform_data gpio_key_info = {
  435. .buttons = gpio_buttons,
  436. .nbuttons = ARRAY_SIZE(gpio_buttons),
  437. };
  438. static struct platform_device gpio_keys_device = {
  439. .name = "gpio-keys",
  440. .dev = {
  441. .platform_data = &gpio_key_info,
  442. },
  443. };
  444. /* FSI-AK4648 */
  445. static struct sh_fsi_platform_info fsi_info = {
  446. .port_a = {
  447. .tx_id = SHDMA_SLAVE_FSI2A_TX,
  448. },
  449. };
  450. static struct resource fsi_resources[] = {
  451. [0] = {
  452. .name = "FSI",
  453. .start = 0xEC230000,
  454. .end = 0xEC230400 - 1,
  455. .flags = IORESOURCE_MEM,
  456. },
  457. [1] = {
  458. .start = gic_spi(146),
  459. .flags = IORESOURCE_IRQ,
  460. },
  461. };
  462. static struct platform_device fsi_device = {
  463. .name = "sh_fsi2",
  464. .id = -1,
  465. .num_resources = ARRAY_SIZE(fsi_resources),
  466. .resource = fsi_resources,
  467. .dev = {
  468. .platform_data = &fsi_info,
  469. },
  470. };
  471. static struct asoc_simple_card_info fsi2_ak4648_info = {
  472. .name = "AK4648",
  473. .card = "FSI2A-AK4648",
  474. .codec = "ak4642-codec.0-0012",
  475. .platform = "sh_fsi2",
  476. .daifmt = SND_SOC_DAIFMT_LEFT_J,
  477. .cpu_dai = {
  478. .name = "fsia-dai",
  479. .fmt = SND_SOC_DAIFMT_CBS_CFS,
  480. },
  481. .codec_dai = {
  482. .name = "ak4642-hifi",
  483. .fmt = SND_SOC_DAIFMT_CBM_CFM,
  484. .sysclk = 11289600,
  485. },
  486. };
  487. static struct platform_device fsi_ak4648_device = {
  488. .name = "asoc-simple-card",
  489. .dev = {
  490. .platform_data = &fsi2_ak4648_info,
  491. },
  492. };
  493. /* I2C */
  494. static struct pcf857x_platform_data pcf8575_pdata = {
  495. .gpio_base = GPIO_PCF8575_BASE,
  496. };
  497. static struct i2c_board_info i2c0_devices[] = {
  498. {
  499. I2C_BOARD_INFO("ak4648", 0x12),
  500. },
  501. {
  502. I2C_BOARD_INFO("r2025sd", 0x32),
  503. },
  504. {
  505. I2C_BOARD_INFO("ak8975", 0x0c),
  506. .irq = intcs_evt2irq(0x3380), /* IRQ28 */
  507. },
  508. {
  509. I2C_BOARD_INFO("adxl34x", 0x1d),
  510. .irq = intcs_evt2irq(0x3340), /* IRQ26 */
  511. },
  512. };
  513. static struct i2c_board_info i2c1_devices[] = {
  514. {
  515. I2C_BOARD_INFO("st1232-ts", 0x55),
  516. .irq = intcs_evt2irq(0x300), /* IRQ8 */
  517. },
  518. };
  519. static struct i2c_board_info i2c3_devices[] = {
  520. {
  521. I2C_BOARD_INFO("pcf8575", 0x20),
  522. .irq = intcs_evt2irq(0x3260), /* IRQ19 */
  523. .platform_data = &pcf8575_pdata,
  524. },
  525. };
  526. static struct platform_device *kzm_devices[] __initdata = {
  527. &smsc_device,
  528. &usb_host_device,
  529. &usbhs_device,
  530. &lcdc_device,
  531. &mmc_device,
  532. &sdhi0_device,
  533. &sdhi2_device,
  534. &gpio_keys_device,
  535. &fsi_device,
  536. &fsi_ak4648_device,
  537. };
  538. /*
  539. * FIXME
  540. *
  541. * This is quick hack for enabling LCDC backlight
  542. */
  543. static int __init as3711_enable_lcdc_backlight(void)
  544. {
  545. struct i2c_adapter *a = i2c_get_adapter(0);
  546. struct i2c_msg msg;
  547. int i, ret;
  548. __u8 magic[] = {
  549. 0x40, 0x2a,
  550. 0x43, 0x3c,
  551. 0x44, 0x3c,
  552. 0x45, 0x3c,
  553. 0x54, 0x03,
  554. 0x51, 0x00,
  555. 0x51, 0x01,
  556. 0xff, 0x00, /* wait */
  557. 0x43, 0xf0,
  558. 0x44, 0xf0,
  559. 0x45, 0xf0,
  560. };
  561. if (!of_machine_is_compatible("renesas,kzm9g"))
  562. return 0;
  563. if (!a)
  564. return 0;
  565. msg.addr = 0x40;
  566. msg.len = 2;
  567. msg.flags = 0;
  568. for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
  569. msg.buf = magic + i;
  570. if (0xff == msg.buf[0]) {
  571. udelay(500);
  572. continue;
  573. }
  574. ret = i2c_transfer(a, &msg, 1);
  575. if (ret < 0) {
  576. pr_err("i2c transfer fail\n");
  577. break;
  578. }
  579. }
  580. return 0;
  581. }
  582. device_initcall(as3711_enable_lcdc_backlight);
  583. static void __init kzm_init(void)
  584. {
  585. regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
  586. ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
  587. regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
  588. ARRAY_SIZE(fixed2v8_power_consumers), 2800000);
  589. regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  590. sh73a0_pinmux_init();
  591. /* enable SCIFA4 */
  592. gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
  593. gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
  594. gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
  595. gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
  596. /* CS4 for SMSC/USB */
  597. gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
  598. /* SMSC */
  599. gpio_request_one(GPIO_PORT224, GPIOF_IN, NULL); /* IRQ3 */
  600. /* LCDC */
  601. gpio_request(GPIO_FN_LCDD23, NULL);
  602. gpio_request(GPIO_FN_LCDD22, NULL);
  603. gpio_request(GPIO_FN_LCDD21, NULL);
  604. gpio_request(GPIO_FN_LCDD20, NULL);
  605. gpio_request(GPIO_FN_LCDD19, NULL);
  606. gpio_request(GPIO_FN_LCDD18, NULL);
  607. gpio_request(GPIO_FN_LCDD17, NULL);
  608. gpio_request(GPIO_FN_LCDD16, NULL);
  609. gpio_request(GPIO_FN_LCDD15, NULL);
  610. gpio_request(GPIO_FN_LCDD14, NULL);
  611. gpio_request(GPIO_FN_LCDD13, NULL);
  612. gpio_request(GPIO_FN_LCDD12, NULL);
  613. gpio_request(GPIO_FN_LCDD11, NULL);
  614. gpio_request(GPIO_FN_LCDD10, NULL);
  615. gpio_request(GPIO_FN_LCDD9, NULL);
  616. gpio_request(GPIO_FN_LCDD8, NULL);
  617. gpio_request(GPIO_FN_LCDD7, NULL);
  618. gpio_request(GPIO_FN_LCDD6, NULL);
  619. gpio_request(GPIO_FN_LCDD5, NULL);
  620. gpio_request(GPIO_FN_LCDD4, NULL);
  621. gpio_request(GPIO_FN_LCDD3, NULL);
  622. gpio_request(GPIO_FN_LCDD2, NULL);
  623. gpio_request(GPIO_FN_LCDD1, NULL);
  624. gpio_request(GPIO_FN_LCDD0, NULL);
  625. gpio_request(GPIO_FN_LCDDISP, NULL);
  626. gpio_request(GPIO_FN_LCDDCK, NULL);
  627. gpio_request_one(GPIO_PORT222, GPIOF_OUT_INIT_HIGH, NULL); /* LCDCDON */
  628. gpio_request_one(GPIO_PORT226, GPIOF_OUT_INIT_HIGH, NULL); /* SC */
  629. /* Touchscreen */
  630. gpio_request_one(GPIO_PORT223, GPIOF_IN, NULL); /* IRQ8 */
  631. /* enable MMCIF */
  632. gpio_request(GPIO_FN_MMCCLK0, NULL);
  633. gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
  634. gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
  635. gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
  636. gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
  637. gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
  638. gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
  639. gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
  640. gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
  641. gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
  642. /* enable SD */
  643. gpio_request(GPIO_FN_SDHIWP0, NULL);
  644. gpio_request(GPIO_FN_SDHICD0, NULL);
  645. gpio_request(GPIO_FN_SDHICMD0, NULL);
  646. gpio_request(GPIO_FN_SDHICLK0, NULL);
  647. gpio_request(GPIO_FN_SDHID0_3, NULL);
  648. gpio_request(GPIO_FN_SDHID0_2, NULL);
  649. gpio_request(GPIO_FN_SDHID0_1, NULL);
  650. gpio_request(GPIO_FN_SDHID0_0, NULL);
  651. gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL);
  652. gpio_request_one(GPIO_PORT15, GPIOF_OUT_INIT_HIGH, NULL); /* power */
  653. /* enable Micro SD */
  654. gpio_request(GPIO_FN_SDHID2_0, NULL);
  655. gpio_request(GPIO_FN_SDHID2_1, NULL);
  656. gpio_request(GPIO_FN_SDHID2_2, NULL);
  657. gpio_request(GPIO_FN_SDHID2_3, NULL);
  658. gpio_request(GPIO_FN_SDHICMD2, NULL);
  659. gpio_request(GPIO_FN_SDHICLK2, NULL);
  660. gpio_request_one(GPIO_PORT14, GPIOF_OUT_INIT_HIGH, NULL); /* power */
  661. /* I2C 3 */
  662. gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
  663. gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
  664. /* enable FSI2 port A (ak4648) */
  665. gpio_request(GPIO_FN_FSIACK, NULL);
  666. gpio_request(GPIO_FN_FSIAILR, NULL);
  667. gpio_request(GPIO_FN_FSIAIBT, NULL);
  668. gpio_request(GPIO_FN_FSIAISLD, NULL);
  669. gpio_request(GPIO_FN_FSIAOSLD, NULL);
  670. /* enable USB */
  671. gpio_request(GPIO_FN_VBUS_0, NULL);
  672. #ifdef CONFIG_CACHE_L2X0
  673. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  674. l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
  675. #endif
  676. i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
  677. i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
  678. i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
  679. sh73a0_add_standard_devices();
  680. platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
  681. sh73a0_pm_init();
  682. }
  683. static void kzm9g_restart(char mode, const char *cmd)
  684. {
  685. #define RESCNT2 IOMEM(0xe6188020)
  686. /* Do soft power on reset */
  687. writel((1 << 31), RESCNT2);
  688. }
  689. static const char *kzm9g_boards_compat_dt[] __initdata = {
  690. "renesas,kzm9g",
  691. NULL,
  692. };
  693. DT_MACHINE_START(KZM9G_DT, "kzm9g")
  694. .smp = smp_ops(sh73a0_smp_ops),
  695. .map_io = sh73a0_map_io,
  696. .init_early = sh73a0_add_early_devices,
  697. .nr_irqs = NR_IRQS_LEGACY,
  698. .init_irq = sh73a0_init_irq,
  699. .init_machine = kzm_init,
  700. .init_late = shmobile_init_late,
  701. .init_time = sh73a0_earlytimer_init,
  702. .restart = kzm9g_restart,
  703. .dt_compat = kzm9g_boards_compat_dt,
  704. MACHINE_END