diff options
author | Vladimir Barinov <vbarinov@ru.mvista.com> | 2007-12-30 18:21:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:35:02 -0500 |
commit | 91bc4d31e81b15aa6e2d075307b8727041f2e2d1 (patch) | |
tree | 4c7f706fd749aae4cdf3424c664c6a5420fe6cc3 /drivers/usb | |
parent | 18bcbcfe9ca2308ebffb40068b51803da9315d97 (diff) |
USB: add ehci-ixp bus glue
EHCI Glue driver for Intel IXP4XX EHCI USB controller
Signed-off-by: Vladimir Barinov <vbarinov@ru.mvista.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/host/Kconfig | 4 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 5 | ||||
-rw-r--r-- | drivers/usb/host/ehci-ixp4xx.c | 152 | ||||
-rw-r--r-- | drivers/usb/host/ehci.h | 5 |
5 files changed, 165 insertions, 2 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 7a6499008b89..8d48d973efcb 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
@@ -50,6 +50,7 @@ config USB_ARCH_HAS_EHCI | |||
50 | boolean | 50 | boolean |
51 | default y if PPC_83xx | 51 | default y if PPC_83xx |
52 | default y if SOC_AU1200 | 52 | default y if SOC_AU1200 |
53 | default y if ARCH_IXP4XX | ||
53 | default PCI | 54 | default PCI |
54 | 55 | ||
55 | # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. | 56 | # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 1f45aa25608e..3a42bcd27d30 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -69,12 +69,12 @@ config USB_EHCI_TT_NEWSCHED | |||
69 | 69 | ||
70 | config USB_EHCI_BIG_ENDIAN_MMIO | 70 | config USB_EHCI_BIG_ENDIAN_MMIO |
71 | bool | 71 | bool |
72 | depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX) | 72 | depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX) |
73 | default y | 73 | default y |
74 | 74 | ||
75 | config USB_EHCI_BIG_ENDIAN_DESC | 75 | config USB_EHCI_BIG_ENDIAN_DESC |
76 | bool | 76 | bool |
77 | depends on USB_EHCI_HCD && 440EPX | 77 | depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX) |
78 | default y | 78 | default y |
79 | 79 | ||
80 | config USB_EHCI_FSL | 80 | config USB_EHCI_FSL |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 53fc97fced20..4caa6a8b9a37 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -1008,6 +1008,11 @@ MODULE_LICENSE ("GPL"); | |||
1008 | #define PLATFORM_DRIVER ehci_orion_driver | 1008 | #define PLATFORM_DRIVER ehci_orion_driver |
1009 | #endif | 1009 | #endif |
1010 | 1010 | ||
1011 | #ifdef CONFIG_ARCH_IXP4XX | ||
1012 | #include "ehci-ixp4xx.c" | ||
1013 | #define PLATFORM_DRIVER ixp4xx_ehci_driver | ||
1014 | #endif | ||
1015 | |||
1011 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1016 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
1012 | !defined(PS3_SYSTEM_BUS_DRIVER) | 1017 | !defined(PS3_SYSTEM_BUS_DRIVER) |
1013 | #error "missing bus glue for ehci-hcd" | 1018 | #error "missing bus glue for ehci-hcd" |
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c new file mode 100644 index 000000000000..3041d8f055f4 --- /dev/null +++ b/drivers/usb/host/ehci-ixp4xx.c | |||
@@ -0,0 +1,152 @@ | |||
1 | /* | ||
2 | * IXP4XX EHCI Host Controller Driver | ||
3 | * | ||
4 | * Author: Vladimir Barinov <vbarinov@ru.mvista.com> | ||
5 | * | ||
6 | * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com> | ||
7 | * | ||
8 | * 2007 (c) MontaVista Software, Inc. This file is licensed under | ||
9 | * the terms of the GNU General Public License version 2. This program | ||
10 | * is licensed "as is" without any warranty of any kind, whether express | ||
11 | * or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/platform_device.h> | ||
15 | |||
16 | static int ixp4xx_ehci_init(struct usb_hcd *hcd) | ||
17 | { | ||
18 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
19 | int retval = 0; | ||
20 | |||
21 | ehci->big_endian_desc = 1; | ||
22 | ehci->big_endian_mmio = 1; | ||
23 | |||
24 | ehci->caps = hcd->regs + 0x100; | ||
25 | ehci->regs = hcd->regs + 0x100 | ||
26 | + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
27 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
28 | |||
29 | ehci->is_tdi_rh_tt = 1; | ||
30 | ehci_reset(ehci); | ||
31 | |||
32 | retval = ehci_init(hcd); | ||
33 | if (retval) | ||
34 | return retval; | ||
35 | |||
36 | ehci_port_power(ehci, 0); | ||
37 | |||
38 | return retval; | ||
39 | } | ||
40 | |||
41 | static const struct hc_driver ixp4xx_ehci_hc_driver = { | ||
42 | .description = hcd_name, | ||
43 | .product_desc = "IXP4XX EHCI Host Controller", | ||
44 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
45 | .irq = ehci_irq, | ||
46 | .flags = HCD_MEMORY | HCD_USB2, | ||
47 | .reset = ixp4xx_ehci_init, | ||
48 | .start = ehci_run, | ||
49 | .stop = ehci_stop, | ||
50 | .shutdown = ehci_shutdown, | ||
51 | .urb_enqueue = ehci_urb_enqueue, | ||
52 | .urb_dequeue = ehci_urb_dequeue, | ||
53 | .endpoint_disable = ehci_endpoint_disable, | ||
54 | .get_frame_number = ehci_get_frame, | ||
55 | .hub_status_data = ehci_hub_status_data, | ||
56 | .hub_control = ehci_hub_control, | ||
57 | #if defined(CONFIG_PM) | ||
58 | .bus_suspend = ehci_bus_suspend, | ||
59 | .bus_resume = ehci_bus_resume, | ||
60 | #endif | ||
61 | }; | ||
62 | |||
63 | static int ixp4xx_ehci_probe(struct platform_device *pdev) | ||
64 | { | ||
65 | struct usb_hcd *hcd; | ||
66 | const struct hc_driver *driver = &ixp4xx_ehci_hc_driver; | ||
67 | struct resource *res; | ||
68 | int irq; | ||
69 | int retval; | ||
70 | |||
71 | if (usb_disabled()) | ||
72 | return -ENODEV; | ||
73 | |||
74 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
75 | if (!res) { | ||
76 | dev_err(&pdev->dev, | ||
77 | "Found HC with no IRQ. Check %s setup!\n", | ||
78 | pdev->dev.bus_id); | ||
79 | return -ENODEV; | ||
80 | } | ||
81 | irq = res->start; | ||
82 | |||
83 | hcd = usb_create_hcd(driver, &pdev->dev, pdev->dev.bus_id); | ||
84 | if (!hcd) { | ||
85 | retval = -ENOMEM; | ||
86 | goto fail_create_hcd; | ||
87 | } | ||
88 | |||
89 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
90 | if (!res) { | ||
91 | dev_err(&pdev->dev, | ||
92 | "Found HC with no register addr. Check %s setup!\n", | ||
93 | pdev->dev.bus_id); | ||
94 | retval = -ENODEV; | ||
95 | goto fail_request_resource; | ||
96 | } | ||
97 | hcd->rsrc_start = res->start; | ||
98 | hcd->rsrc_len = res->end - res->start + 1; | ||
99 | |||
100 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
101 | driver->description)) { | ||
102 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
103 | retval = -EBUSY; | ||
104 | goto fail_request_resource; | ||
105 | } | ||
106 | |||
107 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
108 | if (hcd->regs == NULL) { | ||
109 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
110 | retval = -EFAULT; | ||
111 | goto fail_ioremap; | ||
112 | } | ||
113 | |||
114 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
115 | if (retval) | ||
116 | goto fail_add_hcd; | ||
117 | |||
118 | return retval; | ||
119 | |||
120 | fail_add_hcd: | ||
121 | iounmap(hcd->regs); | ||
122 | fail_ioremap: | ||
123 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
124 | fail_request_resource: | ||
125 | usb_put_hcd(hcd); | ||
126 | fail_create_hcd: | ||
127 | dev_err(&pdev->dev, "init %s fail, %d\n", pdev->dev.bus_id, retval); | ||
128 | return retval; | ||
129 | } | ||
130 | |||
131 | static int ixp4xx_ehci_remove(struct platform_device *pdev) | ||
132 | { | ||
133 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
134 | |||
135 | usb_remove_hcd(hcd); | ||
136 | iounmap(hcd->regs); | ||
137 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
138 | usb_put_hcd(hcd); | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | MODULE_ALIAS("ixp4xx-ehci"); | ||
144 | |||
145 | static struct platform_driver ixp4xx_ehci_driver = { | ||
146 | .probe = ixp4xx_ehci_probe, | ||
147 | .remove = ixp4xx_ehci_remove, | ||
148 | .driver = { | ||
149 | .name = "ixp4xx-ehci", | ||
150 | .bus = &platform_bus_type | ||
151 | }, | ||
152 | }; | ||
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index c78c52771e64..f83472856a80 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -746,6 +746,11 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) | |||
746 | #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) | 746 | #define writel_be(val, addr) out_be32((__force unsigned *)addr, val) |
747 | #endif | 747 | #endif |
748 | 748 | ||
749 | #if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX) | ||
750 | #define readl_be(addr) __raw_readl((__force unsigned *)addr) | ||
751 | #define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr) | ||
752 | #endif | ||
753 | |||
749 | static inline unsigned int ehci_readl(const struct ehci_hcd *ehci, | 754 | static inline unsigned int ehci_readl(const struct ehci_hcd *ehci, |
750 | __u32 __iomem * regs) | 755 | __u32 __iomem * regs) |
751 | { | 756 | { |