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