[linux-yocto] [PATCH 83/89] usb: Added check to confirm that USB controller is stopped before trying to reset it
Paul Butler
butler.paul at gmail.com
Sun Oct 27 12:48:20 PDT 2013
From: SangeethaRao <sangeetha.rao at lsi.com>
Signed-off-by: SangeethaRao <sangeetha.rao at lsi.com>
---
drivers/usb/host/ehci-ci13612.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/usb/host/ehci-ci13612.c b/drivers/usb/host/ehci-ci13612.c
index 68ac2f4..c56f476 100644
--- a/drivers/usb/host/ehci-ci13612.c
+++ b/drivers/usb/host/ehci-ci13612.c
@@ -90,6 +90,7 @@ static int ci13612_ehci_init(struct usb_hcd *hcd)
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
int retval = 0;
int len;
+ int value, count = 5;
/* EHCI registers start at offset 0x100 */
ehci->caps = hcd->regs + 0x100;
@@ -103,6 +104,29 @@ static int ci13612_ehci_init(struct usb_hcd *hcd)
ehci->sbrn = 0x20;
+ /* Reset is only allowed on a stopped controller,
+ * ehci_reset assumes stopped state */
+ value = ehci_readl(ehci, &ehci->regs->command);
+ if (value & 0x1)
+ {
+ pr_info("ehci-ci13612 (ci13612_ehci_init): Controller Running - Trying to stop\n");
+ ehci_writel(ehci, value & 0xFFFE, &ehci->regs->command);
+ udelay(1);
+
+ /* Timed loop to try and stop the running Controller */
+ do {
+ value = ehci_readl(ehci, &ehci->regs->command);
+ udelay(1);
+ count--;
+ } while ((value & 0x1) && (count > 0));
+
+ if (value & 0x1) {
+ pr_err("ehci-ci13612: USB controller is in running state and cannot be"
+ "stopped\n");
+ return -EFAULT;
+ }
+ }
+
/* reset and halt controller */
ehci_reset(ehci);
--
1.8.3.4
More information about the linux-yocto
mailing list