// 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);
// 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++) {
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;
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));
* 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