aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile/setup-r8a7779.c
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 /arch/arm/mach-shmobile/setup-r8a7779.c
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>
Diffstat (limited to 'arch/arm/mach-shmobile/setup-r8a7779.c')
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7779.c185
1 files changed, 182 insertions, 3 deletions
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 */