board-kzm9g.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  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. .ccs_unsupported = true,
  327. .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
  328. .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
  329. };
  330. static struct platform_device mmc_device = {
  331. .name = "sh_mmcif",
  332. .dev = {
  333. .dma_mask = NULL,
  334. .coherent_dma_mask = 0xffffffff,
  335. .platform_data = &sh_mmcif_platdata,
  336. },
  337. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  338. .resource = sh_mmcif_resources,
  339. };
  340. /* Fixed 3.3V regulators to be used by SDHI0 */
  341. static struct regulator_consumer_supply vcc_sdhi0_consumers[] =
  342. {
  343. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  344. };
  345. static struct regulator_init_data vcc_sdhi0_init_data = {
  346. .constraints = {
  347. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  348. },
  349. .num_consumer_supplies = ARRAY_SIZE(vcc_sdhi0_consumers),
  350. .consumer_supplies = vcc_sdhi0_consumers,
  351. };
  352. static struct fixed_voltage_config vcc_sdhi0_info = {
  353. .supply_name = "SDHI0 Vcc",
  354. .microvolts = 3300000,
  355. .gpio = 15,
  356. .enable_high = 1,
  357. .init_data = &vcc_sdhi0_init_data,
  358. };
  359. static struct platform_device vcc_sdhi0 = {
  360. .name = "reg-fixed-voltage",
  361. .id = 0,
  362. .dev = {
  363. .platform_data = &vcc_sdhi0_info,
  364. },
  365. };
  366. /* Fixed 3.3V regulators to be used by SDHI2 */
  367. static struct regulator_consumer_supply vcc_sdhi2_consumers[] =
  368. {
  369. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
  370. };
  371. static struct regulator_init_data vcc_sdhi2_init_data = {
  372. .constraints = {
  373. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  374. },
  375. .num_consumer_supplies = ARRAY_SIZE(vcc_sdhi2_consumers),
  376. .consumer_supplies = vcc_sdhi2_consumers,
  377. };
  378. static struct fixed_voltage_config vcc_sdhi2_info = {
  379. .supply_name = "SDHI2 Vcc",
  380. .microvolts = 3300000,
  381. .gpio = 14,
  382. .enable_high = 1,
  383. .init_data = &vcc_sdhi2_init_data,
  384. };
  385. static struct platform_device vcc_sdhi2 = {
  386. .name = "reg-fixed-voltage",
  387. .id = 1,
  388. .dev = {
  389. .platform_data = &vcc_sdhi2_info,
  390. },
  391. };
  392. /* SDHI */
  393. static struct sh_mobile_sdhi_info sdhi0_info = {
  394. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  395. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  396. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  397. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  398. MMC_CAP_POWER_OFF_CARD,
  399. };
  400. static struct resource sdhi0_resources[] = {
  401. [0] = {
  402. .name = "SDHI0",
  403. .start = 0xee100000,
  404. .end = 0xee1000ff,
  405. .flags = IORESOURCE_MEM,
  406. },
  407. [1] = {
  408. .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
  409. .start = gic_spi(83),
  410. .flags = IORESOURCE_IRQ,
  411. },
  412. [2] = {
  413. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  414. .start = gic_spi(84),
  415. .flags = IORESOURCE_IRQ,
  416. },
  417. [3] = {
  418. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  419. .start = gic_spi(85),
  420. .flags = IORESOURCE_IRQ,
  421. },
  422. };
  423. static struct platform_device sdhi0_device = {
  424. .name = "sh_mobile_sdhi",
  425. .num_resources = ARRAY_SIZE(sdhi0_resources),
  426. .resource = sdhi0_resources,
  427. .dev = {
  428. .platform_data = &sdhi0_info,
  429. },
  430. };
  431. /* Micro SD */
  432. static struct sh_mobile_sdhi_info sdhi2_info = {
  433. .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
  434. .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
  435. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
  436. TMIO_MMC_USE_GPIO_CD |
  437. TMIO_MMC_WRPROTECT_DISABLE,
  438. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_POWER_OFF_CARD,
  439. .cd_gpio = 13,
  440. };
  441. static struct resource sdhi2_resources[] = {
  442. [0] = {
  443. .name = "SDHI2",
  444. .start = 0xee140000,
  445. .end = 0xee1400ff,
  446. .flags = IORESOURCE_MEM,
  447. },
  448. [1] = {
  449. .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
  450. .start = gic_spi(103),
  451. .flags = IORESOURCE_IRQ,
  452. },
  453. [2] = {
  454. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  455. .start = gic_spi(104),
  456. .flags = IORESOURCE_IRQ,
  457. },
  458. [3] = {
  459. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  460. .start = gic_spi(105),
  461. .flags = IORESOURCE_IRQ,
  462. },
  463. };
  464. static struct platform_device sdhi2_device = {
  465. .name = "sh_mobile_sdhi",
  466. .id = 2,
  467. .num_resources = ARRAY_SIZE(sdhi2_resources),
  468. .resource = sdhi2_resources,
  469. .dev = {
  470. .platform_data = &sdhi2_info,
  471. },
  472. };
  473. /* KEY */
  474. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  475. static struct gpio_keys_button gpio_buttons[] = {
  476. GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
  477. GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
  478. GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
  479. GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
  480. GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
  481. GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
  482. GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
  483. };
  484. static struct gpio_keys_platform_data gpio_key_info = {
  485. .buttons = gpio_buttons,
  486. .nbuttons = ARRAY_SIZE(gpio_buttons),
  487. };
  488. static struct platform_device gpio_keys_device = {
  489. .name = "gpio-keys",
  490. .dev = {
  491. .platform_data = &gpio_key_info,
  492. },
  493. };
  494. /* FSI-AK4648 */
  495. static struct sh_fsi_platform_info fsi_info = {
  496. .port_a = {
  497. .tx_id = SHDMA_SLAVE_FSI2A_TX,
  498. },
  499. };
  500. static struct resource fsi_resources[] = {
  501. [0] = {
  502. .name = "FSI",
  503. .start = 0xEC230000,
  504. .end = 0xEC230400 - 1,
  505. .flags = IORESOURCE_MEM,
  506. },
  507. [1] = {
  508. .start = gic_spi(146),
  509. .flags = IORESOURCE_IRQ,
  510. },
  511. };
  512. static struct platform_device fsi_device = {
  513. .name = "sh_fsi2",
  514. .id = -1,
  515. .num_resources = ARRAY_SIZE(fsi_resources),
  516. .resource = fsi_resources,
  517. .dev = {
  518. .platform_data = &fsi_info,
  519. },
  520. };
  521. static struct asoc_simple_card_info fsi2_ak4648_info = {
  522. .name = "AK4648",
  523. .card = "FSI2A-AK4648",
  524. .codec = "ak4642-codec.0-0012",
  525. .platform = "sh_fsi2",
  526. .daifmt = SND_SOC_DAIFMT_LEFT_J,
  527. .cpu_dai = {
  528. .name = "fsia-dai",
  529. .fmt = SND_SOC_DAIFMT_CBS_CFS,
  530. },
  531. .codec_dai = {
  532. .name = "ak4642-hifi",
  533. .fmt = SND_SOC_DAIFMT_CBM_CFM,
  534. .sysclk = 11289600,
  535. },
  536. };
  537. static struct platform_device fsi_ak4648_device = {
  538. .name = "asoc-simple-card",
  539. .dev = {
  540. .platform_data = &fsi2_ak4648_info,
  541. },
  542. };
  543. /* I2C */
  544. /* StepDown1 is used to supply 1.315V to the CPU */
  545. static struct regulator_init_data as3711_sd1 = {
  546. .constraints = {
  547. .name = "1.315V CPU",
  548. .boot_on = 1,
  549. .always_on = 1,
  550. .min_uV = 1315000,
  551. .max_uV = 1335000,
  552. },
  553. };
  554. /* StepDown2 is used to supply 1.8V to the CPU and to the board */
  555. static struct regulator_init_data as3711_sd2 = {
  556. .constraints = {
  557. .name = "1.8V",
  558. .boot_on = 1,
  559. .always_on = 1,
  560. .min_uV = 1800000,
  561. .max_uV = 1800000,
  562. },
  563. };
  564. /*
  565. * StepDown3 is switched in parallel with StepDown2, seems to be off,
  566. * according to read-back pre-set register values
  567. */
  568. /* StepDown4 is used to supply 1.215V to the CPU and to the board */
  569. static struct regulator_init_data as3711_sd4 = {
  570. .constraints = {
  571. .name = "1.215V",
  572. .boot_on = 1,
  573. .always_on = 1,
  574. .min_uV = 1215000,
  575. .max_uV = 1235000,
  576. },
  577. };
  578. /* LDO1 is unused and unconnected */
  579. /* LDO2 is used to supply 2.8V to the CPU */
  580. static struct regulator_init_data as3711_ldo2 = {
  581. .constraints = {
  582. .name = "2.8V CPU",
  583. .boot_on = 1,
  584. .always_on = 1,
  585. .min_uV = 2800000,
  586. .max_uV = 2800000,
  587. },
  588. };
  589. /* LDO3 is used to supply 3.0V to the CPU */
  590. static struct regulator_init_data as3711_ldo3 = {
  591. .constraints = {
  592. .name = "3.0V CPU",
  593. .boot_on = 1,
  594. .always_on = 1,
  595. .min_uV = 3000000,
  596. .max_uV = 3000000,
  597. },
  598. };
  599. /* LDO4 is used to supply 2.8V to the board */
  600. static struct regulator_init_data as3711_ldo4 = {
  601. .constraints = {
  602. .name = "2.8V",
  603. .boot_on = 1,
  604. .always_on = 1,
  605. .min_uV = 2800000,
  606. .max_uV = 2800000,
  607. },
  608. };
  609. /* LDO5 is switched parallel to LDO4, also set to 2.8V */
  610. static struct regulator_init_data as3711_ldo5 = {
  611. .constraints = {
  612. .name = "2.8V #2",
  613. .boot_on = 1,
  614. .always_on = 1,
  615. .min_uV = 2800000,
  616. .max_uV = 2800000,
  617. },
  618. };
  619. /* LDO6 is unused and unconnected */
  620. /* LDO7 is used to supply 1.15V to the CPU */
  621. static struct regulator_init_data as3711_ldo7 = {
  622. .constraints = {
  623. .name = "1.15V CPU",
  624. .boot_on = 1,
  625. .always_on = 1,
  626. .min_uV = 1150000,
  627. .max_uV = 1150000,
  628. },
  629. };
  630. /* LDO8 is switched parallel to LDO7, also set to 1.15V */
  631. static struct regulator_init_data as3711_ldo8 = {
  632. .constraints = {
  633. .name = "1.15V CPU #2",
  634. .boot_on = 1,
  635. .always_on = 1,
  636. .min_uV = 1150000,
  637. .max_uV = 1150000,
  638. },
  639. };
  640. static struct as3711_platform_data as3711_pdata = {
  641. .regulator = {
  642. .init_data = {
  643. [AS3711_REGULATOR_SD_1] = &as3711_sd1,
  644. [AS3711_REGULATOR_SD_2] = &as3711_sd2,
  645. [AS3711_REGULATOR_SD_4] = &as3711_sd4,
  646. [AS3711_REGULATOR_LDO_2] = &as3711_ldo2,
  647. [AS3711_REGULATOR_LDO_3] = &as3711_ldo3,
  648. [AS3711_REGULATOR_LDO_4] = &as3711_ldo4,
  649. [AS3711_REGULATOR_LDO_5] = &as3711_ldo5,
  650. [AS3711_REGULATOR_LDO_7] = &as3711_ldo7,
  651. [AS3711_REGULATOR_LDO_8] = &as3711_ldo8,
  652. },
  653. },
  654. .backlight = {
  655. .su2_fb = "sh_mobile_lcdc_fb.0",
  656. .su2_max_uA = 36000,
  657. .su2_feedback = AS3711_SU2_CURR_AUTO,
  658. .su2_fbprot = AS3711_SU2_GPIO4,
  659. .su2_auto_curr1 = true,
  660. .su2_auto_curr2 = true,
  661. .su2_auto_curr3 = true,
  662. },
  663. };
  664. static struct pcf857x_platform_data pcf8575_pdata = {
  665. .gpio_base = GPIO_PCF8575_BASE,
  666. };
  667. static struct i2c_board_info i2c0_devices[] = {
  668. {
  669. I2C_BOARD_INFO("ak4648", 0x12),
  670. },
  671. {
  672. I2C_BOARD_INFO("r2025sd", 0x32),
  673. },
  674. {
  675. I2C_BOARD_INFO("ak8975", 0x0c),
  676. .irq = irq_pin(28), /* IRQ28 */
  677. },
  678. {
  679. I2C_BOARD_INFO("adxl34x", 0x1d),
  680. .irq = irq_pin(26), /* IRQ26 */
  681. },
  682. {
  683. I2C_BOARD_INFO("as3711", 0x40),
  684. .irq = intcs_evt2irq(0x3300), /* IRQ24 */
  685. .platform_data = &as3711_pdata,
  686. },
  687. };
  688. static struct i2c_board_info i2c1_devices[] = {
  689. {
  690. I2C_BOARD_INFO("st1232-ts", 0x55),
  691. .irq = irq_pin(8), /* IRQ8 */
  692. },
  693. };
  694. static struct i2c_board_info i2c3_devices[] = {
  695. {
  696. I2C_BOARD_INFO("pcf8575", 0x20),
  697. .irq = irq_pin(19), /* IRQ19 */
  698. .platform_data = &pcf8575_pdata,
  699. },
  700. };
  701. static struct platform_device *kzm_devices[] __initdata = {
  702. &smsc_device,
  703. &usb_host_device,
  704. &usbhs_device,
  705. &lcdc_device,
  706. &mmc_device,
  707. &vcc_sdhi0,
  708. &vcc_sdhi2,
  709. &sdhi0_device,
  710. &sdhi2_device,
  711. &gpio_keys_device,
  712. &fsi_device,
  713. &fsi_ak4648_device,
  714. };
  715. static unsigned long pin_pullup_conf[] = {
  716. PIN_CONF_PACKED(PIN_CONFIG_BIAS_PULL_UP, 0),
  717. };
  718. static const struct pinctrl_map kzm_pinctrl_map[] = {
  719. /* FSIA (AK4648) */
  720. PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2", "pfc-sh73a0",
  721. "fsia_mclk_in", "fsia"),
  722. PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2", "pfc-sh73a0",
  723. "fsia_sclk_in", "fsia"),
  724. PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2", "pfc-sh73a0",
  725. "fsia_data_in", "fsia"),
  726. PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2", "pfc-sh73a0",
  727. "fsia_data_out", "fsia"),
  728. /* I2C3 */
  729. PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.3", "pfc-sh73a0",
  730. "i2c3_1", "i2c3"),
  731. /* LCD */
  732. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
  733. "lcd_data24", "lcd"),
  734. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
  735. "lcd_sync", "lcd"),
  736. /* MMCIF */
  737. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
  738. "mmc0_data8_0", "mmc0"),
  739. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
  740. "mmc0_ctrl_0", "mmc0"),
  741. PIN_MAP_CONFIGS_PIN_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
  742. "PORT279", pin_pullup_conf),
  743. PIN_MAP_CONFIGS_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
  744. "mmc0_data8_0", pin_pullup_conf),
  745. /* SCIFA4 */
  746. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
  747. "scifa4_data", "scifa4"),
  748. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
  749. "scifa4_ctrl", "scifa4"),
  750. /* SDHI0 */
  751. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
  752. "sdhi0_data4", "sdhi0"),
  753. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
  754. "sdhi0_ctrl", "sdhi0"),
  755. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
  756. "sdhi0_cd", "sdhi0"),
  757. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
  758. "sdhi0_wp", "sdhi0"),
  759. /* SDHI2 */
  760. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh73a0",
  761. "sdhi2_data4", "sdhi2"),
  762. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh73a0",
  763. "sdhi2_ctrl", "sdhi2"),
  764. /* SMSC */
  765. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x.0", "pfc-sh73a0",
  766. "bsc_cs4", "bsc"),
  767. /* USB */
  768. PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-sh73a0",
  769. "usb_vbus", "usb"),
  770. };
  771. static void __init kzm_init(void)
  772. {
  773. regulator_register_always_on(2, "fixed-1.8V", fixed1v8_power_consumers,
  774. ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
  775. regulator_register_fixed(3, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  776. pinctrl_register_mappings(kzm_pinctrl_map, ARRAY_SIZE(kzm_pinctrl_map));
  777. sh73a0_pinmux_init();
  778. /* SMSC */
  779. gpio_request_one(224, GPIOF_IN, NULL); /* IRQ3 */
  780. /* LCDC */
  781. gpio_request_one(222, GPIOF_OUT_INIT_HIGH, NULL); /* LCDCDON */
  782. gpio_request_one(226, GPIOF_OUT_INIT_HIGH, NULL); /* SC */
  783. /* Touchscreen */
  784. gpio_request_one(223, GPIOF_IN, NULL); /* IRQ8 */
  785. #ifdef CONFIG_CACHE_L2X0
  786. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  787. l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
  788. #endif
  789. i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
  790. i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
  791. i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
  792. sh73a0_add_standard_devices();
  793. platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
  794. sh73a0_pm_init();
  795. }
  796. static void kzm9g_restart(enum reboot_mode mode, const char *cmd)
  797. {
  798. #define RESCNT2 IOMEM(0xe6188020)
  799. /* Do soft power on reset */
  800. writel((1 << 31), RESCNT2);
  801. }
  802. static const char *kzm9g_boards_compat_dt[] __initdata = {
  803. "renesas,kzm9g",
  804. NULL,
  805. };
  806. DT_MACHINE_START(KZM9G_DT, "kzm9g")
  807. .smp = smp_ops(sh73a0_smp_ops),
  808. .map_io = sh73a0_map_io,
  809. .init_early = sh73a0_add_early_devices,
  810. .nr_irqs = NR_IRQS_LEGACY,
  811. .init_irq = sh73a0_init_irq,
  812. .init_machine = kzm_init,
  813. .init_late = shmobile_init_late,
  814. .init_time = sh73a0_earlytimer_init,
  815. .restart = kzm9g_restart,
  816. .dt_compat = kzm9g_boards_compat_dt,
  817. MACHINE_END