]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/usb_hub.c
usb: dwc3: add dwc3 folder from linux kernel to u-boot
[people/ms/u-boot.git] / common / usb_hub.c
index 0f1eab448649541a45e674bcfbd599460cc89677..f54a404a4958bb1bce61ab0a7b084abb95a9e413 100644 (file)
@@ -86,6 +86,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
        int i;
        struct usb_device *dev;
        unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2;
+       const char *env;
 
        dev = hub->pusb_dev;
 
@@ -98,7 +99,14 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
        /*
         * Wait for power to become stable,
         * plus spec-defined max time for device to connect
+        * but allow this time to be increased via env variable as some
+        * devices break the spec and require longer warm-up times
         */
+       env = getenv("usb_pgood_delay");
+       if (env)
+               pgood_delay = max(pgood_delay,
+                                 (unsigned)simple_strtol(env, NULL, 0));
+       debug("pgood_delay=%dms\n", pgood_delay);
        mdelay(pgood_delay + 1000);
 }
 
@@ -300,7 +308,8 @@ static int usb_hub_configure(struct usb_device *dev)
        }
        descriptor = (struct usb_hub_descriptor *)buffer;
 
-       length = min(descriptor->bLength, sizeof(struct usb_hub_descriptor));
+       length = min_t(int, descriptor->bLength,
+                      sizeof(struct usb_hub_descriptor));
 
        if (usb_get_hub_descriptor(dev, buffer, length) < 0) {
                debug("usb_hub_configure: failed to get hub " \