Also, the max packet size for super speed devices is 512 bytes (not 256 bytes).
Signed-off-by: Kevin O'Connor kevin@koconnor.net ---
Some additional patches on my xhci-testing branch. Also available at:
https://github.com/KevinOConnor/seabios/tree/xhci-testing
--- src/hw/usb-xhci.c | 11 ++--------- src/hw/usb.c | 9 ++++++++- 2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c index daa7b5a..3366f09 100644 --- a/src/hw/usb-xhci.c +++ b/src/hw/usb-xhci.c @@ -282,13 +282,6 @@ static const int speed_to_xhci[] = { [ USB_SUPERSPEED ] = 4, };
-static const int speed_to_ctlsize[] = { - [ USB_FULLSPEED ] = 8, - [ USB_LOWSPEED ] = 8, - [ USB_HIGHSPEED ] = 64, - [ USB_SUPERSPEED ] = 256, -}; - static const int eptype_to_xhci_in[] = { [ USB_ENDPOINT_XFER_CONTROL] = 4, [ USB_ENDPOINT_XFER_ISOC ] = 5, @@ -955,12 +948,12 @@ xhci_alloc_pipe(struct usbdevice_s *usbdev struct xhci_epctx *ep = (void*)&in[2 << xhci->context64]; ep->ctx[0] |= (3 << 16); // interval: 1ms ep->ctx[1] |= (4 << 3); // control pipe - ep->ctx[1] |= (speed_to_ctlsize[usbdev->speed] << 16); + ep->ctx[1] |= (pipe->pipe.maxpacket << 16);
ep->deq_low = (u32)&pipe->reqs.ring[0]; ep->deq_low |= 1; // dcs ep->deq_high = 0; - ep->length = 8; + ep->length = pipe->pipe.maxpacket;
int cc = xhci_cmd_address_device(xhci, slotid, in); free(in); diff --git a/src/hw/usb.c b/src/hw/usb.c index ff20b6c..7b8a9f5 100644 --- a/src/hw/usb.c +++ b/src/hw/usb.c @@ -261,6 +261,13 @@ set_configuration(struct usb_pipe *pipe, u16 val) * Initialization and enumeration ****************************************************************/
+static const int speed_to_ctlsize[] = { + [ USB_FULLSPEED ] = 8, + [ USB_LOWSPEED ] = 8, + [ USB_HIGHSPEED ] = 64, + [ USB_SUPERSPEED ] = 512, +}; + // Assign an address to a device in the default state on the given // controller. static int @@ -276,7 +283,7 @@ usb_set_address(struct usbdevice_s *usbdev)
// Create a pipe for the default address. struct usb_endpoint_descriptor epdesc = { - .wMaxPacketSize = 8, + .wMaxPacketSize = speed_to_ctlsize[usbdev->speed], .bmAttributes = USB_ENDPOINT_XFER_CONTROL, }; usbdev->defpipe = usb_alloc_pipe(usbdev, &epdesc);