board-kzm9g.c 22 KB

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