[coreboot-gerrit] New patch to review for coreboot: 84b0f09 usbdebug: Halt host controller before resetting it
Kyösti Mälkki (kyosti.malkki@gmail.com)
gerrit at coreboot.org
Wed Aug 14 17:04:43 CEST 2013
Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3862
-gerrit
commit 84b0f09a4082c87b7cafeb8a67ce6a3c86f88498
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date: Mon Aug 12 15:32:25 2013 +0300
usbdebug: Halt host controller before resetting it
Resetting an EHCI controller when it is not halted can have
undefined behaviour. This mostly fixes a case where calling
usbdebug_init() twice would fail to reset the USB dongle device
properly.
On amd/persimmon it still requires one extra retry, but at least it
is now possible to have usbdebug enabled for both romstage and
ramstage.
Change-Id: Ib0e6e5a0167404f68af2edf112306fdb8def0be9
Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
src/lib/usbdebug.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c
index 81e78c6..c7c5520 100644
--- a/src/lib/usbdebug.c
+++ b/src/lib/usbdebug.c
@@ -449,6 +449,23 @@ try_next_port:
return -1;
}
+ /* Wait until the controller is halted */
+ status = read32((unsigned long)&ehci_regs->status);
+ if (!(status & STS_HALT)) {
+ cmd = read32((unsigned long)&ehci_regs->command);
+ cmd &= ~CMD_RUN;
+ write32((unsigned long)&ehci_regs->command, cmd);
+ loop = 100;
+ do {
+ dbgp_mdelay(10);
+ status = read32((unsigned long)&ehci_regs->status);
+ } while (!(status & STS_HALT) && (--loop > 0));
+ if (status & STS_HALT)
+ dprintk(BIOS_INFO, "EHCI controller halted successfully.\n");
+ else
+ dprintk(BIOS_INFO, "EHCI controller is not halted. Reset may fail.\n");
+ }
+
loop = 100;
/* Reset the EHCI controller */
cmd = read32((unsigned long)&ehci_regs->command);
More information about the coreboot-gerrit
mailing list