aboutsummaryrefslogtreecommitdiff
path: root/src/hw
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2014-09-10 10:33:36 -0400
committerKevin O'Connor <kevin@koconnor.net>2014-09-16 11:16:36 -0400
commit6cd080a5b8ec3bfabbff8ba12c2ce0e118e99f7c (patch)
tree367e668b346a0aaaff55e36d64c328430d6368ac /src/hw
parentdc6552c133ba6099eda754b7a037a71b63d65fea (diff)
downloadseabios-6cd080a5b8ec3bfabbff8ba12c2ce0e118e99f7c.zip
seabios-6cd080a5b8ec3bfabbff8ba12c2ce0e118e99f7c.tar.gz
seabios-6cd080a5b8ec3bfabbff8ba12c2ce0e118e99f7c.tar.bz2
uhci: Repeatedly poll for device detect for 100ms.
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>
Diffstat (limited to 'src/hw')
-rw-r--r--src/hw/usb-uhci.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/hw/usb-uhci.c b/src/hw/usb-uhci.c
index 9d7ef6a..406af90 100644
--- a/src/hw/usb-uhci.c
+++ b/src/hw/usb-uhci.c
@@ -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?