board-kzm9g.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. /*
  2. * KZM-A9-GT board support
  3. *
  4. * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include <linux/delay.h>
  20. #include <linux/gpio.h>
  21. #include <linux/gpio_keys.h>
  22. #include <linux/io.h>
  23. #include <linux/irq.h>
  24. #include <linux/i2c.h>
  25. #include <linux/i2c/pcf857x.h>
  26. #include <linux/input.h>
  27. #include <linux/irqchip/arm-gic.h>
  28. #include <linux/mmc/host.h>
  29. #include <linux/mmc/sh_mmcif.h>
  30. #include <linux/mmc/sh_mobile_sdhi.h>
  31. #include <linux/mfd/tmio.h>
  32. #include <linux/pinctrl/machine.h>
  33. #include <linux/pinctrl/pinconf-generic.h>
  34. #include <linux/platform_device.h>
  35. #include <linux/regulator/fixed.h>
  36. #include <linux/regulator/machine.h>
  37. #include <linux/smsc911x.h>
  38. #include <linux/usb/r8a66597.h>
  39. #include <linux/usb/renesas_usbhs.h>
  40. #include <linux/videodev2.h>
  41. #include <sound/sh_fsi.h>
  42. #include <sound/simple_card.h>
  43. #include <mach/irqs.h>
  44. #include <mach/sh73a0.h>
  45. #include <mach/common.h>
  46. #include <asm/hardware/cache-l2x0.h>
  47. #include <asm/mach-types.h>
  48. #include <asm/mach/arch.h>
  49. #include <video/sh_mobile_lcdc.h>
  50. /*
  51. * external GPIO
  52. */
  53. #define GPIO_PCF8575_BASE (GPIO_NR)
  54. #define GPIO_PCF8575_PORT10 (GPIO_NR + 8)
  55. #define GPIO_PCF8575_PORT11 (GPIO_NR + 9)
  56. #define GPIO_PCF8575_PORT12 (GPIO_NR + 10)
  57. #define GPIO_PCF8575_PORT13 (GPIO_NR + 11)
  58. #define GPIO_PCF8575_PORT14 (GPIO_NR + 12)
  59. #define GPIO_PCF8575_PORT15 (GPIO_NR + 13)
  60. #define GPIO_PCF8575_PORT16 (GPIO_NR + 14)
  61. /* Dummy supplies, where voltage doesn't matter */
  62. static struct regulator_consumer_supply dummy_supplies[] = {
  63. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  64. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  65. };
  66. /*
  67. * FSI-AK4648
  68. *
  69. * this command is required when playback.
  70. *
  71. * # amixer set "LINEOUT Mixer DACL" on
  72. */
  73. /* SMSC 9221 */
  74. static struct resource smsc9221_resources[] = {
  75. [0] = {
  76. .start = 0x10000000, /* CS4 */
  77. .end = 0x100000ff,
  78. .flags = IORESOURCE_MEM,
  79. },
  80. [1] = {
  81. .start = irq_pin(3), /* IRQ3 */
  82. .flags = IORESOURCE_IRQ,
  83. },
  84. };
  85. static struct smsc911x_platform_config smsc9221_platdata = {
  86. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  87. .phy_interface = PHY_INTERFACE_MODE_MII,
  88. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  89. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  90. };
  91. static struct platform_device smsc_device = {
  92. .name = "smsc911x",
  93. .dev = {
  94. .platform_data = &smsc9221_platdata,
  95. },
  96. .resource = smsc9221_resources,
  97. .num_resources = ARRAY_SIZE(smsc9221_resources),
  98. };
  99. /* USB external chip */
  100. static struct r8a66597_platdata usb_host_data = {
  101. .on_chip = 0,
  102. .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
  103. };
  104. static struct resource usb_resources[] = {
  105. [0] = {
  106. .start = 0x10010000,
  107. .end = 0x1001ffff - 1,
  108. .flags = IORESOURCE_MEM,
  109. },
  110. [1] = {
  111. .start = irq_pin(1), /* IRQ1 */
  112. .flags = IORESOURCE_IRQ,
  113. },
  114. };
  115. static struct platform_device usb_host_device = {
  116. .name = "r8a66597_hcd",
  117. .dev = {
  118. .platform_data = &usb_host_data,
  119. .dma_mask = NULL,
  120. .coherent_dma_mask = 0xffffffff,
  121. },
  122. .num_resources = ARRAY_SIZE(usb_resources),
  123. .resource = usb_resources,
  124. };
  125. /* USB Func CN17 */
  126. struct usbhs_private {
  127. void __iomem *phy;
  128. void __iomem *cr2;
  129. struct renesas_usbhs_platform_info info;
  130. };
  131. #define IRQ15 irq_pin(15)
  132. #define USB_PHY_MODE (1 << 4)
  133. #define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
  134. #define USB_PHY_ON (1 << 1)
  135. #define USB_PHY_OFF (1 << 0)
  136. #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
  137. #define usbhs_get_priv(pdev) \
  138. container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
  139. static int usbhs_get_vbus(struct platform_device *pdev)
  140. {
  141. struct usbhs_private *priv = usbhs_get_priv(pdev);
  142. return !((1 << 7) & __raw_readw(priv->cr2));
  143. }
  144. static int usbhs_phy_reset(struct platform_device *pdev)
  145. {
  146. struct usbhs_private *priv = usbhs_get_priv(pdev);
  147. /* init phy */
  148. __raw_writew(0x8a0a, priv->cr2);
  149. return 0;
  150. }
  151. static int usbhs_get_id(struct platform_device *pdev)
  152. {
  153. return USBHS_GADGET;
  154. }
  155. static irqreturn_t usbhs_interrupt(int irq, void *data)
  156. {
  157. struct platform_device *pdev = data;
  158. struct usbhs_private *priv = usbhs_get_priv(pdev);
  159. renesas_usbhs_call_notify_hotplug(pdev);
  160. /* clear status */
  161. __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy);
  162. return IRQ_HANDLED;
  163. }
  164. static int usbhs_hardware_init(struct platform_device *pdev)
  165. {
  166. struct usbhs_private *priv = usbhs_get_priv(pdev);
  167. int ret;
  168. /* clear interrupt status */
  169. __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
  170. ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH,
  171. dev_name(&pdev->dev), pdev);
  172. if (ret) {
  173. dev_err(&pdev->dev, "request_irq err\n");
  174. return ret;
  175. }
  176. /* enable USB phy interrupt */
  177. __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy);
  178. return 0;
  179. }
  180. static int usbhs_hardware_exit(struct platform_device *pdev)
  181. {
  182. struct usbhs_private *priv = usbhs_get_priv(pdev);
  183. /* clear interrupt status */
  184. __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
  185. free_irq(IRQ15, pdev);
  186. return 0;
  187. }
  188. static u32 usbhs_pipe_cfg[] = {
  189. USB_ENDPOINT_XFER_CONTROL,
  190. USB_ENDPOINT_XFER_ISOC,
  191. USB_ENDPOINT_XFER_ISOC,
  192. USB_ENDPOINT_XFER_BULK,
  193. USB_ENDPOINT_XFER_BULK,
  194. USB_ENDPOINT_XFER_BULK,
  195. USB_ENDPOINT_XFER_INT,
  196. USB_ENDPOINT_XFER_INT,
  197. USB_ENDPOINT_XFER_INT,
  198. USB_ENDPOINT_XFER_BULK,
  199. USB_ENDPOINT_XFER_BULK,
  200. USB_ENDPOINT_XFER_BULK,
  201. USB_ENDPOINT_XFER_BULK,
  202. USB_ENDPOINT_XFER_BULK,
  203. USB_ENDPOINT_XFER_BULK,
  204. USB_ENDPOINT_XFER_BULK,
  205. };
  206. static struct usbhs_private usbhs_private = {
  207. .phy = IOMEM(0xe60781e0), /* USBPHYINT */
  208. .cr2 = IOMEM(0xe605810c), /* USBCR2 */
  209. .info = {
  210. .platform_callback = {
  211. .hardware_init = usbhs_hardware_init,
  212. .hardware_exit = usbhs_hardware_exit,
  213. .get_id = usbhs_get_id,
  214. .phy_reset = usbhs_phy_reset,
  215. .get_vbus = usbhs_get_vbus,
  216. },
  217. .driver_param = {
  218. .buswait_bwait = 4,
  219. .has_otg = 1,
  220. .pipe_type = usbhs_pipe_cfg,
  221. .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
  222. },
  223. },
  224. };
  225. static struct resource usbhs_resources[] = {
  226. [0] = {
  227. .start = 0xE6890000,
  228. .end = 0xE68900e6 - 1,
  229. .flags = IORESOURCE_MEM,
  230. },
  231. [1] = {
  232. .start = gic_spi(62),
  233. .end = gic_spi(62),
  234. .flags = IORESOURCE_IRQ,
  235. },
  236. };
  237. static struct platform_device usbhs_device = {
  238. .name = "renesas_usbhs",
  239. .id = -1,
  240. .dev = {
  241. .dma_mask = NULL,
  242. .coherent_dma_mask = 0xffffffff,
  243. .platform_data = &usbhs_private.info,
  244. },
  245. .num_resources = ARRAY_SIZE(usbhs_resources),
  246. .resource = usbhs_resources,
  247. };
  248. /* LCDC */
  249. static struct fb_videomode kzm_lcdc_mode = {
  250. .name = "WVGA Panel",
  251. .xres = 800,
  252. .yres = 480,
  253. .left_margin = 220,
  254. .right_margin = 110,
  255. .hsync_len = 70,
  256. .upper_margin = 20,
  257. .lower_margin = 5,
  258. .vsync_len = 5,
  259. .sync = 0,
  260. };
  261. static struct sh_mobile_lcdc_info lcdc_info = {
  262. .clock_source = LCDC_CLK_BUS,
  263. .ch[0] = {
  264. .chan = LCDC_CHAN_MAINLCD,
  265. .fourcc = V4L2_PIX_FMT_RGB565,
  266. .interface_type = RGB24,
  267. .lcd_modes = &kzm_lcdc_mode,
  268. .num_modes = 1,
  269. .clock_divider = 5,
  270. .flags = 0,
  271. .panel_cfg = {
  272. .width = 152,
  273. .height = 91,
  274. },
  275. }
  276. };
  277. static struct resource lcdc_resources[] = {
  278. [0] = {
  279. .name = "LCDC",
  280. .start = 0xfe940000,
  281. .end = 0xfe943fff,
  282. .flags = IORESOURCE_MEM,
  283. },
  284. [1] = {
  285. .start = intcs_evt2irq(0x580),
  286. .flags = IORESOURCE_IRQ,
  287. },
  288. };
  289. static struct platform_device lcdc_device = {
  290. .name = "sh_mobile_lcdc_fb",
  291. .num_resources = ARRAY_SIZE(lcdc_resources),
  292. .resource = lcdc_resources,
  293. .dev = {
  294. .platform_data = &lcdc_info,
  295. .coherent_dma_mask = ~0,
  296. },
  297. };
  298. /* Fixed 1.8V regulator to be used by MMCIF */
  299. static struct regulator_consumer_supply fixed1v8_power_consumers[] =
  300. {
  301. REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
  302. REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
  303. };
  304. /* MMCIF */
  305. static struct resource sh_mmcif_resources[] = {
  306. [0] = {
  307. .name = "MMCIF",
  308. .start = 0xe6bd0000,
  309. .end = 0xe6bd00ff,
  310. .flags = IORESOURCE_MEM,
  311. },
  312. [1] = {
  313. .start = gic_spi(140),
  314. .flags = IORESOURCE_IRQ,
  315. },
  316. [2] = {
  317. .start = gic_spi(141),
  318. .flags = IORESOURCE_IRQ,
  319. },
  320. };
  321. static struct sh_mmcif_plat_data sh_mmcif_platdata = {
  322. .ocr = MMC_VDD_165_195,
  323. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  324. .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
  325. .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
  326. };
  327. static struct platform_device mmc_device = {
  328. .name = "sh_mmcif",
  329. .dev = {
  330. .dma_mask = NULL,
  331. .coherent_dma_mask = 0xffffffff,
  332. .platform_data = &sh_mmcif_platdata,
  333. },
  334. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  335. .resource = sh_mmcif_resources,
  336. };
  337. /* Fixed 2.8V regulators to be used by SDHI0 and SDHI2 */
  338. static struct regulator_consumer_supply fixed2v8_power_consumers[] =
  339. {
  340. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  341. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  342. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
  343. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
  344. };
  345. /* SDHI */
  346. static struct sh_mobile_sdhi_info sdhi0_info = {
  347. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  348. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  349. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  350. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  351. .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
  352. };
  353. static struct resource sdhi0_resources[] = {
  354. [0] = {
  355. .name = "SDHI0",
  356. .start = 0xee100000,
  357. .end = 0xee1000ff,
  358. .flags = IORESOURCE_MEM,
  359. },
  360. [1] = {
  361. .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
  362. .start = gic_spi(83),
  363. .flags = IORESOURCE_IRQ,
  364. },
  365. [2] = {
  366. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  367. .start = gic_spi(84),
  368. .flags = IORESOURCE_IRQ,
  369. },
  370. [3] = {
  371. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  372. .start = gic_spi(85),
  373. .flags = IORESOURCE_IRQ,
  374. },
  375. };
  376. static struct platform_device sdhi0_device = {
  377. .name = "sh_mobile_sdhi",
  378. .num_resources = ARRAY_SIZE(sdhi0_resources),
  379. .resource = sdhi0_resources,
  380. .dev = {
  381. .platform_data = &sdhi0_info,
  382. },
  383. };
  384. /* Micro SD */
  385. static struct sh_mobile_sdhi_info sdhi2_info = {
  386. .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
  387. .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
  388. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
  389. TMIO_MMC_USE_GPIO_CD |
  390. TMIO_MMC_WRPROTECT_DISABLE,
  391. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  392. .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
  393. .cd_gpio = 13,
  394. };
  395. static struct resource sdhi2_resources[] = {
  396. [0] = {
  397. .name = "SDHI2",
  398. .start = 0xee140000,
  399. .end = 0xee1400ff,
  400. .flags = IORESOURCE_MEM,
  401. },
  402. [1] = {
  403. .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
  404. .start = gic_spi(103),
  405. .flags = IORESOURCE_IRQ,
  406. },
  407. [2] = {
  408. .name = SH_MOBILE_SDHI_IRQ_SDCARD,
  409. .start = gic_spi(104),
  410. .flags = IORESOURCE_IRQ,
  411. },
  412. [3] = {
  413. .name = SH_MOBILE_SDHI_IRQ_SDIO,
  414. .start = gic_spi(105),
  415. .flags = IORESOURCE_IRQ,
  416. },
  417. };
  418. static struct platform_device sdhi2_device = {
  419. .name = "sh_mobile_sdhi",
  420. .id = 2,
  421. .num_resources = ARRAY_SIZE(sdhi2_resources),
  422. .resource = sdhi2_resources,
  423. .dev = {
  424. .platform_data = &sdhi2_info,
  425. },
  426. };
  427. /* KEY */
  428. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  429. static struct gpio_keys_button gpio_buttons[] = {
  430. GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
  431. GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
  432. GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
  433. GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
  434. GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
  435. GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
  436. GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
  437. };
  438. static struct gpio_keys_platform_data gpio_key_info = {
  439. .buttons = gpio_buttons,
  440. .nbuttons = ARRAY_SIZE(gpio_buttons),
  441. };
  442. static struct platform_device gpio_keys_device = {
  443. .name = "gpio-keys",
  444. .dev = {
  445. .platform_data = &gpio_key_info,
  446. },
  447. };
  448. /* FSI-AK4648 */
  449. static struct sh_fsi_platform_info fsi_info = {
  450. .port_a = {
  451. .tx_id = SHDMA_SLAVE_FSI2A_TX,
  452. },
  453. };
  454. static struct resource fsi_resources[] = {
  455. [0] = {
  456. .name = "FSI",
  457. .start = 0xEC230000,
  458. .end = 0xEC230400 - 1,
  459. .flags = IORESOURCE_MEM,
  460. },
  461. [1] = {
  462. .start = gic_spi(146),
  463. .flags = IORESOURCE_IRQ,
  464. },
  465. };
  466. static struct platform_device fsi_device = {
  467. .name = "sh_fsi2",
  468. .id = -1,
  469. .num_resources = ARRAY_SIZE(fsi_resources),
  470. .resource = fsi_resources,
  471. .dev = {
  472. .platform_data = &fsi_info,
  473. },
  474. };
  475. static struct asoc_simple_card_info fsi2_ak4648_info = {
  476. .name = "AK4648",
  477. .card = "FSI2A-AK4648",
  478. .codec = "ak4642-codec.0-0012",
  479. .platform = "sh_fsi2",
  480. .daifmt = SND_SOC_DAIFMT_LEFT_J,
  481. .cpu_dai = {
  482. .name = "fsia-dai",
  483. .fmt = SND_SOC_DAIFMT_CBS_CFS,
  484. },
  485. .codec_dai = {
  486. .name = "ak4642-hifi",
  487. .fmt = SND_SOC_DAIFMT_CBM_CFM,
  488. .sysclk = 11289600,
  489. },
  490. };
  491. static struct platform_device fsi_ak4648_device = {
  492. .name = "asoc-simple-card",
  493. .dev = {
  494. .platform_data = &fsi2_ak4648_info,
  495. },
  496. };
  497. /* I2C */
  498. static struct pcf857x_platform_data pcf8575_pdata = {
  499. .gpio_base = GPIO_PCF8575_BASE,
  500. };
  501. static struct i2c_board_info i2c0_devices[] = {
  502. {
  503. I2C_BOARD_INFO("ak4648", 0x12),
  504. },
  505. {
  506. I2C_BOARD_INFO("r2025sd", 0x32),
  507. },
  508. {
  509. I2C_BOARD_INFO("ak8975", 0x0c),
  510. .irq = irq_pin(28), /* IRQ28 */
  511. },
  512. {
  513. I2C_BOARD_INFO("adxl34x", 0x1d),
  514. .irq = irq_pin(26), /* IRQ26 */
  515. },
  516. };
  517. static struct i2c_board_info i2c1_devices[] = {
  518. {
  519. I2C_BOARD_INFO("st1232-ts", 0x55),
  520. .irq = irq_pin(8), /* IRQ8 */
  521. },
  522. };
  523. static struct i2c_board_info i2c3_devices[] = {
  524. {
  525. I2C_BOARD_INFO("pcf8575", 0x20),
  526. .irq = irq_pin(19), /* IRQ19 */
  527. .platform_data = &pcf8575_pdata,
  528. },
  529. };
  530. static struct platform_device *kzm_devices[] __initdata = {
  531. &smsc_device,
  532. &usb_host_device,
  533. &usbhs_device,
  534. &lcdc_device,
  535. &mmc_device,
  536. &sdhi0_device,
  537. &sdhi2_device,
  538. &gpio_keys_device,
  539. &fsi_device,
  540. &fsi_ak4648_device,
  541. };
  542. static unsigned long pin_pullup_conf[] = {
  543. PIN_CONF_PACKED(PIN_CONFIG_BIAS_PULL_UP, 0),
  544. };
  545. static const struct pinctrl_map kzm_pinctrl_map[] = {
  546. /* FSIA (AK4648) */
  547. PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
  548. "fsia_mclk_in", "fsia"),
  549. PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
  550. "fsia_sclk_in", "fsia"),
  551. PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
  552. "fsia_data_in", "fsia"),
  553. PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
  554. "fsia_data_out", "fsia"),
  555. /* I2C3 */
  556. PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.3", "pfc-sh73a0",
  557. "i2c3_1", "i2c3"),
  558. /* LCD */
  559. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
  560. "lcd_data24", "lcd"),
  561. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
  562. "lcd_sync", "lcd"),
  563. /* MMCIF */
  564. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
  565. "mmc0_data8_0", "mmc0"),
  566. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
  567. "mmc0_ctrl_0", "mmc0"),
  568. PIN_MAP_CONFIGS_PIN_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
  569. "PORT279", pin_pullup_conf),
  570. PIN_MAP_CONFIGS_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh73a0",
  571. "mmc0_data8_0", pin_pullup_conf),
  572. /* SCIFA4 */
  573. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
  574. "scifa4_data", "scifa4"),
  575. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
  576. "scifa4_ctrl", "scifa4"),
  577. /* SDHI0 */
  578. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
  579. "sdhi0_data4", "sdhi0"),
  580. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
  581. "sdhi0_ctrl", "sdhi0"),
  582. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
  583. "sdhi0_cd", "sdhi0"),
  584. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh73a0",
  585. "sdhi0_wp", "sdhi0"),
  586. /* SDHI2 */
  587. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh73a0",
  588. "sdhi2_data4", "sdhi2"),
  589. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh73a0",
  590. "sdhi2_ctrl", "sdhi2"),
  591. /* SMSC */
  592. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x.0", "pfc-sh73a0",
  593. "bsc_cs4", "bsc"),
  594. /* USB */
  595. PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-sh73a0",
  596. "usb_vbus", "usb"),
  597. };
  598. /*
  599. * FIXME
  600. *
  601. * This is quick hack for enabling LCDC backlight
  602. */
  603. static int __init as3711_enable_lcdc_backlight(void)
  604. {
  605. struct i2c_adapter *a = i2c_get_adapter(0);
  606. struct i2c_msg msg;
  607. int i, ret;
  608. __u8 magic[] = {
  609. 0x40, 0x2a,
  610. 0x43, 0x3c,
  611. 0x44, 0x3c,
  612. 0x45, 0x3c,
  613. 0x54, 0x03,
  614. 0x51, 0x00,
  615. 0x51, 0x01,
  616. 0xff, 0x00, /* wait */
  617. 0x43, 0xf0,
  618. 0x44, 0xf0,
  619. 0x45, 0xf0,
  620. };
  621. if (!of_machine_is_compatible("renesas,kzm9g"))
  622. return 0;
  623. if (!a)
  624. return 0;
  625. msg.addr = 0x40;
  626. msg.len = 2;
  627. msg.flags = 0;
  628. for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
  629. msg.buf = magic + i;
  630. if (0xff == msg.buf[0]) {
  631. udelay(500);
  632. continue;
  633. }
  634. ret = i2c_transfer(a, &msg, 1);
  635. if (ret < 0) {
  636. pr_err("i2c transfer fail\n");
  637. break;
  638. }
  639. }
  640. return 0;
  641. }
  642. device_initcall(as3711_enable_lcdc_backlight);
  643. static void __init kzm_init(void)
  644. {
  645. regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
  646. ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
  647. regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
  648. ARRAY_SIZE(fixed2v8_power_consumers), 2800000);
  649. regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  650. pinctrl_register_mappings(kzm_pinctrl_map, ARRAY_SIZE(kzm_pinctrl_map));
  651. sh73a0_pinmux_init();
  652. /* SMSC */
  653. gpio_request_one(224, GPIOF_IN, NULL); /* IRQ3 */
  654. /* LCDC */
  655. gpio_request_one(222, GPIOF_OUT_INIT_HIGH, NULL); /* LCDCDON */
  656. gpio_request_one(226, GPIOF_OUT_INIT_HIGH, NULL); /* SC */
  657. /* Touchscreen */
  658. gpio_request_one(223, GPIOF_IN, NULL); /* IRQ8 */
  659. /* enable SD */
  660. gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL);
  661. gpio_request_one(15, GPIOF_OUT_INIT_HIGH, NULL); /* power */
  662. /* enable Micro SD */
  663. gpio_request_one(14, GPIOF_OUT_INIT_HIGH, NULL); /* power */
  664. #ifdef CONFIG_CACHE_L2X0
  665. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  666. l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
  667. #endif
  668. i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
  669. i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
  670. i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
  671. sh73a0_add_standard_devices();
  672. platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
  673. sh73a0_pm_init();
  674. }
  675. static void kzm9g_restart(char mode, const char *cmd)
  676. {
  677. #define RESCNT2 IOMEM(0xe6188020)
  678. /* Do soft power on reset */
  679. writel((1 << 31), RESCNT2);
  680. }
  681. static const char *kzm9g_boards_compat_dt[] __initdata = {
  682. "renesas,kzm9g",
  683. NULL,
  684. };
  685. DT_MACHINE_START(KZM9G_DT, "kzm9g")
  686. .smp = smp_ops(sh73a0_smp_ops),
  687. .map_io = sh73a0_map_io,
  688. .init_early = sh73a0_add_early_devices,
  689. .nr_irqs = NR_IRQS_LEGACY,
  690. .init_irq = sh73a0_init_irq,
  691. .init_machine = kzm_init,
  692. .init_late = shmobile_init_late,
  693. .init_time = sh73a0_earlytimer_init,
  694. .restart = kzm9g_restart,
  695. .dt_compat = kzm9g_boards_compat_dt,
  696. MACHINE_END