From b8ef4c9a840ebf1549694db9967f101ab2211db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Mon, 12 Aug 2013 21:35:20 +0300 Subject: usbdebug: Reduce bus reset delays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to EHCI specification, host controller software stops the USB Reset condition by writing PORT_RESET=0. Software then poll-waits this bit until controller hardware has completed USB Reset sequence and read returns with PORT_RESET==0. Change-Id: I6033c4d904c2af9eb16f5f3c1eb825776648cc1d Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/3863 Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) --- src/drivers/usb/ehci_debug.c | 48 ++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/usb/ehci_debug.c b/src/drivers/usb/ehci_debug.c index 55530b73b4..62b10c57ed 100644 --- a/src/drivers/usb/ehci_debug.c +++ b/src/drivers/usb/ehci_debug.c @@ -365,7 +365,6 @@ int dbgp_control_msg(struct ehci_dbg_port *ehci_debug, unsigned devnum, int requ static int ehci_reset_port(struct ehci_regs *ehci_regs, int port) { u32 portsc; - u32 delay_time, delay_ms; int loop; /* Reset the usb debug port */ @@ -374,39 +373,30 @@ static int ehci_reset_port(struct ehci_regs *ehci_regs, int port) portsc |= PORT_RESET; write32((unsigned long)&ehci_regs->port_status[port - 1], portsc); - delay_ms = HUB_ROOT_RESET_TIME; - for (delay_time = 0; delay_time < HUB_RESET_TIMEOUT; - delay_time += delay_ms) { - dbgp_mdelay(delay_ms); + dbgp_mdelay(HUB_ROOT_RESET_TIME); + portsc = read32((unsigned long)&ehci_regs->port_status[port - 1]); + write32((unsigned long)&ehci_regs->port_status[port - 1], + portsc & ~(PORT_RWC_BITS | PORT_RESET)); + + loop = 100; + do { + dbgp_mdelay(1); portsc = read32((unsigned long)&ehci_regs->port_status[port - 1]); - if (portsc & PORT_RESET) { - /* force reset to complete */ - loop = 2; - write32((unsigned long)&ehci_regs->port_status[port - 1], - portsc & ~(PORT_RWC_BITS | PORT_RESET)); - do { - dbgp_mdelay(delay_ms); - portsc = read32((unsigned long)&ehci_regs->port_status[port - 1]); - delay_time += delay_ms; - } while ((portsc & PORT_RESET) && (--loop > 0)); - if (!loop) { - printk(BIOS_DEBUG, "ehci_reset_port forced done"); - } - } + } while ((portsc & PORT_RESET) && (--loop > 0)); - /* Device went away? */ - if (!(portsc & PORT_CONNECT)) - return -1; //-ENOTCONN; + /* Device went away? */ + if (!(portsc & PORT_CONNECT)) + return -1; //-ENOTCONN; - /* bomb out completely if something weird happened */ - if ((portsc & PORT_CSC)) - return -2; //-EINVAL; + /* bomb out completely if something weird happened */ + if ((portsc & PORT_CSC)) + return -2; //-EINVAL; + + /* If we've finished resetting, then break out of the loop */ + if (!(portsc & PORT_RESET) && (portsc & PORT_PE)) + return 0; - /* If we've finished resetting, then break out of the loop */ - if (!(portsc & PORT_RESET) && (portsc & PORT_PE)) - return 0; - } return -3; //-EBUSY; } -- cgit v1.2.3