4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 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/kernel.h>
22 #include <linux/init.h>
23 #include <linux/interrupt.h>
24 #include <linux/irq.h>
25 #include <linux/platform_device.h>
26 #include <linux/delay.h>
28 #include <linux/gpio.h>
29 #include <linux/dma-mapping.h>
30 #include <linux/regulator/fixed.h>
31 #include <linux/regulator/machine.h>
32 #include <linux/smsc911x.h>
33 #include <linux/spi/spi.h>
34 #include <linux/spi/sh_hspi.h>
35 #include <linux/mmc/sh_mobile_sdhi.h>
36 #include <linux/mfd/tmio.h>
37 #include <linux/usb/otg.h>
38 #include <linux/usb/ehci_pdriver.h>
39 #include <linux/usb/ohci_pdriver.h>
40 #include <linux/pm_runtime.h>
41 #include <mach/hardware.h>
42 #include <mach/r8a7779.h>
43 #include <mach/common.h>
44 #include <mach/irqs.h>
45 #include <asm/mach-types.h>
46 #include <asm/mach/arch.h>
47 #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 smsc911x_resources[] = {
64 .start = 0x18000000, /* ExCS0 */
65 .end = 0x180000ff, /* A1->A7 */
66 .flags = IORESOURCE_MEM,
69 .start = gic_spi(28), /* IRQ 1 */
70 .flags = IORESOURCE_IRQ,
74 static struct smsc911x_platform_config smsc911x_platdata = {
75 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
76 .phy_interface = PHY_INTERFACE_MODE_MII,
77 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
78 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
81 static struct platform_device eth_device = {
85 .platform_data = &smsc911x_platdata,
87 .resource = smsc911x_resources,
88 .num_resources = ARRAY_SIZE(smsc911x_resources),
91 static struct resource sdhi0_resources[] = {
96 .flags = IORESOURCE_MEM,
99 .start = gic_spi(104),
100 .flags = IORESOURCE_IRQ,
104 static struct sh_mobile_sdhi_info sdhi0_platform_data = {
105 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
106 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
109 static struct platform_device sdhi0_device = {
110 .name = "sh_mobile_sdhi",
111 .num_resources = ARRAY_SIZE(sdhi0_resources),
112 .resource = sdhi0_resources,
115 .platform_data = &sdhi0_platform_data,
120 static struct resource thermal_resources[] = {
123 .end = 0xFFC48038 - 1,
124 .flags = IORESOURCE_MEM,
128 static struct platform_device thermal_device = {
129 .name = "rcar_thermal",
130 .resource = thermal_resources,
131 .num_resources = ARRAY_SIZE(thermal_resources),
135 static struct resource hspi_resources[] = {
138 .end = 0xFFFC7018 - 1,
139 .flags = IORESOURCE_MEM,
143 static struct platform_device hspi_device = {
146 .resource = hspi_resources,
147 .num_resources = ARRAY_SIZE(hspi_resources),
151 static struct resource usb_phy_resources[] = {
154 .end = 0xffe70900 - 1,
155 .flags = IORESOURCE_MEM,
159 .end = 0xfff70900 - 1,
160 .flags = IORESOURCE_MEM,
164 static struct platform_device usb_phy_device = {
165 .name = "rcar_usb_phy",
166 .resource = usb_phy_resources,
167 .num_resources = ARRAY_SIZE(usb_phy_resources),
170 static struct platform_device *marzen_devices[] __initdata = {
179 static struct usb_phy *phy;
180 static int usb_power_on(struct platform_device *pdev)
185 pm_runtime_enable(&pdev->dev);
186 pm_runtime_get_sync(&pdev->dev);
193 static void usb_power_off(struct platform_device *pdev)
198 usb_phy_shutdown(phy);
200 pm_runtime_put_sync(&pdev->dev);
201 pm_runtime_disable(&pdev->dev);
204 static struct usb_ehci_pdata ehcix_pdata = {
205 .power_on = usb_power_on,
206 .power_off = usb_power_off,
207 .power_suspend = usb_power_off,
210 static struct resource ehci0_resources[] = {
213 .end = 0xffe70400 - 1,
214 .flags = IORESOURCE_MEM,
217 .start = gic_spi(44),
218 .flags = IORESOURCE_IRQ,
222 static struct platform_device ehci0_device = {
223 .name = "ehci-platform",
226 .dma_mask = &ehci0_device.dev.coherent_dma_mask,
227 .coherent_dma_mask = 0xffffffff,
228 .platform_data = &ehcix_pdata,
230 .num_resources = ARRAY_SIZE(ehci0_resources),
231 .resource = ehci0_resources,
234 static struct resource ehci1_resources[] = {
237 .end = 0xfff70400 - 1,
238 .flags = IORESOURCE_MEM,
241 .start = gic_spi(45),
242 .flags = IORESOURCE_IRQ,
246 static struct platform_device ehci1_device = {
247 .name = "ehci-platform",
250 .dma_mask = &ehci1_device.dev.coherent_dma_mask,
251 .coherent_dma_mask = 0xffffffff,
252 .platform_data = &ehcix_pdata,
254 .num_resources = ARRAY_SIZE(ehci1_resources),
255 .resource = ehci1_resources,
258 static struct usb_ohci_pdata ohcix_pdata = {
259 .power_on = usb_power_on,
260 .power_off = usb_power_off,
261 .power_suspend = usb_power_off,
264 static struct resource ohci0_resources[] = {
267 .end = 0xffe70800 - 1,
268 .flags = IORESOURCE_MEM,
271 .start = gic_spi(44),
272 .flags = IORESOURCE_IRQ,
276 static struct platform_device ohci0_device = {
277 .name = "ohci-platform",
280 .dma_mask = &ohci0_device.dev.coherent_dma_mask,
281 .coherent_dma_mask = 0xffffffff,
282 .platform_data = &ohcix_pdata,
284 .num_resources = ARRAY_SIZE(ohci0_resources),
285 .resource = ohci0_resources,
288 static struct resource ohci1_resources[] = {
291 .end = 0xfff70800 - 1,
292 .flags = IORESOURCE_MEM,
295 .start = gic_spi(45),
296 .flags = IORESOURCE_IRQ,
300 static struct platform_device ohci1_device = {
301 .name = "ohci-platform",
304 .dma_mask = &ohci1_device.dev.coherent_dma_mask,
305 .coherent_dma_mask = 0xffffffff,
306 .platform_data = &ohcix_pdata,
308 .num_resources = ARRAY_SIZE(ohci1_resources),
309 .resource = ohci1_resources,
312 static struct platform_device *marzen_late_devices[] __initdata = {
319 void __init marzen_init_late(void)
322 phy = usb_get_phy(USB_PHY_TYPE_USB2);
324 shmobile_init_late();
325 platform_add_devices(marzen_late_devices,
326 ARRAY_SIZE(marzen_late_devices));
329 static void __init marzen_init(void)
331 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
332 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
333 regulator_register_fixed(1, dummy_supplies,
334 ARRAY_SIZE(dummy_supplies));
336 r8a7779_pinmux_init();
338 /* SCIF2 (CN18: DEBUG0) */
339 gpio_request(GPIO_FN_TX2_C, NULL);
340 gpio_request(GPIO_FN_RX2_C, NULL);
342 /* SCIF4 (CN19: DEBUG1) */
343 gpio_request(GPIO_FN_TX4, NULL);
344 gpio_request(GPIO_FN_RX4, NULL);
347 gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
348 gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
351 gpio_request(GPIO_FN_SD0_CLK, NULL);
352 gpio_request(GPIO_FN_SD0_CMD, NULL);
353 gpio_request(GPIO_FN_SD0_DAT0, NULL);
354 gpio_request(GPIO_FN_SD0_DAT1, NULL);
355 gpio_request(GPIO_FN_SD0_DAT2, NULL);
356 gpio_request(GPIO_FN_SD0_DAT3, NULL);
357 gpio_request(GPIO_FN_SD0_CD, NULL);
358 gpio_request(GPIO_FN_SD0_WP, NULL);
361 gpio_request(GPIO_FN_HSPI_CLK0, NULL);
362 gpio_request(GPIO_FN_HSPI_CS0, NULL);
363 gpio_request(GPIO_FN_HSPI_TX0, NULL);
364 gpio_request(GPIO_FN_HSPI_RX0, NULL);
367 gpio_request(GPIO_FN_USB_OVC0, NULL);
368 gpio_request(GPIO_FN_USB_OVC1, NULL);
369 gpio_request(GPIO_FN_USB_OVC2, NULL);
372 gpio_request(GPIO_FN_USB_PENC2, NULL);
374 r8a7779_add_standard_devices();
375 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
378 MACHINE_START(MARZEN, "marzen")
379 .smp = smp_ops(r8a7779_smp_ops),
380 .map_io = r8a7779_map_io,
381 .init_early = r8a7779_add_early_devices,
382 .nr_irqs = NR_IRQS_LEGACY,
383 .init_irq = r8a7779_init_irq,
384 .init_machine = marzen_init,
385 .init_late = marzen_init_late,
386 .timer = &shmobile_timer,