uint32_t endpt, token, usbsts;
uint32_t c, toggle;
uint32_t cmd;
+ int timeout;
int ret = 0;
debug("dev=%p, pipe=%lx, buffer=%p, length=%d, req=%p\n", dev, pipe,
/* Wait for TDs to be processed. */
ts = get_timer(0);
vtd = td;
+ timeout = USB_TIMEOUT_MS(pipe);
do {
/* Invalidate dcache */
ehci_invalidate_dcache(&qh_list);
if (!(token & 0x80))
break;
WATCHDOG_RESET();
- } while (get_timer(ts) < CONFIG_SYS_HZ);
+ } while (get_timer(ts) < timeout);
+
+ /* Check that the TD processing happened */
+ if (token & 0x80) {
+ printf("EHCI timed out on TD - token=%#x\n", token);
+ goto fail;
+ }
/* Disable async schedule. */
cmd = ehci_readl(&hcor->or_usbcmd);
/* ohci_dump_status(&gohci); */
#endif
- /* allow more time for a BULK device to react - some are slow */
-#define BULK_TO 5000 /* timeout in milliseconds */
- if (usb_pipebulk(pipe))
- timeout = BULK_TO;
- else
- timeout = 1000;
+ timeout = USB_TIMEOUT_MS(pipe);
/* wait for it to complete */
for (;;) {
#define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
+/*
+ * This is the timeout to allow for submitting an urb in ms. We allow more
+ * time for a BULK device to react - some are slow.
+ */
+#define USB_TIMEOUT_MS(pipe) (usb_pipebulk(pipe) ? 5000 : 100)
+
/* device request (setup) */
struct devrequest {
unsigned char requesttype;