board-kzm9g.c 19 KB

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