summaryrefslogtreecommitdiff
path: root/Platform
diff options
context:
space:
mode:
authorMichael Brown <mbrown@fensystems.co.uk>2019-07-17 12:46:44 +0100
committerLeif Lindholm <leif.lindholm@linaro.org>2019-07-19 17:32:04 +0100
commit24614a0e84261706e7f70e6fe3fec2a1f78faa89 (patch)
tree05281bef6d79895b40567f18bf495e69aabbeb80 /Platform
parent2b728814e510fa9c9bcd5054bd9fd0db08fcb14e (diff)
Platform/RPi3: Gracefully disable USB channel after a timeout
When a timeout occurs, attempt to gracefully disable the channel. Report a final status of EFI_TIMEOUT if the channel was disabled successfully, or EFI_DEVICE_ERROR if we were unable to disable the channel. Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'Platform')
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
index c1e1229f..22d9bd82 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
@@ -318,13 +318,21 @@ DwHcTransfer (
Ret = Wait4Chhltd (DwHc, Timeout, Channel, &Sub, Pid, IgnoreAck, &Split);
if (Ret == XFER_NOT_HALTED) {
- /*
- * FIXME: do proper channel reset.
- */
- MmioWrite32 (DwHc->DwUsbBase + HCCHAR (Channel), DWC2_HCCHAR_CHDIS);
-
*TransferResult = EFI_USB_ERR_TIMEOUT;
- Status = EFI_DEVICE_ERROR;
+ MmioOr32 (DwHc->DwUsbBase + HCCHAR (Channel), DWC2_HCCHAR_CHDIS);
+ Status = gBS->SetTimer (Timeout, TimerRelative,
+ EFI_TIMER_PERIOD_MILLISECONDS (1));
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ Status = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel),
+ DWC2_HCINT_CHHLTD, 1);
+ if (Status == EFI_SUCCESS) {
+ Status = EFI_TIMEOUT;
+ } else {
+ Status = EFI_DEVICE_ERROR;
+ }
break;
} else if (Ret == XFER_STALL) {
*TransferResult = EFI_USB_ERR_STALL;