diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-05-22 00:33:59 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-05-23 09:45:49 +0200 |
commit | 6044d6c08e1c8e367efc5b5c699083c7982d60d9 (patch) | |
tree | fd94434b11a20b3699cff9c7c0740faa06ed600c /drivers/usb | |
parent | e4d102602056745f4bcce94501671daad53dc2b8 (diff) | |
download | barebox-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')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 21 | ||||
-rw-r--r-- | drivers/usb/host/ehci.h | 1 |
2 files changed, 8 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 ++) { diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 39de763749..5b0920d0e0 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -62,6 +62,7 @@ struct ehci_hcor { #define STD_ASS (1 << 15) #define STS_PSS (1 << 14) #define STS_HALT (1 << 12) +#define STS_USBINT BIT(0) uint32_t or_usbintr; uint32_t or_frindex; uint32_t or_ctrldssegment; |