From b14743a8ff89dcadfcbaea507b8478088199c346 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 2 Aug 2016 11:19:43 +0200 Subject: usb: Build correct route string for USB3 devices behind a hub 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 Reviewed-by: Nikunj A Dadhania Signed-off-by: Alexey Kardashevskiy --- lib/libusb/usb-xhci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/libusb/usb-xhci.c') diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c index f3de6fb..97cc116 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) { printf("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)) { -- cgit v1.1