diff options
author | Vitaly Bordug <vitb@kernel.crashing.org> | 2008-11-09 13:43:30 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-07 12:59:52 -0500 |
commit | 796bcae7361c28cf825780f6f1aac9dd3411394e (patch) | |
tree | 3fe4ee89e373bf29f868d70430098b7dc625c16f /drivers/usb/host | |
parent | cd40c4c45eaedc289d2e1cc33b18a49a211f0f82 (diff) |
USB: powerpc: Workaround for the PPC440EPX USBH_23 errata [take 3]
A published errata for ppc440epx states, that when running Linux with
both EHCI and OHCI modules loaded, the EHCI module experiences a fatal
error when a high-speed device is connected to the USB2.0, and
functions normally if OHCI module is not loaded.
There used to be recommendation to use only hi-speed or full-speed
devices with specific conditions, when respective module was unloaded.
Later, it was observed that ohci suspend is enough to keep things
going, and it was turned into workaround, as explained below.
Quote from original descriprion:
The 440EPx USB 2.0 Host controller is an EHCI compliant controller. In
USB 2.0 Host controllers, each EHCI controller has one or more companion
controllers, which may be OHCI or UHCI. An USB 2.0 Host controller will
contain one or more ports. For each port, only one of the controllers
is connected at any one time. In the 440EPx, there is only one OHCI
companion controller, and only one USB 2.0 Host port.
All ports on an USB 2.0 controller default to the companion
controller. If you load only an ohci driver, it will have control of
the ports and any deviceplugged in will operate, although high speed
devices will be forced to operate at full speed. When an ehci driver
is loaded, it explicitly takes control of the ports. If there is a
device connected, and / or every time there is a new device connected,
the ehci driver determines if the device is high speed or not. If it
is high speed, the driver retains control of the port. If it is not,
the driver explicitly gives the companion controller control of the
port.
The is a software workaround that uses
Initial version of the software workaround was posted to
linux-usb-devel:
http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg54019.html
and later available from amcc.com:
http://www.amcc.com/Embedded/Downloads/download.html?cat=1&family=15&ins=2
The patch below is generally based on the latter, but reworked to
powerpc/of_device USB drivers, and uses a few devicetree inquiries to
get rid of (some) hardcoded defines.
Signed-off-by: Vitaly Bordug <vitb@kernel.crashing.org>
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r-- | drivers/usb/host/ehci-hub.c | 9 | ||||
-rw-r--r-- | drivers/usb/host/ehci-ppc-of.c | 45 | ||||
-rw-r--r-- | drivers/usb/host/ehci.h | 34 | ||||
-rw-r--r-- | drivers/usb/host/ohci-ppc-of.c | 25 |
4 files changed, 111 insertions, 2 deletions
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 38650707dfe0..97a53a48a3d8 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -434,8 +434,15 @@ static int check_reset_complete ( | |||
434 | port_status &= ~PORT_RWC_BITS; | 434 | port_status &= ~PORT_RWC_BITS; |
435 | ehci_writel(ehci, port_status, status_reg); | 435 | ehci_writel(ehci, port_status, status_reg); |
436 | 436 | ||
437 | } else | 437 | /* ensure 440EPX ohci controller state is operational */ |
438 | if (ehci->has_amcc_usb23) | ||
439 | set_ohci_hcfs(ehci, 1); | ||
440 | } else { | ||
438 | ehci_dbg (ehci, "port %d high speed\n", index + 1); | 441 | ehci_dbg (ehci, "port %d high speed\n", index + 1); |
442 | /* ensure 440EPx ohci controller state is suspended */ | ||
443 | if (ehci->has_amcc_usb23) | ||
444 | set_ohci_hcfs(ehci, 0); | ||
445 | } | ||
439 | 446 | ||
440 | return port_status; | 447 | return port_status; |
441 | } | 448 | } |
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c index b018deed2e8f..ef732b704f53 100644 --- a/drivers/usb/host/ehci-ppc-of.c +++ b/drivers/usb/host/ehci-ppc-of.c | |||
@@ -107,11 +107,13 @@ ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) | |||
107 | { | 107 | { |
108 | struct device_node *dn = op->node; | 108 | struct device_node *dn = op->node; |
109 | struct usb_hcd *hcd; | 109 | struct usb_hcd *hcd; |
110 | struct ehci_hcd *ehci; | 110 | struct ehci_hcd *ehci = NULL; |
111 | struct resource res; | 111 | struct resource res; |
112 | int irq; | 112 | int irq; |
113 | int rv; | 113 | int rv; |
114 | 114 | ||
115 | struct device_node *np; | ||
116 | |||
115 | if (usb_disabled()) | 117 | if (usb_disabled()) |
116 | return -ENODEV; | 118 | return -ENODEV; |
117 | 119 | ||
@@ -149,6 +151,20 @@ ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) | |||
149 | } | 151 | } |
150 | 152 | ||
151 | ehci = hcd_to_ehci(hcd); | 153 | ehci = hcd_to_ehci(hcd); |
154 | np = of_find_compatible_node(NULL, NULL, "ibm,usb-ohci-440epx"); | ||
155 | if (np != NULL) { | ||
156 | /* claim we really affected by usb23 erratum */ | ||
157 | if (!of_address_to_resource(np, 0, &res)) | ||
158 | ehci->ohci_hcctrl_reg = ioremap(res.start + | ||
159 | OHCI_HCCTRL_OFFSET, OHCI_HCCTRL_LEN); | ||
160 | else | ||
161 | pr_debug(__FILE__ ": no ohci offset in fdt\n"); | ||
162 | if (!ehci->ohci_hcctrl_reg) { | ||
163 | pr_debug(__FILE__ ": ioremap for ohci hcctrl failed\n"); | ||
164 | } else { | ||
165 | ehci->has_amcc_usb23 = 1; | ||
166 | } | ||
167 | } | ||
152 | 168 | ||
153 | if (of_get_property(dn, "big-endian", NULL)) { | 169 | if (of_get_property(dn, "big-endian", NULL)) { |
154 | ehci->big_endian_mmio = 1; | 170 | ehci->big_endian_mmio = 1; |
@@ -181,6 +197,9 @@ err_ioremap: | |||
181 | irq_dispose_mapping(irq); | 197 | irq_dispose_mapping(irq); |
182 | err_irq: | 198 | err_irq: |
183 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 199 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
200 | |||
201 | if (ehci->has_amcc_usb23) | ||
202 | iounmap(ehci->ohci_hcctrl_reg); | ||
184 | err_rmr: | 203 | err_rmr: |
185 | usb_put_hcd(hcd); | 204 | usb_put_hcd(hcd); |
186 | 205 | ||
@@ -191,6 +210,11 @@ err_rmr: | |||
191 | static int ehci_hcd_ppc_of_remove(struct of_device *op) | 210 | static int ehci_hcd_ppc_of_remove(struct of_device *op) |
192 | { | 211 | { |
193 | struct usb_hcd *hcd = dev_get_drvdata(&op->dev); | 212 | struct usb_hcd *hcd = dev_get_drvdata(&op->dev); |
213 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
214 | |||
215 | struct device_node *np; | ||
216 | struct resource res; | ||
217 | |||
194 | dev_set_drvdata(&op->dev, NULL); | 218 | dev_set_drvdata(&op->dev, NULL); |
195 | 219 | ||
196 | dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n"); | 220 | dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n"); |
@@ -201,6 +225,25 @@ static int ehci_hcd_ppc_of_remove(struct of_device *op) | |||
201 | irq_dispose_mapping(hcd->irq); | 225 | irq_dispose_mapping(hcd->irq); |
202 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 226 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
203 | 227 | ||
228 | /* use request_mem_region to test if the ohci driver is loaded. if so | ||
229 | * ensure the ohci core is operational. | ||
230 | */ | ||
231 | if (ehci->has_amcc_usb23) { | ||
232 | np = of_find_compatible_node(NULL, NULL, "ibm,usb-ohci-440epx"); | ||
233 | if (np != NULL) { | ||
234 | if (!of_address_to_resource(np, 0, &res)) | ||
235 | if (!request_mem_region(res.start, | ||
236 | 0x4, hcd_name)) | ||
237 | set_ohci_hcfs(ehci, 1); | ||
238 | else | ||
239 | release_mem_region(res.start, 0x4); | ||
240 | else | ||
241 | pr_debug(__FILE__ ": no ohci offset in fdt\n"); | ||
242 | of_node_put(np); | ||
243 | } | ||
244 | |||
245 | iounmap(ehci->ohci_hcctrl_reg); | ||
246 | } | ||
204 | usb_put_hcd(hcd); | 247 | usb_put_hcd(hcd); |
205 | 248 | ||
206 | return 0; | 249 | return 0; |
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index c7d4b5a06bdb..fb7054ccf4fc 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -120,6 +120,16 @@ struct ehci_hcd { /* one per controller */ | |||
120 | unsigned has_fsl_port_bug:1; /* FreeScale */ | 120 | unsigned has_fsl_port_bug:1; /* FreeScale */ |
121 | unsigned big_endian_mmio:1; | 121 | unsigned big_endian_mmio:1; |
122 | unsigned big_endian_desc:1; | 122 | unsigned big_endian_desc:1; |
123 | unsigned has_amcc_usb23:1; | ||
124 | |||
125 | /* required for usb32 quirk */ | ||
126 | #define OHCI_CTRL_HCFS (3 << 6) | ||
127 | #define OHCI_USB_OPER (2 << 6) | ||
128 | #define OHCI_USB_SUSPEND (3 << 6) | ||
129 | |||
130 | #define OHCI_HCCTRL_OFFSET 0x4 | ||
131 | #define OHCI_HCCTRL_LEN 0x4 | ||
132 | __hc32 *ohci_hcctrl_reg; | ||
123 | 133 | ||
124 | u8 sbrn; /* packed release number */ | 134 | u8 sbrn; /* packed release number */ |
125 | 135 | ||
@@ -636,6 +646,30 @@ static inline void ehci_writel(const struct ehci_hcd *ehci, | |||
636 | #endif | 646 | #endif |
637 | } | 647 | } |
638 | 648 | ||
649 | /* | ||
650 | * On certain ppc-44x SoC there is a HW issue, that could only worked around with | ||
651 | * explicit suspend/operate of OHCI. This function hereby makes sense only on that arch. | ||
652 | * Other common bits are dependant on has_amcc_usb23 quirk flag. | ||
653 | */ | ||
654 | #ifdef CONFIG_44x | ||
655 | static inline void set_ohci_hcfs(struct ehci_hcd *ehci, int operational) | ||
656 | { | ||
657 | u32 hc_control; | ||
658 | |||
659 | hc_control = (readl_be(ehci->ohci_hcctrl_reg) & ~OHCI_CTRL_HCFS); | ||
660 | if (operational) | ||
661 | hc_control |= OHCI_USB_OPER; | ||
662 | else | ||
663 | hc_control |= OHCI_USB_SUSPEND; | ||
664 | |||
665 | writel_be(hc_control, ehci->ohci_hcctrl_reg); | ||
666 | (void) readl_be(ehci->ohci_hcctrl_reg); | ||
667 | } | ||
668 | #else | ||
669 | static inline void set_ohci_hcfs(struct ehci_hcd *ehci, int operational) | ||
670 | { } | ||
671 | #endif | ||
672 | |||
639 | /*-------------------------------------------------------------------------*/ | 673 | /*-------------------------------------------------------------------------*/ |
640 | 674 | ||
641 | /* | 675 | /* |
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c index 7ac53264ead3..68a301710297 100644 --- a/drivers/usb/host/ohci-ppc-of.c +++ b/drivers/usb/host/ohci-ppc-of.c | |||
@@ -91,6 +91,7 @@ ohci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) | |||
91 | 91 | ||
92 | int rv; | 92 | int rv; |
93 | int is_bigendian; | 93 | int is_bigendian; |
94 | struct device_node *np; | ||
94 | 95 | ||
95 | if (usb_disabled()) | 96 | if (usb_disabled()) |
96 | return -ENODEV; | 97 | return -ENODEV; |
@@ -147,6 +148,30 @@ ohci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) | |||
147 | if (rv == 0) | 148 | if (rv == 0) |
148 | return 0; | 149 | return 0; |
149 | 150 | ||
151 | /* by now, 440epx is known to show usb_23 erratum */ | ||
152 | np = of_find_compatible_node(NULL, NULL, "ibm,usb-ehci-440epx"); | ||
153 | |||
154 | /* Work around - At this point ohci_run has executed, the | ||
155 | * controller is running, everything, the root ports, etc., is | ||
156 | * set up. If the ehci driver is loaded, put the ohci core in | ||
157 | * the suspended state. The ehci driver will bring it out of | ||
158 | * suspended state when / if a non-high speed USB device is | ||
159 | * attached to the USB Host port. If the ehci driver is not | ||
160 | * loaded, do nothing. request_mem_region is used to test if | ||
161 | * the ehci driver is loaded. | ||
162 | */ | ||
163 | if (np != NULL) { | ||
164 | if (!of_address_to_resource(np, 0, &res)) { | ||
165 | if (!request_mem_region(res.start, 0x4, hcd_name)) { | ||
166 | writel_be((readl_be(&ohci->regs->control) | | ||
167 | OHCI_USB_SUSPEND), &ohci->regs->control); | ||
168 | (void) readl_be(&ohci->regs->control); | ||
169 | } else | ||
170 | release_mem_region(res.start, 0x4); | ||
171 | } else | ||
172 | pr_debug(__FILE__ ": cannot get ehci offset from fdt\n"); | ||
173 | } | ||
174 | |||
150 | iounmap(hcd->regs); | 175 | iounmap(hcd->regs); |
151 | err_ioremap: | 176 | err_ioremap: |
152 | irq_dispose_mapping(irq); | 177 | irq_dispose_mapping(irq); |