From: Wu Liang feng Date: Tue, 16 Aug 2016 06:20:11 +0000 (+0800) Subject: usb: dwc3: fix PM resume error for rockchip platforms X-Git-Tag: firefly_0821_release~1752 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=389d138fabdf76cd7cb7919f83e6bb30edf72b24;p=firefly-linux-kernel-4.4.55.git usb: dwc3: fix PM resume error for rockchip platforms 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 --- diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 96294d6458d5..19254eb77beb 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -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); diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 906f10793eda..9bddcd27005e 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -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;