diff options
author | Keshava Munegowda <keshava_mgowda@ti.com> | 2011-03-01 09:38:18 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2011-03-01 10:02:29 -0500 |
commit | 2236396d4d23828a0875a4d447103d0ab48aed0b (patch) | |
tree | 73ef87ca6ba9abdc6c57599c4c91bac12abe91a1 /arch/arm/mach-omap2 | |
parent | 17cdd29d6e1ab4164c792d78c6f096fbafb94e3f (diff) |
arm: omap: usb: usbhs core device initialization
A new usbhs platform device is defined;
this device will be the parent device of ehci and
ohci platform devices. the usbhs_init function
is defined which does the usbhs device initialization
and I/O mux of ehci and ohci.
Signed-off-by: Keshava Munegowda <keshava_mgowda@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r-- | arch/arm/mach-omap2/usb-host.c | 195 |
1 files changed, 181 insertions, 14 deletions
diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c index b04ce6f8f013..ab0638208748 100644 --- a/arch/arm/mach-omap2/usb-host.c +++ b/arch/arm/mach-omap2/usb-host.c | |||
@@ -6,6 +6,7 @@ | |||
6 | * | 6 | * |
7 | * Copyright (C) 2007-2011 Texas Instruments | 7 | * Copyright (C) 2007-2011 Texas Instruments |
8 | * Author: Vikram Pandita <vikram.pandita@ti.com> | 8 | * Author: Vikram Pandita <vikram.pandita@ti.com> |
9 | * Author: Keshava Munegowda <keshava_mgowda@ti.com> | ||
9 | * | 10 | * |
10 | * Generalization by: | 11 | * Generalization by: |
11 | * Felipe Balbi <balbi@ti.com> | 12 | * Felipe Balbi <balbi@ti.com> |
@@ -19,7 +20,7 @@ | |||
19 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
20 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
21 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
22 | #include <linux/clk.h> | 23 | #include <linux/slab.h> |
23 | #include <linux/dma-mapping.h> | 24 | #include <linux/dma-mapping.h> |
24 | 25 | ||
25 | #include <asm/io.h> | 26 | #include <asm/io.h> |
@@ -30,7 +31,7 @@ | |||
30 | 31 | ||
31 | #include "mux.h" | 32 | #include "mux.h" |
32 | 33 | ||
33 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE) | 34 | #ifdef CONFIG_MFD_OMAP_USB_HOST |
34 | 35 | ||
35 | static struct resource ehci_resources[] = { | 36 | static struct resource ehci_resources[] = { |
36 | { | 37 | { |
@@ -361,17 +362,6 @@ void __init usb_ehci_init(const struct usbhs_omap_board_data *pdata) | |||
361 | } | 362 | } |
362 | } | 363 | } |
363 | 364 | ||
364 | #else | ||
365 | |||
366 | void __init usb_ehci_init(const struct usbhs_omap_board_data *pdata) | ||
367 | |||
368 | { | ||
369 | } | ||
370 | |||
371 | #endif /* CONFIG_USB_EHCI_HCD */ | ||
372 | |||
373 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | ||
374 | |||
375 | static struct resource ohci_resources[] = { | 365 | static struct resource ohci_resources[] = { |
376 | { | 366 | { |
377 | .name = "ohci", | 367 | .name = "ohci", |
@@ -508,6 +498,77 @@ static void setup_ohci_io_mux(const enum usbhs_omap_port_mode *port_mode) | |||
508 | } | 498 | } |
509 | } | 499 | } |
510 | 500 | ||
501 | static void setup_4430ohci_io_mux(const enum usbhs_omap_port_mode *port_mode) | ||
502 | { | ||
503 | switch (port_mode[0]) { | ||
504 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0: | ||
505 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM: | ||
506 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0: | ||
507 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM: | ||
508 | omap_mux_init_signal("usbb1_mm_rxdp", | ||
509 | OMAP_PIN_INPUT_PULLDOWN); | ||
510 | omap_mux_init_signal("usbb1_mm_rxdm", | ||
511 | OMAP_PIN_INPUT_PULLDOWN); | ||
512 | |||
513 | case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM: | ||
514 | case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM: | ||
515 | omap_mux_init_signal("usbb1_mm_rxrcv", | ||
516 | OMAP_PIN_INPUT_PULLDOWN); | ||
517 | |||
518 | case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0: | ||
519 | case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0: | ||
520 | omap_mux_init_signal("usbb1_mm_txen", | ||
521 | OMAP_PIN_INPUT_PULLDOWN); | ||
522 | |||
523 | |||
524 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0: | ||
525 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM: | ||
526 | omap_mux_init_signal("usbb1_mm_txdat", | ||
527 | OMAP_PIN_INPUT_PULLDOWN); | ||
528 | omap_mux_init_signal("usbb1_mm_txse0", | ||
529 | OMAP_PIN_INPUT_PULLDOWN); | ||
530 | break; | ||
531 | |||
532 | case OMAP_USBHS_PORT_MODE_UNUSED: | ||
533 | default: | ||
534 | break; | ||
535 | } | ||
536 | |||
537 | switch (port_mode[1]) { | ||
538 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0: | ||
539 | case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM: | ||
540 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0: | ||
541 | case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM: | ||
542 | omap_mux_init_signal("usbb2_mm_rxdp", | ||
543 | OMAP_PIN_INPUT_PULLDOWN); | ||
544 | omap_mux_init_signal("usbb2_mm_rxdm", | ||
545 | OMAP_PIN_INPUT_PULLDOWN); | ||
546 | |||
547 | case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM: | ||
548 | case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM: | ||
549 | omap_mux_init_signal("usbb2_mm_rxrcv", | ||
550 | OMAP_PIN_INPUT_PULLDOWN); | ||
551 | |||
552 | case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0: | ||
553 | case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0: | ||
554 | omap_mux_init_signal("usbb2_mm_txen", | ||
555 | OMAP_PIN_INPUT_PULLDOWN); | ||
556 | |||
557 | |||
558 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0: | ||
559 | case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM: | ||
560 | omap_mux_init_signal("usbb2_mm_txdat", | ||
561 | OMAP_PIN_INPUT_PULLDOWN); | ||
562 | omap_mux_init_signal("usbb2_mm_txse0", | ||
563 | OMAP_PIN_INPUT_PULLDOWN); | ||
564 | break; | ||
565 | |||
566 | case OMAP_USBHS_PORT_MODE_UNUSED: | ||
567 | default: | ||
568 | break; | ||
569 | } | ||
570 | } | ||
571 | |||
511 | void __init usb_ohci_init(const struct usbhs_omap_board_data *pdata) | 572 | void __init usb_ohci_init(const struct usbhs_omap_board_data *pdata) |
512 | { | 573 | { |
513 | platform_device_add_data(&ohci_device, pdata, sizeof(*pdata)); | 574 | platform_device_add_data(&ohci_device, pdata, sizeof(*pdata)); |
@@ -522,10 +583,116 @@ void __init usb_ohci_init(const struct usbhs_omap_board_data *pdata) | |||
522 | } | 583 | } |
523 | } | 584 | } |
524 | 585 | ||
586 | #define OMAP_USBHS_DEVICE "usbhs-omap" | ||
587 | |||
588 | static struct resource usbhs_resources[] = { | ||
589 | { | ||
590 | .name = "uhh", | ||
591 | .flags = IORESOURCE_MEM, | ||
592 | }, | ||
593 | { | ||
594 | .name = "tll", | ||
595 | .flags = IORESOURCE_MEM, | ||
596 | }, | ||
597 | { | ||
598 | .name = "ehci", | ||
599 | .flags = IORESOURCE_MEM, | ||
600 | }, | ||
601 | { | ||
602 | .name = "ehci-irq", | ||
603 | .flags = IORESOURCE_IRQ, | ||
604 | }, | ||
605 | { | ||
606 | .name = "ohci", | ||
607 | .flags = IORESOURCE_MEM, | ||
608 | }, | ||
609 | { | ||
610 | .name = "ohci-irq", | ||
611 | .flags = IORESOURCE_IRQ, | ||
612 | } | ||
613 | }; | ||
614 | |||
615 | static struct platform_device usbhs_device = { | ||
616 | .name = OMAP_USBHS_DEVICE, | ||
617 | .id = 0, | ||
618 | .num_resources = ARRAY_SIZE(usbhs_resources), | ||
619 | .resource = usbhs_resources, | ||
620 | }; | ||
621 | |||
622 | static struct usbhs_omap_platform_data usbhs_data; | ||
623 | static struct ehci_hcd_omap_platform_data ehci_data; | ||
624 | static struct ohci_hcd_omap_platform_data ohci_data; | ||
625 | |||
626 | void __init usbhs_init(const struct usbhs_omap_board_data *pdata) | ||
627 | { | ||
628 | int i; | ||
629 | |||
630 | for (i = 0; i < OMAP3_HS_USB_PORTS; i++) { | ||
631 | usbhs_data.port_mode[i] = pdata->port_mode[i]; | ||
632 | ohci_data.port_mode[i] = pdata->port_mode[i]; | ||
633 | ehci_data.port_mode[i] = pdata->port_mode[i]; | ||
634 | ehci_data.reset_gpio_port[i] = pdata->reset_gpio_port[i]; | ||
635 | ehci_data.regulator[i] = pdata->regulator[i]; | ||
636 | } | ||
637 | ehci_data.phy_reset = pdata->phy_reset; | ||
638 | ohci_data.es2_compatibility = pdata->es2_compatibility; | ||
639 | usbhs_data.ehci_data = &ehci_data; | ||
640 | usbhs_data.ohci_data = &ohci_data; | ||
641 | |||
642 | if (cpu_is_omap34xx()) { | ||
643 | usbhs_resources[0].start = OMAP34XX_UHH_CONFIG_BASE; | ||
644 | usbhs_resources[0].end = OMAP34XX_UHH_CONFIG_BASE + SZ_1K - 1; | ||
645 | usbhs_resources[1].start = OMAP34XX_USBTLL_BASE; | ||
646 | usbhs_resources[1].end = OMAP34XX_USBTLL_BASE + SZ_4K - 1; | ||
647 | usbhs_resources[2].start = OMAP34XX_EHCI_BASE; | ||
648 | usbhs_resources[2].end = OMAP34XX_EHCI_BASE + SZ_1K - 1; | ||
649 | usbhs_resources[3].start = INT_34XX_EHCI_IRQ; | ||
650 | usbhs_resources[4].start = OMAP34XX_OHCI_BASE; | ||
651 | usbhs_resources[4].end = OMAP34XX_OHCI_BASE + SZ_1K - 1; | ||
652 | usbhs_resources[5].start = INT_34XX_OHCI_IRQ; | ||
653 | setup_ehci_io_mux(pdata->port_mode); | ||
654 | setup_ohci_io_mux(pdata->port_mode); | ||
655 | } else if (cpu_is_omap44xx()) { | ||
656 | usbhs_resources[0].start = OMAP44XX_UHH_CONFIG_BASE; | ||
657 | usbhs_resources[0].end = OMAP44XX_UHH_CONFIG_BASE + SZ_1K - 1; | ||
658 | usbhs_resources[1].start = OMAP44XX_USBTLL_BASE; | ||
659 | usbhs_resources[1].end = OMAP44XX_USBTLL_BASE + SZ_4K - 1; | ||
660 | usbhs_resources[2].start = OMAP44XX_HSUSB_EHCI_BASE; | ||
661 | usbhs_resources[2].end = OMAP44XX_HSUSB_EHCI_BASE + SZ_1K - 1; | ||
662 | usbhs_resources[3].start = OMAP44XX_IRQ_EHCI; | ||
663 | usbhs_resources[4].start = OMAP44XX_HSUSB_OHCI_BASE; | ||
664 | usbhs_resources[4].end = OMAP44XX_HSUSB_OHCI_BASE + SZ_1K - 1; | ||
665 | usbhs_resources[5].start = OMAP44XX_IRQ_OHCI; | ||
666 | setup_4430ehci_io_mux(pdata->port_mode); | ||
667 | setup_4430ohci_io_mux(pdata->port_mode); | ||
668 | } | ||
669 | |||
670 | if (platform_device_add_data(&usbhs_device, | ||
671 | &usbhs_data, sizeof(usbhs_data)) < 0) { | ||
672 | printk(KERN_ERR "USBHS platform_device_add_data failed\n"); | ||
673 | goto init_end; | ||
674 | } | ||
675 | |||
676 | if (platform_device_register(&usbhs_device) < 0) | ||
677 | printk(KERN_ERR "USBHS platform_device_register failed\n"); | ||
678 | |||
679 | init_end: | ||
680 | return; | ||
681 | } | ||
682 | |||
525 | #else | 683 | #else |
526 | 684 | ||
685 | void __init usbhs_init(const struct usbhs_omap_board_data *pdata) | ||
686 | { | ||
687 | } | ||
688 | |||
527 | void __init usb_ohci_init(const struct usbhs_omap_board_data *pdata) | 689 | void __init usb_ohci_init(const struct usbhs_omap_board_data *pdata) |
528 | { | 690 | { |
529 | } | 691 | } |
530 | 692 | ||
531 | #endif /* CONFIG_USB_OHCI_HCD */ | 693 | void __init usb_ehci_init(const struct usbhs_omap_board_data *pdata) |
694 | { | ||
695 | } | ||
696 | #endif | ||
697 | |||
698 | |||