summaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci-hcd.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-05-22 00:33:59 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2019-05-23 09:45:49 +0200
commit6044d6c08e1c8e367efc5b5c699083c7982d60d9 (patch)
treefd94434b11a20b3699cff9c7c0740faa06ed600c /drivers/usb/host/ehci-hcd.c
parente4d102602056745f4bcce94501671daad53dc2b8 (diff)
downloadbarebox-6044d6c08e1c8e367efc5b5c699083c7982d60d9.tar.gz
barebox-6044d6c08e1c8e367efc5b5c699083c7982d60d9.tar.xz
usb: host: ehci: Use to USBSTS to wait for transfer completion
Since we already set up our last qTD to have IOC flag set we may as well take advange of that and poll USBSTS to wait for transfer completion. Doesn't change much, but allows us to drop a custom polling loop and re-use handshake() instead. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb/host/ehci-hcd.c')
-rw-r--r--drivers/usb/host/ehci-hcd.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 4ccaec743f..0757ea44ac 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -238,12 +238,10 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
struct ehci_host *ehci = to_ehci(host);
struct QH *qh;
struct qTD *td;
- volatile struct qTD *vtd;
uint32_t *tdp;
uint32_t endpt, token, usbsts;
uint32_t c, toggle;
int ret = 0, i;
- uint64_t start, timeout_val;
dev_dbg(ehci->dev, "pipe=%lx, buffer=%p, length=%d, req=%p\n", pipe,
buffer, length, req);
@@ -375,18 +373,13 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
goto fail;
}
- /* Wait for TDs to be processed. */
- timeout_val = timeout_ms * MSECOND;
- start = get_time_ns();
- vtd = td;
- do {
- token = hc32_to_cpu(vtd->qt_token);
- if (is_timeout_non_interruptible(start, timeout_val)) {
- ehci_enable_async_schedule(ehci, false);
- ehci_writel(&qh->qt_token, 0);
- return -ETIMEDOUT;
- }
- } while (token & 0x80);
+ ret = handshake(&ehci->hcor->or_usbsts, STS_USBINT, STS_USBINT,
+ timeout_ms * 1000);
+ if (ret < 0) {
+ ehci_enable_async_schedule(ehci, false);
+ ehci_writel(&qh->qt_token, 0);
+ return -ETIMEDOUT;
+ }
if (IS_ENABLED(CONFIG_MMU)) {
for (i = 0; i < NUM_TD; i ++) {