usb: dwc2: exit hibernation on session request
authorMian Yousaf Kaukab <[email protected]>
Tue, 29 Sep 2015 10:08:30 +0000 (12:08 +0200)
committerFelipe Balbi <[email protected]>
Thu, 1 Oct 2015 17:40:27 +0000 (12:40 -0500)
Controller enters hibernation through suspend interrupt on
disconnection. On connection, session request interrupt is generated.
dwc2 must exit hibernation and restore state from this interrupt
before continuing.

In host mode, exit from hibernation is handled by bus_resume function.

Signed-off-by: Mian Yousaf Kaukab <[email protected]>
Signed-off-by: Gregory Herrero <[email protected]>
Tested-by: Robert Baldyga <[email protected]>
Tested-by: Dinh Nguyen <[email protected]>
Tested-by: John Youn <[email protected]>
Acked-by: John Youn <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
drivers/usb/dwc2/core_intr.c

index d8a5400a2d2db199cdfe373e562207d6f66e32bb..27daa42788b1a4ab2ac74200d15d8b1a6f212f38 100644 (file)
@@ -313,16 +313,28 @@ static void dwc2_handle_conn_id_status_change_intr(struct dwc2_hsotg *hsotg)
  */
 static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg)
 {
-       dev_dbg(hsotg->dev, "++Session Request Interrupt++\n");
+       int ret;
+
+       dev_dbg(hsotg->dev, "Session request interrupt - lx_state=%d\n",
+                                                       hsotg->lx_state);
 
        /* Clear interrupt */
        dwc2_writel(GINTSTS_SESSREQINT, hsotg->regs + GINTSTS);
 
-       /*
-        * Report disconnect if there is any previous session established
-        */
-       if (dwc2_is_device_mode(hsotg))
+       if (dwc2_is_device_mode(hsotg)) {
+               if (hsotg->lx_state == DWC2_L2) {
+                       ret = dwc2_exit_hibernation(hsotg, true);
+                       if (ret && (ret != -ENOTSUPP))
+                               dev_err(hsotg->dev,
+                                       "exit hibernation failed\n");
+               }
+
+               /*
+                * Report disconnect if there is any previous session
+                * established
+                */
                dwc2_hsotg_disconnect(hsotg);
+       }
 }
 
 /*