aboutsummaryrefslogtreecommitdiffstats
path: root/src/hw/usb-xhci.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2014-09-10 11:33:01 -0400
committerKevin O'Connor <kevin@koconnor.net>2014-09-16 11:16:40 -0400
commit0f6813009fd8630ee89545f74f728eac742369aa (patch)
tree139310ab7b6b56f85729cd4b96258439fddcefbb /src/hw/usb-xhci.c
parente2d6fddcd956b3bbcb9852d8f87ff41eab239a2e (diff)
downloadseabios-0f6813009fd8630ee89545f74f728eac742369aa.tar.gz
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 <kevin@koconnor.net>
Diffstat (limited to 'src/hw/usb-xhci.c')
-rw-r--r--src/hw/usb-xhci.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c
index 5f91d89b..eafa4cb4 100644
--- a/src/hw/usb-xhci.c
+++ b/src/hw/usb-xhci.c
@@ -320,6 +320,8 @@ static int wait_bit(u32 *reg, u32 mask, int value, u32 timeout)
* Root hub
****************************************************************/
+#define XHCI_TIME_POSTPOWER 20
+
// Check if device attached to port
static void
xhci_print_port_state(int loglevel, const char *prefix, u32 port, u32 portsc)
@@ -339,7 +341,7 @@ xhci_hub_detect(struct usbhub_s *hub, u32 port)
{
struct usb_xhci_s *xhci = container_of(hub->cntl, struct usb_xhci_s, usb);
u32 portsc = readl(&xhci->pr[port].portsc);
- return (portsc & XHCI_PORTSC_CCS) ? 0 : -1;
+ return (portsc & XHCI_PORTSC_CCS) ? 1 : 0;
}
// Reset device on port
@@ -388,8 +390,8 @@ static struct usbhub_op_s xhci_hub_ops = {
static int
xhci_check_ports(struct usb_xhci_s *xhci)
{
- // FIXME: try find a more elegant way than a fixed delay
- msleep(100);
+ // Wait for port power to stabilize.
+ msleep(XHCI_TIME_POSTPOWER);
struct usbhub_s hub;
memset(&hub, 0, sizeof(hub));