4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Copyright (C) 2013 Magnus Damm
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.
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.
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
21 #include <linux/gpio.h>
22 #include <linux/gpio_keys.h>
23 #include <linux/i2c.h>
24 #include <linux/input.h>
25 #include <linux/interrupt.h>
26 #include <linux/irq.h>
27 #include <linux/kernel.h>
28 #include <linux/leds.h>
29 #include <linux/mfd/tmio.h>
30 #include <linux/mmc/host.h>
31 #include <linux/mmc/sh_mmcif.h>
32 #include <linux/mmc/sh_mobile_sdhi.h>
33 #include <linux/pinctrl/machine.h>
34 #include <linux/platform_data/camera-rcar.h>
35 #include <linux/platform_data/gpio-rcar.h>
36 #include <linux/platform_data/rcar-du.h>
37 #include <linux/platform_data/usb-rcar-gen2-phy.h>
38 #include <linux/platform_device.h>
39 #include <linux/phy.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/usb/phy.h>
46 #include <linux/usb/renesas_usbhs.h>
47 #include <mach/common.h>
48 #include <mach/irqs.h>
49 #include <mach/r8a7790.h>
50 #include <media/soc_camera.h>
51 #include <asm/mach-types.h>
52 #include <asm/mach/arch.h>
53 #include <linux/mtd/partitions.h>
54 #include <linux/mtd/mtd.h>
55 #include <linux/spi/flash.h>
56 #include <linux/spi/rspi.h>
57 #include <linux/spi/spi.h>
58 #include <sound/rcar_snd.h>
59 #include <sound/simple_card.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 = {
113 static const struct rcar_du_platform_data lager_du_pdata __initconst = {
114 .encoders = lager_du_encoders,
115 .num_encoders = ARRAY_SIZE(lager_du_encoders),
118 static const struct resource du_resources[] __initconst = {
119 DEFINE_RES_MEM(0xfeb00000, 0x70000),
120 DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
121 DEFINE_RES_MEM_NAMED(0xfeb94000, 0x1c, "lvds.1"),
122 DEFINE_RES_IRQ(gic_spi(256)),
123 DEFINE_RES_IRQ(gic_spi(268)),
124 DEFINE_RES_IRQ(gic_spi(269)),
127 static void __init lager_add_du_device(void)
129 struct platform_device_info info = {
130 .name = "rcar-du-r8a7790",
133 .num_res = ARRAY_SIZE(du_resources),
134 .data = &lager_du_pdata,
135 .size_data = sizeof(lager_du_pdata),
136 .dma_mask = DMA_BIT_MASK(32),
139 platform_device_register_full(&info);
143 static struct gpio_led lager_leds[] = {
146 .gpio = RCAR_GP_PIN(5, 17),
147 .default_state = LEDS_GPIO_DEFSTATE_ON,
150 .gpio = RCAR_GP_PIN(4, 23),
151 .default_state = LEDS_GPIO_DEFSTATE_ON,
154 .gpio = RCAR_GP_PIN(4, 22),
155 .default_state = LEDS_GPIO_DEFSTATE_ON,
159 static const struct gpio_led_platform_data lager_leds_pdata __initconst = {
161 .num_leds = ARRAY_SIZE(lager_leds),
165 #define GPIO_KEY(c, g, d, ...) \
166 { .code = c, .gpio = g, .desc = d, .active_low = 1, \
167 .wakeup = 1, .debounce_interval = 20 }
169 static struct gpio_keys_button gpio_buttons[] = {
170 GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"),
171 GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"),
172 GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"),
173 GPIO_KEY(KEY_1, RCAR_GP_PIN(1, 14), "SW2-pin1"),
176 static const struct gpio_keys_platform_data lager_keys_pdata __initconst = {
177 .buttons = gpio_buttons,
178 .nbuttons = ARRAY_SIZE(gpio_buttons),
181 /* Fixed 3.3V regulator to be used by MMCIF */
182 static struct regulator_consumer_supply fixed3v3_power_consumers[] =
184 REGULATOR_SUPPLY("vmmc", "sh_mmcif.1"),
188 * SDHI regulator macro
191 * Lager board vqmmc is provided via DA9063 PMIC chip,
192 * and we should use ${LINK}/drivers/mfd/da9063-* driver for it.
193 * but, it doesn't have regulator support at this point.
194 * It uses gpio-regulator for vqmmc as quick-hack.
196 #define SDHI_REGULATOR(idx, vdd_pin, vccq_pin) \
197 static struct regulator_consumer_supply vcc_sdhi##idx##_consumer = \
198 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi." #idx); \
200 static struct regulator_init_data vcc_sdhi##idx##_init_data = { \
202 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
204 .consumer_supplies = &vcc_sdhi##idx##_consumer, \
205 .num_consumer_supplies = 1, \
208 static const struct fixed_voltage_config vcc_sdhi##idx##_info __initconst = {\
209 .supply_name = "SDHI" #idx "Vcc", \
210 .microvolts = 3300000, \
213 .init_data = &vcc_sdhi##idx##_init_data, \
216 static struct regulator_consumer_supply vccq_sdhi##idx##_consumer = \
217 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi." #idx); \
219 static struct regulator_init_data vccq_sdhi##idx##_init_data = { \
221 .input_uV = 3300000, \
224 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | \
225 REGULATOR_CHANGE_STATUS, \
227 .consumer_supplies = &vccq_sdhi##idx##_consumer, \
228 .num_consumer_supplies = 1, \
231 static struct gpio vccq_sdhi##idx##_gpio = \
232 { vccq_pin, GPIOF_OUT_INIT_HIGH, "vccq-sdhi" #idx }; \
234 static struct gpio_regulator_state vccq_sdhi##idx##_states[] = { \
235 { .value = 1800000, .gpios = 0 }, \
236 { .value = 3300000, .gpios = 1 }, \
239 static const struct gpio_regulator_config vccq_sdhi##idx##_info __initconst = {\
240 .supply_name = "vqmmc", \
241 .gpios = &vccq_sdhi##idx##_gpio, \
243 .states = vccq_sdhi##idx##_states, \
244 .nr_states = ARRAY_SIZE(vccq_sdhi##idx##_states), \
245 .type = REGULATOR_VOLTAGE, \
246 .init_data = &vccq_sdhi##idx##_init_data, \
249 SDHI_REGULATOR(0, RCAR_GP_PIN(5, 24), RCAR_GP_PIN(5, 29));
250 SDHI_REGULATOR(2, RCAR_GP_PIN(5, 25), RCAR_GP_PIN(5, 30));
253 static const struct sh_mmcif_plat_data mmcif1_pdata __initconst = {
254 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
255 .clk_ctrl2_present = true,
256 .ccs_unsupported = true,
259 static const struct resource mmcif1_resources[] __initconst = {
260 DEFINE_RES_MEM(0xee220000, 0x80),
261 DEFINE_RES_IRQ(gic_spi(170)),
265 static const struct sh_eth_plat_data ether_pdata __initconst = {
267 .phy_irq = irq_pin(0),
268 .edmac_endian = EDMAC_LITTLE_ENDIAN,
269 .phy_interface = PHY_INTERFACE_MODE_RMII,
270 .ether_link_active_low = 1,
273 static const struct resource ether_resources[] __initconst = {
274 DEFINE_RES_MEM(0xee700000, 0x400),
275 DEFINE_RES_IRQ(gic_spi(162)),
278 /* SPI Flash memory (Spansion S25FL512SAGMFIG11 64Mb) */
279 static struct mtd_partition spi_flash_part[] = {
280 /* Reserved for user loader program, read-only */
285 .mask_flags = MTD_WRITEABLE,
287 /* Reserved for user program, read-only */
290 .offset = MTDPART_OFS_APPEND,
292 .mask_flags = MTD_WRITEABLE,
294 /* All else is writable (e.g. JFFS2) */
297 .offset = MTDPART_OFS_APPEND,
298 .size = MTDPART_SIZ_FULL,
303 static const struct flash_platform_data spi_flash_data = {
305 .parts = spi_flash_part,
306 .nr_parts = ARRAY_SIZE(spi_flash_part),
310 static const struct rspi_plat_data qspi_pdata __initconst = {
314 static const struct spi_board_info spi_info[] __initconst = {
316 .modalias = "m25p80",
317 .platform_data = &spi_flash_data,
319 .max_speed_hz = 30000000,
326 static const struct resource qspi_resources[] __initconst = {
327 DEFINE_RES_MEM(0xe6b10000, 0x1000),
328 DEFINE_RES_IRQ_NAMED(gic_spi(184), "mux"),
332 static const struct resource vin_resources[] __initconst = {
334 DEFINE_RES_MEM(0xe6ef0000, 0x1000),
335 DEFINE_RES_IRQ(gic_spi(188)),
337 DEFINE_RES_MEM(0xe6ef1000, 0x1000),
338 DEFINE_RES_IRQ(gic_spi(189)),
341 static void __init lager_add_vin_device(unsigned idx,
342 struct rcar_vin_platform_data *pdata)
344 struct platform_device_info vin_info = {
345 .parent = &platform_bus,
346 .name = "r8a7790-vin",
348 .res = &vin_resources[idx * 2],
350 .dma_mask = DMA_BIT_MASK(32),
352 .size_data = sizeof(*pdata),
357 platform_device_register_full(&vin_info);
360 #define LAGER_CAMERA(idx, name, addr, pdata, flag) \
361 static struct i2c_board_info i2c_cam##idx##_device = { \
362 I2C_BOARD_INFO(name, addr), \
365 static struct rcar_vin_platform_data vin##idx##_pdata = { \
369 static struct soc_camera_link cam##idx##_link = { \
371 .board_info = &i2c_cam##idx##_device, \
372 .i2c_adapter_id = 2, \
373 .module_name = name, \
377 /* Camera 0 is not currently supported due to adv7612 support missing */
378 LAGER_CAMERA(1, "adv7180", 0x20, NULL, RCAR_VIN_BT656);
380 static void __init lager_add_camera1_device(void)
382 platform_device_register_data(&platform_bus, "soc-camera-pdrv", 1,
383 &cam1_link, sizeof(cam1_link));
384 lager_add_vin_device(1, &vin1_pdata);
388 static const struct resource sata1_resources[] __initconst = {
389 DEFINE_RES_MEM(0xee500000, 0x2000),
390 DEFINE_RES_IRQ(gic_spi(106)),
393 static const struct platform_device_info sata1_info __initconst = {
394 .parent = &platform_bus,
395 .name = "sata-r8a7790",
397 .res = sata1_resources,
398 .num_res = ARRAY_SIZE(sata1_resources),
399 .dma_mask = DMA_BIT_MASK(32),
403 static const struct resource usbhs_resources[] __initconst = {
404 DEFINE_RES_MEM(0xe6590000, 0x100),
405 DEFINE_RES_IRQ(gic_spi(107)),
408 struct usbhs_private {
409 struct renesas_usbhs_platform_info info;
413 #define usbhs_get_priv(pdev) \
414 container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
416 static int usbhs_power_ctrl(struct platform_device *pdev,
417 void __iomem *base, int enable)
419 struct usbhs_private *priv = usbhs_get_priv(pdev);
425 int retval = usb_phy_init(priv->phy);
428 retval = usb_phy_set_suspend(priv->phy, 0);
432 usb_phy_set_suspend(priv->phy, 1);
433 usb_phy_shutdown(priv->phy);
437 static int usbhs_hardware_init(struct platform_device *pdev)
439 struct usbhs_private *priv = usbhs_get_priv(pdev);
443 /* USB0 Function - use PWEN as GPIO input to detect DIP Switch SW5
444 * setting to avoid VBUS short circuit due to wrong cable.
445 * PWEN should be pulled up high if USB Function is selected by SW5
447 gpio_request_one(RCAR_GP_PIN(5, 18), GPIOF_IN, NULL); /* USB0_PWEN */
448 if (!gpio_get_value(RCAR_GP_PIN(5, 18))) {
449 pr_warn("Error: USB Function not selected - check SW5 + SW6\n");
454 phy = usb_get_phy_dev(&pdev->dev, 0);
463 gpio_free(RCAR_GP_PIN(5, 18));
467 static int usbhs_hardware_exit(struct platform_device *pdev)
469 struct usbhs_private *priv = usbhs_get_priv(pdev);
474 usb_put_phy(priv->phy);
477 gpio_free(RCAR_GP_PIN(5, 18));
481 static int usbhs_get_id(struct platform_device *pdev)
486 static u32 lager_usbhs_pipe_type[] = {
487 USB_ENDPOINT_XFER_CONTROL,
488 USB_ENDPOINT_XFER_ISOC,
489 USB_ENDPOINT_XFER_ISOC,
490 USB_ENDPOINT_XFER_BULK,
491 USB_ENDPOINT_XFER_BULK,
492 USB_ENDPOINT_XFER_BULK,
493 USB_ENDPOINT_XFER_INT,
494 USB_ENDPOINT_XFER_INT,
495 USB_ENDPOINT_XFER_INT,
496 USB_ENDPOINT_XFER_BULK,
497 USB_ENDPOINT_XFER_BULK,
498 USB_ENDPOINT_XFER_BULK,
499 USB_ENDPOINT_XFER_BULK,
500 USB_ENDPOINT_XFER_BULK,
501 USB_ENDPOINT_XFER_BULK,
502 USB_ENDPOINT_XFER_BULK,
505 static struct usbhs_private usbhs_priv __initdata = {
507 .platform_callback = {
508 .power_ctrl = usbhs_power_ctrl,
509 .hardware_init = usbhs_hardware_init,
510 .hardware_exit = usbhs_hardware_exit,
511 .get_id = usbhs_get_id,
515 .pipe_type = lager_usbhs_pipe_type,
516 .pipe_size = ARRAY_SIZE(lager_usbhs_pipe_type),
521 static void __init lager_register_usbhs(void)
523 usb_bind_phy("renesas_usbhs", 0, "usb_phy_rcar_gen2");
524 platform_device_register_resndata(&platform_bus,
527 ARRAY_SIZE(usbhs_resources),
529 sizeof(usbhs_priv.info));
533 static const struct rcar_gen2_phy_platform_data usbhs_phy_pdata __initconst = {
534 .chan0_pci = 0, /* Channel 0 is USBHS */
535 .chan2_pci = 1, /* Channel 2 is PCI USB */
538 static const struct resource usbhs_phy_resources[] __initconst = {
539 DEFINE_RES_MEM(0xe6590100, 0x100),
543 static struct i2c_board_info i2c2_devices[] = {
545 I2C_BOARD_INFO("ak4643", 0x12),
550 static struct resource rsnd_resources[] __initdata = {
551 [RSND_GEN2_SCU] = DEFINE_RES_MEM(0xec500000, 0x1000),
552 [RSND_GEN2_ADG] = DEFINE_RES_MEM(0xec5a0000, 0x100),
553 [RSND_GEN2_SSIU] = DEFINE_RES_MEM(0xec540000, 0x1000),
554 [RSND_GEN2_SSI] = DEFINE_RES_MEM(0xec541000, 0x1280),
557 static struct rsnd_ssi_platform_info rsnd_ssi[] = {
558 RSND_SSI_SET(0, 0, gic_spi(370), RSND_SSI_PLAY),
559 RSND_SSI_SET(0, 0, gic_spi(371), RSND_SSI_CLK_PIN_SHARE),
562 static struct rsnd_scu_platform_info rsnd_scu[2] = {
563 /* no member at this point */
566 static struct rcar_snd_info rsnd_info = {
568 .ssi_info = rsnd_ssi,
569 .ssi_info_nr = ARRAY_SIZE(rsnd_ssi),
570 .scu_info = rsnd_scu,
571 .scu_info_nr = ARRAY_SIZE(rsnd_scu),
574 static struct asoc_simple_card_info rsnd_card_info = {
576 .card = "SSI01-AK4643",
577 .codec = "ak4642-codec.2-0012",
578 .platform = "rcar_sound",
579 .daifmt = SND_SOC_DAIFMT_LEFT_J,
581 .name = "rcar_sound",
582 .fmt = SND_SOC_DAIFMT_CBS_CFS,
585 .name = "ak4642-hifi",
586 .fmt = SND_SOC_DAIFMT_CBM_CFM,
591 static void __init lager_add_rsnd_device(void)
593 struct platform_device_info cardinfo = {
594 .parent = &platform_bus,
595 .name = "asoc-simple-card",
597 .data = &rsnd_card_info,
598 .size_data = sizeof(struct asoc_simple_card_info),
599 .dma_mask = DMA_BIT_MASK(32),
602 i2c_register_board_info(2, i2c2_devices,
603 ARRAY_SIZE(i2c2_devices));
605 platform_device_register_resndata(
606 &platform_bus, "rcar_sound", -1,
607 rsnd_resources, ARRAY_SIZE(rsnd_resources),
608 &rsnd_info, sizeof(rsnd_info));
610 platform_device_register_full(&cardinfo);
614 static struct sh_mobile_sdhi_info sdhi0_info __initdata = {
615 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
616 MMC_CAP_POWER_OFF_CARD,
617 .tmio_caps2 = MMC_CAP2_NO_MULTI_READ,
618 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
619 TMIO_MMC_WRPROTECT_DISABLE,
622 static struct resource sdhi0_resources[] __initdata = {
623 DEFINE_RES_MEM(0xee100000, 0x200),
624 DEFINE_RES_IRQ(gic_spi(165)),
628 static struct sh_mobile_sdhi_info sdhi2_info __initdata = {
629 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
630 MMC_CAP_POWER_OFF_CARD,
631 .tmio_caps2 = MMC_CAP2_NO_MULTI_READ,
632 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
633 TMIO_MMC_WRPROTECT_DISABLE,
636 static struct resource sdhi2_resources[] __initdata = {
637 DEFINE_RES_MEM(0xee140000, 0x100),
638 DEFINE_RES_IRQ(gic_spi(167)),
641 static const struct pinctrl_map lager_pinctrl_map[] = {
642 /* DU (CN10: ARGB0, CN13: LVDS) */
643 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
645 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
647 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
648 "du_clk_out_0", "du"),
650 PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar.2", "pfc-r8a7790",
652 /* SCIF0 (CN19: DEBUG SERIAL0) */
653 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
654 "scif0_data", "scif0"),
655 /* SCIF1 (CN20: DEBUG SERIAL1) */
656 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7790",
657 "scif1_data", "scif1"),
659 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790",
660 "sdhi0_data4", "sdhi0"),
661 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790",
662 "sdhi0_ctrl", "sdhi0"),
663 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790",
664 "sdhi0_cd", "sdhi0"),
666 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790",
667 "sdhi2_data4", "sdhi2"),
668 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790",
669 "sdhi2_ctrl", "sdhi2"),
670 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790",
671 "sdhi2_cd", "sdhi2"),
672 /* SSI (CN17: sound) */
673 PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
674 "ssi0129_ctrl", "ssi"),
675 PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
677 PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
679 PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
680 "audio_clk_a", "audio_clk"),
682 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
683 "mmc1_data8", "mmc1"),
684 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
685 "mmc1_ctrl", "mmc1"),
687 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
689 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
691 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
693 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
694 "intc_irq0", "intc"),
696 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
697 "vin0_data24", "vin0"),
698 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
699 "vin0_sync", "vin0"),
700 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
701 "vin0_field", "vin0"),
702 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
703 "vin0_clkenb", "vin0"),
704 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
707 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790",
708 "vin1_data8", "vin1"),
709 PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790",
712 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7790",
713 "usb0_ovc_vbus", "usb0"),
716 static void __init lager_add_standard_devices(void)
718 int fixed_regulator_idx = 0;
719 int gpio_regulator_idx = 0;
721 r8a7790_clock_init();
723 pinctrl_register_mappings(lager_pinctrl_map,
724 ARRAY_SIZE(lager_pinctrl_map));
725 r8a7790_pinmux_init();
727 r8a7790_add_standard_devices();
728 platform_device_register_data(&platform_bus, "leds-gpio", -1,
730 sizeof(lager_leds_pdata));
731 platform_device_register_data(&platform_bus, "gpio-keys", -1,
733 sizeof(lager_keys_pdata));
734 regulator_register_always_on(fixed_regulator_idx++,
735 "fixed-3.3V", fixed3v3_power_consumers,
736 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
737 platform_device_register_resndata(&platform_bus, "sh_mmcif", 1,
738 mmcif1_resources, ARRAY_SIZE(mmcif1_resources),
739 &mmcif1_pdata, sizeof(mmcif1_pdata));
741 platform_device_register_resndata(&platform_bus, "r8a7790-ether", -1,
743 ARRAY_SIZE(ether_resources),
744 ðer_pdata, sizeof(ether_pdata));
746 lager_add_du_device();
748 platform_device_register_resndata(&platform_bus, "qspi", 0,
750 ARRAY_SIZE(qspi_resources),
751 &qspi_pdata, sizeof(qspi_pdata));
752 spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
754 platform_device_register_data(&platform_bus, "reg-fixed-voltage", fixed_regulator_idx++,
755 &vcc_sdhi0_info, sizeof(struct fixed_voltage_config));
756 platform_device_register_data(&platform_bus, "reg-fixed-voltage", fixed_regulator_idx++,
757 &vcc_sdhi2_info, sizeof(struct fixed_voltage_config));
759 platform_device_register_data(&platform_bus, "gpio-regulator", gpio_regulator_idx++,
760 &vccq_sdhi0_info, sizeof(struct gpio_regulator_config));
761 platform_device_register_data(&platform_bus, "gpio-regulator", gpio_regulator_idx++,
762 &vccq_sdhi2_info, sizeof(struct gpio_regulator_config));
764 lager_add_camera1_device();
766 platform_device_register_full(&sata1_info);
768 platform_device_register_resndata(&platform_bus, "usb_phy_rcar_gen2",
769 -1, usbhs_phy_resources,
770 ARRAY_SIZE(usbhs_phy_resources),
772 sizeof(usbhs_phy_pdata));
773 lager_register_usbhs();
775 lager_add_rsnd_device();
777 platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 0,
778 sdhi0_resources, ARRAY_SIZE(sdhi0_resources),
779 &sdhi0_info, sizeof(struct sh_mobile_sdhi_info));
780 platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 2,
781 sdhi2_resources, ARRAY_SIZE(sdhi2_resources),
782 &sdhi2_info, sizeof(struct sh_mobile_sdhi_info));
786 * Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds
787 * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits
788 * 14-15. We have to set them back to 01 from the default 00 value each time
789 * the PHY is reset. It's also important because the PHY's LED0 signal is
790 * connected to SoC's ETH_LINK signal and in the PHY's default mode it will
791 * bounce on and off after each packet, which we apparently want to avoid.
793 static int lager_ksz8041_fixup(struct phy_device *phydev)
795 u16 phyctrl1 = phy_read(phydev, 0x1e);
799 return phy_write(phydev, 0x1e, phyctrl1);
802 static void __init lager_init(void)
804 lager_add_standard_devices();
806 irq_set_irq_type(irq_pin(0), IRQ_TYPE_LEVEL_LOW);
808 if (IS_ENABLED(CONFIG_PHYLIB))
809 phy_register_fixup_for_id("r8a7790-ether-ff:01",
810 lager_ksz8041_fixup);
813 static const char * const lager_boards_compat_dt[] __initconst = {
818 DT_MACHINE_START(LAGER_DT, "lager")
819 .smp = smp_ops(r8a7790_smp_ops),
820 .init_early = r8a7790_init_early,
821 .init_time = rcar_gen2_timer_init,
822 .init_machine = lager_init,
823 .init_late = shmobile_init_late,
824 .dt_compat = lager_boards_compat_dt,