usb: dwc3: workaround: unexpected transtion U3 -> RESUME
authorFelipe Balbi <balbi@ti.com>
Tue, 18 Sep 2012 18:39:24 +0000 (21:39 +0300)
committerFelipe Balbi <balbi@ti.com>
Mon, 18 Mar 2013 09:17:57 +0000 (11:17 +0200)
In DWC3 versions < 2.50a configured without
Hibernation mode enabled, there will be an
extra link status change interrupt if device
detects host-initiated U3 exit.

In that case, core will generate an unnecessary
U3 -> RESUME transition which should be ignored
by the driver.

Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/gadget.c

index 4ffec1aa2e25d2e6ddc265ce3944e4b9f53ffbe6..8e53acc0e43e3e6437bb3e914120ae38ca89f399 100644 (file)
@@ -2317,6 +2317,34 @@ static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc,
                unsigned int evtinfo)
 {
        enum dwc3_link_state    next = evtinfo & DWC3_LINK_STATE_MASK;
+       unsigned int            pwropt;
+
+       /*
+        * WORKAROUND: DWC3 < 2.50a have an issue when configured without
+        * Hibernation mode enabled which would show up when device detects
+        * host-initiated U3 exit.
+        *
+        * In that case, device will generate a Link State Change Interrupt
+        * from U3 to RESUME which is only necessary if Hibernation is
+        * configured in.
+        *
+        * There are no functional changes due to such spurious event and we
+        * just need to ignore it.
+        *
+        * Refers to:
+        *
+        * STAR#9000570034 RTL: SS Resume event generated in non-Hibernation
+        * operational mode
+        */
+       pwropt = DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1);
+       if ((dwc->revision < DWC3_REVISION_250A) &&
+                       (pwropt != DWC3_GHWPARAMS1_EN_PWROPT_HIB)) {
+               if ((dwc->link_state == DWC3_LINK_STATE_U3) &&
+                               (next == DWC3_LINK_STATE_RESUME)) {
+                       dev_vdbg(dwc->dev, "ignoring transition U3 -> Resume\n");
+                       return;
+               }
+       }
 
        /*
         * WORKAROUND: DWC3 Revisions <1.83a have an issue which, depending