libpayload: usb: Remove generic roothub reset port function
The generic roothub reset port function is overly broad and does some
things which may be undesirable, such as issuing multiple resets to a
port if the reset is deemed to have finished too quickly. Remove the
generic function and replace it with a controller-specific function,
currently only implemented for xhci.
Change-Id: Id46f73ea3341d4d01d2b517c6bf687402022d272
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/189495
Reviewed-by: Julius Werner <jwerner@chromium.org>
(cherry picked from commit 54e1da075b0106b0a1f736641fa52c39401d349d)
Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com>
Reviewed-on: http://review.coreboot.org/7001
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
diff --git a/payloads/libpayload/drivers/usb/xhci_rh.c b/payloads/libpayload/drivers/usb/xhci_rh.c
index c4cbeea..26bb4f9 100644
--- a/payloads/libpayload/drivers/usb/xhci_rh.c
+++ b/payloads/libpayload/drivers/usb/xhci_rh.c
@@ -100,12 +100,22 @@
}
static int
-xhci_rh_start_port_reset(usbdev_t *const dev, const int port)
+xhci_rh_reset_port(usbdev_t *const dev, const int port)
{
xhci_t *const xhci = XHCI_INST(dev->controller);
volatile u32 *const portsc = &xhci->opreg->prs[port - 1].portsc;
+ /* Trigger port reset. */
*portsc = (*portsc & PORTSC_RW_MASK) | PORTSC_PR;
+
+ /* Wait for port_in_reset == 0, up to 150 * 1000us = 150ms */
+ if (generic_hub_wait_for_port(dev, port, 0, xhci_rh_port_in_reset,
+ 150, 1000) == 0)
+ usb_debug("xhci_rh: Reset timed out at port %d\n", port);
+ else
+ /* Clear reset status bits, since port is out of reset. */
+ *portsc = (*portsc & PORTSC_RW_MASK) | PORTSC_PRC | PORTSC_WRC;
+
return 0;
}
@@ -118,8 +128,8 @@
.port_speed = xhci_rh_port_speed,
.enable_port = NULL,
.disable_port = NULL,
- .start_port_reset = xhci_rh_start_port_reset,
- .reset_port = generic_hub_rh_resetport,
+ .start_port_reset = NULL,
+ .reset_port = xhci_rh_reset_port,
};
void