board-bockw.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /*
  2. * Bock-W board support
  3. *
  4. * Copyright (C) 2013 Renesas Solutions Corp.
  5. * Copyright (C) 2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. * Copyright (C) 2013 Cogent Embedded, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <linux/mfd/tmio.h>
  22. #include <linux/mmc/host.h>
  23. #include <linux/mmc/sh_mobile_sdhi.h>
  24. #include <linux/mmc/sh_mmcif.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/pinctrl/machine.h>
  27. #include <linux/platform_data/camera-rcar.h>
  28. #include <linux/platform_data/usb-rcar-phy.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/regulator/fixed.h>
  31. #include <linux/regulator/machine.h>
  32. #include <linux/smsc911x.h>
  33. #include <linux/spi/spi.h>
  34. #include <linux/spi/flash.h>
  35. #include <linux/usb/renesas_usbhs.h>
  36. #include <media/soc_camera.h>
  37. #include <mach/common.h>
  38. #include <mach/irqs.h>
  39. #include <mach/r8a7778.h>
  40. #include <asm/mach/arch.h>
  41. #include <sound/rcar_snd.h>
  42. #include <sound/simple_card.h>
  43. #define FPGA 0x18200000
  44. #define IRQ0MR 0x30
  45. #define COMCTLR 0x101c
  46. static void __iomem *fpga;
  47. /*
  48. * CN9(Upper side) SCIF/RCAN selection
  49. *
  50. * 1,4 3,6
  51. * SW40 SCIF RCAN
  52. * SW41 SCIF RCAN
  53. */
  54. /*
  55. * MMC (CN26) pin
  56. *
  57. * SW6 (D2) 3 pin
  58. * SW7 (D5) ON
  59. * SW8 (D3) 3 pin
  60. * SW10 (D4) 1 pin
  61. * SW12 (CLK) 1 pin
  62. * SW13 (D6) 3 pin
  63. * SW14 (CMD) ON
  64. * SW15 (D6) 1 pin
  65. * SW16 (D0) ON
  66. * SW17 (D1) ON
  67. * SW18 (D7) 3 pin
  68. * SW19 (MMC) 1 pin
  69. */
  70. /*
  71. * SSI settings
  72. *
  73. * SW45: 1-4 side (SSI5 out, ROUT/LOUT CN19 Mid)
  74. * SW46: 1101 (SSI6 Recorde)
  75. * SW47: 1110 (SSI5 Playback)
  76. * SW48: 11 (Recorde power)
  77. * SW49: 1 (SSI slave mode)
  78. * SW50: 1111 (SSI7, SSI8)
  79. * SW51: 1111 (SSI3, SSI4)
  80. * SW54: 1pin (ak4554 FPGA control)
  81. * SW55: 1 (CLKB is 24.5760MHz)
  82. * SW60: 1pin (ak4554 FPGA control)
  83. * SW61: 3pin (use X11 clock)
  84. * SW78: 3-6 (ak4642 connects I2C0)
  85. *
  86. * You can use sound as
  87. *
  88. * hw0: CN19: SSI56-AK4643
  89. * hw1: CN21: SSI3-AK4554(playback)
  90. * hw2: CN21: SSI4-AK4554(capture)
  91. * hw3: CN20: SSI7-AK4554(playback)
  92. * hw4: CN20: SSI8-AK4554(capture)
  93. *
  94. * this command is required when playback on hw0.
  95. *
  96. * # amixer set "LINEOUT Mixer DACL" on
  97. */
  98. /*
  99. * USB
  100. *
  101. * USB1 (CN29) can be Host/Function
  102. *
  103. * Host Func
  104. * SW98 1 2
  105. * SW99 1 3
  106. */
  107. /* Dummy supplies, where voltage doesn't matter */
  108. static struct regulator_consumer_supply dummy_supplies[] = {
  109. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  110. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  111. };
  112. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  113. REGULATOR_SUPPLY("vmmc", "sh_mmcif"),
  114. REGULATOR_SUPPLY("vqmmc", "sh_mmcif"),
  115. };
  116. static struct smsc911x_platform_config smsc911x_data __initdata = {
  117. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  118. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  119. .flags = SMSC911X_USE_32BIT,
  120. .phy_interface = PHY_INTERFACE_MODE_MII,
  121. };
  122. static struct resource smsc911x_resources[] __initdata = {
  123. DEFINE_RES_MEM(0x18300000, 0x1000),
  124. DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */
  125. };
  126. #if IS_ENABLED(CONFIG_USB_RENESAS_USBHS_UDC)
  127. /*
  128. * When USB1 is Func
  129. */
  130. static int usbhsf_get_id(struct platform_device *pdev)
  131. {
  132. return USBHS_GADGET;
  133. }
  134. #define SUSPMODE 0x102
  135. static int usbhsf_power_ctrl(struct platform_device *pdev,
  136. void __iomem *base, int enable)
  137. {
  138. enable = !!enable;
  139. r8a7778_usb_phy_power(enable);
  140. iowrite16(enable << 14, base + SUSPMODE);
  141. return 0;
  142. }
  143. static struct resource usbhsf_resources[] __initdata = {
  144. DEFINE_RES_MEM(0xffe60000, 0x110),
  145. DEFINE_RES_IRQ(gic_iid(0x4f)),
  146. };
  147. static struct renesas_usbhs_platform_info usbhs_info __initdata = {
  148. .platform_callback = {
  149. .get_id = usbhsf_get_id,
  150. .power_ctrl = usbhsf_power_ctrl,
  151. },
  152. .driver_param = {
  153. .buswait_bwait = 4,
  154. },
  155. };
  156. #define USB_PHY_SETTING {.port1_func = 1, .ovc_pin[1].active_high = 1,}
  157. #define USB1_DEVICE "renesas_usbhs"
  158. #define ADD_USB_FUNC_DEVICE_IF_POSSIBLE() \
  159. platform_device_register_resndata( \
  160. &platform_bus, "renesas_usbhs", -1, \
  161. usbhsf_resources, \
  162. ARRAY_SIZE(usbhsf_resources), \
  163. &usbhs_info, sizeof(struct renesas_usbhs_platform_info))
  164. #else
  165. /*
  166. * When USB1 is Host
  167. */
  168. #define USB_PHY_SETTING { }
  169. #define USB1_DEVICE "ehci-platform"
  170. #define ADD_USB_FUNC_DEVICE_IF_POSSIBLE()
  171. #endif
  172. /* USB */
  173. static struct resource usb_phy_resources[] __initdata = {
  174. DEFINE_RES_MEM(0xffe70800, 0x100),
  175. DEFINE_RES_MEM(0xffe76000, 0x100),
  176. };
  177. static struct rcar_phy_platform_data usb_phy_platform_data __initdata =
  178. USB_PHY_SETTING;
  179. /* SDHI */
  180. static struct sh_mobile_sdhi_info sdhi0_info __initdata = {
  181. .dma_slave_tx = HPBDMA_SLAVE_SDHI0_TX,
  182. .dma_slave_rx = HPBDMA_SLAVE_SDHI0_RX,
  183. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  184. .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  185. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  186. };
  187. static struct resource sdhi0_resources[] __initdata = {
  188. DEFINE_RES_MEM(0xFFE4C000, 0x100),
  189. DEFINE_RES_IRQ(gic_iid(0x77)),
  190. };
  191. /* Ether */
  192. static struct resource ether_resources[] __initdata = {
  193. DEFINE_RES_MEM(0xfde00000, 0x400),
  194. DEFINE_RES_IRQ(gic_iid(0x89)),
  195. };
  196. static struct sh_eth_plat_data ether_platform_data __initdata = {
  197. .phy = 0x01,
  198. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  199. .phy_interface = PHY_INTERFACE_MODE_RMII,
  200. /*
  201. * Although the LINK signal is available on the board, it's connected to
  202. * the link/activity LED output of the PHY, thus the link disappears and
  203. * reappears after each packet. We'd be better off ignoring such signal
  204. * and getting the link state from the PHY indirectly.
  205. */
  206. .no_ether_link = 1,
  207. };
  208. /* I2C */
  209. static struct i2c_board_info i2c0_devices[] = {
  210. {
  211. I2C_BOARD_INFO("rx8581", 0x51),
  212. }, {
  213. I2C_BOARD_INFO("ak4643", 0x12),
  214. }
  215. };
  216. /* HSPI*/
  217. static struct mtd_partition m25p80_spi_flash_partitions[] = {
  218. {
  219. .name = "data(spi)",
  220. .size = 0x0100000,
  221. .offset = 0,
  222. },
  223. };
  224. static struct flash_platform_data spi_flash_data = {
  225. .name = "m25p80",
  226. .type = "s25fl008k",
  227. .parts = m25p80_spi_flash_partitions,
  228. .nr_parts = ARRAY_SIZE(m25p80_spi_flash_partitions),
  229. };
  230. static struct spi_board_info spi_board_info[] __initdata = {
  231. {
  232. .modalias = "m25p80",
  233. .max_speed_hz = 104000000,
  234. .chip_select = 0,
  235. .bus_num = 0,
  236. .mode = SPI_MODE_0,
  237. .platform_data = &spi_flash_data,
  238. },
  239. };
  240. /* MMC */
  241. static struct resource mmc_resources[] __initdata = {
  242. DEFINE_RES_MEM(0xffe4e000, 0x100),
  243. DEFINE_RES_IRQ(gic_iid(0x5d)),
  244. };
  245. static struct sh_mmcif_plat_data sh_mmcif_plat __initdata = {
  246. .sup_pclk = 0,
  247. .caps = MMC_CAP_4_BIT_DATA |
  248. MMC_CAP_8_BIT_DATA |
  249. MMC_CAP_NEEDS_POLL,
  250. };
  251. /* In the default configuration both decoders reside on I2C bus 0 */
  252. #define BOCKW_CAMERA(idx) \
  253. static struct i2c_board_info camera##idx##_info = { \
  254. I2C_BOARD_INFO("ml86v7667", 0x41 + 2 * (idx)), \
  255. }; \
  256. \
  257. static struct soc_camera_link iclink##idx##_ml86v7667 __initdata = { \
  258. .bus_id = idx, \
  259. .i2c_adapter_id = 0, \
  260. .board_info = &camera##idx##_info, \
  261. }
  262. BOCKW_CAMERA(0);
  263. BOCKW_CAMERA(1);
  264. /* VIN */
  265. static struct rcar_vin_platform_data vin_platform_data __initdata = {
  266. .flags = RCAR_VIN_BT656,
  267. };
  268. #define R8A7778_VIN(idx) \
  269. static struct resource vin##idx##_resources[] __initdata = { \
  270. DEFINE_RES_MEM(0xffc50000 + 0x1000 * (idx), 0x1000), \
  271. DEFINE_RES_IRQ(gic_iid(0x5a)), \
  272. }; \
  273. \
  274. static struct platform_device_info vin##idx##_info __initdata = { \
  275. .parent = &platform_bus, \
  276. .name = "r8a7778-vin", \
  277. .id = idx, \
  278. .res = vin##idx##_resources, \
  279. .num_res = ARRAY_SIZE(vin##idx##_resources), \
  280. .dma_mask = DMA_BIT_MASK(32), \
  281. .data = &vin_platform_data, \
  282. .size_data = sizeof(vin_platform_data), \
  283. }
  284. R8A7778_VIN(0);
  285. R8A7778_VIN(1);
  286. /* Sound */
  287. static struct resource rsnd_resources[] __initdata = {
  288. [RSND_GEN1_SRU] = DEFINE_RES_MEM(0xffd90000, 0x1000),
  289. [RSND_GEN1_SSI] = DEFINE_RES_MEM(0xffd91000, 0x1240),
  290. [RSND_GEN1_ADG] = DEFINE_RES_MEM(0xfffe0000, 0x24),
  291. };
  292. static struct rsnd_ssi_platform_info rsnd_ssi[] = {
  293. RSND_SSI_UNUSED, /* SSI 0 */
  294. RSND_SSI_UNUSED, /* SSI 1 */
  295. RSND_SSI_UNUSED, /* SSI 2 */
  296. RSND_SSI_SET(1, 0, gic_iid(0x85), RSND_SSI_PLAY),
  297. RSND_SSI_SET(2, 0, gic_iid(0x85), RSND_SSI_CLK_PIN_SHARE),
  298. RSND_SSI_SET(0, 0, gic_iid(0x86), RSND_SSI_PLAY),
  299. RSND_SSI_SET(0, 0, gic_iid(0x86), 0),
  300. RSND_SSI_SET(3, 0, gic_iid(0x86), RSND_SSI_PLAY),
  301. RSND_SSI_SET(4, 0, gic_iid(0x86), RSND_SSI_CLK_PIN_SHARE),
  302. };
  303. static struct rsnd_scu_platform_info rsnd_scu[9] = {
  304. /* no member at this point */
  305. };
  306. enum {
  307. AK4554_34 = 0,
  308. AK4643_56,
  309. AK4554_78,
  310. SOUND_MAX,
  311. };
  312. static int rsnd_codec_power(int id, int enable)
  313. {
  314. static int sound_user[SOUND_MAX] = {0, 0, 0};
  315. int *usr = NULL;
  316. u32 bit;
  317. switch (id) {
  318. case 3:
  319. case 4:
  320. usr = sound_user + AK4554_34;
  321. bit = (1 << 10);
  322. break;
  323. case 5:
  324. case 6:
  325. usr = sound_user + AK4643_56;
  326. bit = (1 << 6);
  327. break;
  328. case 7:
  329. case 8:
  330. usr = sound_user + AK4554_78;
  331. bit = (1 << 7);
  332. break;
  333. }
  334. if (!usr)
  335. return -EIO;
  336. if (enable) {
  337. if (*usr == 0) {
  338. u32 val = ioread16(fpga + COMCTLR);
  339. val &= ~bit;
  340. iowrite16(val, fpga + COMCTLR);
  341. }
  342. (*usr)++;
  343. } else {
  344. if (*usr == 0)
  345. return 0;
  346. (*usr)--;
  347. if (*usr == 0) {
  348. u32 val = ioread16(fpga + COMCTLR);
  349. val |= bit;
  350. iowrite16(val, fpga + COMCTLR);
  351. }
  352. }
  353. return 0;
  354. }
  355. static int rsnd_start(int id)
  356. {
  357. return rsnd_codec_power(id, 1);
  358. }
  359. static int rsnd_stop(int id)
  360. {
  361. return rsnd_codec_power(id, 0);
  362. }
  363. static struct rcar_snd_info rsnd_info = {
  364. .flags = RSND_GEN1,
  365. .ssi_info = rsnd_ssi,
  366. .ssi_info_nr = ARRAY_SIZE(rsnd_ssi),
  367. .scu_info = rsnd_scu,
  368. .scu_info_nr = ARRAY_SIZE(rsnd_scu),
  369. .start = rsnd_start,
  370. .stop = rsnd_stop,
  371. };
  372. static struct asoc_simple_card_info rsnd_card_info[] = {
  373. /* SSI5, SSI6 */
  374. {
  375. .name = "AK4643",
  376. .card = "SSI56-AK4643",
  377. .codec = "ak4642-codec.0-0012",
  378. .platform = "rcar_sound",
  379. .daifmt = SND_SOC_DAIFMT_LEFT_J,
  380. .cpu_dai = {
  381. .name = "rsnd-dai.0",
  382. .fmt = SND_SOC_DAIFMT_CBS_CFS,
  383. },
  384. .codec_dai = {
  385. .name = "ak4642-hifi",
  386. .fmt = SND_SOC_DAIFMT_CBM_CFM,
  387. .sysclk = 11289600,
  388. },
  389. },
  390. /* SSI3 */
  391. {
  392. .name = "AK4554",
  393. .card = "SSI3-AK4554(playback)",
  394. .codec = "ak4554-adc-dac.0",
  395. .platform = "rcar_sound",
  396. .cpu_dai = {
  397. .name = "rsnd-dai.1",
  398. .fmt = SND_SOC_DAIFMT_CBM_CFM |
  399. SND_SOC_DAIFMT_RIGHT_J,
  400. },
  401. .codec_dai = {
  402. .name = "ak4554-hifi",
  403. },
  404. },
  405. /* SSI4 */
  406. {
  407. .name = "AK4554",
  408. .card = "SSI4-AK4554(capture)",
  409. .codec = "ak4554-adc-dac.0",
  410. .platform = "rcar_sound",
  411. .cpu_dai = {
  412. .name = "rsnd-dai.2",
  413. .fmt = SND_SOC_DAIFMT_CBM_CFM |
  414. SND_SOC_DAIFMT_LEFT_J,
  415. },
  416. .codec_dai = {
  417. .name = "ak4554-hifi",
  418. },
  419. },
  420. /* SSI7 */
  421. {
  422. .name = "AK4554",
  423. .card = "SSI7-AK4554(playback)",
  424. .codec = "ak4554-adc-dac.1",
  425. .platform = "rcar_sound",
  426. .cpu_dai = {
  427. .name = "rsnd-dai.3",
  428. .fmt = SND_SOC_DAIFMT_CBM_CFM |
  429. SND_SOC_DAIFMT_RIGHT_J,
  430. },
  431. .codec_dai = {
  432. .name = "ak4554-hifi",
  433. },
  434. },
  435. /* SSI8 */
  436. {
  437. .name = "AK4554",
  438. .card = "SSI8-AK4554(capture)",
  439. .codec = "ak4554-adc-dac.1",
  440. .platform = "rcar_sound",
  441. .cpu_dai = {
  442. .name = "rsnd-dai.4",
  443. .fmt = SND_SOC_DAIFMT_CBM_CFM |
  444. SND_SOC_DAIFMT_LEFT_J,
  445. },
  446. .codec_dai = {
  447. .name = "ak4554-hifi",
  448. },
  449. }
  450. };
  451. static const struct pinctrl_map bockw_pinctrl_map[] = {
  452. /* AUDIO */
  453. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  454. "audio_clk_a", "audio_clk"),
  455. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  456. "audio_clk_b", "audio_clk"),
  457. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  458. "ssi34_ctrl", "ssi"),
  459. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  460. "ssi3_data", "ssi"),
  461. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  462. "ssi4_data", "ssi"),
  463. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  464. "ssi5_ctrl", "ssi"),
  465. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  466. "ssi5_data", "ssi"),
  467. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  468. "ssi6_ctrl", "ssi"),
  469. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  470. "ssi6_data", "ssi"),
  471. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  472. "ssi78_ctrl", "ssi"),
  473. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  474. "ssi7_data", "ssi"),
  475. PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7778",
  476. "ssi8_data", "ssi"),
  477. /* Ether */
  478. PIN_MAP_MUX_GROUP_DEFAULT("r8a777x-ether", "pfc-r8a7778",
  479. "ether_rmii", "ether"),
  480. /* HSPI0 */
  481. PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7778",
  482. "hspi0_a", "hspi0"),
  483. /* MMC */
  484. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif", "pfc-r8a7778",
  485. "mmc_data8", "mmc"),
  486. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif", "pfc-r8a7778",
  487. "mmc_ctrl", "mmc"),
  488. /* SCIF0 */
  489. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
  490. "scif0_data_a", "scif0"),
  491. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
  492. "scif0_ctrl", "scif0"),
  493. /* USB */
  494. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778",
  495. "usb0", "usb0"),
  496. PIN_MAP_MUX_GROUP_DEFAULT(USB1_DEVICE, "pfc-r8a7778",
  497. "usb1", "usb1"),
  498. /* SDHI0 */
  499. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
  500. "sdhi0_data4", "sdhi0"),
  501. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
  502. "sdhi0_ctrl", "sdhi0"),
  503. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
  504. "sdhi0_cd", "sdhi0"),
  505. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
  506. "sdhi0_wp", "sdhi0"),
  507. /* VIN0 */
  508. PIN_MAP_MUX_GROUP_DEFAULT("r8a7778-vin.0", "pfc-r8a7778",
  509. "vin0_clk", "vin0"),
  510. PIN_MAP_MUX_GROUP_DEFAULT("r8a7778-vin.0", "pfc-r8a7778",
  511. "vin0_data8", "vin0"),
  512. /* VIN1 */
  513. PIN_MAP_MUX_GROUP_DEFAULT("r8a7778-vin.1", "pfc-r8a7778",
  514. "vin1_clk", "vin1"),
  515. PIN_MAP_MUX_GROUP_DEFAULT("r8a7778-vin.1", "pfc-r8a7778",
  516. "vin1_data8", "vin1"),
  517. };
  518. #define PFC 0xfffc0000
  519. #define PUPR4 0x110
  520. static void __init bockw_init(void)
  521. {
  522. void __iomem *base;
  523. struct clk *clk;
  524. int i;
  525. r8a7778_clock_init();
  526. r8a7778_init_irq_extpin(1);
  527. r8a7778_add_standard_devices();
  528. platform_device_register_resndata(&platform_bus, "r8a777x-ether", -1,
  529. ether_resources,
  530. ARRAY_SIZE(ether_resources),
  531. &ether_platform_data,
  532. sizeof(ether_platform_data));
  533. platform_device_register_full(&vin0_info);
  534. /* VIN1 has a pin conflict with Ether */
  535. if (!IS_ENABLED(CONFIG_SH_ETH))
  536. platform_device_register_full(&vin1_info);
  537. platform_device_register_data(&platform_bus, "soc-camera-pdrv", 0,
  538. &iclink0_ml86v7667,
  539. sizeof(iclink0_ml86v7667));
  540. platform_device_register_data(&platform_bus, "soc-camera-pdrv", 1,
  541. &iclink1_ml86v7667,
  542. sizeof(iclink1_ml86v7667));
  543. i2c_register_board_info(0, i2c0_devices,
  544. ARRAY_SIZE(i2c0_devices));
  545. spi_register_board_info(spi_board_info,
  546. ARRAY_SIZE(spi_board_info));
  547. pinctrl_register_mappings(bockw_pinctrl_map,
  548. ARRAY_SIZE(bockw_pinctrl_map));
  549. r8a7778_pinmux_init();
  550. platform_device_register_resndata(
  551. &platform_bus, "sh_mmcif", -1,
  552. mmc_resources, ARRAY_SIZE(mmc_resources),
  553. &sh_mmcif_plat, sizeof(struct sh_mmcif_plat_data));
  554. platform_device_register_resndata(
  555. &platform_bus, "rcar_usb_phy", -1,
  556. usb_phy_resources,
  557. ARRAY_SIZE(usb_phy_resources),
  558. &usb_phy_platform_data,
  559. sizeof(struct rcar_phy_platform_data));
  560. regulator_register_fixed(0, dummy_supplies,
  561. ARRAY_SIZE(dummy_supplies));
  562. regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
  563. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  564. /* for SMSC */
  565. fpga = ioremap_nocache(FPGA, SZ_1M);
  566. if (fpga) {
  567. /*
  568. * CAUTION
  569. *
  570. * IRQ0/1 is cascaded interrupt from FPGA.
  571. * it should be cared in the future
  572. * Now, it is assuming IRQ0 was used only from SMSC.
  573. */
  574. u16 val = ioread16(fpga + IRQ0MR);
  575. val &= ~(1 << 4); /* enable SMSC911x */
  576. iowrite16(val, fpga + IRQ0MR);
  577. platform_device_register_resndata(
  578. &platform_bus, "smsc911x", -1,
  579. smsc911x_resources, ARRAY_SIZE(smsc911x_resources),
  580. &smsc911x_data, sizeof(smsc911x_data));
  581. }
  582. /* for SDHI */
  583. base = ioremap_nocache(PFC, 0x200);
  584. if (base) {
  585. /*
  586. * FIXME
  587. *
  588. * SDHI CD/WP pin needs pull-up
  589. */
  590. iowrite32(ioread32(base + PUPR4) | (3 << 26), base + PUPR4);
  591. iounmap(base);
  592. platform_device_register_resndata(
  593. &platform_bus, "sh_mobile_sdhi", 0,
  594. sdhi0_resources, ARRAY_SIZE(sdhi0_resources),
  595. &sdhi0_info, sizeof(struct sh_mobile_sdhi_info));
  596. }
  597. /* for Audio */
  598. clk = clk_get(NULL, "audio_clk_b");
  599. clk_set_rate(clk, 24576000);
  600. clk_put(clk);
  601. rsnd_codec_power(5, 1); /* enable ak4642 */
  602. platform_device_register_simple(
  603. "ak4554-adc-dac", 0, NULL, 0);
  604. platform_device_register_simple(
  605. "ak4554-adc-dac", 1, NULL, 0);
  606. platform_device_register_resndata(
  607. &platform_bus, "rcar_sound", -1,
  608. rsnd_resources, ARRAY_SIZE(rsnd_resources),
  609. &rsnd_info, sizeof(rsnd_info));
  610. for (i = 0; i < ARRAY_SIZE(rsnd_card_info); i++) {
  611. struct platform_device_info cardinfo = {
  612. .parent = &platform_bus,
  613. .name = "asoc-simple-card",
  614. .id = i,
  615. .data = &rsnd_card_info[i],
  616. .size_data = sizeof(struct asoc_simple_card_info),
  617. .dma_mask = DMA_BIT_MASK(32),
  618. };
  619. platform_device_register_full(&cardinfo);
  620. }
  621. }
  622. static void __init bockw_init_late(void)
  623. {
  624. r8a7778_init_late();
  625. ADD_USB_FUNC_DEVICE_IF_POSSIBLE();
  626. }
  627. static const char *bockw_boards_compat_dt[] __initdata = {
  628. "renesas,bockw",
  629. NULL,
  630. };
  631. DT_MACHINE_START(BOCKW_DT, "bockw")
  632. .init_early = r8a7778_init_delay,
  633. .init_irq = r8a7778_init_irq_dt,
  634. .init_machine = bockw_init,
  635. .dt_compat = bockw_boards_compat_dt,
  636. .init_late = bockw_init_late,
  637. MACHINE_END