From 35b2941b419c9d426e9101e3799161bae811496f Mon Sep 17 00:00:00 2001 From: hselasky Date: Sat, 31 Dec 2011 13:23:04 +0000 Subject: [PATCH] MFC r227396, r227401, r227541, r227654 and r228493: Relax XHCI timeouts which should fix enumeration issues. Fix definition of XHCI port power bit. Correct size of some USB 3.0 descriptor fields. Reported by: Kohji Okuno, Jan Henrik Sylvester git-svn-id: svn://svn.freebsd.org/base/stable/9@229084 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/usb/controller/xhci.c | 29 +++++++++++++++-------------- sys/dev/usb/controller/xhcireg.h | 2 +- sys/dev/usb/usb.h | 4 ++-- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 0df4c4d17..2b765aadb 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -292,7 +292,7 @@ xhci_start_controller(struct xhci_softc *sc) XWRITE4(sc, oper, XHCI_USBCMD, XHCI_CMD_HCRST); for (i = 0; i != 100; i++) { - usb_pause_mtx(NULL, hz / 1000); + usb_pause_mtx(NULL, hz / 100); temp = XREAD4(sc, oper, XHCI_USBCMD) & (XHCI_CMD_HCRST | XHCI_STS_CNR); if (!temp) @@ -453,7 +453,7 @@ xhci_start_controller(struct xhci_softc *sc) XHCI_CMD_INTE | XHCI_CMD_HSEE); for (i = 0; i != 100; i++) { - usb_pause_mtx(NULL, hz / 1000); + usb_pause_mtx(NULL, hz / 100); temp = XREAD4(sc, oper, XHCI_USBSTS) & XHCI_STS_HCH; if (!temp) break; @@ -487,7 +487,7 @@ xhci_halt_controller(struct xhci_softc *sc) XWRITE4(sc, oper, XHCI_USBCMD, 0); for (i = 0; i != 100; i++) { - usb_pause_mtx(NULL, hz / 1000); + usb_pause_mtx(NULL, hz / 100); temp = XREAD4(sc, oper, XHCI_USBSTS) & XHCI_STS_HCH; if (temp) break; @@ -1110,7 +1110,7 @@ xhci_cmd_nop(struct xhci_softc *sc) trb.dwTrb3 = htole32(temp); - return (xhci_do_command(sc, &trb, 50 /* ms */)); + return (xhci_do_command(sc, &trb, 100 /* ms */)); } #endif @@ -1127,7 +1127,7 @@ xhci_cmd_enable_slot(struct xhci_softc *sc, uint8_t *pslot) trb.dwTrb2 = 0; trb.dwTrb3 = htole32(XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_ENABLE_SLOT)); - err = xhci_do_command(sc, &trb, 50 /* ms */); + err = xhci_do_command(sc, &trb, 100 /* ms */); if (err) goto done; @@ -1154,7 +1154,7 @@ xhci_cmd_disable_slot(struct xhci_softc *sc, uint8_t slot_id) trb.dwTrb3 = htole32(temp); - return (xhci_do_command(sc, &trb, 50 /* ms */)); + return (xhci_do_command(sc, &trb, 100 /* ms */)); } static usb_error_t @@ -1310,7 +1310,7 @@ xhci_cmd_configure_ep(struct xhci_softc *sc, uint64_t input_ctx, trb.dwTrb3 = htole32(temp); - return (xhci_do_command(sc, &trb, 50 /* ms */)); + return (xhci_do_command(sc, &trb, 100 /* ms */)); } static usb_error_t @@ -1328,7 +1328,7 @@ xhci_cmd_evaluate_ctx(struct xhci_softc *sc, uint64_t input_ctx, XHCI_TRB_3_SLOT_SET(slot_id); trb.dwTrb3 = htole32(temp); - return (xhci_do_command(sc, &trb, 50 /* ms */)); + return (xhci_do_command(sc, &trb, 100 /* ms */)); } static usb_error_t @@ -1351,7 +1351,7 @@ xhci_cmd_reset_ep(struct xhci_softc *sc, uint8_t preserve, trb.dwTrb3 = htole32(temp); - return (xhci_do_command(sc, &trb, 50 /* ms */)); + return (xhci_do_command(sc, &trb, 100 /* ms */)); } static usb_error_t @@ -1373,7 +1373,7 @@ xhci_cmd_set_tr_dequeue_ptr(struct xhci_softc *sc, uint64_t dequeue_ptr, XHCI_TRB_3_EP_SET(ep_id); trb.dwTrb3 = htole32(temp); - return (xhci_do_command(sc, &trb, 50 /* ms */)); + return (xhci_do_command(sc, &trb, 100 /* ms */)); } static usb_error_t @@ -1396,7 +1396,7 @@ xhci_cmd_stop_ep(struct xhci_softc *sc, uint8_t suspend, trb.dwTrb3 = htole32(temp); - return (xhci_do_command(sc, &trb, 50 /* ms */)); + return (xhci_do_command(sc, &trb, 100 /* ms */)); } static usb_error_t @@ -1414,7 +1414,7 @@ xhci_cmd_reset_dev(struct xhci_softc *sc, uint8_t slot_id) trb.dwTrb3 = htole32(temp); - return (xhci_do_command(sc, &trb, 50 /* ms */)); + return (xhci_do_command(sc, &trb, 100 /* ms */)); } /*------------------------------------------------------------------------* @@ -2831,7 +2831,7 @@ struct xhci_bos_desc xhci_bosd = { .bLength = sizeof(xhci_bosd.usb2extd), .bDescriptorType = 1, .bDevCapabilityType = 2, - .bmAttributes = 2, + .bmAttributes[0] = 2, }, .usbdcd = { .bLength = sizeof(xhci_bosd.usbdcd), @@ -2841,7 +2841,8 @@ struct xhci_bos_desc xhci_bosd = { HSETW(.wSpeedsSupported, 0x000C), .bFunctionalitySupport = 8, .bU1DevExitLat = 255, /* dummy - not used */ - .bU2DevExitLat = 255, /* dummy - not used */ + .wU2DevExitLat[0] = 0x00, + .wU2DevExitLat[1] = 0x08, }, .cidd = { .bLength = sizeof(xhci_bosd.cidd), diff --git a/sys/dev/usb/controller/xhcireg.h b/sys/dev/usb/controller/xhcireg.h index 8be502ef3..b14dabcff 100644 --- a/sys/dev/usb/controller/xhcireg.h +++ b/sys/dev/usb/controller/xhcireg.h @@ -115,7 +115,7 @@ #define XHCI_PS_PR 0x00000010 /* RW - port reset */ #define XHCI_PS_PLS_GET(x) (((x) >> 5) & 0xF) /* RW - port link state */ #define XHCI_PS_PLS_SET(x) (((x) & 0xF) << 5) /* RW - port link state */ -#define XHCI_PS_PP 0x00000100 /* RW - port power */ +#define XHCI_PS_PP 0x00000200 /* RW - port power */ #define XHCI_PS_SPEED_GET(x) (((x) >> 10) & 0xF) /* RO - port speed */ #define XHCI_PS_PIC_GET(x) (((x) >> 14) & 0x3) /* RW - port indicator */ #define XHCI_PS_PIC_SET(x) (((x) & 0x3) << 14) /* RW - port indicator */ diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h index 6a9b12663..fb1c8e677 100644 --- a/sys/dev/usb/usb.h +++ b/sys/dev/usb/usb.h @@ -323,7 +323,7 @@ struct usb_devcap_usb2ext_descriptor { uByte bLength; uByte bDescriptorType; uByte bDevCapabilityType; - uByte bmAttributes; + uDWord bmAttributes; #define USB_V2EXT_LPM 0x02 } __packed; typedef struct usb_devcap_usb2ext_descriptor usb_devcap_usb2ext_descriptor_t; @@ -336,7 +336,7 @@ struct usb_devcap_ss_descriptor { uWord wSpeedsSupported; uByte bFunctionalitySupport; uByte bU1DevExitLat; - uByte bU2DevExitLat; + uWord wU2DevExitLat; } __packed; typedef struct usb_devcap_ss_descriptor usb_devcap_ss_descriptor_t; -- 2.45.0