diff options
author | Douglas Anderson <dianders@chromium.org> | 2019-04-16 17:53:49 -0400 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2019-05-03 02:13:47 -0400 |
commit | c40cf7705e13d288d900e044c0a2f756e9e4909a (patch) | |
tree | 31ab9133f03c69cda3587744766a8ce59a72eddb /drivers/usb/dwc2/hcd.c | |
parent | cc389eaabd7082a14e46aaa5a02f87c9eef37d7f (diff) |
usb: dwc2: optionally assert phy reset when waking up
On the rk3288 USB host-only port (the one that's not the OTG-enabled
port) the PHY can get into a bad state when a wakeup is asserted (not
just a wakeup from full system suspend but also a wakeup from
autosuspend).
We can get the PHY out of its bad state by asserting its "port reset",
but unfortunately that seems to assert a reset onto the USB bus so it
could confuse things if we don't actually deenumerate / reenumerate the
device.
We can also get the PHY out of its bad state by fully resetting it using
the reset from the CRU (clock reset unit), which does a more full
reset. The CRU-based reset appears to actually cause devices on the bus
to be removed and reinserted, which fixes the problem (albeit in a hacky
way).
It's unfortunate that we need to do a full re-enumeration of devices at
wakeup time, but this is better than alternative of letting the bus get
wedged.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Yunzhi Li <lyz@rock-chips.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/dwc2/hcd.c')
-rw-r--r-- | drivers/usb/dwc2/hcd.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 8667ddf3ca74..978232a9e4a8 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c | |||
@@ -4376,6 +4376,17 @@ static void dwc2_hcd_reset_func(struct work_struct *work) | |||
4376 | spin_unlock_irqrestore(&hsotg->lock, flags); | 4376 | spin_unlock_irqrestore(&hsotg->lock, flags); |
4377 | } | 4377 | } |
4378 | 4378 | ||
4379 | static void dwc2_hcd_phy_reset_func(struct work_struct *work) | ||
4380 | { | ||
4381 | struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, | ||
4382 | phy_reset_work); | ||
4383 | int ret; | ||
4384 | |||
4385 | ret = phy_reset(hsotg->phy); | ||
4386 | if (ret) | ||
4387 | dev_warn(hsotg->dev, "PHY reset failed\n"); | ||
4388 | } | ||
4389 | |||
4379 | /* | 4390 | /* |
4380 | * ========================================================================= | 4391 | * ========================================================================= |
4381 | * Linux HC Driver Functions | 4392 | * Linux HC Driver Functions |
@@ -5152,6 +5163,8 @@ static void dwc2_hcd_free(struct dwc2_hsotg *hsotg) | |||
5152 | destroy_workqueue(hsotg->wq_otg); | 5163 | destroy_workqueue(hsotg->wq_otg); |
5153 | } | 5164 | } |
5154 | 5165 | ||
5166 | cancel_work_sync(&hsotg->phy_reset_work); | ||
5167 | |||
5155 | del_timer(&hsotg->wkp_timer); | 5168 | del_timer(&hsotg->wkp_timer); |
5156 | } | 5169 | } |
5157 | 5170 | ||
@@ -5293,11 +5306,10 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) | |||
5293 | hsotg->hc_ptr_array[i] = channel; | 5306 | hsotg->hc_ptr_array[i] = channel; |
5294 | } | 5307 | } |
5295 | 5308 | ||
5296 | /* Initialize hsotg start work */ | 5309 | /* Initialize work */ |
5297 | INIT_DELAYED_WORK(&hsotg->start_work, dwc2_hcd_start_func); | 5310 | INIT_DELAYED_WORK(&hsotg->start_work, dwc2_hcd_start_func); |
5298 | |||
5299 | /* Initialize port reset work */ | ||
5300 | INIT_DELAYED_WORK(&hsotg->reset_work, dwc2_hcd_reset_func); | 5311 | INIT_DELAYED_WORK(&hsotg->reset_work, dwc2_hcd_reset_func); |
5312 | INIT_WORK(&hsotg->phy_reset_work, dwc2_hcd_phy_reset_func); | ||
5301 | 5313 | ||
5302 | /* | 5314 | /* |
5303 | * Allocate space for storing data on status transactions. Normally no | 5315 | * Allocate space for storing data on status transactions. Normally no |