[U-Boot] [PATCH 5/7] usb: hub: Increase device enumeration timeout for broken drives

Vivek Gautam gautam.vivek at samsung.com
Wed Mar 27 10:29:01 CET 2013


Few broken usb mass storage devices can take some time to set
Current Connect Status (CCS) and Connect Status Change (CSC) in
Port status register after an attach.
So increasing some timeout when both CCS and CSC bits are not set.

Signed-off-by: Amar <amarendra.xt at samsung.com>
Signed-off-by: Vivek Gautam <gautam.vivek at samsung.com>
---
 common/usb_hub.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index d77f98d..8ba7a0d 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -416,6 +416,7 @@ static int usb_hub_configure(struct usb_device *dev)
 		unsigned short portstatus, portchange;
 		int ret;
 		ulong start = get_timer(0);
+		ulong ts = 0;
 
 		/*
 		 * Wait for (whichever finishes first)
@@ -436,9 +437,23 @@ static int usb_hub_configure(struct usb_device *dev)
 			portchange = le16_to_cpu(portsts->wPortChange);
 
 			if ((portchange & USB_PORT_STAT_C_CONNECTION) ==
-				(portstatus & USB_PORT_STAT_CONNECTION))
-				break;
-
+			    (portstatus & USB_PORT_STAT_CONNECTION)) {
+				/*
+				 * Few brokern pen drives can take some
+				 * time to even report CSC or CCS state after
+				 * an attach. So giving this time lag so that
+				 * the CCS or CSC state can be changed and
+				 * reflected in Port status register.
+				 * XXX: This approach however has a drawback,
+				 * with this we are going to wait for 1 sec
+				 * even for ports on which nothing is connected.
+				 */
+				if (ts == 0)
+					ts = get_timer(0);
+				if ((portchange & USB_PORT_STAT_C_CONNECTION) ||
+				    (get_timer(ts) > CONFIG_SYS_HZ * 1))
+					break;
+			}
 		} while (get_timer(start) < CONFIG_SYS_HZ * 10);
 
 		if (ret < 0)
-- 
1.7.6.5



More information about the U-Boot mailing list