4 * Copyright (C) 2011, 2013 Renesas Solutions Corp.
5 * Copyright (C) 2011 Magnus Damm
6 * Copyright (C) 2013 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/kernel.h>
19 #include <linux/init.h>
20 #include <linux/interrupt.h>
21 #include <linux/irq.h>
22 #include <linux/platform_device.h>
23 #include <linux/delay.h>
25 #include <linux/leds.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/pinctrl/machine.h>
28 #include <linux/platform_data/camera-rcar.h>
29 #include <linux/platform_data/gpio-rcar.h>
30 #include <linux/platform_data/usb-rcar-phy.h>
31 #include <linux/regulator/fixed.h>
32 #include <linux/regulator/machine.h>
33 #include <linux/smsc911x.h>
34 #include <linux/spi/spi.h>
35 #include <linux/spi/sh_hspi.h>
36 #include <linux/mmc/host.h>
37 #include <linux/mmc/sh_mobile_sdhi.h>
38 #include <linux/mfd/tmio.h>
40 #include <media/soc_camera.h>
41 #include <asm/mach-types.h>
42 #include <asm/mach/arch.h>
43 #include <asm/traps.h>
49 /* Fixed 3.3V regulator to be used by SDHI0 */
50 static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
51 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
52 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
55 /* Dummy supplies, where voltage doesn't matter */
56 static struct regulator_consumer_supply dummy_supplies[] = {
57 REGULATOR_SUPPLY("vddvario", "smsc911x"),
58 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
62 static struct resource usb_phy_resources[] = {
65 .end = 0xffe70900 - 1,
66 .flags = IORESOURCE_MEM,
70 static struct rcar_phy_platform_data usb_phy_platform_data;
72 static struct platform_device usb_phy = {
73 .name = "rcar_usb_phy",
76 .platform_data = &usb_phy_platform_data,
78 .resource = usb_phy_resources,
79 .num_resources = ARRAY_SIZE(usb_phy_resources),
83 static struct resource smsc911x_resources[] = {
85 .start = 0x18000000, /* ExCS0 */
86 .end = 0x180000ff, /* A1->A7 */
87 .flags = IORESOURCE_MEM,
90 .start = irq_pin(1), /* IRQ 1 */
91 .flags = IORESOURCE_IRQ,
95 static struct smsc911x_platform_config smsc911x_platdata = {
96 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
97 .phy_interface = PHY_INTERFACE_MODE_MII,
98 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
99 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
102 static struct platform_device eth_device = {
106 .platform_data = &smsc911x_platdata,
108 .resource = smsc911x_resources,
109 .num_resources = ARRAY_SIZE(smsc911x_resources),
112 static struct resource sdhi0_resources[] = {
117 .flags = IORESOURCE_MEM,
120 .start = gic_iid(0x88),
121 .flags = IORESOURCE_IRQ,
125 static struct sh_mobile_sdhi_info sdhi0_platform_data = {
126 .dma_slave_tx = HPBDMA_SLAVE_SDHI0_TX,
127 .dma_slave_rx = HPBDMA_SLAVE_SDHI0_RX,
128 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
129 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
132 static struct platform_device sdhi0_device = {
133 .name = "sh_mobile_sdhi",
134 .num_resources = ARRAY_SIZE(sdhi0_resources),
135 .resource = sdhi0_resources,
138 .platform_data = &sdhi0_platform_data,
143 static struct resource thermal_resources[] = {
146 .end = 0xFFC48038 - 1,
147 .flags = IORESOURCE_MEM,
151 static struct platform_device thermal_device = {
152 .name = "rcar_thermal",
153 .resource = thermal_resources,
154 .num_resources = ARRAY_SIZE(thermal_resources),
158 static struct resource hspi_resources[] = {
161 .end = 0xFFFC7018 - 1,
162 .flags = IORESOURCE_MEM,
166 static struct platform_device hspi_device = {
169 .resource = hspi_resources,
170 .num_resources = ARRAY_SIZE(hspi_resources),
174 static struct gpio_led marzen_leds[] = {
177 .gpio = RCAR_GP_PIN(4, 29),
178 .default_state = LEDS_GPIO_DEFSTATE_ON,
181 .gpio = RCAR_GP_PIN(4, 30),
182 .default_state = LEDS_GPIO_DEFSTATE_ON,
185 .gpio = RCAR_GP_PIN(4, 31),
186 .default_state = LEDS_GPIO_DEFSTATE_ON,
190 static struct gpio_led_platform_data marzen_leds_pdata = {
192 .num_leds = ARRAY_SIZE(marzen_leds),
195 static struct platform_device leds_device = {
199 .platform_data = &marzen_leds_pdata,
204 static struct rcar_vin_platform_data vin_platform_data __initdata = {
205 .flags = RCAR_VIN_BT656,
208 #define MARZEN_VIN(idx) \
209 static struct resource vin##idx##_resources[] __initdata = { \
210 DEFINE_RES_MEM(0xffc50000 + 0x1000 * (idx), 0x1000), \
211 DEFINE_RES_IRQ(gic_iid(0x5f + (idx))), \
214 static struct platform_device_info vin##idx##_info __initdata = { \
215 .parent = &platform_bus, \
216 .name = "r8a7779-vin", \
218 .res = vin##idx##_resources, \
219 .num_res = ARRAY_SIZE(vin##idx##_resources), \
220 .dma_mask = DMA_BIT_MASK(32), \
221 .data = &vin_platform_data, \
222 .size_data = sizeof(vin_platform_data), \
227 #define MARZEN_CAMERA(idx) \
228 static struct i2c_board_info camera##idx##_info = { \
229 I2C_BOARD_INFO("adv7180", 0x20 + (idx)), \
232 static struct soc_camera_link iclink##idx##_adv7180 = { \
233 .bus_id = 1 + 2 * (idx), \
234 .i2c_adapter_id = 0, \
235 .board_info = &camera##idx##_info, \
238 static struct platform_device camera##idx##_device = { \
239 .name = "soc-camera-pdrv", \
242 .platform_data = &iclink##idx##_adv7180, \
249 static struct platform_device *marzen_devices[] __initdata = {
260 static const struct pinctrl_map marzen_pinctrl_map[] = {
261 /* DU (CN10: ARGB0, CN13: LVDS) */
262 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
263 "du0_rgb888", "du0"),
264 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
265 "du0_sync_1", "du0"),
266 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
267 "du0_clk_out_0", "du0"),
268 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
269 "du1_rgb666", "du1"),
270 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
271 "du1_sync_1", "du1"),
272 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
273 "du1_clk_out", "du1"),
275 PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
277 /* SCIF2 (CN18: DEBUG0) */
278 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
279 "scif2_data_c", "scif2"),
280 /* SCIF4 (CN19: DEBUG1) */
281 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
282 "scif4_data", "scif4"),
284 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
285 "sdhi0_data4", "sdhi0"),
286 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
287 "sdhi0_ctrl", "sdhi0"),
288 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
289 "sdhi0_cd", "sdhi0"),
291 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
292 "intc_irq1_b", "intc"),
293 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
294 "lbsc_ex_cs0", "lbsc"),
296 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
299 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
302 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779",
305 PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
307 PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
308 "vin1_data8", "vin1"),
310 PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
312 PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
313 "vin3_data8", "vin3"),
316 static void __init marzen_init(void)
318 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
319 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
320 regulator_register_fixed(1, dummy_supplies,
321 ARRAY_SIZE(dummy_supplies));
323 pinctrl_register_mappings(marzen_pinctrl_map,
324 ARRAY_SIZE(marzen_pinctrl_map));
325 r8a7779_pinmux_init();
326 r8a7779_init_irq_extpin(1); /* IRQ1 as individual interrupt */
328 r8a7779_add_standard_devices();
329 platform_device_register_full(&vin1_info);
330 platform_device_register_full(&vin3_info);
331 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
334 static const char *marzen_boards_compat_dt[] __initdata = {
339 DT_MACHINE_START(MARZEN, "marzen")
340 .smp = smp_ops(r8a7779_smp_ops),
341 .map_io = r8a7779_map_io,
342 .init_early = r8a7779_add_early_devices,
343 .init_irq = r8a7779_init_irq_dt,
344 .init_machine = marzen_init,
345 .init_late = r8a7779_init_late,
346 .dt_compat = marzen_boards_compat_dt,
347 .init_time = r8a7779_earlytimer_init,