usb: dwc3: gadget: fix gadget suspend/resume
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Wed, 4 May 2016 12:50:27 +0000 (15:50 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 20 Jun 2016 09:30:04 +0000 (12:30 +0300)
Instead of trying hard to stay connected to the
host, it's best (and far easier) to disconnect from
the host already.

Anything relying on KEEP_CONNECT will just have that
ignored, but we don't have proper hibernation
implementation yet, so there are no regressions.

In any case, hibernation is only useful for runtime
PM, not system sleep.

While at that, also remove dwc3.dcfg which has been
rendered unnecessary.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/core.h
drivers/usb/dwc3/gadget.c

index 654050684f4fadb4004587edcb653ca03c0d4f3f..c881c8232e2165376dbf34ccac617c1645fb2774 100644 (file)
@@ -819,7 +819,6 @@ struct dwc3 {
        enum usb_dr_mode        dr_mode;
 
        /* used for suspend/resume */
-       u32                     dcfg;
        u32                     gctl;
 
        u32                     nr_scratch;
index 54e36b70361ab7950bf425f402153caa85e9bdf1..ae55f500cdbd2b6e8b505a3a60bfc9e70ebb92c5 100644 (file)
@@ -2943,60 +2943,40 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
 
 int dwc3_gadget_suspend(struct dwc3 *dwc)
 {
+       int ret;
+
        if (!dwc->gadget_driver)
                return 0;
 
-       if (dwc->pullups_connected) {
-               dwc3_gadget_disable_irq(dwc);
-               dwc3_gadget_run_stop(dwc, true, true);
-       }
-
-       __dwc3_gadget_ep_disable(dwc->eps[0]);
-       __dwc3_gadget_ep_disable(dwc->eps[1]);
+       ret = dwc3_gadget_run_stop(dwc, false, false);
+       if (ret < 0)
+               return ret;
 
-       dwc->dcfg = dwc3_readl(dwc->regs, DWC3_DCFG);
+       dwc3_disconnect_gadget(dwc);
+       __dwc3_gadget_stop(dwc);
 
        return 0;
 }
 
 int dwc3_gadget_resume(struct dwc3 *dwc)
 {
-       struct dwc3_ep          *dep;
        int                     ret;
 
        if (!dwc->gadget_driver)
                return 0;
 
-       /* Start with SuperSpeed Default */
-       dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
-
-       dep = dwc->eps[0];
-       ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false,
-                       false);
-       if (ret)
+       ret = __dwc3_gadget_start(dwc);
+       if (ret < 0)
                goto err0;
 
-       dep = dwc->eps[1];
-       ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false,
-                       false);
-       if (ret)
+       ret = dwc3_gadget_run_stop(dwc, true, false);
+       if (ret < 0)
                goto err1;
 
-       /* begin to receive SETUP packets */
-       dwc->ep0state = EP0_SETUP_PHASE;
-       dwc3_ep0_out_start(dwc);
-
-       dwc3_writel(dwc->regs, DWC3_DCFG, dwc->dcfg);
-
-       if (dwc->pullups_connected) {
-               dwc3_gadget_enable_irq(dwc);
-               dwc3_gadget_run_stop(dwc, true, false);
-       }
-
        return 0;
 
 err1:
-       __dwc3_gadget_ep_disable(dwc->eps[0]);
+       __dwc3_gadget_stop(dwc);
 
 err0:
        return ret;