[SLOF] [PATCH v2 4/5] usb: Build correct route string for USB3 devices behind a hub
Thomas Huth
thuth at redhat.com
Tue Aug 2 19:19:43 AEST 2016
To support USB3 devices attached to a hub, we've got to set
the so-called "route string" in the slot context, which is
a concatenation of the hub port numbers that need to be
traversed between the root hub port and the destination device.
Signed-off-by: Thomas Huth <thuth at redhat.com>
---
lib/libusb/usb-xhci.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c
index 2d34133..0b45c26 100644
--- a/lib/libusb/usb-xhci.c
+++ b/lib/libusb/usb-xhci.c
@@ -538,7 +538,7 @@ static bool xhci_alloc_dev(struct xhci_hcd *xhcd, struct usb_dev *hub,
struct xhci_ep_ctx *ep0;
uint32_t ctx_size, val;
uint16_t max_packet;
- uint32_t newport;
+ uint32_t newport, rootport;
if (slot_id > XHCI_CONFIG_MAX_SLOT) {
dprintf("USB3 slot ID %d is too high (max is %d)\n", slot_id,
@@ -565,10 +565,16 @@ static bool xhci_alloc_dev(struct xhci_hcd *xhcd, struct usb_dev *hub,
/* Step 3 */
slot = xhci_get_slot_ctx(&xdev->in_ctx, ctx_size);
- newport = port + 1;
- val = LAST_CONTEXT(1) | SLOT_SPEED_SS | (newport << 16); /* FIXME speed, read from PS */
+ newport = rootport = port + 1;
+ val = newport & 0xf;
+ for (dev = hub; dev != NULL; dev = dev->hub) {
+ val = (val << 4) | (dev->port & 0xf); /* Build route string */
+ rootport = dev->port;
+ }
+ val >>= 4; /* Remove root hub ID from the string */
+ val |= LAST_CONTEXT(1) | SLOT_SPEED_SS; /* FIXME speed, read from PS */
slot->field1 = cpu_to_le32(val);
- slot->field2 = cpu_to_le32(ROOT_HUB_PORT(newport)); /* FIXME how to get port no */
+ slot->field2 = cpu_to_le32(ROOT_HUB_PORT(rootport));
/* Step 4 */
if (!xhci_alloc_seg(&xdev->control, XHCI_CONTROL_TRBS_SIZE, TYPE_CTRL)) {
--
1.8.3.1
More information about the SLOF
mailing list