]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
usb-hub: Enable power to all ports prior to calling usb_enumerate().
authorKevin O'Connor <kevin@koconnor.net>
Wed, 10 Sep 2014 14:18:02 +0000 (10:18 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 10 Sep 2014 17:33:52 +0000 (13:33 -0400)
Don't perform port power up in the detect code.  Instead do it prior
to calling usb_enumerate().  This makes the code more similar to the
usb root hub drivers.  It can also reduce the total boot time when
threads are disabled.

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

index 477518b338f250c528377fb4d78104b444405e9e..2a34e57b0b9c07ba20d4134c411bafd702bee605 100644 (file)
@@ -72,19 +72,11 @@ 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)
 {
-    // Turn on power to port.
-    int ret = set_port_feature(hub, port, USB_PORT_FEAT_POWER);
-    if (ret)
-        goto fail;
-
-    // Wait for port power to stabilize.
-    msleep(hub->powerwait);
-
     // Check periodically for a device connect.
     struct usb_port_status sts;
     u32 end = timer_calc(USB_TIME_SIGATT);
     for (;;) {
-        ret = get_port_status(hub, port, &sts);
+        int ret = get_port_status(hub, port, &sts);
         if (ret)
             goto fail;
         if (sts.wPortStatus & USB_PORT_STAT_CONNECTION)
@@ -175,9 +167,19 @@ usb_hub_setup(struct usbdevice_s *usbdev)
     memset(&hub, 0, sizeof(hub));
     hub.usbdev = usbdev;
     hub.cntl = usbdev->defpipe->cntl;
-    hub.powerwait = desc.bPwrOn2PwrGood * 2;
     hub.portcount = desc.bNbrPorts;
     hub.op = &HubOp;
+
+    // Turn on power to ports.
+    int port;
+    for (port=0; port<desc.bNbrPorts; port++) {
+        ret = set_port_feature(&hub, port, USB_PORT_FEAT_POWER);
+        if (ret)
+            return ret;
+    }
+    // Wait for port power to stabilize.
+    msleep(desc.bPwrOn2PwrGood * 2);
+
     usb_enumerate(&hub);
 
     dprintf(1, "Initialized USB HUB (%d ports used)\n", hub.devcount);
index 3a663ce1e6356510a0d58f32d8dd6ef1f920e947..223e4d6eafcf472ef11aa2afb9d1ce94b00e0cfa 100644 (file)
@@ -46,7 +46,6 @@ struct usbhub_s {
     struct usbdevice_s *usbdev;
     struct usb_s *cntl;
     struct mutex_s lock;
-    u32 powerwait;
     u32 port;
     u32 threads;
     u32 portcount;