board-kzm9g.c 19 KB

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