[coreboot-gerrit] Patch set updated for coreboot: libpayload: usb: xhci: Support rockchip xHCI controller
Martin Roth (martinroth@google.com)
gerrit at coreboot.org
Thu Jun 9 00:07:46 CEST 2016
Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15111
-gerrit
commit 9a2c83fddea5512626bce896bc222a064cd5972e
Author: Liangfeng Wu <wulf at rock-chips.com>
Date: Tue May 24 19:40:46 2016 +0800
libpayload: usb: xhci: Support rockchip xHCI controller
1. Make the xHCI driver to support xHCI controller v1.1
2. And a new function xhci_ring_doorbell(), it aims to
add a memory barrier before ringing the doorbell, to ensure
all TRB changes are written to memory.
BRANCH=none
BUG=chrome-os-partner:52684
TEST=boot from USB on Kevin rk3399 platform
Change-Id: Ife1070d1265476d0f5b88e2acf3299fc84af5832
Signed-off-by: Martin Roth <martinroth at chromium.org>
Original-Commit-Id:
Original-Change-Id: I4e38e04dc3c7d32ee4bb424a473c70956a3c3ea9
Original-Signed-off-by: Liangfeng Wu <wulf at rock-chips.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/346831
Original-Commit-Ready: Brian Norris <briannorris at chromium.org>
Original-Tested-by: Douglas Anderson <dianders at chromium.org>
Original-Reviewed-by: Douglas Anderson <dianders at chromium.org>
Original-Reviewed-by: Julius Werner <jwerner at chromium.org>
---
payloads/libpayload/drivers/usb/xhci.c | 19 ++++++++++++++-----
payloads/libpayload/drivers/usb/xhci_private.h | 2 +-
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/payloads/libpayload/drivers/usb/xhci.c b/payloads/libpayload/drivers/usb/xhci.c
index d223d0f..2e70316 100644
--- a/payloads/libpayload/drivers/usb/xhci.c
+++ b/payloads/libpayload/drivers/usb/xhci.c
@@ -197,7 +197,7 @@ xhci_init (unsigned long physical_bar)
xhci_debug("hciversion: %"PRIx8".%"PRIx8"\n",
xhci->capreg->hciver_hi, xhci->capreg->hciver_lo);
if ((xhci->capreg->hciversion < 0x96) ||
- (xhci->capreg->hciversion > 0x100)) {
+ (xhci->capreg->hciversion > 0x110)) {
xhci_debug("Unsupported xHCI version\n");
goto _free_xhci;
}
@@ -534,6 +534,15 @@ xhci_enqueue_trb(transfer_ring_t *const tr)
}
static void
+xhci_ring_doorbell(endpoint_t *const ep)
+{
+ /* Ensure all TRB changes are written to memory. */
+ wmb();
+ XHCI_INST(ep->dev->controller)->dbreg[ep->dev->address] =
+ xhci_ep_id(ep);
+}
+
+static void
xhci_enqueue_td(transfer_ring_t *const tr, const int ep, const size_t mps,
const int dalen, void *const data, const int dir)
{
@@ -670,7 +679,7 @@ xhci_control(usbdev_t *const dev, const direction_t dir,
xhci_enqueue_trb(tr);
/* Ring doorbell for EP0 */
- xhci->dbreg[dev->address] = 1;
+ xhci_ring_doorbell(&dev->endpoints[0]);
/* Wait for transfer events */
int i, transferred = 0;
@@ -745,7 +754,7 @@ xhci_bulk(endpoint_t *const ep, const int size, u8 *const src,
const unsigned mps = EC_GET(MPS, epctx);
const unsigned dir = (ep->direction == OUT) ? TRB_DIR_OUT : TRB_DIR_IN;
xhci_enqueue_td(tr, ep_id, mps, size, data, dir);
- xhci->dbreg[ep->dev->address] = ep_id;
+ xhci_ring_doorbell(ep);
/* Wait for transfer event */
const int ret = xhci_wait_for_transfer(xhci, ep->dev->address, ep_id);
@@ -852,7 +861,7 @@ xhci_create_intr_queue(endpoint_t *const ep,
and ring the doorbell. */
for (i = 0; i < (reqcount - 1); ++i)
xhci_enqueue_trb(tr);
- xhci->dbreg[slot_id] = ep_id;
+ xhci_ring_doorbell(ep);
return intrq;
@@ -930,7 +939,7 @@ xhci_poll_intr_queue(void *const q)
/* Enqueue the last (spare) TRB and ring doorbell */
xhci_enqueue_trb(tr);
- xhci->dbreg[ep->dev->address] = ep_id;
+ xhci_ring_doorbell(ep);
/* Reuse the current buffer for the next spare TRB */
xhci_clear_trb(tr->cur, tr->pcs);
diff --git a/payloads/libpayload/drivers/usb/xhci_private.h b/payloads/libpayload/drivers/usb/xhci_private.h
index f644425..47a464f 100644
--- a/payloads/libpayload/drivers/usb/xhci_private.h
+++ b/payloads/libpayload/drivers/usb/xhci_private.h
@@ -515,7 +515,7 @@ int xhci_cmd_stop_endpoint(xhci_t *, int slot_id, int ep);
int xhci_cmd_set_tr_dq(xhci_t *, int slot_id, int ep, trb_t *, int dcs);
static inline int xhci_ep_id(const endpoint_t *const ep) {
- return ((ep->endpoint & 0x7f) << 1) + (ep->direction == IN);
+ return ((ep->endpoint & 0x7f) * 2) + (ep->direction != OUT);
}
More information about the coreboot-gerrit
mailing list