diff mbox

[U-Boot,v2] usb: hub: allow pgood_delay to be specified via env

Message ID 1428520872-5247-1-git-send-email-tharvey@gateworks.com
State Accepted
Delegated to: Marek Vasut
Headers show

Commit Message

Tim Harvey April 8, 2015, 7:21 p.m. UTC
Some USB devices break the spec and require longer warm-up times. Allow
the usb_pgood_delay env variable to override the calculated time.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
v2:
 - added cast to fix compiler warning
---
 common/usb_hub.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Marek Vasut April 11, 2015, 4:59 p.m. UTC | #1
On Wednesday, April 08, 2015 at 09:21:12 PM, Tim Harvey wrote:
> Some USB devices break the spec and require longer warm-up times. Allow
> the usb_pgood_delay env variable to override the calculated time.
> 
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>

It'd be nice if this variable was documented somewhere. Can you please
do that ? Subsequent patch would be fine, though I'm not sure where exactly
to place such documentation. Any ideas ?

Best regards,
Marek Vasut
Marek Vasut April 11, 2015, 5:08 p.m. UTC | #2
On Wednesday, April 08, 2015 at 09:21:12 PM, Tim Harvey wrote:
> Some USB devices break the spec and require longer warm-up times. Allow
> the usb_pgood_delay env variable to override the calculated time.
> 
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>

Applied to u-boot-usb/next , thanks!

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 66b4a72..f54a404 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -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);
 }