board-kzm9g.c 19 KB

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