Add symbolic definitions for USB delays.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 14 Feb 2010 17:16:32 +0000 (12:16 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 14 Feb 2010 17:16:32 +0000 (12:16 -0500)
src/usb-ohci.c
src/usb-uhci.c
src/usb.c
src/usb.h

index 2d33fa98c2c5149521bc5faae7e92655ad888188..8ebd340a50463d6ece3f990a7c37d8f1923f09f3 100644 (file)
@@ -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; i<ports; i++) {
index 950ec6a3b116f5e649eae65449990249e4049029..b09b17afcbfbb3009e8b9baf74a4098970ec606e 100644 (file)
@@ -106,10 +106,10 @@ check_ports(struct usb_s *cntl)
         outw(USBPORTSC_PR, cntl->uhci.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;
index 3d59faf64a64b0a1390625ae3542c8d494ad7e2e..7d4520ea8b32a752850a434c7b4fdcece59ff062 100644 (file)
--- 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));
index 8b9c5f1ecacba1b95d74ebae9e48d296ca7ce09c..e4d0a660bdb9375a28a4c039d52cb6099db94de8 100644 (file)
--- 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