summaryrefslogtreecommitdiff
path: root/payloads/libpayload
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2014-03-10 14:12:29 -0700
committerIsaac Christensen <isaac.christensen@se-eng.com>2014-10-02 17:28:47 +0200
commita16029a93d06dc73f7ee2796db7c90b2211ee776 (patch)
tree75f372b40b9ec766d3e50234cc9a9f1d6ff78969 /payloads/libpayload
parent758f26aa2dd7447267ac7e08b32ef157fc55a755 (diff)
downloadcoreboot-a16029a93d06dc73f7ee2796db7c90b2211ee776.tar.xz
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>
Diffstat (limited to 'payloads/libpayload')
-rw-r--r--payloads/libpayload/drivers/usb/generic_hub.c34
-rw-r--r--payloads/libpayload/drivers/usb/generic_hub.h5
-rw-r--r--payloads/libpayload/drivers/usb/xhci_rh.c16
3 files changed, 18 insertions, 37 deletions
diff --git a/payloads/libpayload/drivers/usb/generic_hub.c b/payloads/libpayload/drivers/usb/generic_hub.c
index fa95969f2a..9f8670597e 100644
--- a/payloads/libpayload/drivers/usb/generic_hub.c
+++ b/payloads/libpayload/drivers/usb/generic_hub.c
@@ -93,7 +93,7 @@ generic_hub_debounce(usbdev_t *const dev, const int port)
return 0; /* ignore timeouts, try to always go on */
}
-static int
+int
generic_hub_wait_for_port(usbdev_t *const dev, const int port,
const int wait_for,
int (*const port_op)(usbdev_t *, int),
@@ -135,38 +135,6 @@ generic_hub_resetport(usbdev_t *const dev, const int port)
return 0; /* ignore timeouts, try to always go on */
}
-int
-generic_hub_rh_resetport(usbdev_t *const dev, const int port)
-{
- generic_hub_t *const hub = GEN_HUB(dev);
-
- /*
- * Resetting a root hub port should hold 50ms with pulses of at
- * least 10ms and gaps of at most 3ms (usb20 spec 7.1.7.5).
- * After reset, the port will be enabled automatically.
- */
- int total = 500; /* 500 * 100us = 50ms */
- while (total > 0) {
- if (hub->ops->start_port_reset(dev, port) < 0)
- return -1;
-
- /* wait 100ms for the hub to finish the reset pulse */
- const int timeout = generic_hub_wait_for_port(
- /* time out after 1000 * 100us = 100ms */
- dev, port, 0, hub->ops->port_in_reset, 1000, 100);
- const int reset_time = 1000 - timeout;
- if (timeout < 0)
- return -1;
- else if (!timeout)
- usb_debug("generic_hub: Reset timed out at port %d\n",
- port);
- else if (reset_time < 100) /* i.e. < 100 * 100us */
- usb_debug("generic_hub: Port reset too short\n");
- total -= reset_time;
- }
- return 0; /* ignore timeouts, try to always go on */
-}
-
static int
generic_hub_detach_dev(usbdev_t *const dev, const int port)
{
diff --git a/payloads/libpayload/drivers/usb/generic_hub.h b/payloads/libpayload/drivers/usb/generic_hub.h
index cd4ebb6616..21536c0ecf 100644
--- a/payloads/libpayload/drivers/usb/generic_hub.h
+++ b/payloads/libpayload/drivers/usb/generic_hub.h
@@ -72,8 +72,11 @@ typedef struct generic_hub {
} generic_hub_t;
void generic_hub_destroy(usbdev_t *);
+int generic_hub_wait_for_port(usbdev_t *const dev, const int port,
+ const int wait_for,
+ int (*const port_op)(usbdev_t *, int),
+ int timeout_steps, const int step_us);
int generic_hub_resetport(usbdev_t *, int port);
-int generic_hub_rh_resetport(usbdev_t *, int port); /* root hubs have different timing requirements */
int generic_hub_scanport(usbdev_t *, int port);
/* the provided generic_hub_ops struct has to be static */
int generic_hub_init(usbdev_t *, int num_ports, const generic_hub_ops_t *);
diff --git a/payloads/libpayload/drivers/usb/xhci_rh.c b/payloads/libpayload/drivers/usb/xhci_rh.c
index c4cbeeaab8..26bb4f9c02 100644
--- a/payloads/libpayload/drivers/usb/xhci_rh.c
+++ b/payloads/libpayload/drivers/usb/xhci_rh.c
@@ -100,12 +100,22 @@ xhci_rh_port_speed(usbdev_t *const dev, const int port)
}
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 @@ static const generic_hub_ops_t xhci_rh_ops = {
.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