From 0d437bcaf9be36d7bb954cb261635678c790dff7 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 19 May 2014 14:21:17 -0600 Subject: usb: hub: fix power good delay timing usb_hub_power_on() currently waits for the maximum of (a) the hub port's power output to become good, (b) the max time the USB specification allows a device to take to connect. However, these two operations must occur in series rather than in parallel. First, the power supply ramps up to the level required to power the USB device, and then the device may take a certain amount of time to connect (assert D+/D- pullups). Related, the maximum time that a device has to assert pullups is 1s not 100ms. This is explained in "Connect Timing ECN.pdf", itself part of usb_20_042814.zip from www.usb.org. Signed-off-by: Stephen Warren --- common/usb_hub.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/usb_hub.c b/common/usb_hub.c index ffac0e7..4875a51 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -36,7 +36,7 @@ #endif #ifndef CONFIG_USB_HUB_MIN_POWER_ON_DELAY -#define CONFIG_USB_HUB_MIN_POWER_ON_DELAY 100 +#define CONFIG_USB_HUB_MIN_POWER_ON_DELAY 1000 #endif #define USB_BUFSIZ 512 @@ -138,8 +138,11 @@ static void usb_hub_power_on(struct usb_hub_device *hub) debug("port %d returns %lX\n", i + 1, dev->status); } - /* Wait for power to become stable */ - mdelay(max(pgood_delay, CONFIG_USB_HUB_MIN_POWER_ON_DELAY)); + /* + * Wait for power to become stable, + * plus spec-defined max time for device to connect + */ + mdelay(pgood_delay + CONFIG_USB_HUB_MIN_POWER_ON_DELAY); } void usb_hub_reset(void) -- cgit v1.1 From 77b83e6d099cb2149e5b2c33a700003227d99297 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 19 May 2014 14:21:18 -0600 Subject: usb: hub: remove CONFIG_USB_HUB_MIN_POWER_ON_DELAY Now that we wait the correct specification-mandated time at the end of usb_hub_power_on(), I suspect that CONFIG_USB_HUB_MIN_POWER_ON_DELAY has no purpose. For cm_t35.h, we already wait longer than the original MIN_POWER_ON_DELAY, so this change is safe. For gw_ventana.h, we will wait as long as the original MIN_POWER_ON_DELAY iff pgood_delay was at least 200ms. I'm not sure if this is the case or not, hence I've CC'd relevant people to test this change. Cc: Igor Grinberg Cc: Tim Harvey Signed-off-by: Stephen Warren --- common/usb_hub.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'common') diff --git a/common/usb_hub.c b/common/usb_hub.c index 4875a51..2add4b9 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -35,10 +35,6 @@ #include #endif -#ifndef CONFIG_USB_HUB_MIN_POWER_ON_DELAY -#define CONFIG_USB_HUB_MIN_POWER_ON_DELAY 1000 -#endif - #define USB_BUFSIZ 512 static struct usb_hub_device hub_dev[USB_MAX_HUB]; @@ -142,7 +138,7 @@ 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 */ - mdelay(pgood_delay + CONFIG_USB_HUB_MIN_POWER_ON_DELAY); + mdelay(pgood_delay + 1000); } void usb_hub_reset(void) -- cgit v1.1