Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3861
-gerrit
commit 482d31f295e74b75faa8f6cac65516217a650e34 Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Mon Aug 12 00:09:21 2013 +0300
usbdebug: Only test two possible USB device numbers
After an USB device sees USB bus reset on the bus, it will reset to device number 0. Per the EHCI debug port specification, a debug dongle device may reset to the fixed debug device number of 127 instead. Thus there is no need to try device numbers from 1 to 126.
Do a sanity-check on a returned debug descriptor as I experienced some USB flash memory to respond on this request with zero-fill data.
Change-Id: I78d58f3dc049cd8c20c6e2aa3a4207ad7e6a6d33 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/lib/usbdebug.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c index a9a7e17..4a1228f 100644 --- a/src/lib/usbdebug.c +++ b/src/lib/usbdebug.c @@ -540,24 +540,28 @@ try_next_port: dbgp_mdelay(100);
/* Find the debug device and make it device number 127 */ - for (devnum = 0; devnum <= 127; devnum++) { - ret = dbgp_control_msg(ehci_debug, devnum, - USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE, - USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0, - &dbgp_desc, sizeof(dbgp_desc)); - if (ret > 0) - break; + devnum = 0; +debug_dev_retry: + memset(&dbgp_desc, 0, sizeof(dbgp_desc)); + ret = dbgp_control_msg(ehci_debug, devnum, + USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE, + USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0, + &dbgp_desc, sizeof(dbgp_desc)); + if (ret == sizeof(dbgp_desc)) { + if (dbgp_desc.bLength == sizeof(dbgp_desc) && dbgp_desc.bDescriptorType==USB_DT_DEBUG) + goto debug_dev_found; + else + dprintk(BIOS_INFO, "Invalid debug device descriptor.\n"); } - if (devnum > 127) { + if (devnum == 0) { + devnum = USB_DEBUG_DEVNUM; + goto debug_dev_retry; + } else { dprintk(BIOS_INFO, "Could not find attached debug device.\n"); ret = -5; goto err; } - if (ret < 0) { - dprintk(BIOS_INFO, "Attached device is not a debug device.\n"); - ret = -6; - goto err; - } +debug_dev_found:
/* Move the device to 127 if it isn't already there */ if (devnum != USB_DEBUG_DEVNUM) {