usb: dwc3: fix PM resume error for rockchip platforms
authorWu Liang feng <wulf@rock-chips.com>
Tue, 16 Aug 2016 06:20:11 +0000 (14:20 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 17 Aug 2016 10:40:29 +0000 (18:40 +0800)
We enable PM runtime auto suspend on rockchip platforms (e.g. rk3399),
it allows DWC3 controller to enter runtime suspend if usb cable detached.
So we don't need to do anything in dwc3_suspend() and dwc3_resume()
which duplicated the same operations as dwc3_runtime_suspend() and
dwc3_runtime_resume().

And if DWC3 controller works on HOST mode, we can't do runtime resume
DWC3 gadget.

Change-Id: I63e734f51b05274251d8a88a664eee768568eb7b
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
drivers/usb/dwc3/core.c
drivers/usb/dwc3/gadget.c

index 96294d6458d55ae4bdaa50aceae68f0cf7aaaa88..19254eb77beb89f8eaae966b42fdc58098cc1bf4 100644 (file)
@@ -1247,6 +1247,9 @@ static int dwc3_suspend(struct device *dev)
        struct dwc3     *dwc = dev_get_drvdata(dev);
        int             ret;
 
+       if (pm_runtime_suspended(dwc->dev))
+               return 0;
+
        ret = dwc3_suspend_common(dwc);
        if (ret)
                return ret;
@@ -1261,6 +1264,9 @@ static int dwc3_resume(struct device *dev)
        struct dwc3     *dwc = dev_get_drvdata(dev);
        int             ret;
 
+       if (pm_runtime_suspended(dwc->dev))
+               return 0;
+
        pinctrl_pm_select_default_state(dev);
 
        ret = dwc3_resume_common(dwc);
index 906f10793edaed5e7219372be08e7ff95cc2aef0..9bddcd27005ebb8d633d69b19c6c404d0fcc7613 100644 (file)
@@ -2873,7 +2873,10 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
        u32 count;
        u32 reg;
 
-       if (pm_runtime_suspended(dwc->dev)) {
+       reg = dwc3_readl(dwc->regs, DWC3_GCTL);
+
+       if (pm_runtime_suspended(dwc->dev) &&
+           DWC3_GCTL_PRTCAP(reg) != DWC3_GCTL_PRTCAP_HOST) {
                pm_runtime_get(dwc->dev);
                disable_irq_nosync(dwc->irq_gadget);
                dwc->pending_events = true;