usb: dwc2: gadget: exit hibernation before power down
authorGregory Herrero <gregory.herrero@intel.com>
Tue, 29 Sep 2015 10:08:28 +0000 (12:08 +0200)
committerFelipe Balbi <balbi@ti.com>
Thu, 1 Oct 2015 17:40:27 +0000 (12:40 -0500)
When disconnecting cable, controller will detect a suspend condition
and enter partial power down. If vbus_session is called by the phy
driver during hibernation, make sure controller exit hibernation
before it is accessed.

Signed-off-by: Jianqiang Tang <jianqiang.tang@intel.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Tested-by: John Youn <johnyoun@synopsys.com>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc2/gadget.c

index e87a7359e632e5827717b096f80b4414ac76d90d..ef964814b9286187067d02a49b8700e331ee0f28 100644 (file)
@@ -3285,14 +3285,15 @@ static int dwc2_hsotg_vbus_session(struct usb_gadget *gadget, int is_active)
        dev_dbg(hsotg->dev, "%s: is_active: %d\n", __func__, is_active);
        spin_lock_irqsave(&hsotg->lock, flags);
 
+       /*
+        * If controller is hibernated, it must exit from hibernation
+        * before being initialized / de-initialized
+        */
+       if (hsotg->lx_state == DWC2_L2)
+               dwc2_exit_hibernation(hsotg, false);
+
        if (is_active) {
                hsotg->op_state = OTG_STATE_B_PERIPHERAL;
-               /*
-                * If controller is hibernated, it must exit from hibernation
-                * before being initialized
-                */
-               if (hsotg->lx_state == DWC2_L2)
-                       dwc2_exit_hibernation(hsotg, false);
 
                dwc2_hsotg_core_init_disconnected(hsotg, false);
                if (hsotg->enabled)
This page took 0.025923 seconds and 5 git commands to generate.