[SeaBIOS] [PATCH 5/7] ohci: Repeatedly poll for device detect for 100ms.
Kevin O'Connor
kevin at koconnor.net
Wed Sep 10 20:46:04 CEST 2014
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.
Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
src/hw/usb-ohci.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c
index f566c4b..8089e13 100644
--- a/src/hw/usb-ohci.c
+++ b/src/hw/usb-ohci.c
@@ -42,10 +42,17 @@ static int
ohci_hub_detect(struct usbhub_s *hub, u32 port)
{
struct usb_ohci_s *cntl = container_of(hub->cntl, struct usb_ohci_s, usb);
- u32 sts = readl(&cntl->regs->roothub_portstatus[port]);
- if (!(sts & RH_PS_CCS))
- // No device.
- return -1;
+ u32 end = timer_calc(USB_TIME_SIGATT);
+ for (;;) {
+ u32 sts = readl(&cntl->regs->roothub_portstatus[port]);
+ if (sts & RH_PS_CCS)
+ // Device connected.
+ break;
+ if (timer_check(end))
+ // No device found.
+ return -1;
+ msleep(5);
+ }
// XXX - need to wait for USB_TIME_ATTDB if just powered up?
--
1.9.3
More information about the SeaBIOS
mailing list