ARM: shmobile: lager: Add USBHS support
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / arm / mach-shmobile / board-lager.c
1 /*
2  * Lager board support
3  *
4  * Copyright (C) 2013  Renesas Solutions Corp.
5  * Copyright (C) 2013  Magnus Damm
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21 #include <linux/gpio.h>
22 #include <linux/gpio_keys.h>
23 #include <linux/input.h>
24 #include <linux/interrupt.h>
25 #include <linux/kernel.h>
26 #include <linux/leds.h>
27 #include <linux/mmc/host.h>
28 #include <linux/mmc/sh_mmcif.h>
29 #include <linux/pinctrl/machine.h>
30 #include <linux/platform_data/camera-rcar.h>
31 #include <linux/platform_data/gpio-rcar.h>
32 #include <linux/platform_data/rcar-du.h>
33 #include <linux/platform_data/usb-rcar-gen2-phy.h>
34 #include <linux/platform_device.h>
35 #include <linux/phy.h>
36 #include <linux/regulator/driver.h>
37 #include <linux/regulator/fixed.h>
38 #include <linux/regulator/gpio-regulator.h>
39 #include <linux/regulator/machine.h>
40 #include <linux/sh_eth.h>
41 #include <linux/usb/phy.h>
42 #include <linux/usb/renesas_usbhs.h>
43 #include <mach/common.h>
44 #include <mach/irqs.h>
45 #include <mach/r8a7790.h>
46 #include <media/soc_camera.h>
47 #include <asm/mach-types.h>
48 #include <asm/mach/arch.h>
49 #include <linux/mtd/partitions.h>
50 #include <linux/mtd/mtd.h>
51 #include <linux/spi/flash.h>
52 #include <linux/spi/rspi.h>
53 #include <linux/spi/spi.h>
54
55 /* DU */
56 static struct rcar_du_encoder_data lager_du_encoders[] = {
57         {
58                 .type = RCAR_DU_ENCODER_VGA,
59                 .output = RCAR_DU_OUTPUT_DPAD0,
60         }, {
61                 .type = RCAR_DU_ENCODER_NONE,
62                 .output = RCAR_DU_OUTPUT_LVDS1,
63                 .connector.lvds.panel = {
64                         .width_mm = 210,
65                         .height_mm = 158,
66                         .mode = {
67                                 .clock = 65000,
68                                 .hdisplay = 1024,
69                                 .hsync_start = 1048,
70                                 .hsync_end = 1184,
71                                 .htotal = 1344,
72                                 .vdisplay = 768,
73                                 .vsync_start = 771,
74                                 .vsync_end = 777,
75                                 .vtotal = 806,
76                                 .flags = 0,
77                         },
78                 },
79         },
80 };
81
82 static const struct rcar_du_platform_data lager_du_pdata __initconst = {
83         .encoders = lager_du_encoders,
84         .num_encoders = ARRAY_SIZE(lager_du_encoders),
85 };
86
87 static const struct resource du_resources[] __initconst = {
88         DEFINE_RES_MEM(0xfeb00000, 0x70000),
89         DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
90         DEFINE_RES_MEM_NAMED(0xfeb94000, 0x1c, "lvds.1"),
91         DEFINE_RES_IRQ(gic_spi(256)),
92         DEFINE_RES_IRQ(gic_spi(268)),
93         DEFINE_RES_IRQ(gic_spi(269)),
94 };
95
96 static void __init lager_add_du_device(void)
97 {
98         struct platform_device_info info = {
99                 .name = "rcar-du-r8a7790",
100                 .id = -1,
101                 .res = du_resources,
102                 .num_res = ARRAY_SIZE(du_resources),
103                 .data = &lager_du_pdata,
104                 .size_data = sizeof(lager_du_pdata),
105                 .dma_mask = DMA_BIT_MASK(32),
106         };
107
108         platform_device_register_full(&info);
109 }
110
111 /* LEDS */
112 static struct gpio_led lager_leds[] = {
113         {
114                 .name           = "led8",
115                 .gpio           = RCAR_GP_PIN(5, 17),
116                 .default_state  = LEDS_GPIO_DEFSTATE_ON,
117         }, {
118                 .name           = "led7",
119                 .gpio           = RCAR_GP_PIN(4, 23),
120                 .default_state  = LEDS_GPIO_DEFSTATE_ON,
121         }, {
122                 .name           = "led6",
123                 .gpio           = RCAR_GP_PIN(4, 22),
124                 .default_state  = LEDS_GPIO_DEFSTATE_ON,
125         },
126 };
127
128 static const struct gpio_led_platform_data lager_leds_pdata __initconst = {
129         .leds           = lager_leds,
130         .num_leds       = ARRAY_SIZE(lager_leds),
131 };
132
133 /* GPIO KEY */
134 #define GPIO_KEY(c, g, d, ...) \
135         { .code = c, .gpio = g, .desc = d, .active_low = 1, \
136           .wakeup = 1, .debounce_interval = 20 }
137
138 static struct gpio_keys_button gpio_buttons[] = {
139         GPIO_KEY(KEY_4,         RCAR_GP_PIN(1, 28),     "SW2-pin4"),
140         GPIO_KEY(KEY_3,         RCAR_GP_PIN(1, 26),     "SW2-pin3"),
141         GPIO_KEY(KEY_2,         RCAR_GP_PIN(1, 24),     "SW2-pin2"),
142         GPIO_KEY(KEY_1,         RCAR_GP_PIN(1, 14),     "SW2-pin1"),
143 };
144
145 static const struct gpio_keys_platform_data lager_keys_pdata __initconst = {
146         .buttons        = gpio_buttons,
147         .nbuttons       = ARRAY_SIZE(gpio_buttons),
148 };
149
150 /* Fixed 3.3V regulator to be used by MMCIF */
151 static struct regulator_consumer_supply fixed3v3_power_consumers[] =
152 {
153         REGULATOR_SUPPLY("vmmc", "sh_mmcif.1"),
154 };
155
156 /*
157  * SDHI regulator macro
158  *
159  ** FIXME**
160  * Lager board vqmmc is provided via DA9063 PMIC chip,
161  * and we should use ${LINK}/drivers/mfd/da9063-* driver for it.
162  * but, it doesn't have regulator support at this point.
163  * It uses gpio-regulator for vqmmc as quick-hack.
164  */
165 #define SDHI_REGULATOR(idx, vdd_pin, vccq_pin)                          \
166 static struct regulator_consumer_supply vcc_sdhi##idx##_consumer =      \
167         REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi." #idx);               \
168                                                                         \
169 static struct regulator_init_data vcc_sdhi##idx##_init_data = {         \
170         .constraints = {                                                \
171                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,              \
172         },                                                              \
173         .consumer_supplies      = &vcc_sdhi##idx##_consumer,            \
174         .num_consumer_supplies  = 1,                                    \
175 };                                                                      \
176                                                                         \
177 static const struct fixed_voltage_config vcc_sdhi##idx##_info __initconst = {\
178         .supply_name    = "SDHI" #idx "Vcc",                            \
179         .microvolts     = 3300000,                                      \
180         .gpio           = vdd_pin,                                      \
181         .enable_high    = 1,                                            \
182         .init_data      = &vcc_sdhi##idx##_init_data,                   \
183 };                                                                      \
184                                                                         \
185 static struct regulator_consumer_supply vccq_sdhi##idx##_consumer =     \
186         REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi." #idx);              \
187                                                                         \
188 static struct regulator_init_data vccq_sdhi##idx##_init_data = {        \
189         .constraints = {                                                \
190                 .input_uV       = 3300000,                              \
191                 .min_uV         = 1800000,                              \
192                 .max_uV         = 3300000,                              \
193                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |            \
194                                   REGULATOR_CHANGE_STATUS,              \
195         },                                                              \
196         .consumer_supplies      = &vccq_sdhi##idx##_consumer,           \
197         .num_consumer_supplies  = 1,                                    \
198 };                                                                      \
199                                                                         \
200 static struct gpio vccq_sdhi##idx##_gpio =                              \
201         { vccq_pin, GPIOF_OUT_INIT_HIGH, "vccq-sdhi" #idx };            \
202                                                                         \
203 static struct gpio_regulator_state vccq_sdhi##idx##_states[] = {        \
204         { .value = 1800000, .gpios = 0 },                               \
205         { .value = 3300000, .gpios = 1 },                               \
206 };                                                                      \
207                                                                         \
208 static const struct gpio_regulator_config vccq_sdhi##idx##_info __initconst = {\
209         .supply_name    = "vqmmc",                                      \
210         .gpios          = &vccq_sdhi##idx##_gpio,                       \
211         .nr_gpios       = 1,                                            \
212         .states         = vccq_sdhi##idx##_states,                      \
213         .nr_states      = ARRAY_SIZE(vccq_sdhi##idx##_states),          \
214         .type           = REGULATOR_VOLTAGE,                            \
215         .init_data      = &vccq_sdhi##idx##_init_data,                  \
216 };
217
218 SDHI_REGULATOR(0, RCAR_GP_PIN(5, 24), RCAR_GP_PIN(5, 29));
219 SDHI_REGULATOR(2, RCAR_GP_PIN(5, 25), RCAR_GP_PIN(5, 30));
220
221 /* MMCIF */
222 static const struct sh_mmcif_plat_data mmcif1_pdata __initconst = {
223         .caps           = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
224         .clk_ctrl2_present = true,
225         .ccs_unsupported = true,
226 };
227
228 static const struct resource mmcif1_resources[] __initconst = {
229         DEFINE_RES_MEM(0xee220000, 0x80),
230         DEFINE_RES_IRQ(gic_spi(170)),
231 };
232
233 /* Ether */
234 static const struct sh_eth_plat_data ether_pdata __initconst = {
235         .phy                    = 0x1,
236         .edmac_endian           = EDMAC_LITTLE_ENDIAN,
237         .phy_interface          = PHY_INTERFACE_MODE_RMII,
238         .ether_link_active_low  = 1,
239 };
240
241 static const struct resource ether_resources[] __initconst = {
242         DEFINE_RES_MEM(0xee700000, 0x400),
243         DEFINE_RES_IRQ(gic_spi(162)),
244 };
245
246 /* SPI Flash memory (Spansion S25FL512SAGMFIG11 64Mb) */
247 static struct mtd_partition spi_flash_part[] = {
248         /* Reserved for user loader program, read-only */
249         {
250                 .name = "loader",
251                 .offset = 0,
252                 .size = SZ_256K,
253                 .mask_flags = MTD_WRITEABLE,
254         },
255         /* Reserved for user program, read-only */
256         {
257                 .name = "user",
258                 .offset = MTDPART_OFS_APPEND,
259                 .size = SZ_4M,
260                 .mask_flags = MTD_WRITEABLE,
261         },
262         /* All else is writable (e.g. JFFS2) */
263         {
264                 .name = "flash",
265                 .offset = MTDPART_OFS_APPEND,
266                 .size = MTDPART_SIZ_FULL,
267                 .mask_flags = 0,
268         },
269 };
270
271 static const struct flash_platform_data spi_flash_data = {
272         .name           = "m25p80",
273         .parts          = spi_flash_part,
274         .nr_parts       = ARRAY_SIZE(spi_flash_part),
275         .type           = "s25fl512s",
276 };
277
278 static const struct rspi_plat_data qspi_pdata __initconst = {
279         .num_chipselect = 1,
280 };
281
282 static const struct spi_board_info spi_info[] __initconst = {
283         {
284                 .modalias               = "m25p80",
285                 .platform_data          = &spi_flash_data,
286                 .mode                   = SPI_MODE_0,
287                 .max_speed_hz           = 30000000,
288                 .bus_num                = 0,
289                 .chip_select            = 0,
290         },
291 };
292
293 /* QSPI resource */
294 static const struct resource qspi_resources[] __initconst = {
295         DEFINE_RES_MEM(0xe6b10000, 0x1000),
296         DEFINE_RES_IRQ(gic_spi(184)),
297 };
298
299 /* VIN */
300 static const struct resource vin_resources[] __initconst = {
301         /* VIN0 */
302         DEFINE_RES_MEM(0xe6ef0000, 0x1000),
303         DEFINE_RES_IRQ(gic_spi(188)),
304         /* VIN1 */
305         DEFINE_RES_MEM(0xe6ef1000, 0x1000),
306         DEFINE_RES_IRQ(gic_spi(189)),
307 };
308
309 static void __init lager_add_vin_device(unsigned idx,
310                                         struct rcar_vin_platform_data *pdata)
311 {
312         struct platform_device_info vin_info = {
313                 .parent         = &platform_bus,
314                 .name           = "r8a7790-vin",
315                 .id             = idx,
316                 .res            = &vin_resources[idx * 2],
317                 .num_res        = 2,
318                 .dma_mask       = DMA_BIT_MASK(32),
319                 .data           = pdata,
320                 .size_data      = sizeof(*pdata),
321         };
322
323         BUG_ON(idx > 1);
324
325         platform_device_register_full(&vin_info);
326 }
327
328 #define LAGER_CAMERA(idx, name, addr, pdata, flag)                      \
329 static struct i2c_board_info i2c_cam##idx##_device = {                  \
330         I2C_BOARD_INFO(name, addr),                                     \
331 };                                                                      \
332                                                                         \
333 static struct rcar_vin_platform_data vin##idx##_pdata = {               \
334         .flags = flag,                                                  \
335 };                                                                      \
336                                                                         \
337 static struct soc_camera_link cam##idx##_link = {                       \
338         .bus_id = idx,                                                  \
339         .board_info = &i2c_cam##idx##_device,                           \
340         .i2c_adapter_id = 2,                                            \
341         .module_name = name,                                            \
342         .priv = pdata,                                                  \
343 }
344
345 /* Camera 0 is not currently supported due to adv7612 support missing */
346 LAGER_CAMERA(1, "adv7180", 0x20, NULL, RCAR_VIN_BT656);
347
348 static void __init lager_add_camera1_device(void)
349 {
350         platform_device_register_data(&platform_bus, "soc-camera-pdrv", 1,
351                                       &cam1_link, sizeof(cam1_link));
352         lager_add_vin_device(1, &vin1_pdata);
353 }
354
355 /* SATA1 */
356 static const struct resource sata1_resources[] __initconst = {
357         DEFINE_RES_MEM(0xee500000, 0x2000),
358         DEFINE_RES_IRQ(gic_spi(106)),
359 };
360
361 static const struct platform_device_info sata1_info __initconst = {
362         .parent         = &platform_bus,
363         .name           = "sata-r8a7790",
364         .id             = 1,
365         .res            = sata1_resources,
366         .num_res        = ARRAY_SIZE(sata1_resources),
367         .dma_mask       = DMA_BIT_MASK(32),
368 };
369
370 /* USBHS */
371 #if IS_ENABLED(CONFIG_USB_RENESAS_USBHS_UDC)
372 static const struct resource usbhs_resources[] __initconst = {
373         DEFINE_RES_MEM(0xe6590000, 0x100),
374         DEFINE_RES_IRQ(gic_spi(107)),
375 };
376
377 struct usbhs_private {
378         struct renesas_usbhs_platform_info info;
379         struct usb_phy *phy;
380 };
381
382 #define usbhs_get_priv(pdev) \
383         container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
384
385 static int usbhs_power_ctrl(struct platform_device *pdev,
386                                 void __iomem *base, int enable)
387 {
388         struct usbhs_private *priv = usbhs_get_priv(pdev);
389
390         if (!priv->phy)
391                 return -ENODEV;
392
393         if (enable) {
394                 int retval = usb_phy_init(priv->phy);
395
396                 if (!retval)
397                         retval = usb_phy_set_suspend(priv->phy, 0);
398                 return retval;
399         }
400
401         usb_phy_set_suspend(priv->phy, 1);
402         usb_phy_shutdown(priv->phy);
403         return 0;
404 }
405
406 static int usbhs_hardware_init(struct platform_device *pdev)
407 {
408         struct usbhs_private *priv = usbhs_get_priv(pdev);
409         struct usb_phy *phy;
410
411         phy = usb_get_phy_dev(&pdev->dev, 0);
412         if (IS_ERR(phy))
413                 return PTR_ERR(phy);
414
415         priv->phy = phy;
416         return 0;
417 }
418
419 static int usbhs_hardware_exit(struct platform_device *pdev)
420 {
421         struct usbhs_private *priv = usbhs_get_priv(pdev);
422
423         if (!priv->phy)
424                 return 0;
425
426         usb_put_phy(priv->phy);
427         priv->phy = NULL;
428         return 0;
429 }
430
431 static int usbhs_get_id(struct platform_device *pdev)
432 {
433         return USBHS_GADGET;
434 }
435
436 static u32 lager_usbhs_pipe_type[] = {
437         USB_ENDPOINT_XFER_CONTROL,
438         USB_ENDPOINT_XFER_ISOC,
439         USB_ENDPOINT_XFER_ISOC,
440         USB_ENDPOINT_XFER_BULK,
441         USB_ENDPOINT_XFER_BULK,
442         USB_ENDPOINT_XFER_BULK,
443         USB_ENDPOINT_XFER_INT,
444         USB_ENDPOINT_XFER_INT,
445         USB_ENDPOINT_XFER_INT,
446         USB_ENDPOINT_XFER_BULK,
447         USB_ENDPOINT_XFER_BULK,
448         USB_ENDPOINT_XFER_BULK,
449         USB_ENDPOINT_XFER_BULK,
450         USB_ENDPOINT_XFER_BULK,
451         USB_ENDPOINT_XFER_BULK,
452         USB_ENDPOINT_XFER_BULK,
453 };
454
455 static struct usbhs_private usbhs_priv __initdata = {
456         .info = {
457                 .platform_callback = {
458                         .power_ctrl     = usbhs_power_ctrl,
459                         .hardware_init  = usbhs_hardware_init,
460                         .hardware_exit  = usbhs_hardware_exit,
461                         .get_id         = usbhs_get_id,
462                 },
463                 .driver_param = {
464                         .buswait_bwait  = 4,
465                         .pipe_type = lager_usbhs_pipe_type,
466                         .pipe_size = ARRAY_SIZE(lager_usbhs_pipe_type),
467                 },
468         }
469 };
470
471 static void __init lager_register_usbhs(void)
472 {
473         usb_bind_phy("renesas_usbhs", 0, "usb_phy_rcar_gen2");
474         platform_device_register_resndata(&platform_bus,
475                                           "renesas_usbhs", -1,
476                                           usbhs_resources,
477                                           ARRAY_SIZE(usbhs_resources),
478                                           &usbhs_priv.info,
479                                           sizeof(usbhs_priv.info));
480 }
481 #else   /* CONFIG_USB_RENESAS_USBHS_UDC */
482 static inline void lager_register_usbhs(void) { }
483 #endif  /* CONFIG_USB_RENESAS_USBHS_UDC */
484
485 /* USBHS PHY */
486 static const struct rcar_gen2_phy_platform_data usbhs_phy_pdata __initconst = {
487         .chan0_pci = 0, /* Channel 0 is USBHS */
488         .chan2_pci = 1, /* Channel 2 is PCI USB */
489 };
490
491 static const struct resource usbhs_phy_resources[] __initconst = {
492         DEFINE_RES_MEM(0xe6590100, 0x100),
493 };
494
495 static const struct pinctrl_map lager_pinctrl_map[] = {
496         /* DU (CN10: ARGB0, CN13: LVDS) */
497         PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
498                                   "du_rgb666", "du"),
499         PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
500                                   "du_sync_1", "du"),
501         PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
502                                   "du_clk_out_0", "du"),
503         /* SCIF0 (CN19: DEBUG SERIAL0) */
504         PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
505                                   "scif0_data", "scif0"),
506         /* SCIF1 (CN20: DEBUG SERIAL1) */
507         PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7790",
508                                   "scif1_data", "scif1"),
509         /* MMCIF1 */
510         PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
511                                   "mmc1_data8", "mmc1"),
512         PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
513                                   "mmc1_ctrl", "mmc1"),
514         /* Ether */
515         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
516                                   "eth_link", "eth"),
517         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
518                                   "eth_mdio", "eth"),
519         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
520                                   "eth_rmii", "eth"),
521         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
522                                   "intc_irq0", "intc"),
523         /* VIN0 */
524         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
525                                   "vin0_data24", "vin0"),
526         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
527                                   "vin0_sync", "vin0"),
528         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
529                                   "vin0_field", "vin0"),
530         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
531                                   "vin0_clkenb", "vin0"),
532         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
533                                   "vin0_clk", "vin0"),
534         /* VIN1 */
535         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790",
536                                   "vin1_data8", "vin1"),
537         PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790",
538                                   "vin1_clk", "vin1"),
539         /* USB0 */
540         PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7790",
541                                   "usb0", "usb0"),
542 };
543
544 static void __init lager_add_standard_devices(void)
545 {
546         int fixed_regulator_idx = 0;
547         int gpio_regulator_idx = 0;
548
549         r8a7790_clock_init();
550
551         pinctrl_register_mappings(lager_pinctrl_map,
552                                   ARRAY_SIZE(lager_pinctrl_map));
553         r8a7790_pinmux_init();
554
555         r8a7790_add_standard_devices();
556         platform_device_register_data(&platform_bus, "leds-gpio", -1,
557                                       &lager_leds_pdata,
558                                       sizeof(lager_leds_pdata));
559         platform_device_register_data(&platform_bus, "gpio-keys", -1,
560                                       &lager_keys_pdata,
561                                       sizeof(lager_keys_pdata));
562         regulator_register_always_on(fixed_regulator_idx++,
563                                      "fixed-3.3V", fixed3v3_power_consumers,
564                                      ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
565         platform_device_register_resndata(&platform_bus, "sh_mmcif", 1,
566                                           mmcif1_resources, ARRAY_SIZE(mmcif1_resources),
567                                           &mmcif1_pdata, sizeof(mmcif1_pdata));
568
569         platform_device_register_resndata(&platform_bus, "r8a7790-ether", -1,
570                                           ether_resources,
571                                           ARRAY_SIZE(ether_resources),
572                                           &ether_pdata, sizeof(ether_pdata));
573
574         lager_add_du_device();
575
576         platform_device_register_resndata(&platform_bus, "qspi", 0,
577                                           qspi_resources,
578                                           ARRAY_SIZE(qspi_resources),
579                                           &qspi_pdata, sizeof(qspi_pdata));
580         spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
581
582         platform_device_register_data(&platform_bus, "reg-fixed-voltage", fixed_regulator_idx++,
583                                       &vcc_sdhi0_info, sizeof(struct fixed_voltage_config));
584         platform_device_register_data(&platform_bus, "reg-fixed-voltage", fixed_regulator_idx++,
585                                       &vcc_sdhi2_info, sizeof(struct fixed_voltage_config));
586
587         platform_device_register_data(&platform_bus, "gpio-regulator", gpio_regulator_idx++,
588                                       &vccq_sdhi0_info, sizeof(struct gpio_regulator_config));
589         platform_device_register_data(&platform_bus, "gpio-regulator", gpio_regulator_idx++,
590                                       &vccq_sdhi2_info, sizeof(struct gpio_regulator_config));
591
592         lager_add_camera1_device();
593
594         platform_device_register_full(&sata1_info);
595
596         platform_device_register_resndata(&platform_bus, "usb_phy_rcar_gen2",
597                                           -1, usbhs_phy_resources,
598                                           ARRAY_SIZE(usbhs_phy_resources),
599                                           &usbhs_phy_pdata,
600                                           sizeof(usbhs_phy_pdata));
601         lager_register_usbhs();
602 }
603
604 /*
605  * Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds
606  * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits
607  * 14-15. We have to set them back to 01 from the default 00 value each time
608  * the PHY is reset. It's also important because the PHY's LED0 signal is
609  * connected to SoC's ETH_LINK signal and in the PHY's default mode it will
610  * bounce on and off after each packet, which we apparently want to avoid.
611  */
612 static int lager_ksz8041_fixup(struct phy_device *phydev)
613 {
614         u16 phyctrl1 = phy_read(phydev, 0x1e);
615
616         phyctrl1 &= ~0xc000;
617         phyctrl1 |= 0x4000;
618         return phy_write(phydev, 0x1e, phyctrl1);
619 }
620
621 static void __init lager_init(void)
622 {
623         lager_add_standard_devices();
624
625         if (IS_ENABLED(CONFIG_PHYLIB))
626                 phy_register_fixup_for_id("r8a7790-ether-ff:01",
627                                           lager_ksz8041_fixup);
628 }
629
630 static const char * const lager_boards_compat_dt[] __initconst = {
631         "renesas,lager",
632         NULL,
633 };
634
635 DT_MACHINE_START(LAGER_DT, "lager")
636         .smp            = smp_ops(r8a7790_smp_ops),
637         .init_early     = r8a7790_init_early,
638         .init_time      = rcar_gen2_timer_init,
639         .init_machine   = lager_init,
640         .init_late      = shmobile_init_late,
641         .dt_compat      = lager_boards_compat_dt,
642 MACHINE_END