board-kzm9g.c 18 KB

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