Hello.

On 02/25/2014 10:40 PM, Felipe Balbi wrote:

From: Paul Zimmerman <paul.zimmer...@synopsys.com>

This function will be used during hibernation to get
the current link state. It will be needed at least
for Hibernation support.

Signed-off-by: Paul Zimmerman <pa...@synopsys.com>
Signed-off-by: Felipe Balbi <ba...@ti.com>
---
  drivers/usb/dwc3/gadget.c | 36 ++++++++++++++++++++++++++++++++++++
  drivers/usb/dwc3/gadget.h |  1 +
  2 files changed, 37 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 31b13c2..ff10161 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -68,6 +68,42 @@ int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode)
  }

  /**
+ * dwc3_gadget_get_lik_state - Gets current state of USB Link
+ * @dwc: pointer to our context structure
+ *
+ * Caller should take care of locking. This function will
+ * return the link state on success (>= 0) or -ETIMEDOUT.
+ */
+int dwc3_gadget_get_link_state(struct dwc3 *dwc)
+{
+       u32             reg;
+
+       reg = dwc3_readl(dwc->regs, DWC3_DSTS);
+
+       /*
+        * Wait until device controller is ready.
+        * (This only applied to 1.94a and later
+        * RTL releases)
+        */
+       if (dwc->revision >= DWC3_REVISION_194A) {
+               int     retries = 10000;
+
+               do {
+                       reg = dwc3_readl(dwc->regs, DWC3_DSTS);
+                       if (!(reg & DWC3_DSTS_DCNRD))
+                               break;
+
+                       if (!retries)

Hm, I doubt this will ever be true. This check would be meaningful after the loop...

+                               return -ETIMEDOUT;
+
+                       udelay(5);
+               } while (--retries);
+       }
+
+       return DWC3_DSTS_USBLNKST(reg);
+}

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to