aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>2013-06-01 17:30:15 -0400
committerSimon Horman <horms+renesas@verge.net.au>2013-06-11 03:10:40 -0400
commit2c8788bfd89bad424d3c288b5a52ce141271b862 (patch)
tree7bfaa3328c62be862903d97aabf4aae26ebc7c13
parentae8b378faea7f04d4517b22f5d70d824adcbc4dc (diff)
ARM: shmobile: Marzen: move USB EHCI, OHCI, and PHY devices to R8A7779 code
USB EHCI, OHCI, and common PHY are the SoC devices but are wrongly defined and registered in the Marzen board file. Move the data and code to their proper place in setup-r8a7779.c; while at it, we have to rename r8a7779_late_devices[] to r8a7779_standard_devices[] -- this seems legitimate since they are registered from r8a7779_add_standard_devices() anyway. Note that I'm deliberately changing the USB PHY platform device's 'id' field from (previously just omitted) 0 to -1 as the device is a single of its kind. Note also that the board and SoC code have to be in one patch to keep the code bisectable... The patch has been tested on the Marzen board. Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> [horms+renesas@verge.net.au: manually applied] Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
-rw-r--r--arch/arm/mach-shmobile/board-marzen.c178
-rw-r--r--arch/arm/mach-shmobile/include/mach/r8a7779.h1
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7779.c185
3 files changed, 184 insertions, 180 deletions
diff --git a/arch/arm/mach-shmobile/board-marzen.c b/arch/arm/mach-shmobile/board-marzen.c
index fac9e0f87897..fff353f670b8 100644
--- a/arch/arm/mach-shmobile/board-marzen.c
+++ b/arch/arm/mach-shmobile/board-marzen.c
@@ -37,10 +37,6 @@
37#include <linux/mmc/host.h> 37#include <linux/mmc/host.h>
38#include <linux/mmc/sh_mobile_sdhi.h> 38#include <linux/mmc/sh_mobile_sdhi.h>
39#include <linux/mfd/tmio.h> 39#include <linux/mfd/tmio.h>
40#include <linux/usb/otg.h>
41#include <linux/usb/ehci_pdriver.h>
42#include <linux/usb/ohci_pdriver.h>
43#include <linux/pm_runtime.h>
44#include <mach/hardware.h> 40#include <mach/hardware.h>
45#include <mach/r8a7779.h> 41#include <mach/r8a7779.h>
46#include <mach/common.h> 42#include <mach/common.h>
@@ -150,26 +146,6 @@ static struct platform_device hspi_device = {
150 .num_resources = ARRAY_SIZE(hspi_resources), 146 .num_resources = ARRAY_SIZE(hspi_resources),
151}; 147};
152 148
153/* USB PHY */
154static struct resource usb_phy_resources[] = {
155 [0] = {
156 .start = 0xffe70000,
157 .end = 0xffe70900 - 1,
158 .flags = IORESOURCE_MEM,
159 },
160 [1] = {
161 .start = 0xfff70000,
162 .end = 0xfff70900 - 1,
163 .flags = IORESOURCE_MEM,
164 },
165};
166
167static struct platform_device usb_phy_device = {
168 .name = "rcar_usb_phy",
169 .resource = usb_phy_resources,
170 .num_resources = ARRAY_SIZE(usb_phy_resources),
171};
172
173/* LEDS */ 149/* LEDS */
174static struct gpio_led marzen_leds[] = { 150static struct gpio_led marzen_leds[] = {
175 { 151 {
@@ -205,161 +181,9 @@ static struct platform_device *marzen_devices[] __initdata = {
205 &sdhi0_device, 181 &sdhi0_device,
206 &thermal_device, 182 &thermal_device,
207 &hspi_device, 183 &hspi_device,
208 &usb_phy_device,
209 &leds_device, 184 &leds_device,
210}; 185};
211 186
212/* USB */
213static struct usb_phy *phy;
214static int usb_power_on(struct platform_device *pdev)
215{
216 if (!phy)
217 return -EIO;
218
219 pm_runtime_enable(&pdev->dev);
220 pm_runtime_get_sync(&pdev->dev);
221
222 usb_phy_init(phy);
223
224 return 0;
225}
226
227static void usb_power_off(struct platform_device *pdev)
228{
229 if (!phy)
230 return;
231
232 usb_phy_shutdown(phy);
233
234 pm_runtime_put_sync(&pdev->dev);
235 pm_runtime_disable(&pdev->dev);
236}
237
238static struct usb_ehci_pdata ehcix_pdata = {
239 .power_on = usb_power_on,
240 .power_off = usb_power_off,
241 .power_suspend = usb_power_off,
242};
243
244static struct resource ehci0_resources[] = {
245 [0] = {
246 .start = 0xffe70000,
247 .end = 0xffe70400 - 1,
248 .flags = IORESOURCE_MEM,
249 },
250 [1] = {
251 .start = gic_iid(0x4c),
252 .flags = IORESOURCE_IRQ,
253 },
254};
255
256static struct platform_device ehci0_device = {
257 .name = "ehci-platform",
258 .id = 0,
259 .dev = {
260 .dma_mask = &ehci0_device.dev.coherent_dma_mask,
261 .coherent_dma_mask = 0xffffffff,
262 .platform_data = &ehcix_pdata,
263 },
264 .num_resources = ARRAY_SIZE(ehci0_resources),
265 .resource = ehci0_resources,
266};
267
268static struct resource ehci1_resources[] = {
269 [0] = {
270 .start = 0xfff70000,
271 .end = 0xfff70400 - 1,
272 .flags = IORESOURCE_MEM,
273 },
274 [1] = {
275 .start = gic_iid(0x4d),
276 .flags = IORESOURCE_IRQ,
277 },
278};
279
280static struct platform_device ehci1_device = {
281 .name = "ehci-platform",
282 .id = 1,
283 .dev = {
284 .dma_mask = &ehci1_device.dev.coherent_dma_mask,
285 .coherent_dma_mask = 0xffffffff,
286 .platform_data = &ehcix_pdata,
287 },
288 .num_resources = ARRAY_SIZE(ehci1_resources),
289 .resource = ehci1_resources,
290};
291
292static struct usb_ohci_pdata ohcix_pdata = {
293 .power_on = usb_power_on,
294 .power_off = usb_power_off,
295 .power_suspend = usb_power_off,
296};
297
298static struct resource ohci0_resources[] = {
299 [0] = {
300 .start = 0xffe70400,
301 .end = 0xffe70800 - 1,
302 .flags = IORESOURCE_MEM,
303 },
304 [1] = {
305 .start = gic_iid(0x4c),
306 .flags = IORESOURCE_IRQ,
307 },
308};
309
310static struct platform_device ohci0_device = {
311 .name = "ohci-platform",
312 .id = 0,
313 .dev = {
314 .dma_mask = &ohci0_device.dev.coherent_dma_mask,
315 .coherent_dma_mask = 0xffffffff,
316 .platform_data = &ohcix_pdata,
317 },
318 .num_resources = ARRAY_SIZE(ohci0_resources),
319 .resource = ohci0_resources,
320};
321
322static struct resource ohci1_resources[] = {
323 [0] = {
324 .start = 0xfff70400,
325 .end = 0xfff70800 - 1,
326 .flags = IORESOURCE_MEM,
327 },
328 [1] = {
329 .start = gic_iid(0x4d),
330 .flags = IORESOURCE_IRQ,
331 },
332};
333
334static struct platform_device ohci1_device = {
335 .name = "ohci-platform",
336 .id = 1,
337 .dev = {
338 .dma_mask = &ohci1_device.dev.coherent_dma_mask,
339 .coherent_dma_mask = 0xffffffff,
340 .platform_data = &ohcix_pdata,
341 },
342 .num_resources = ARRAY_SIZE(ohci1_resources),
343 .resource = ohci1_resources,
344};
345
346static struct platform_device *marzen_late_devices[] __initdata = {
347 &ehci0_device,
348 &ehci1_device,
349 &ohci0_device,
350 &ohci1_device,
351};
352
353void __init marzen_init_late(void)
354{
355 /* get usb phy */
356 phy = usb_get_phy(USB_PHY_TYPE_USB2);
357
358 shmobile_init_late();
359 platform_add_devices(marzen_late_devices,
360 ARRAY_SIZE(marzen_late_devices));
361}
362
363static const struct pinctrl_map marzen_pinctrl_map[] = { 187static const struct pinctrl_map marzen_pinctrl_map[] = {
364 /* HSPI0 */ 188 /* HSPI0 */
365 PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779", 189 PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
@@ -417,6 +241,6 @@ MACHINE_START(MARZEN, "marzen")
417 .nr_irqs = NR_IRQS_LEGACY, 241 .nr_irqs = NR_IRQS_LEGACY,
418 .init_irq = r8a7779_init_irq, 242 .init_irq = r8a7779_init_irq,
419 .init_machine = marzen_init, 243 .init_machine = marzen_init,
420 .init_late = marzen_init_late, 244 .init_late = r8a7779_init_late,
421 .init_time = r8a7779_earlytimer_init, 245 .init_time = r8a7779_earlytimer_init,
422MACHINE_END 246MACHINE_END
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7779.h b/arch/arm/mach-shmobile/include/mach/r8a7779.h
index 188b295938a5..f10727f77b11 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7779.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7779.h
@@ -33,6 +33,7 @@ extern void r8a7779_add_early_devices(void);
33extern void r8a7779_add_standard_devices(void); 33extern void r8a7779_add_standard_devices(void);
34extern void r8a7779_add_standard_devices_dt(void); 34extern void r8a7779_add_standard_devices_dt(void);
35extern void r8a7779_add_ether_device(struct sh_eth_plat_data *pdata); 35extern void r8a7779_add_ether_device(struct sh_eth_plat_data *pdata);
36extern void r8a7779_init_late(void);
36extern void r8a7779_clock_init(void); 37extern void r8a7779_clock_init(void);
37extern void r8a7779_pinmux_init(void); 38extern void r8a7779_pinmux_init(void);
38extern void r8a7779_pm_init(void); 39extern void r8a7779_pm_init(void);
diff --git a/arch/arm/mach-shmobile/setup-r8a7779.c b/arch/arm/mach-shmobile/setup-r8a7779.c
index dbb13f289e79..533d7fd39644 100644
--- a/arch/arm/mach-shmobile/setup-r8a7779.c
+++ b/arch/arm/mach-shmobile/setup-r8a7779.c
@@ -32,6 +32,10 @@
32#include <linux/sh_intc.h> 32#include <linux/sh_intc.h>
33#include <linux/sh_timer.h> 33#include <linux/sh_timer.h>
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/usb/otg.h>
36#include <linux/usb/ehci_pdriver.h>
37#include <linux/usb/ohci_pdriver.h>
38#include <linux/pm_runtime.h>
35#include <mach/hardware.h> 39#include <mach/hardware.h>
36#include <mach/irqs.h> 40#include <mach/irqs.h>
37#include <mach/r8a7779.h> 41#include <mach/r8a7779.h>
@@ -383,6 +387,162 @@ static struct platform_device sata_device = {
383 }, 387 },
384}; 388};
385 389
390/* USB PHY */
391static struct resource usb_phy_resources[] = {
392 [0] = {
393 .start = 0xffe70000,
394 .end = 0xffe70900 - 1,
395 .flags = IORESOURCE_MEM,
396 },
397 [1] = {
398 .start = 0xfff70000,
399 .end = 0xfff70900 - 1,
400 .flags = IORESOURCE_MEM,
401 },
402};
403
404static struct platform_device usb_phy_device = {
405 .name = "rcar_usb_phy",
406 .id = -1,
407 .resource = usb_phy_resources,
408 .num_resources = ARRAY_SIZE(usb_phy_resources),
409};
410
411/* USB */
412static struct usb_phy *phy;
413
414static int usb_power_on(struct platform_device *pdev)
415{
416 if (IS_ERR(phy))
417 return PTR_ERR(phy);
418
419 pm_runtime_enable(&pdev->dev);
420 pm_runtime_get_sync(&pdev->dev);
421
422 usb_phy_init(phy);
423
424 return 0;
425}
426
427static void usb_power_off(struct platform_device *pdev)
428{
429 if (IS_ERR(phy))
430 return;
431
432 usb_phy_shutdown(phy);
433
434 pm_runtime_put_sync(&pdev->dev);
435 pm_runtime_disable(&pdev->dev);
436}
437
438static struct usb_ehci_pdata ehcix_pdata = {
439 .power_on = usb_power_on,
440 .power_off = usb_power_off,
441 .power_suspend = usb_power_off,
442};
443
444static struct resource ehci0_resources[] = {
445 [0] = {
446 .start = 0xffe70000,
447 .end = 0xffe70400 - 1,
448 .flags = IORESOURCE_MEM,
449 },
450 [1] = {
451 .start = gic_iid(0x4c),
452 .flags = IORESOURCE_IRQ,
453 },
454};
455
456static struct platform_device ehci0_device = {
457 .name = "ehci-platform",
458 .id = 0,
459 .dev = {
460 .dma_mask = &ehci0_device.dev.coherent_dma_mask,
461 .coherent_dma_mask = 0xffffffff,
462 .platform_data = &ehcix_pdata,
463 },
464 .num_resources = ARRAY_SIZE(ehci0_resources),
465 .resource = ehci0_resources,
466};
467
468static struct resource ehci1_resources[] = {
469 [0] = {
470 .start = 0xfff70000,
471 .end = 0xfff70400 - 1,
472 .flags = IORESOURCE_MEM,
473 },
474 [1] = {
475 .start = gic_iid(0x4d),
476 .flags = IORESOURCE_IRQ,
477 },
478};
479
480static struct platform_device ehci1_device = {
481 .name = "ehci-platform",
482 .id = 1,
483 .dev = {
484 .dma_mask = &ehci1_device.dev.coherent_dma_mask,
485 .coherent_dma_mask = 0xffffffff,
486 .platform_data = &ehcix_pdata,
487 },
488 .num_resources = ARRAY_SIZE(ehci1_resources),
489 .resource = ehci1_resources,
490};
491
492static struct usb_ohci_pdata ohcix_pdata = {
493 .power_on = usb_power_on,
494 .power_off = usb_power_off,
495 .power_suspend = usb_power_off,
496};
497
498static struct resource ohci0_resources[] = {
499 [0] = {
500 .start = 0xffe70400,
501 .end = 0xffe70800 - 1,
502 .flags = IORESOURCE_MEM,
503 },
504 [1] = {
505 .start = gic_iid(0x4c),
506 .flags = IORESOURCE_IRQ,
507 },
508};
509
510static struct platform_device ohci0_device = {
511 .name = "ohci-platform",
512 .id = 0,
513 .dev = {
514 .dma_mask = &ohci0_device.dev.coherent_dma_mask,
515 .coherent_dma_mask = 0xffffffff,
516 .platform_data = &ohcix_pdata,
517 },
518 .num_resources = ARRAY_SIZE(ohci0_resources),
519 .resource = ohci0_resources,
520};
521
522static struct resource ohci1_resources[] = {
523 [0] = {
524 .start = 0xfff70400,
525 .end = 0xfff70800 - 1,
526 .flags = IORESOURCE_MEM,
527 },
528 [1] = {
529 .start = gic_iid(0x4d),
530 .flags = IORESOURCE_IRQ,
531 },
532};
533
534static struct platform_device ohci1_device = {
535 .name = "ohci-platform",
536 .id = 1,
537 .dev = {
538 .dma_mask = &ohci1_device.dev.coherent_dma_mask,
539 .coherent_dma_mask = 0xffffffff,
540 .platform_data = &ohcix_pdata,
541 },
542 .num_resources = ARRAY_SIZE(ohci1_resources),
543 .resource = ohci1_resources,
544};
545
386/* Ether */ 546/* Ether */
387static struct resource ether_resources[] = { 547static struct resource ether_resources[] = {
388 { 548 {
@@ -404,9 +564,10 @@ static struct platform_device *r8a7779_devices_dt[] __initdata = {
404 &scif5_device, 564 &scif5_device,
405 &tmu00_device, 565 &tmu00_device,
406 &tmu01_device, 566 &tmu01_device,
567 &usb_phy_device,
407}; 568};
408 569
409static struct platform_device *r8a7779_late_devices[] __initdata = { 570static struct platform_device *r8a7779_standard_devices[] __initdata = {
410 &i2c0_device, 571 &i2c0_device,
411 &i2c1_device, 572 &i2c1_device,
412 &i2c2_device, 573 &i2c2_device,
@@ -426,8 +587,8 @@ void __init r8a7779_add_standard_devices(void)
426 587
427 platform_add_devices(r8a7779_devices_dt, 588 platform_add_devices(r8a7779_devices_dt,
428 ARRAY_SIZE(r8a7779_devices_dt)); 589 ARRAY_SIZE(r8a7779_devices_dt));
429 platform_add_devices(r8a7779_late_devices, 590 platform_add_devices(r8a7779_standard_devices,
430 ARRAY_SIZE(r8a7779_late_devices)); 591 ARRAY_SIZE(r8a7779_standard_devices));
431} 592}
432 593
433void __init r8a7779_add_ether_device(struct sh_eth_plat_data *pdata) 594void __init r8a7779_add_ether_device(struct sh_eth_plat_data *pdata)
@@ -470,6 +631,23 @@ void __init r8a7779_add_early_devices(void)
470 */ 631 */
471} 632}
472 633
634static struct platform_device *r8a7779_late_devices[] __initdata = {
635 &ehci0_device,
636 &ehci1_device,
637 &ohci0_device,
638 &ohci1_device,
639};
640
641void __init r8a7779_init_late(void)
642{
643 /* get USB PHY */
644 phy = usb_get_phy(USB_PHY_TYPE_USB2);
645
646 shmobile_init_late();
647 platform_add_devices(r8a7779_late_devices,
648 ARRAY_SIZE(r8a7779_late_devices));
649}
650
473#ifdef CONFIG_USE_OF 651#ifdef CONFIG_USE_OF
474void __init r8a7779_init_delay(void) 652void __init r8a7779_init_delay(void)
475{ 653{
@@ -503,6 +681,7 @@ DT_MACHINE_START(R8A7779_DT, "Generic R8A7779 (Flattened Device Tree)")
503 .init_irq = r8a7779_init_irq_dt, 681 .init_irq = r8a7779_init_irq_dt,
504 .init_machine = r8a7779_add_standard_devices_dt, 682 .init_machine = r8a7779_add_standard_devices_dt,
505 .init_time = shmobile_timer_init, 683 .init_time = shmobile_timer_init,
684 .init_late = r8a7779_init_late,
506 .dt_compat = r8a7779_compat_dt, 685 .dt_compat = r8a7779_compat_dt,
507MACHINE_END 686MACHINE_END
508#endif /* CONFIG_USE_OF */ 687#endif /* CONFIG_USE_OF */