]> xenbits.xensource.com Git - seabios.git/commitdiff
uhci: Repeatedly poll for device detect for 100ms.
authorKevin O'Connor <kevin@koconnor.net>
Wed, 10 Sep 2014 14:33:36 +0000 (10:33 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 16 Sep 2014 15:16:36 +0000 (11:16 -0400)
According to the USB2 specification, a device may take up to 100ms
(USB_TIME_SIGATT) after port power stabilizes to be detected.  So,
continually recheck for a device connection event.

Technically, the uhci root hub ports are always powered up, but it's
not possible to know how long the machine has been on, so it's better
to be safe here.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/usb-uhci.c

index 9d7ef6aa33600325cecbb12ac497dbe4c7c750b8..406af908baf2ec34db0927c064ed2d0d5452f8f6 100644 (file)
@@ -44,10 +44,17 @@ uhci_hub_detect(struct usbhub_s *hub, u32 port)
     struct usb_uhci_s *cntl = container_of(hub->cntl, struct usb_uhci_s, usb);
     u16 ioport = cntl->iobase + USBPORTSC1 + port * 2;
 
-    u16 status = inw(ioport);
-    if (!(status & USBPORTSC_CCS))
-        // No device
-        return -1;
+    u32 end = timer_calc(USB_TIME_SIGATT);
+    for (;;) {
+        u16 status = inw(ioport);
+        if (status & USBPORTSC_CCS)
+            // Device connected.
+            break;
+        if (timer_check(end))
+            // No device found.
+            return -1;
+        msleep(5);
+    }
 
     // XXX - if just powered up, need to wait for USB_TIME_ATTDB?