diff options
-rw-r--r-- | sys/dev/usb/xhci.c | 30 | ||||
-rw-r--r-- | sys/dev/usb/xhcireg.h | 8 |
2 files changed, 32 insertions, 6 deletions
diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index cc7bb108c41..ce39e822196 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci.c,v 1.38 2014/11/10 14:16:13 mpi Exp $ */ +/* $OpenBSD: xhci.c,v 1.39 2014/11/10 14:29:49 mpi Exp $ */ /* * Copyright (c) 2014 Martin Pieuchot @@ -1119,6 +1119,9 @@ xhci_context_setup(struct xhci_softc *sc, struct usbd_pipe *pipe) sdev->slot_ctx->tt = 0; sdev->slot_ctx->state = 0; +/* XXX */ +#define UHUB_IS_MTT(dev) (dev->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) + /* * If we are opening the interrupt pipe of a hub, update its * context before putting it in the CONFIGURED state. @@ -1131,7 +1134,32 @@ xhci_context_setup(struct xhci_softc *sc, struct usbd_pipe *pipe) sdev->slot_ctx->info_lo |= htole32(XHCI_SCTX_HUB(1)); sdev->slot_ctx->info_hi |= htole32(XHCI_SCTX_NPORTS(nports)); + + if (UHUB_IS_MTT(pipe->device)) + sdev->slot_ctx->info_lo |= htole32(XHCI_SCTX_MTT(1)); + + sdev->slot_ctx->tt |= htole32( + XHCI_SCTX_TT_THINK_TIME(pipe->device->hub->ttthink) + ); + } + + /* + * If this is a Low or Full Speed device below an external High + * Speed hub, it needs some TT love. + */ + if (speed < XHCI_SPEED_HIGH && pipe->device->myhsport != NULL) { + struct usbd_device *hshub = pipe->device->myhsport->parent; + uint8_t slot = ((struct xhci_pipe *)hshub->default_pipe)->slot; + + if (UHUB_IS_MTT(hshub)) + sdev->slot_ctx->info_lo |= htole32(XHCI_SCTX_MTT(1)); + + sdev->slot_ctx->tt |= htole32( + XHCI_SCTX_TT_HUB_SID(slot) | + XHCI_SCTX_TT_PORT_NUM(pipe->device->myhsport->portno) + ); } +#undef UHUB_IS_MTT usb_syncmem(&sdev->ictx_dma, 0, sc->sc_pagesize, BUS_DMASYNC_PREWRITE); } diff --git a/sys/dev/usb/xhcireg.h b/sys/dev/usb/xhcireg.h index 0eb2f0af841..a37bb7d3fbe 100644 --- a/sys/dev/usb/xhcireg.h +++ b/sys/dev/usb/xhcireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xhcireg.h,v 1.4 2014/10/05 12:46:58 mpi Exp $ */ +/* $OpenBSD: xhcireg.h,v 1.5 2014/11/10 14:29:49 mpi Exp $ */ /*- * Copyright (c) 2014 Martin Pieuchot. All rights reserved. @@ -257,10 +257,8 @@ struct xhci_sctx { uint32_t tt; #define XHCI_SCTX_TT_HUB_SID(x) ((x) & 0xff) -#define XHCI_SCTX_SET_TT_PORT_NUM(x) (((x) & 0xff) << 8) -#define XHCI_SCTX_GET_TT_PORT_NUM(x) (((x) >> 8) & 0xff) -#define XHCI_SCTX_SET_TT_THINK_TIME(x) (((x) & 0x3) << 16) -#define XHCI_SCTX_GET_TT_THINK_TIME(x) (((x) >> 16) & 0x3) +#define XHCI_SCTX_TT_PORT_NUM(x) (((x) & 0xff) << 8) +#define XHCI_SCTX_TT_THINK_TIME(x) (((x) & 0x3) << 16) #define XHCI_SCTX_SET_IRQ_TARGET(x) (((x) & 0x3ff) << 22) #define XHCI_SCTX_GET_IRQ_TARGET(x) (((x) >> 22) & 0x3ff) |