diff options
author | Julius Werner <jwerner@chromium.org> | 2013-09-24 20:03:54 -0700 |
---|---|---|
committer | Isaac Christensen <isaac.christensen@se-eng.com> | 2014-09-04 01:28:42 +0200 |
commit | e00ba2168bf9e61535b83ab4320364fa8e26910c (patch) | |
tree | 98d9fdb28b0214fa7823b580b693635f4af62fe1 /payloads/libpayload/drivers/usb/xhci_devconf.c | |
parent | f9d7252a8d869cfda08c872b49d3ce5d7c27b083 (diff) | |
download | coreboot-e00ba2168bf9e61535b83ab4320364fa8e26910c.tar.xz |
libpayload: usb: Unify USB speed between XHCI stack and USB core
This patch removes the confusing concept of a special "xhci_speed" with
a different numeric value from the usual speed used throughout the USB
core (except for the places directly interacting with the xHC, which are
explicitly marked). It also moves the MPS0 decoding function into the
core and moves some definitions around in preparation of later changes
that will make the stack SuperSpeed-ready. It makes both set_address
implementations share a constant for the specification-defined
SetAddress() recovery delay and removes pointless additional delays from
the non-XHCI version.
Change-Id: I422379d05d4a502b12dae183504e5231add5466a
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170664
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Commit-Queue: Ronald Minnich <rminnich@chromium.org>
(cherry picked from commit f160d4439c0d7cea1d2e6b97207935d61dcbb2f2)
Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com>
Reviewed-on: http://review.coreboot.org/6776
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'payloads/libpayload/drivers/usb/xhci_devconf.c')
-rw-r--r-- | payloads/libpayload/drivers/usb/xhci_devconf.c | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/payloads/libpayload/drivers/usb/xhci_devconf.c b/payloads/libpayload/drivers/usb/xhci_devconf.c index f1064f0247..2b1de3bf9e 100644 --- a/payloads/libpayload/drivers/usb/xhci_devconf.c +++ b/payloads/libpayload/drivers/usb/xhci_devconf.c @@ -30,6 +30,7 @@ //#define XHCI_SPEW_DEBUG #include <arch/virtual.h> +#include <usb/usb.h> #include "xhci_private.h" static u32 @@ -57,7 +58,7 @@ xhci_get_rh_port(xhci_t *const xhci, const int hubport, const int hubaddr) } static int -xhci_get_tt(xhci_t *const xhci, const int xhci_speed, +xhci_get_tt(xhci_t *const xhci, const usb_speed speed, const int hubport, const int hubaddr, int *const tt, int *const tt_port) { @@ -66,8 +67,8 @@ xhci_get_tt(xhci_t *const xhci, const int xhci_speed, const slotctx_t *const slot = xhci->dev[hubaddr].ctx.slot; if ((*tt = SC_GET(TTID, slot))) { *tt_port = SC_GET(TTPORT, slot); - } else if (xhci_speed < XHCI_HIGH_SPEED && - SC_GET(SPEED, slot) == XHCI_HIGH_SPEED) { + } else if (speed < HIGH_SPEED && + SC_GET(SPEED1, slot) - 1 == HIGH_SPEED) { *tt = hubaddr; *tt_port = hubport; } @@ -75,37 +76,7 @@ xhci_get_tt(xhci_t *const xhci, const int xhci_speed, } static long -xhci_decode_mps0(const int xhci_speed, const u8 b_mps) -{ - switch (xhci_speed) { - case XHCI_LOW_SPEED: - case XHCI_FULL_SPEED: - case XHCI_HIGH_SPEED: - switch (b_mps) { - case 8: case 16: case 32: case 64: - return b_mps; - default: - xhci_debug("Invalid MPS0: 0x%02x\n", b_mps); - return 8; - } - break; - case XHCI_SUPER_SPEED: - if (b_mps == 9) { - return 2 << b_mps; - } else { - xhci_debug("Invalid MPS0: 0x%02x\n", b_mps); - return 2 << 9; - } - break; - default: - xhci_debug("Invalid speed for MPS0: %d\n", xhci_speed); - return 8; - } -} - - -static long -xhci_get_mps0(usbdev_t *const dev, const int xhci_speed) +xhci_get_mps0(usbdev_t *const dev, const int speed) { u8 buf[8]; dev_req_t dr = { @@ -121,7 +92,7 @@ xhci_get_mps0(usbdev_t *const dev, const int xhci_speed) xhci_debug("Failed to read MPS0\n"); return COMMUNICATION_ERROR; } else { - return xhci_decode_mps0(xhci_speed, buf[7]); + return usb_decode_mps0(speed, buf[7]); } } @@ -150,10 +121,9 @@ xhci_make_inputctx(const size_t ctxsize) } int -xhci_set_address (hci_t *controller, int speed, int hubport, int hubaddr) +xhci_set_address (hci_t *controller, usb_speed speed, int hubport, int hubaddr) { xhci_t *const xhci = XHCI_INST(controller); - const int xhci_speed = speed + 1; const size_t ctxsize = CTXSIZE(xhci); devinfo_t *di = NULL; @@ -188,12 +158,12 @@ xhci_set_address (hci_t *controller, int speed, int hubport, int hubaddr) *ic->add = (1 << 0) /* Slot Context */ | (1 << 1) /* EP0 Context */ ; SC_SET(ROUTE, ic->dev.slot, xhci_gen_route(xhci, hubport, hubaddr)); - SC_SET(SPEED, ic->dev.slot, xhci_speed); + SC_SET(SPEED1, ic->dev.slot, speed + 1); SC_SET(CTXENT, ic->dev.slot, 1); /* the endpoint 0 context */ SC_SET(RHPORT, ic->dev.slot, xhci_get_rh_port(xhci, hubport, hubaddr)); int tt, tt_port; - if (xhci_get_tt(xhci, xhci_speed, hubport, hubaddr, &tt, &tt_port)) { + if (xhci_get_tt(xhci, speed, hubport, hubaddr, &tt, &tt_port)) { xhci_debug("TT for %d: %d[%d]\n", slot_id, tt, tt_port); SC_SET(MTT, ic->dev.slot, SC_GET(MTT, xhci->dev[tt].ctx.slot)); SC_SET(TTID, ic->dev.slot, tt); @@ -221,13 +191,13 @@ xhci_set_address (hci_t *controller, int speed, int hubport, int hubaddr) xhci_debug("Addressed device %d (USB: %d)\n", slot_id, SC_GET(UADDR, di->ctx.slot)); } - mdelay(2); /* SetAddress() recovery interval (usb20 spec 9.2.6.3) */ + mdelay(SET_ADDRESS_MDELAY); init_device_entry(controller, slot_id); controller->devices[slot_id]->address = slot_id; const long mps0 = xhci_get_mps0( - controller->devices[slot_id], xhci_speed); + controller->devices[slot_id], speed); if (mps0 < 0) { goto _disable_return; } else if (mps0 != 8) { |