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