From 0f6813009fd8630ee89545f74f728eac742369aa Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 10 Sep 2014 11:33:01 -0400 Subject: usb: Perform device detect polling on all usb controllers. Move the 100ms (USB_TIME_SIGATT) device detect polling from the ohci/uhci/usb-hub code to the generic usb_hub_port_setup() code. This extends the 100ms polling to ehci and xhci controllers. The code in usb_hub_port_setup() now compares USB_TIME_SIGATT to the start of usb_enumerate(), which may make boots faster when threads are disabled. This patch also changes the meaning of the return code for hub->op->detect() calls. Now 1 indicates device found, 0 indicates device not found, and -1 indicates permanent failure. Also, the xhci controller generic delay of 100ms is replaced with a 20ms root hub power stabilize time. This in combination with the 100ms for USB_TIME_SIGATT should be closer to the USB2 spec (the USB3 spec does not seem to declare an equivalent of USB_TIME_SIGATT). Signed-off-by: Kevin O'Connor --- src/hw/usb-hub.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'src/hw/usb-hub.c') diff --git a/src/hw/usb-hub.c b/src/hw/usb-hub.c index 2a34e57b..4731a91c 100644 --- a/src/hw/usb-hub.c +++ b/src/hw/usb-hub.c @@ -72,29 +72,13 @@ get_port_status(struct usbhub_s *hub, int port, struct usb_port_status *sts) static int usb_hub_detect(struct usbhub_s *hub, u32 port) { - // Check periodically for a device connect. struct usb_port_status sts; - u32 end = timer_calc(USB_TIME_SIGATT); - for (;;) { - int ret = get_port_status(hub, port, &sts); - if (ret) - goto fail; - if (sts.wPortStatus & USB_PORT_STAT_CONNECTION) - // Device connected. - break; - if (timer_check(end)) - // No device found. - return -1; - msleep(5); + int ret = get_port_status(hub, port, &sts); + if (ret) { + dprintf(1, "Failure on hub port %d detect\n", port); + return -1; } - - // XXX - wait USB_TIME_ATTDB time? - - return 0; - -fail: - dprintf(1, "Failure on hub port %d detect\n", port); - return -1; + return (sts.wPortStatus & USB_PORT_STAT_CONNECTION) ? 1 : 0; } // Disable port -- cgit