board-kzm9g.c 22 KB

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