commit 8bbc79c435c896ad0107725fa77c7aeb860af625 Author: Kevin O'Connor Date: Sun Feb 14 12:16:32 2010 -0500 Add symbolic definitions for USB delays. diff --git a/src/usb-ohci.c b/src/usb-ohci.c index 2d33fa9..8ebd340 100644 --- a/src/usb-ohci.c +++ b/src/usb-ohci.c @@ -25,7 +25,7 @@ start_ohci(struct usb_s *cntl, struct ohci_hcca *hcca) // Do reset writel(&cntl->ohci.regs->control, OHCI_USB_RESET | oldrwc); readl(&cntl->ohci.regs->control); // flush writes - msleep(50); + msleep(USB_TIME_DRSTR); // Do software init (min 10us, max 2ms) u64 end = calc_future_tsc_usec(10); @@ -96,7 +96,8 @@ check_ohci_ports(struct usb_s *cntl) // No devices connected goto shutdown; - msleep(60); // XXX - should poll instead of using timer. + // XXX - should poll instead of using timer. + msleep(USB_TIME_DRSTR + USB_TIME_RSTRCY); totalcount = 0; for (i=0; iuhci.iobase + USBPORTSC1); if (port2 & USBPORTSC_CCS) outw(USBPORTSC_PR, cntl->uhci.iobase + USBPORTSC2); - msleep(50); + msleep(USB_TIME_DRSTR); outw(0, cntl->uhci.iobase + USBPORTSC1); outw(0, cntl->uhci.iobase + USBPORTSC2); - msleep(10); + msleep(USB_TIME_RSTRCY); // Configure ports int totalcount = 0; diff --git a/src/usb.c b/src/usb.c index 3d59faf..7d4520e 100644 --- a/src/usb.c +++ b/src/usb.c @@ -125,7 +125,7 @@ set_address(u32 endp) int ret = send_default_control(endp, &req, NULL); if (ret) return 0; - msleep(2); + msleep(USB_TIME_SETADDR_RECOVERY); cntl->maxaddr++; return mkendp(cntl, cntl->maxaddr, 0, endp2speed(endp), endp2maxsize(endp)); diff --git a/src/usb.h b/src/usb.h index 8b9c5f1..e4d0a66 100644 --- a/src/usb.h +++ b/src/usb.h @@ -75,6 +75,15 @@ static inline u8 endp2maxsize(u32 endp) { * usb structs and flags ****************************************************************/ +// USB mandated timings (in ms) +#define USB_TIME_SIGATT 100 +#define USB_TIME_ATTDB 100 +#define USB_TIME_DRST 10 +#define USB_TIME_DRSTR 50 +#define USB_TIME_RSTRCY 10 + +#define USB_TIME_SETADDR_RECOVERY 2 + #define USB_PID_OUT 0xe1 #define USB_PID_IN 0x69 #define USB_PID_SETUP 0x2d