4 * Copyright (C) 2013-2014 Renesas Solutions Corp.
5 * Copyright (C) 2013 Magnus Damm
6 * Copyright (C) 2014 Cogent Embedded, Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/gpio.h>
19 #include <linux/gpio_keys.h>
20 #include <linux/i2c.h>
21 #include <linux/input.h>
22 #include <linux/interrupt.h>
23 #include <linux/irq.h>
24 #include <linux/kernel.h>
25 #include <linux/leds.h>
26 #include <linux/mfd/tmio.h>
27 #include <linux/mmc/host.h>
28 #include <linux/mmc/sh_mmcif.h>
29 #include <linux/mmc/sh_mobile_sdhi.h>
30 #include <linux/mtd/partitions.h>
31 #include <linux/mtd/mtd.h>
32 #include <linux/pinctrl/machine.h>
33 #include <linux/platform_data/camera-rcar.h>
34 #include <linux/platform_data/gpio-rcar.h>
35 #include <linux/platform_data/rcar-du.h>
36 #include <linux/platform_data/usb-rcar-gen2-phy.h>
37 #include <linux/platform_device.h>
38 #include <linux/phy.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 <linux/usb/phy.h>
48 #include <linux/usb/renesas_usbhs.h>
50 #include <media/soc_camera.h>
51 #include <asm/mach-types.h>
52 #include <asm/mach/arch.h>
53 #include <sound/rcar_snd.h>
54 #include <sound/simple_card.h>
59 #include "rcar-gen2.h"
68 * this command is required when playback.
70 * # amixer set "LINEOUT Mixer DACL" on
79 * GP5_24: 1: VDD 3.3V (defult)
81 * GP5_29: 1: VccQ 3.3V (defult)
87 static struct rcar_du_encoder_data lager_du_encoders[] = {
89 .type = RCAR_DU_ENCODER_VGA,
90 .output = RCAR_DU_OUTPUT_DPAD0,
92 .type = RCAR_DU_ENCODER_NONE,
93 .output = RCAR_DU_OUTPUT_LVDS1,
94 .connector.lvds.panel = {
98 .pixelclock = 65000000,
112 static const struct rcar_du_platform_data lager_du_pdata __initconst = {
113 .encoders = lager_du_encoders,
114 .num_encoders = ARRAY_SIZE(lager_du_encoders),
117 static const struct resource du_resources[] __initconst = {
118 DEFINE_RES_MEM(0xfeb00000, 0x70000),
119 DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
120 DEFINE_RES_MEM_NAMED(0xfeb94000, 0x1c, "lvds.1"),
121 DEFINE_RES_IRQ(gic_spi(256)),
122 DEFINE_RES_IRQ(gic_spi(268)),
123 DEFINE_RES_IRQ(gic_spi(269)),
126 static void __init lager_add_du_device(void)
128 struct platform_device_info info = {
129 .name = "rcar-du-r8a7790",
132 .num_res = ARRAY_SIZE(du_resources),
133 .data = &lager_du_pdata,
134 .size_data = sizeof(lager_du_pdata),
135 .dma_mask = DMA_BIT_MASK(32),
138 platform_device_register_full(&info);
142 static struct gpio_led lager_leds[] = {
145 .gpio = RCAR_GP_PIN(5, 17),
146 .default_state = LEDS_GPIO_DEFSTATE_ON,
149 .gpio = RCAR_GP_PIN(4, 23),
150 .default_state = LEDS_GPIO_DEFSTATE_ON,
153 .gpio = RCAR_GP_PIN(4, 22),
154 .default_state = LEDS_GPIO_DEFSTATE_ON,
158 static const struct gpio_led_platform_data lager_leds_pdata __initconst = {
160 .num_leds = ARRAY_SIZE(lager_leds),
164 #define GPIO_KEY(c, g, d, ...) \
165 { .code = c, .gpio = g, .desc = d, .active_low = 1, \
166 .wakeup = 1, .debounce_interval = 20 }
168 static struct gpio_keys_button gpio_buttons[] = {
169 GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"),
170 GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"),
171 GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"),
172 GPIO_KEY(KEY_1, RCAR_GP_PIN(1, 14), "SW2-pin1"),
175 static const struct gpio_keys_platform_data lager_keys_pdata __initconst = {
176 .buttons = gpio_buttons,
177 .nbuttons = ARRAY_SIZE(gpio_buttons),
180 /* Fixed 3.3V regulator to be used by MMCIF */
181 static struct regulator_consumer_supply fixed3v3_power_consumers[] =
183 REGULATOR_SUPPLY("vmmc", "sh_mmcif.1"),
187 * SDHI regulator macro
190 * Lager board vqmmc is provided via DA9063 PMIC chip,
191 * and we should use ${LINK}/drivers/mfd/da9063-* driver for it.
192 * but, it doesn't have regulator support at this point.
193 * It uses gpio-regulator for vqmmc as quick-hack.
195 #define SDHI_REGULATOR(idx, vdd_pin, vccq_pin) \
196 static struct regulator_consumer_supply vcc_sdhi##idx##_consumer = \
197 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi." #idx); \
199 static struct regulator_init_data vcc_sdhi##idx##_init_data = { \
201 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
203 .consumer_supplies = &vcc_sdhi##idx##_consumer, \
204 .num_consumer_supplies = 1, \
207 static const struct fixed_voltage_config vcc_sdhi##idx##_info __initconst = {\
208 .supply_name = "SDHI" #idx "Vcc", \
209 .microvolts = 3300000, \
212 .init_data = &vcc_sdhi##idx##_init_data, \
215 static struct regulator_consumer_supply vccq_sdhi##idx##_consumer = \
216 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi." #idx); \
218 static struct regulator_init_data vccq_sdhi##idx##_init_data = { \
220 .input_uV = 3300000, \
223 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | \
224 REGULATOR_CHANGE_STATUS, \
226 .consumer_supplies = &vccq_sdhi##idx##_consumer, \
227 .num_consumer_supplies = 1, \
230 static struct gpio vccq_sdhi##idx##_gpio = \
231 { vccq_pin, GPIOF_OUT_INIT_HIGH, "vccq-sdhi" #idx }; \
233 static struct gpio_regulator_state vccq_sdhi##idx##_states[] = { \
234 { .value = 1800000, .gpios = 0 }, \
235 { .value = 3300000, .gpios = 1 }, \
238 static const struct gpio_regulator_config vccq_sdhi##idx##_info __initconst = {\
239 .supply_name = "vqmmc", \
240 .gpios = &vccq_sdhi##idx##_gpio, \
242 .states = vccq_sdhi##idx##_states, \
243 .nr_states = ARRAY_SIZE(vccq_sdhi##idx##_states), \
244 .type = REGULATOR_VOLTAGE, \
245 .init_data = &vccq_sdhi##idx##_init_data, \
248 SDHI_REGULATOR(0, RCAR_GP_PIN(5, 24), RCAR_GP_PIN(5, 29));
249 SDHI_REGULATOR(2, RCAR_GP_PIN(5, 25), RCAR_GP_PIN(5, 30));
252 static const struct sh_mmcif_plat_data mmcif1_pdata __initconst = {
253 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
254 .clk_ctrl2_present = true,
255 .ccs_unsupported = true,
258 static const struct resource mmcif1_resources[] __initconst = {
259 DEFINE_RES_MEM(0xee220000, 0x80),
260 DEFINE_RES_IRQ(gic_spi(170)),
264 static const struct sh_eth_plat_data ether_pdata __initconst = {
266 .phy_irq = irq_pin(0),
267 .edmac_endian = EDMAC_LITTLE_ENDIAN,
268 .phy_interface = PHY_INTERFACE_MODE_RMII,
269 .ether_link_active_low = 1,
272 static const struct resource ether_resources[] __initconst = {
273 DEFINE_RES_MEM(0xee700000, 0x400),
274 DEFINE_RES_IRQ(gic_spi(162)),
277 static const struct platform_device_info ether_info __initconst = {
278 .parent = &platform_bus,
279 .name = "r8a7790-ether",
281 .res = ether_resources,
282 .num_res = ARRAY_SIZE(ether_resources),
283 .data = ðer_pdata,
284 .size_data = sizeof(ether_pdata),
285 .dma_mask = DMA_BIT_MASK(32),
288 /* SPI Flash memory (Spansion S25FL512SAGMFIG11 64Mb) */
289 static struct mtd_partition spi_flash_part[] = {
290 /* Reserved for user loader program, read-only */
295 .mask_flags = MTD_WRITEABLE,
297 /* Reserved for user program, read-only */
300 .offset = MTDPART_OFS_APPEND,
302 .mask_flags = MTD_WRITEABLE,
304 /* All else is writable (e.g. JFFS2) */
307 .offset = MTDPART_OFS_APPEND,
308 .size = MTDPART_SIZ_FULL,
313 static const struct flash_platform_data spi_flash_data = {
315 .parts = spi_flash_part,
316 .nr_parts = ARRAY_SIZE(spi_flash_part),
320 static const struct rspi_plat_data qspi_pdata __initconst = {
324 static const struct spi_board_info spi_info[] __initconst = {
326 .modalias = "m25p80",
327 .platform_data = &spi_flash_data,
328 .mode = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD,
329 .max_speed_hz = 30000000,
336 static const struct resource qspi_resources[] __initconst = {
337 DEFINE_RES_MEM(0xe6b10000, 0x1000),
338 DEFINE_RES_IRQ_NAMED(gic_spi(184), "mux"),
342 static const struct resource vin_resources[] __initconst = {
344 DEFINE_RES_MEM(0xe6ef0000, 0x1000),
345 DEFINE_RES_IRQ(gic_spi(188)),
347 DEFINE_RES_MEM(0xe6ef1000, 0x1000),
348 DEFINE_RES_IRQ(gic_spi(189)),
351 static void __init lager_add_vin_device(unsigned idx,
352 struct rcar_vin_platform_data *pdata)
354 struct platform_device_info vin_info = {
355 .parent = &platform_bus,
356 .name = "r8a7790-vin",
358 .res = &vin_resources[idx * 2],
360 .dma_mask = DMA_BIT_MASK(32),
362 .size_data = sizeof(*pdata),
367 platform_device_register_full(&vin_info);
370 #define LAGER_CAMERA(idx, name, addr, pdata, flag) \
371 static struct i2c_board_info i2c_cam##idx##_device = { \
372 I2C_BOARD_INFO(name, addr), \
375 static struct rcar_vin_platform_data vin##idx##_pdata = { \
379 static struct soc_camera_link cam##idx##_link = { \
381 .board_info = &i2c_cam##idx##_device, \
382 .i2c_adapter_id = 2, \
383 .module_name = name, \
387 /* Camera 0 is not currently supported due to adv7612 support missing */
388 LAGER_CAMERA(1, "adv7180", 0x20, NULL, RCAR_VIN_BT656);
390 static void __init lager_add_camera1_device(void)
392 platform_device_register_data(&platform_bus, "soc-camera-pdrv", 1,
393 &cam1_link, sizeof(cam1_link));
394 lager_add_vin_device(1, &vin1_pdata);
398 static const struct resource sata1_resources[] __initconst = {
399 DEFINE_RES_MEM(0xee500000, 0x2000),
400 DEFINE_RES_IRQ(gic_spi(106)),
403 static const struct platform_device_info sata1_info __initconst = {
404 .parent = &platform_bus,
405 .name = "sata-r8a7790",
407 .res = sata1_resources,
408 .num_res = ARRAY_SIZE(sata1_resources),
409 .dma_mask = DMA_BIT_MASK(32),
413 static const struct resource usbhs_resources[] __initconst = {
414 DEFINE_RES_MEM(0xe6590000, 0x100),
415 DEFINE_RES_IRQ(gic_spi(107)),
418 struct usbhs_private {
419 struct renesas_usbhs_platform_info info;
423 #define usbhs_get_priv(pdev) \
424 container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
426 static int usbhs_power_ctrl(struct platform_device *pdev,
427 void __iomem *base, int enable)
429 struct usbhs_private *priv = usbhs_get_priv(pdev);
435 int retval = usb_phy_init(priv->phy);
438 retval = usb_phy_set_suspend(priv->phy, 0);
442 usb_phy_set_suspend(priv->phy, 1);
443 usb_phy_shutdown(priv->phy);
447 static int usbhs_hardware_init(struct platform_device *pdev)
449 struct usbhs_private *priv = usbhs_get_priv(pdev);
453 /* USB0 Function - use PWEN as GPIO input to detect DIP Switch SW5
454 * setting to avoid VBUS short circuit due to wrong cable.
455 * PWEN should be pulled up high if USB Function is selected by SW5
457 gpio_request_one(RCAR_GP_PIN(5, 18), GPIOF_IN, NULL); /* USB0_PWEN */
458 if (!gpio_get_value(RCAR_GP_PIN(5, 18))) {
459 pr_warn("Error: USB Function not selected - check SW5 + SW6\n");
464 phy = usb_get_phy_dev(&pdev->dev, 0);
473 gpio_free(RCAR_GP_PIN(5, 18));
477 static int usbhs_hardware_exit(struct platform_device *pdev)
479 struct usbhs_private *priv = usbhs_get_priv(pdev);
484 usb_put_phy(priv->phy);
487 gpio_free(RCAR_GP_PIN(5, 18));
491 static int usbhs_get_id(struct platform_device *pdev)
496 static u32 lager_usbhs_pipe_type[] = {
497 USB_ENDPOINT_XFER_CONTROL,
498 USB_ENDPOINT_XFER_ISOC,
499 USB_ENDPOINT_XFER_ISOC,
500 USB_ENDPOINT_XFER_BULK,
501 USB_ENDPOINT_XFER_BULK,
502 USB_ENDPOINT_XFER_BULK,
503 USB_ENDPOINT_XFER_INT,
504 USB_ENDPOINT_XFER_INT,
505 USB_ENDPOINT_XFER_INT,
506 USB_ENDPOINT_XFER_BULK,
507 USB_ENDPOINT_XFER_BULK,
508 USB_ENDPOINT_XFER_BULK,
509 USB_ENDPOINT_XFER_BULK,
510 USB_ENDPOINT_XFER_BULK,
511 USB_ENDPOINT_XFER_BULK,
512 USB_ENDPOINT_XFER_BULK,
515 static struct usbhs_private usbhs_priv __initdata = {
517 .platform_callback = {
518 .power_ctrl = usbhs_power_ctrl,
519 .hardware_init = usbhs_hardware_init,
520 .hardware_exit = usbhs_hardware_exit,
521 .get_id = usbhs_get_id,
525 .pipe_type = lager_usbhs_pipe_type,
526 .pipe_size = ARRAY_SIZE(lager_usbhs_pipe_type),
531 static void __init lager_register_usbhs(void)
533 usb_bind_phy("renesas_usbhs", 0, "usb_phy_rcar_gen2");
534 platform_device_register_resndata(&platform_bus,
537 ARRAY_SIZE(usbhs_resources),
539 sizeof(usbhs_priv.info));
543 static const struct rcar_gen2_phy_platform_data usbhs_phy_pdata __initconst = {
544 .chan0_pci = 0, /* Channel 0 is USBHS */
545 .chan2_pci = 1, /* Channel 2 is PCI USB */
548 static const struct resource usbhs_phy_resources[] __initconst = {
549 DEFINE_RES_MEM(0xe6590100, 0x100),
553 static struct i2c_board_info i2c2_devices[] = {
555 I2C_BOARD_INFO("ak4643", 0x12),
560 static struct resource rsnd_resources[] __initdata = {
561 [RSND_GEN2_SCU] = DEFINE_RES_MEM(0xec500000, 0x1000),
562 [RSND_GEN2_ADG] = DEFINE_RES_MEM(0xec5a0000, 0x100),
563 [RSND_GEN2_SSIU] = DEFINE_RES_MEM(0xec540000, 0x1000),
564 [RSND_GEN2_SSI] = DEFINE_RES_MEM(0xec541000, 0x1280),
567 static struct rsnd_ssi_platform_info rsnd_ssi[] = {
568 RSND_SSI(0, gic_spi(370), 0),
569 RSND_SSI(0, gic_spi(371), RSND_SSI_CLK_PIN_SHARE),
572 static struct rsnd_src_platform_info rsnd_src[2] = {
573 /* no member at this point */
576 static struct rsnd_dai_platform_info rsnd_dai = {
577 .playback = { .ssi = &rsnd_ssi[0], },
578 .capture = { .ssi = &rsnd_ssi[1], },
581 static struct rcar_snd_info rsnd_info = {
583 .ssi_info = rsnd_ssi,
584 .ssi_info_nr = ARRAY_SIZE(rsnd_ssi),
585 .src_info = rsnd_src,
586 .src_info_nr = ARRAY_SIZE(rsnd_src),
587 .dai_info = &rsnd_dai,
591 static struct asoc_simple_card_info rsnd_card_info = {
593 .card = "SSI01-AK4643",
594 .codec = "ak4642-codec.2-0012",
595 .platform = "rcar_sound",
596 .daifmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM,
598 .name = "rcar_sound",
601 .name = "ak4642-hifi",
606 static void __init lager_add_rsnd_device(void)
608 struct platform_device_info cardinfo = {
609 .parent = &platform_bus,
610 .name = "asoc-simple-card",
612 .data = &rsnd_card_info,
613 .size_data = sizeof(struct asoc_simple_card_info),
614 .dma_mask = DMA_BIT_MASK(32),
617 i2c_register_board_info(2, i2c2_devices,
618 ARRAY_SIZE(i2c2_devices));
620 platform_device_register_resndata(
621 &platform_bus, "rcar_sound", -1,
622 rsnd_resources, ARRAY_SIZE(rsnd_resources),
623 &rsnd_info, sizeof(rsnd_info));
625 platform_device_register_full(&cardinfo);
629 static struct sh_mobile_sdhi_info sdhi0_info __initdata = {
630 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
631 MMC_CAP_POWER_OFF_CARD,
632 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
633 TMIO_MMC_WRPROTECT_DISABLE,
636 static struct resource sdhi0_resources[] __initdata = {
637 DEFINE_RES_MEM(0xee100000, 0x200),
638 DEFINE_RES_IRQ(gic_spi(165)),
642 static struct sh_mobile_sdhi_info sdhi2_info __initdata = {
643 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
644 MMC_CAP_POWER_OFF_CARD,
645 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
646 TMIO_MMC_WRPROTECT_DISABLE,
649 static struct resource sdhi2_resources[] __initdata = {
650 DEFINE_RES_MEM(0xee140000, 0x100),
651 DEFINE_RES_IRQ(gic_spi(167)),
655 static const struct resource pci1_resources[] __initconst = {
656 DEFINE_RES_MEM(0xee0b0000, 0x10000), /* CFG */
657 DEFINE_RES_MEM(0xee0a0000, 0x10000), /* MEM */
658 DEFINE_RES_IRQ(gic_spi(112)),
661 static const struct platform_device_info pci1_info __initconst = {
662 .parent = &platform_bus,
663 .name = "pci-rcar-gen2",
665 .res = pci1_resources,
666 .num_res = ARRAY_SIZE(pci1_resources),
667 .dma_mask = DMA_BIT_MASK(32),
670 static void __init lager_add_usb1_device(void)
672 platform_device_register_full(&pci1_info);
676 static const struct resource pci2_resources[] __initconst = {
677 DEFINE_RES_MEM(0xee0d0000, 0x10000), /* CFG */
678 DEFINE_RES_MEM(0xee0c0000, 0x10000), /* MEM */
679 DEFINE_RES_IRQ(gic_spi(113)),
682 static const struct platform_device_info pci2_info __initconst = {
683 .parent = &platform_bus,
684 .name = "pci-rcar-gen2",
686 .res = pci2_resources,
687 .num_res = ARRAY_SIZE(pci2_resources),
688 .dma_mask = DMA_BIT_MASK(32),
691 static void __init lager_add_usb2_device(void)
693 platform_device_register_full(&pci2_info);
696 static const struct pinctrl_map lager_pinctrl_map[] = {
697 /* DU (CN10: ARGB0, CN13: LVDS) */
698 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
700 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
702 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
703 "du_clk_out_0", "du"),
705 PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar.2", "pfc-r8a7790",
708 PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7790",
709 "qspi_ctrl", "qspi"),
710 PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7790",
711 "qspi_data4", "qspi"),
712 /* SCIF0 (CN19: DEBUG SERIAL0) */
713 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
714 "scif0_data", "scif0"),
715 /* SCIF1 (CN20: DEBUG SERIAL1) */
716 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7790",
717 "scif1_data", "scif1"),
719 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790",
720 "sdhi0_data4", "sdhi0"),
721 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790",
722 "sdhi0_ctrl", "sdhi0"),
723 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790",
724 "sdhi0_cd", "sdhi0"),
726 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790",
727 "sdhi2_data4", "sdhi2"),
728 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790",
729 "sdhi2_ctrl", "sdhi2"),
730 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790",
731 "sdhi2_cd", "sdhi2"),
732 /* SSI (CN17: sound) */
733 PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
734 "ssi0129_ctrl", "ssi"),
735 PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
737 PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
739 PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
740 "audio_clk_a", "audio_clk"),
742 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
743 "mmc1_data8", "mmc1"),
744 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
745 "mmc1_ctrl", "mmc1"),
747 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
749 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
751 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
753 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
754 "intc_irq0", "intc"),
756 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
757 "vin0_data24", "vin0"),
758 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
759 "vin0_sync", "vin0"),
760 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
761 "vin0_field", "vin0"),
762 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
763 "vin0_clkenb", "vin0"),
764 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
767 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790",
768 "vin1_data8", "vin1"),
769 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790",
772 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7790",
773 "usb0_ovc_vbus", "usb0"),
775 PIN_MAP_MUX_GROUP_DEFAULT("pci-rcar-gen2.1", "pfc-r8a7790",
778 PIN_MAP_MUX_GROUP_DEFAULT("pci-rcar-gen2.2", "pfc-r8a7790",
782 static void __init lager_add_standard_devices(void)
784 int fixed_regulator_idx = 0;
785 int gpio_regulator_idx = 0;
787 r8a7790_clock_init();
789 pinctrl_register_mappings(lager_pinctrl_map,
790 ARRAY_SIZE(lager_pinctrl_map));
791 r8a7790_pinmux_init();
793 r8a7790_add_standard_devices();
794 platform_device_register_data(&platform_bus, "leds-gpio", -1,
796 sizeof(lager_leds_pdata));
797 platform_device_register_data(&platform_bus, "gpio-keys", -1,
799 sizeof(lager_keys_pdata));
800 regulator_register_always_on(fixed_regulator_idx++,
801 "fixed-3.3V", fixed3v3_power_consumers,
802 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
803 platform_device_register_resndata(&platform_bus, "sh_mmcif", 1,
804 mmcif1_resources, ARRAY_SIZE(mmcif1_resources),
805 &mmcif1_pdata, sizeof(mmcif1_pdata));
807 platform_device_register_full(ðer_info);
809 lager_add_du_device();
811 platform_device_register_resndata(&platform_bus, "qspi", 0,
813 ARRAY_SIZE(qspi_resources),
814 &qspi_pdata, sizeof(qspi_pdata));
815 spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
817 platform_device_register_data(&platform_bus, "reg-fixed-voltage", fixed_regulator_idx++,
818 &vcc_sdhi0_info, sizeof(struct fixed_voltage_config));
819 platform_device_register_data(&platform_bus, "reg-fixed-voltage", fixed_regulator_idx++,
820 &vcc_sdhi2_info, sizeof(struct fixed_voltage_config));
822 platform_device_register_data(&platform_bus, "gpio-regulator", gpio_regulator_idx++,
823 &vccq_sdhi0_info, sizeof(struct gpio_regulator_config));
824 platform_device_register_data(&platform_bus, "gpio-regulator", gpio_regulator_idx++,
825 &vccq_sdhi2_info, sizeof(struct gpio_regulator_config));
827 lager_add_camera1_device();
829 platform_device_register_full(&sata1_info);
831 platform_device_register_resndata(&platform_bus, "usb_phy_rcar_gen2",
832 -1, usbhs_phy_resources,
833 ARRAY_SIZE(usbhs_phy_resources),
835 sizeof(usbhs_phy_pdata));
836 lager_register_usbhs();
837 lager_add_usb1_device();
838 lager_add_usb2_device();
840 lager_add_rsnd_device();
842 platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 0,
843 sdhi0_resources, ARRAY_SIZE(sdhi0_resources),
844 &sdhi0_info, sizeof(struct sh_mobile_sdhi_info));
845 platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 2,
846 sdhi2_resources, ARRAY_SIZE(sdhi2_resources),
847 &sdhi2_info, sizeof(struct sh_mobile_sdhi_info));
851 * Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds
852 * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits
853 * 14-15. We have to set them back to 01 from the default 00 value each time
854 * the PHY is reset. It's also important because the PHY's LED0 signal is
855 * connected to SoC's ETH_LINK signal and in the PHY's default mode it will
856 * bounce on and off after each packet, which we apparently want to avoid.
858 static int lager_ksz8041_fixup(struct phy_device *phydev)
860 u16 phyctrl1 = phy_read(phydev, 0x1e);
864 return phy_write(phydev, 0x1e, phyctrl1);
867 static void __init lager_init(void)
869 lager_add_standard_devices();
871 irq_set_irq_type(irq_pin(0), IRQ_TYPE_LEVEL_LOW);
873 if (IS_ENABLED(CONFIG_PHYLIB))
874 phy_register_fixup_for_id("r8a7790-ether-ff:01",
875 lager_ksz8041_fixup);
878 static const char * const lager_boards_compat_dt[] __initconst = {
883 DT_MACHINE_START(LAGER_DT, "lager")
884 .smp = smp_ops(r8a7790_smp_ops),
885 .init_early = shmobile_init_delay,
886 .init_time = rcar_gen2_timer_init,
887 .init_machine = lager_init,
888 .init_late = shmobile_init_late,
889 .reserve = rcar_gen2_reserve,
890 .dt_compat = lager_boards_compat_dt,