board-koelsch.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /*
  2. * Koelsch board support
  3. *
  4. * Copyright (C) 2013 Renesas Electronics Corporation
  5. * Copyright (C) 2013-2014 Renesas Solutions Corp.
  6. * Copyright (C) 2013 Magnus Damm
  7. * Copyright (C) 2014 Cogent Embedded, Inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; version 2 of the License.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include <linux/dma-mapping.h>
  23. #include <linux/gpio.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/input.h>
  26. #include <linux/irq.h>
  27. #include <linux/kernel.h>
  28. #include <linux/leds.h>
  29. #include <linux/mfd/tmio.h>
  30. #include <linux/mmc/host.h>
  31. #include <linux/mmc/sh_mobile_sdhi.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/phy.h>
  35. #include <linux/pinctrl/machine.h>
  36. #include <linux/platform_data/gpio-rcar.h>
  37. #include <linux/platform_data/rcar-du.h>
  38. #include <linux/platform_device.h>
  39. #include <linux/regulator/driver.h>
  40. #include <linux/regulator/fixed.h>
  41. #include <linux/regulator/gpio-regulator.h>
  42. #include <linux/regulator/machine.h>
  43. #include <linux/sh_eth.h>
  44. #include <linux/spi/flash.h>
  45. #include <linux/spi/rspi.h>
  46. #include <linux/spi/spi.h>
  47. #include <mach/common.h>
  48. #include <mach/irqs.h>
  49. #include <mach/r8a7791.h>
  50. #include <mach/rcar-gen2.h>
  51. #include <asm/mach-types.h>
  52. #include <asm/mach/arch.h>
  53. /* DU */
  54. static struct rcar_du_encoder_data koelsch_du_encoders[] = {
  55. {
  56. .type = RCAR_DU_ENCODER_NONE,
  57. .output = RCAR_DU_OUTPUT_LVDS0,
  58. .connector.lvds.panel = {
  59. .width_mm = 210,
  60. .height_mm = 158,
  61. .mode = {
  62. .clock = 65000,
  63. .hdisplay = 1024,
  64. .hsync_start = 1048,
  65. .hsync_end = 1184,
  66. .htotal = 1344,
  67. .vdisplay = 768,
  68. .vsync_start = 771,
  69. .vsync_end = 777,
  70. .vtotal = 806,
  71. .flags = 0,
  72. },
  73. },
  74. },
  75. };
  76. static const struct rcar_du_platform_data koelsch_du_pdata __initconst = {
  77. .encoders = koelsch_du_encoders,
  78. .num_encoders = ARRAY_SIZE(koelsch_du_encoders),
  79. };
  80. static const struct resource du_resources[] __initconst = {
  81. DEFINE_RES_MEM(0xfeb00000, 0x40000),
  82. DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
  83. DEFINE_RES_IRQ(gic_spi(256)),
  84. DEFINE_RES_IRQ(gic_spi(268)),
  85. };
  86. static void __init koelsch_add_du_device(void)
  87. {
  88. struct platform_device_info info = {
  89. .name = "rcar-du-r8a7791",
  90. .id = -1,
  91. .res = du_resources,
  92. .num_res = ARRAY_SIZE(du_resources),
  93. .data = &koelsch_du_pdata,
  94. .size_data = sizeof(koelsch_du_pdata),
  95. .dma_mask = DMA_BIT_MASK(32),
  96. };
  97. platform_device_register_full(&info);
  98. }
  99. /* Ether */
  100. static const struct sh_eth_plat_data ether_pdata __initconst = {
  101. .phy = 0x1,
  102. .phy_irq = irq_pin(0),
  103. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  104. .phy_interface = PHY_INTERFACE_MODE_RMII,
  105. .ether_link_active_low = 1,
  106. };
  107. static const struct resource ether_resources[] __initconst = {
  108. DEFINE_RES_MEM(0xee700000, 0x400),
  109. DEFINE_RES_IRQ(gic_spi(162)),
  110. };
  111. static const struct platform_device_info ether_info __initconst = {
  112. .parent = &platform_bus,
  113. .name = "r8a7791-ether",
  114. .id = -1,
  115. .res = ether_resources,
  116. .num_res = ARRAY_SIZE(ether_resources),
  117. .data = &ether_pdata,
  118. .size_data = sizeof(ether_pdata),
  119. .dma_mask = DMA_BIT_MASK(32),
  120. };
  121. /* LEDS */
  122. static struct gpio_led koelsch_leds[] = {
  123. {
  124. .name = "led8",
  125. .gpio = RCAR_GP_PIN(2, 21),
  126. .default_state = LEDS_GPIO_DEFSTATE_ON,
  127. }, {
  128. .name = "led7",
  129. .gpio = RCAR_GP_PIN(2, 20),
  130. .default_state = LEDS_GPIO_DEFSTATE_ON,
  131. }, {
  132. .name = "led6",
  133. .gpio = RCAR_GP_PIN(2, 19),
  134. .default_state = LEDS_GPIO_DEFSTATE_ON,
  135. },
  136. };
  137. static const struct gpio_led_platform_data koelsch_leds_pdata __initconst = {
  138. .leds = koelsch_leds,
  139. .num_leds = ARRAY_SIZE(koelsch_leds),
  140. };
  141. /* GPIO KEY */
  142. #define GPIO_KEY(c, g, d, ...) \
  143. { .code = c, .gpio = g, .desc = d, .active_low = 1, \
  144. .wakeup = 1, .debounce_interval = 20 }
  145. static struct gpio_keys_button gpio_buttons[] = {
  146. GPIO_KEY(KEY_4, RCAR_GP_PIN(5, 3), "SW2-pin4"),
  147. GPIO_KEY(KEY_3, RCAR_GP_PIN(5, 2), "SW2-pin3"),
  148. GPIO_KEY(KEY_2, RCAR_GP_PIN(5, 1), "SW2-pin2"),
  149. GPIO_KEY(KEY_1, RCAR_GP_PIN(5, 0), "SW2-pin1"),
  150. GPIO_KEY(KEY_G, RCAR_GP_PIN(7, 6), "SW36"),
  151. GPIO_KEY(KEY_F, RCAR_GP_PIN(7, 5), "SW35"),
  152. GPIO_KEY(KEY_E, RCAR_GP_PIN(7, 4), "SW34"),
  153. GPIO_KEY(KEY_D, RCAR_GP_PIN(7, 3), "SW33"),
  154. GPIO_KEY(KEY_C, RCAR_GP_PIN(7, 2), "SW32"),
  155. GPIO_KEY(KEY_B, RCAR_GP_PIN(7, 1), "SW31"),
  156. GPIO_KEY(KEY_A, RCAR_GP_PIN(7, 0), "SW30"),
  157. };
  158. static const struct gpio_keys_platform_data koelsch_keys_pdata __initconst = {
  159. .buttons = gpio_buttons,
  160. .nbuttons = ARRAY_SIZE(gpio_buttons),
  161. };
  162. /* QSPI */
  163. static const struct resource qspi_resources[] __initconst = {
  164. DEFINE_RES_MEM(0xe6b10000, 0x1000),
  165. DEFINE_RES_IRQ_NAMED(gic_spi(184), "mux"),
  166. };
  167. static const struct rspi_plat_data qspi_pdata __initconst = {
  168. .num_chipselect = 1,
  169. };
  170. /* SPI Flash memory (Spansion S25FL512SAGMFIG11 64 MiB) */
  171. static struct mtd_partition spi_flash_part[] = {
  172. {
  173. .name = "loader",
  174. .offset = 0x00000000,
  175. .size = 512 * 1024,
  176. .mask_flags = MTD_WRITEABLE,
  177. },
  178. {
  179. .name = "bootenv",
  180. .offset = MTDPART_OFS_APPEND,
  181. .size = 512 * 1024,
  182. .mask_flags = MTD_WRITEABLE,
  183. },
  184. {
  185. .name = "data",
  186. .offset = MTDPART_OFS_APPEND,
  187. .size = MTDPART_SIZ_FULL,
  188. },
  189. };
  190. static const struct flash_platform_data spi_flash_data = {
  191. .name = "m25p80",
  192. .parts = spi_flash_part,
  193. .nr_parts = ARRAY_SIZE(spi_flash_part),
  194. .type = "s25fl512s",
  195. };
  196. static const struct spi_board_info spi_info[] __initconst = {
  197. {
  198. .modalias = "m25p80",
  199. .platform_data = &spi_flash_data,
  200. .mode = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD,
  201. .max_speed_hz = 30000000,
  202. .bus_num = 0,
  203. .chip_select = 0,
  204. },
  205. };
  206. /* SATA0 */
  207. static const struct resource sata0_resources[] __initconst = {
  208. DEFINE_RES_MEM(0xee300000, 0x2000),
  209. DEFINE_RES_IRQ(gic_spi(105)),
  210. };
  211. static const struct platform_device_info sata0_info __initconst = {
  212. .parent = &platform_bus,
  213. .name = "sata-r8a7791",
  214. .id = 0,
  215. .res = sata0_resources,
  216. .num_res = ARRAY_SIZE(sata0_resources),
  217. .dma_mask = DMA_BIT_MASK(32),
  218. };
  219. /* I2C */
  220. static const struct resource i2c_resources[] __initconst = {
  221. /* I2C0 */
  222. DEFINE_RES_MEM(0xE6508000, 0x40),
  223. DEFINE_RES_IRQ(gic_spi(287)),
  224. /* I2C1 */
  225. DEFINE_RES_MEM(0xE6518000, 0x40),
  226. DEFINE_RES_IRQ(gic_spi(288)),
  227. /* I2C2 */
  228. DEFINE_RES_MEM(0xE6530000, 0x40),
  229. DEFINE_RES_IRQ(gic_spi(286)),
  230. /* I2C3 */
  231. DEFINE_RES_MEM(0xE6540000, 0x40),
  232. DEFINE_RES_IRQ(gic_spi(290)),
  233. /* I2C4 */
  234. DEFINE_RES_MEM(0xE6520000, 0x40),
  235. DEFINE_RES_IRQ(gic_spi(19)),
  236. /* I2C5 */
  237. DEFINE_RES_MEM(0xE6528000, 0x40),
  238. DEFINE_RES_IRQ(gic_spi(20)),
  239. };
  240. static void __init koelsch_add_i2c(unsigned idx)
  241. {
  242. unsigned res_idx = idx * 2;
  243. BUG_ON(res_idx >= ARRAY_SIZE(i2c_resources));
  244. platform_device_register_simple("i2c-rcar_gen2", idx,
  245. i2c_resources + res_idx, 2);
  246. }
  247. #define SDHI_REGULATOR(idx, vdd_pin, vccq_pin) \
  248. static struct regulator_consumer_supply vcc_sdhi##idx##_consumer = \
  249. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi." #idx); \
  250. \
  251. static struct regulator_init_data vcc_sdhi##idx##_init_data = { \
  252. .constraints = { \
  253. .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
  254. }, \
  255. .consumer_supplies = &vcc_sdhi##idx##_consumer, \
  256. .num_consumer_supplies = 1, \
  257. }; \
  258. \
  259. static const struct fixed_voltage_config vcc_sdhi##idx##_info __initconst = {\
  260. .supply_name = "SDHI" #idx "Vcc", \
  261. .microvolts = 3300000, \
  262. .gpio = vdd_pin, \
  263. .enable_high = 1, \
  264. .init_data = &vcc_sdhi##idx##_init_data, \
  265. }; \
  266. \
  267. static struct regulator_consumer_supply vccq_sdhi##idx##_consumer = \
  268. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi." #idx); \
  269. \
  270. static struct regulator_init_data vccq_sdhi##idx##_init_data = { \
  271. .constraints = { \
  272. .input_uV = 3300000, \
  273. .min_uV = 1800000, \
  274. .max_uV = 3300000, \
  275. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | \
  276. REGULATOR_CHANGE_STATUS, \
  277. }, \
  278. .consumer_supplies = &vccq_sdhi##idx##_consumer, \
  279. .num_consumer_supplies = 1, \
  280. }; \
  281. \
  282. static struct gpio vccq_sdhi##idx##_gpio = \
  283. { vccq_pin, GPIOF_OUT_INIT_HIGH, "vccq-sdhi" #idx }; \
  284. \
  285. static struct gpio_regulator_state vccq_sdhi##idx##_states[] = { \
  286. { .value = 1800000, .gpios = 0 }, \
  287. { .value = 3300000, .gpios = 1 }, \
  288. }; \
  289. \
  290. static const struct gpio_regulator_config vccq_sdhi##idx##_info __initconst = {\
  291. .supply_name = "vqmmc", \
  292. .gpios = &vccq_sdhi##idx##_gpio, \
  293. .nr_gpios = 1, \
  294. .states = vccq_sdhi##idx##_states, \
  295. .nr_states = ARRAY_SIZE(vccq_sdhi##idx##_states), \
  296. .type = REGULATOR_VOLTAGE, \
  297. .init_data = &vccq_sdhi##idx##_init_data, \
  298. };
  299. SDHI_REGULATOR(0, RCAR_GP_PIN(7, 17), RCAR_GP_PIN(2, 12));
  300. SDHI_REGULATOR(1, RCAR_GP_PIN(7, 18), RCAR_GP_PIN(2, 13));
  301. SDHI_REGULATOR(2, RCAR_GP_PIN(7, 19), RCAR_GP_PIN(2, 26));
  302. /* SDHI0 */
  303. static struct sh_mobile_sdhi_info sdhi0_info __initdata = {
  304. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  305. MMC_CAP_POWER_OFF_CARD,
  306. .tmio_caps2 = MMC_CAP2_NO_MULTI_READ,
  307. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  308. };
  309. static struct resource sdhi0_resources[] __initdata = {
  310. DEFINE_RES_MEM(0xee100000, 0x200),
  311. DEFINE_RES_IRQ(gic_spi(165)),
  312. };
  313. /* SDHI1 */
  314. static struct sh_mobile_sdhi_info sdhi1_info __initdata = {
  315. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  316. MMC_CAP_POWER_OFF_CARD,
  317. .tmio_caps2 = MMC_CAP2_NO_MULTI_READ,
  318. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  319. };
  320. static struct resource sdhi1_resources[] __initdata = {
  321. DEFINE_RES_MEM(0xee140000, 0x100),
  322. DEFINE_RES_IRQ(gic_spi(167)),
  323. };
  324. /* SDHI2 */
  325. static struct sh_mobile_sdhi_info sdhi2_info __initdata = {
  326. .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
  327. MMC_CAP_POWER_OFF_CARD,
  328. .tmio_caps2 = MMC_CAP2_NO_MULTI_READ,
  329. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
  330. TMIO_MMC_WRPROTECT_DISABLE,
  331. };
  332. static struct resource sdhi2_resources[] __initdata = {
  333. DEFINE_RES_MEM(0xee160000, 0x100),
  334. DEFINE_RES_IRQ(gic_spi(168)),
  335. };
  336. static const struct pinctrl_map koelsch_pinctrl_map[] = {
  337. /* DU */
  338. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791",
  339. "du_rgb666", "du"),
  340. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791",
  341. "du_sync", "du"),
  342. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791",
  343. "du_clk_out_0", "du"),
  344. /* Ether */
  345. PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
  346. "eth_link", "eth"),
  347. PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
  348. "eth_mdio", "eth"),
  349. PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
  350. "eth_rmii", "eth"),
  351. PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
  352. "intc_irq0", "intc"),
  353. /* QSPI */
  354. PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7791",
  355. "qspi_ctrl", "qspi"),
  356. PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7791",
  357. "qspi_data4", "qspi"),
  358. /* SCIF0 (CN19: DEBUG SERIAL0) */
  359. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7791",
  360. "scif0_data_d", "scif0"),
  361. /* SCIF1 (CN20: DEBUG SERIAL1) */
  362. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7791",
  363. "scif1_data_d", "scif1"),
  364. /* I2C1 */
  365. PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.1", "pfc-r8a7791",
  366. "i2c1_e", "i2c1"),
  367. /* I2C2 */
  368. PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.2", "pfc-r8a7791",
  369. "i2c2", "i2c2"),
  370. /* I2C4 */
  371. PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.4", "pfc-r8a7791",
  372. "i2c4_c", "i2c4"),
  373. /* SDHI0 */
  374. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
  375. "sdhi0_data4", "sdhi0"),
  376. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
  377. "sdhi0_ctrl", "sdhi0"),
  378. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
  379. "sdhi0_cd", "sdhi0"),
  380. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
  381. "sdhi0_wp", "sdhi0"),
  382. /* SDHI2 */
  383. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
  384. "sdhi1_data4", "sdhi1"),
  385. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
  386. "sdhi1_ctrl", "sdhi1"),
  387. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
  388. "sdhi1_cd", "sdhi1"),
  389. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
  390. "sdhi1_wp", "sdhi1"),
  391. /* SDHI2 */
  392. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791",
  393. "sdhi2_data4", "sdhi2"),
  394. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791",
  395. "sdhi2_ctrl", "sdhi2"),
  396. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791",
  397. "sdhi2_cd", "sdhi2"),
  398. };
  399. static void __init koelsch_add_standard_devices(void)
  400. {
  401. r8a7791_clock_init();
  402. pinctrl_register_mappings(koelsch_pinctrl_map,
  403. ARRAY_SIZE(koelsch_pinctrl_map));
  404. r8a7791_pinmux_init();
  405. r8a7791_add_standard_devices();
  406. platform_device_register_full(&ether_info);
  407. platform_device_register_data(&platform_bus, "leds-gpio", -1,
  408. &koelsch_leds_pdata,
  409. sizeof(koelsch_leds_pdata));
  410. platform_device_register_data(&platform_bus, "gpio-keys", -1,
  411. &koelsch_keys_pdata,
  412. sizeof(koelsch_keys_pdata));
  413. platform_device_register_resndata(&platform_bus, "qspi", 0,
  414. qspi_resources,
  415. ARRAY_SIZE(qspi_resources),
  416. &qspi_pdata, sizeof(qspi_pdata));
  417. spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
  418. koelsch_add_du_device();
  419. platform_device_register_full(&sata0_info);
  420. koelsch_add_i2c(1);
  421. koelsch_add_i2c(2);
  422. koelsch_add_i2c(4);
  423. koelsch_add_i2c(5);
  424. platform_device_register_data(&platform_bus, "reg-fixed-voltage", 0,
  425. &vcc_sdhi0_info, sizeof(struct fixed_voltage_config));
  426. platform_device_register_data(&platform_bus, "reg-fixed-voltage", 1,
  427. &vcc_sdhi1_info, sizeof(struct fixed_voltage_config));
  428. platform_device_register_data(&platform_bus, "reg-fixed-voltage", 2,
  429. &vcc_sdhi2_info, sizeof(struct fixed_voltage_config));
  430. platform_device_register_data(&platform_bus, "gpio-regulator", 0,
  431. &vccq_sdhi0_info, sizeof(struct gpio_regulator_config));
  432. platform_device_register_data(&platform_bus, "gpio-regulator", 1,
  433. &vccq_sdhi1_info, sizeof(struct gpio_regulator_config));
  434. platform_device_register_data(&platform_bus, "gpio-regulator", 2,
  435. &vccq_sdhi2_info, sizeof(struct gpio_regulator_config));
  436. platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 0,
  437. sdhi0_resources, ARRAY_SIZE(sdhi0_resources),
  438. &sdhi0_info, sizeof(struct sh_mobile_sdhi_info));
  439. platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 1,
  440. sdhi1_resources, ARRAY_SIZE(sdhi1_resources),
  441. &sdhi1_info, sizeof(struct sh_mobile_sdhi_info));
  442. platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 2,
  443. sdhi2_resources, ARRAY_SIZE(sdhi2_resources),
  444. &sdhi2_info, sizeof(struct sh_mobile_sdhi_info));
  445. }
  446. /*
  447. * Ether LEDs on the Koelsch board are named LINK and ACTIVE which corresponds
  448. * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits
  449. * 14-15. We have to set them back to 01 from the default 00 value each time
  450. * the PHY is reset. It's also important because the PHY's LED0 signal is
  451. * connected to SoC's ETH_LINK signal and in the PHY's default mode it will
  452. * bounce on and off after each packet, which we apparently want to avoid.
  453. */
  454. static int koelsch_ksz8041_fixup(struct phy_device *phydev)
  455. {
  456. u16 phyctrl1 = phy_read(phydev, 0x1e);
  457. phyctrl1 &= ~0xc000;
  458. phyctrl1 |= 0x4000;
  459. return phy_write(phydev, 0x1e, phyctrl1);
  460. }
  461. static void __init koelsch_init(void)
  462. {
  463. koelsch_add_standard_devices();
  464. irq_set_irq_type(irq_pin(0), IRQ_TYPE_LEVEL_LOW);
  465. if (IS_ENABLED(CONFIG_PHYLIB))
  466. phy_register_fixup_for_id("r8a7791-ether-ff:01",
  467. koelsch_ksz8041_fixup);
  468. }
  469. static const char * const koelsch_boards_compat_dt[] __initconst = {
  470. "renesas,koelsch",
  471. NULL,
  472. };
  473. DT_MACHINE_START(KOELSCH_DT, "koelsch")
  474. .smp = smp_ops(r8a7791_smp_ops),
  475. .init_early = shmobile_init_delay,
  476. .init_time = rcar_gen2_timer_init,
  477. .init_machine = koelsch_init,
  478. .init_late = shmobile_init_late,
  479. .dt_compat = koelsch_boards_compat_dt,
  480. MACHINE_END