board-kzm9g.c 22 KB

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