113540260SHans Petter Selasky 213540260SHans Petter Selasky /*- 34d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 4718cf2ccSPedro F. Giffuni * 533cbbf26SHans Petter Selasky * Copyright (c) 2010-2022 Hans Petter Selasky 613540260SHans Petter Selasky * 713540260SHans Petter Selasky * Redistribution and use in source and binary forms, with or without 813540260SHans Petter Selasky * modification, are permitted provided that the following conditions 913540260SHans Petter Selasky * are met: 1013540260SHans Petter Selasky * 1. Redistributions of source code must retain the above copyright 1113540260SHans Petter Selasky * notice, this list of conditions and the following disclaimer. 1213540260SHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright 1313540260SHans Petter Selasky * notice, this list of conditions and the following disclaimer in the 1413540260SHans Petter Selasky * documentation and/or other materials provided with the distribution. 1513540260SHans Petter Selasky * 1613540260SHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1713540260SHans Petter Selasky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1813540260SHans Petter Selasky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1913540260SHans Petter Selasky * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2013540260SHans Petter Selasky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2113540260SHans Petter Selasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2213540260SHans Petter Selasky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2313540260SHans Petter Selasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2413540260SHans Petter Selasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2513540260SHans Petter Selasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2613540260SHans Petter Selasky * SUCH DAMAGE. 2713540260SHans Petter Selasky */ 2813540260SHans Petter Selasky 2913540260SHans Petter Selasky #ifndef _XHCI_H_ 3013540260SHans Petter Selasky #define _XHCI_H_ 3113540260SHans Petter Selasky 3213540260SHans Petter Selasky #define XHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) 3313540260SHans Petter Selasky #define XHCI_MAX_ENDPOINTS 32 /* hardcoded - do not change */ 34c5390e5aSHans Petter Selasky #define XHCI_MAX_SCRATCHPADS 256 /* theoretical max is 1023 */ 35e036ee6cSHans Petter Selasky #define XHCI_MAX_EVENTS 232 3613540260SHans Petter Selasky #define XHCI_MAX_COMMANDS (16 * 1) 3713540260SHans Petter Selasky #define XHCI_MAX_RSEG 1 3813540260SHans Petter Selasky #define XHCI_MAX_TRANSFERS 4 39a5cf1aaaSHans Petter Selasky #if USB_MAX_EP_STREAMS == 8 40a5cf1aaaSHans Petter Selasky #define XHCI_MAX_STREAMS 8 41a5cf1aaaSHans Petter Selasky #define XHCI_MAX_STREAMS_LOG 3 42a5cf1aaaSHans Petter Selasky #elif USB_MAX_EP_STREAMS == 1 43a5cf1aaaSHans Petter Selasky #define XHCI_MAX_STREAMS 1 44a5cf1aaaSHans Petter Selasky #define XHCI_MAX_STREAMS_LOG 0 45a5cf1aaaSHans Petter Selasky #else 46a5cf1aaaSHans Petter Selasky #error "The USB_MAX_EP_STREAMS value is not supported." 47a5cf1aaaSHans Petter Selasky #endif 4813540260SHans Petter Selasky #define XHCI_DEV_CTX_ADDR_ALIGN 64 /* bytes */ 4913540260SHans Petter Selasky #define XHCI_DEV_CTX_ALIGN 64 /* bytes */ 5013540260SHans Petter Selasky #define XHCI_INPUT_CTX_ALIGN 64 /* bytes */ 5113540260SHans Petter Selasky #define XHCI_SLOT_CTX_ALIGN 32 /* bytes */ 5213540260SHans Petter Selasky #define XHCI_ENDP_CTX_ALIGN 32 /* bytes */ 5313540260SHans Petter Selasky #define XHCI_STREAM_CTX_ALIGN 16 /* bytes */ 5413540260SHans Petter Selasky #define XHCI_TRANS_RING_SEG_ALIGN 16 /* bytes */ 5513540260SHans Petter Selasky #define XHCI_CMD_RING_SEG_ALIGN 64 /* bytes */ 5613540260SHans Petter Selasky #define XHCI_EVENT_RING_SEG_ALIGN 64 /* bytes */ 5713540260SHans Petter Selasky #define XHCI_SCRATCH_BUF_ARRAY_ALIGN 64 /* bytes */ 5813540260SHans Petter Selasky #define XHCI_SCRATCH_BUFFER_ALIGN USB_PAGE_SIZE 5913540260SHans Petter Selasky #define XHCI_TRB_ALIGN 16 /* bytes */ 6013540260SHans Petter Selasky #define XHCI_TD_ALIGN 64 /* bytes */ 6113540260SHans Petter Selasky #define XHCI_PAGE_SIZE 4096 /* bytes */ 6213540260SHans Petter Selasky 6313540260SHans Petter Selasky struct xhci_dev_ctx_addr { 6413540260SHans Petter Selasky volatile uint64_t qwBaaDevCtxAddr[USB_MAX_DEVICES + 1]; 6513540260SHans Petter Selasky struct { 6613540260SHans Petter Selasky volatile uint64_t dummy; 6713540260SHans Petter Selasky } __aligned(64) padding; 6813540260SHans Petter Selasky volatile uint64_t qwSpBufPtr[XHCI_MAX_SCRATCHPADS]; 6913540260SHans Petter Selasky }; 7013540260SHans Petter Selasky 7113540260SHans Petter Selasky #define XHCI_EPNO2EPID(x) \ 7213540260SHans Petter Selasky ((((x) & UE_DIR_IN) ? 1 : 0) | (2 * ((x) & UE_ADDR))) 7313540260SHans Petter Selasky 7413540260SHans Petter Selasky struct xhci_slot_ctx { 7513540260SHans Petter Selasky volatile uint32_t dwSctx0; 7613540260SHans Petter Selasky #define XHCI_SCTX_0_ROUTE_SET(x) ((x) & 0xFFFFF) 7713540260SHans Petter Selasky #define XHCI_SCTX_0_ROUTE_GET(x) ((x) & 0xFFFFF) 7813540260SHans Petter Selasky #define XHCI_SCTX_0_SPEED_SET(x) (((x) & 0xF) << 20) 7913540260SHans Petter Selasky #define XHCI_SCTX_0_SPEED_GET(x) (((x) >> 20) & 0xF) 8013540260SHans Petter Selasky #define XHCI_SCTX_0_MTT_SET(x) (((x) & 0x1) << 25) 8113540260SHans Petter Selasky #define XHCI_SCTX_0_MTT_GET(x) (((x) >> 25) & 0x1) 8213540260SHans Petter Selasky #define XHCI_SCTX_0_HUB_SET(x) (((x) & 0x1) << 26) 8313540260SHans Petter Selasky #define XHCI_SCTX_0_HUB_GET(x) (((x) >> 26) & 0x1) 8413540260SHans Petter Selasky #define XHCI_SCTX_0_CTX_NUM_SET(x) (((x) & 0x1F) << 27) 8513540260SHans Petter Selasky #define XHCI_SCTX_0_CTX_NUM_GET(x) (((x) >> 27) & 0x1F) 8613540260SHans Petter Selasky volatile uint32_t dwSctx1; 8713540260SHans Petter Selasky #define XHCI_SCTX_1_MAX_EL_SET(x) ((x) & 0xFFFF) 8813540260SHans Petter Selasky #define XHCI_SCTX_1_MAX_EL_GET(x) ((x) & 0xFFFF) 8913540260SHans Petter Selasky #define XHCI_SCTX_1_RH_PORT_SET(x) (((x) & 0xFF) << 16) 9013540260SHans Petter Selasky #define XHCI_SCTX_1_RH_PORT_GET(x) (((x) >> 16) & 0xFF) 9113540260SHans Petter Selasky #define XHCI_SCTX_1_NUM_PORTS_SET(x) (((x) & 0xFF) << 24) 9213540260SHans Petter Selasky #define XHCI_SCTX_1_NUM_PORTS_GET(x) (((x) >> 24) & 0xFF) 9313540260SHans Petter Selasky volatile uint32_t dwSctx2; 9413540260SHans Petter Selasky #define XHCI_SCTX_2_TT_HUB_SID_SET(x) ((x) & 0xFF) 9513540260SHans Petter Selasky #define XHCI_SCTX_2_TT_HUB_SID_GET(x) ((x) & 0xFF) 9613540260SHans Petter Selasky #define XHCI_SCTX_2_TT_PORT_NUM_SET(x) (((x) & 0xFF) << 8) 9713540260SHans Petter Selasky #define XHCI_SCTX_2_TT_PORT_NUM_GET(x) (((x) >> 8) & 0xFF) 9813540260SHans Petter Selasky #define XHCI_SCTX_2_TT_THINK_TIME_SET(x) (((x) & 0x3) << 16) 9913540260SHans Petter Selasky #define XHCI_SCTX_2_TT_THINK_TIME_GET(x) (((x) >> 16) & 0x3) 10013540260SHans Petter Selasky #define XHCI_SCTX_2_IRQ_TARGET_SET(x) (((x) & 0x3FF) << 22) 10113540260SHans Petter Selasky #define XHCI_SCTX_2_IRQ_TARGET_GET(x) (((x) >> 22) & 0x3FF) 10213540260SHans Petter Selasky volatile uint32_t dwSctx3; 10313540260SHans Petter Selasky #define XHCI_SCTX_3_DEV_ADDR_SET(x) ((x) & 0xFF) 10413540260SHans Petter Selasky #define XHCI_SCTX_3_DEV_ADDR_GET(x) ((x) & 0xFF) 10513540260SHans Petter Selasky #define XHCI_SCTX_3_SLOT_STATE_SET(x) (((x) & 0x1F) << 27) 10613540260SHans Petter Selasky #define XHCI_SCTX_3_SLOT_STATE_GET(x) (((x) >> 27) & 0x1F) 10713540260SHans Petter Selasky volatile uint32_t dwSctx4; 10813540260SHans Petter Selasky volatile uint32_t dwSctx5; 10913540260SHans Petter Selasky volatile uint32_t dwSctx6; 11013540260SHans Petter Selasky volatile uint32_t dwSctx7; 11113540260SHans Petter Selasky }; 11213540260SHans Petter Selasky 11329863d1eSJessica Clarke struct xhci_slot_ctx64 { 11429863d1eSJessica Clarke struct xhci_slot_ctx ctx; 11529863d1eSJessica Clarke volatile uint8_t padding[32]; 11629863d1eSJessica Clarke }; 11729863d1eSJessica Clarke 11813540260SHans Petter Selasky struct xhci_endp_ctx { 11913540260SHans Petter Selasky volatile uint32_t dwEpCtx0; 12013540260SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_SET(x) ((x) & 0x7) 12113540260SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_GET(x) ((x) & 0x7) 122b8ffd2d5SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_DISABLED 0 123b8ffd2d5SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_RUNNING 1 124b8ffd2d5SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_HALTED 2 125b8ffd2d5SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_STOPPED 3 126b8ffd2d5SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_ERROR 4 127b8ffd2d5SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_RESERVED_5 5 128b8ffd2d5SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_RESERVED_6 6 129b8ffd2d5SHans Petter Selasky #define XHCI_EPCTX_0_EPSTATE_RESERVED_7 7 13013540260SHans Petter Selasky #define XHCI_EPCTX_0_MULT_SET(x) (((x) & 0x3) << 8) 13113540260SHans Petter Selasky #define XHCI_EPCTX_0_MULT_GET(x) (((x) >> 8) & 0x3) 13213540260SHans Petter Selasky #define XHCI_EPCTX_0_MAXP_STREAMS_SET(x) (((x) & 0x1F) << 10) 13313540260SHans Petter Selasky #define XHCI_EPCTX_0_MAXP_STREAMS_GET(x) (((x) >> 10) & 0x1F) 13413540260SHans Petter Selasky #define XHCI_EPCTX_0_LSA_SET(x) (((x) & 0x1) << 15) 13513540260SHans Petter Selasky #define XHCI_EPCTX_0_LSA_GET(x) (((x) >> 15) & 0x1) 13613540260SHans Petter Selasky #define XHCI_EPCTX_0_IVAL_SET(x) (((x) & 0xFF) << 16) 13713540260SHans Petter Selasky #define XHCI_EPCTX_0_IVAL_GET(x) (((x) >> 16) & 0xFF) 13813540260SHans Petter Selasky volatile uint32_t dwEpCtx1; 13913540260SHans Petter Selasky #define XHCI_EPCTX_1_CERR_SET(x) (((x) & 0x3) << 1) 14013540260SHans Petter Selasky #define XHCI_EPCTX_1_CERR_GET(x) (((x) >> 1) & 0x3) 14113540260SHans Petter Selasky #define XHCI_EPCTX_1_EPTYPE_SET(x) (((x) & 0x7) << 3) 14213540260SHans Petter Selasky #define XHCI_EPCTX_1_EPTYPE_GET(x) (((x) >> 3) & 0x7) 14313540260SHans Petter Selasky #define XHCI_EPCTX_1_HID_SET(x) (((x) & 0x1) << 7) 14413540260SHans Petter Selasky #define XHCI_EPCTX_1_HID_GET(x) (((x) >> 7) & 0x1) 14513540260SHans Petter Selasky #define XHCI_EPCTX_1_MAXB_SET(x) (((x) & 0xFF) << 8) 14613540260SHans Petter Selasky #define XHCI_EPCTX_1_MAXB_GET(x) (((x) >> 8) & 0xFF) 14713540260SHans Petter Selasky #define XHCI_EPCTX_1_MAXP_SIZE_SET(x) (((x) & 0xFFFF) << 16) 14813540260SHans Petter Selasky #define XHCI_EPCTX_1_MAXP_SIZE_GET(x) (((x) >> 16) & 0xFFFF) 14913540260SHans Petter Selasky volatile uint64_t qwEpCtx2; 15013540260SHans Petter Selasky #define XHCI_EPCTX_2_DCS_SET(x) ((x) & 0x1) 15113540260SHans Petter Selasky #define XHCI_EPCTX_2_DCS_GET(x) ((x) & 0x1) 15213540260SHans Petter Selasky #define XHCI_EPCTX_2_TR_DQ_PTR_MASK 0xFFFFFFFFFFFFFFF0U 15313540260SHans Petter Selasky volatile uint32_t dwEpCtx4; 15413540260SHans Petter Selasky #define XHCI_EPCTX_4_AVG_TRB_LEN_SET(x) ((x) & 0xFFFF) 15513540260SHans Petter Selasky #define XHCI_EPCTX_4_AVG_TRB_LEN_GET(x) ((x) & 0xFFFF) 15613540260SHans Petter Selasky #define XHCI_EPCTX_4_MAX_ESIT_PAYLOAD_SET(x) (((x) & 0xFFFF) << 16) 15713540260SHans Petter Selasky #define XHCI_EPCTX_4_MAX_ESIT_PAYLOAD_GET(x) (((x) >> 16) & 0xFFFF) 15813540260SHans Petter Selasky volatile uint32_t dwEpCtx5; 15913540260SHans Petter Selasky volatile uint32_t dwEpCtx6; 16013540260SHans Petter Selasky volatile uint32_t dwEpCtx7; 16113540260SHans Petter Selasky }; 16213540260SHans Petter Selasky 16329863d1eSJessica Clarke struct xhci_endp_ctx64 { 16429863d1eSJessica Clarke struct xhci_endp_ctx ctx; 16529863d1eSJessica Clarke volatile uint8_t padding[32]; 16629863d1eSJessica Clarke }; 16729863d1eSJessica Clarke 16813540260SHans Petter Selasky struct xhci_input_ctx { 16913540260SHans Petter Selasky #define XHCI_INCTX_NON_CTRL_MASK 0xFFFFFFFCU 17013540260SHans Petter Selasky volatile uint32_t dwInCtx0; 17113540260SHans Petter Selasky #define XHCI_INCTX_0_DROP_MASK(n) (1U << (n)) 17213540260SHans Petter Selasky volatile uint32_t dwInCtx1; 17313540260SHans Petter Selasky #define XHCI_INCTX_1_ADD_MASK(n) (1U << (n)) 17413540260SHans Petter Selasky volatile uint32_t dwInCtx2; 17513540260SHans Petter Selasky volatile uint32_t dwInCtx3; 17613540260SHans Petter Selasky volatile uint32_t dwInCtx4; 17713540260SHans Petter Selasky volatile uint32_t dwInCtx5; 17813540260SHans Petter Selasky volatile uint32_t dwInCtx6; 17913540260SHans Petter Selasky volatile uint32_t dwInCtx7; 18013540260SHans Petter Selasky }; 18113540260SHans Petter Selasky 18229863d1eSJessica Clarke struct xhci_input_ctx64 { 18329863d1eSJessica Clarke struct xhci_input_ctx ctx; 18429863d1eSJessica Clarke volatile uint8_t padding[32]; 18529863d1eSJessica Clarke }; 18629863d1eSJessica Clarke 18713540260SHans Petter Selasky struct xhci_input_dev_ctx { 18813540260SHans Petter Selasky struct xhci_input_ctx ctx_input; 18913540260SHans Petter Selasky struct xhci_slot_ctx ctx_slot; 19013540260SHans Petter Selasky struct xhci_endp_ctx ctx_ep[XHCI_MAX_ENDPOINTS - 1]; 19113540260SHans Petter Selasky }; 19213540260SHans Petter Selasky 19329863d1eSJessica Clarke struct xhci_input_dev_ctx64 { 19429863d1eSJessica Clarke struct xhci_input_ctx64 ctx_input; 19529863d1eSJessica Clarke struct xhci_slot_ctx64 ctx_slot; 19629863d1eSJessica Clarke struct xhci_endp_ctx64 ctx_ep[XHCI_MAX_ENDPOINTS - 1]; 19729863d1eSJessica Clarke }; 19829863d1eSJessica Clarke 19913540260SHans Petter Selasky struct xhci_dev_ctx { 20013540260SHans Petter Selasky struct xhci_slot_ctx ctx_slot; 20113540260SHans Petter Selasky struct xhci_endp_ctx ctx_ep[XHCI_MAX_ENDPOINTS - 1]; 20213540260SHans Petter Selasky } __aligned(XHCI_DEV_CTX_ALIGN); 20313540260SHans Petter Selasky 20429863d1eSJessica Clarke struct xhci_dev_ctx64 { 20529863d1eSJessica Clarke struct xhci_slot_ctx64 ctx_slot; 20629863d1eSJessica Clarke struct xhci_endp_ctx64 ctx_ep[XHCI_MAX_ENDPOINTS - 1]; 20729863d1eSJessica Clarke } __aligned(XHCI_DEV_CTX_ALIGN); 20829863d1eSJessica Clarke 20913540260SHans Petter Selasky struct xhci_stream_ctx { 21013540260SHans Petter Selasky volatile uint64_t qwSctx0; 21113540260SHans Petter Selasky #define XHCI_SCTX_0_DCS_GET(x) ((x) & 0x1) 21213540260SHans Petter Selasky #define XHCI_SCTX_0_DCS_SET(x) ((x) & 0x1) 21313540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_SET(x) (((x) & 0x7) << 1) 21413540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_GET(x) (((x) >> 1) & 0x7) 21513540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_SEC_TR_RING 0x0 21613540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_PRIM_TR_RING 0x1 21713540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_PRIM_SSA_8 0x2 21813540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_PRIM_SSA_16 0x3 21913540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_PRIM_SSA_32 0x4 22013540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_PRIM_SSA_64 0x5 22113540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_PRIM_SSA_128 0x6 22213540260SHans Petter Selasky #define XHCI_SCTX_0_SCT_PRIM_SSA_256 0x7 22313540260SHans Petter Selasky #define XHCI_SCTX_0_TR_DQ_PTR_MASK 0xFFFFFFFFFFFFFFF0U 22413540260SHans Petter Selasky volatile uint32_t dwSctx2; 22513540260SHans Petter Selasky volatile uint32_t dwSctx3; 22613540260SHans Petter Selasky }; 22713540260SHans Petter Selasky 22813540260SHans Petter Selasky struct xhci_trb { 22913540260SHans Petter Selasky volatile uint64_t qwTrb0; 230c4a1e93fSHans Petter Selasky #define XHCI_TRB_0_DIR_IN_MASK (0x80ULL << 0) 23113540260SHans Petter Selasky #define XHCI_TRB_0_WLENGTH_MASK (0xFFFFULL << 48) 23213540260SHans Petter Selasky volatile uint32_t dwTrb2; 23313540260SHans Petter Selasky #define XHCI_TRB_2_ERROR_GET(x) (((x) >> 24) & 0xFF) 23413540260SHans Petter Selasky #define XHCI_TRB_2_ERROR_SET(x) (((x) & 0xFF) << 24) 23513540260SHans Petter Selasky #define XHCI_TRB_2_TDSZ_GET(x) (((x) >> 17) & 0x1F) 23613540260SHans Petter Selasky #define XHCI_TRB_2_TDSZ_SET(x) (((x) & 0x1F) << 17) 23713540260SHans Petter Selasky #define XHCI_TRB_2_REM_GET(x) ((x) & 0xFFFFFF) 23813540260SHans Petter Selasky #define XHCI_TRB_2_REM_SET(x) ((x) & 0xFFFFFF) 23913540260SHans Petter Selasky #define XHCI_TRB_2_BYTES_GET(x) ((x) & 0x1FFFF) 24013540260SHans Petter Selasky #define XHCI_TRB_2_BYTES_SET(x) ((x) & 0x1FFFF) 24113540260SHans Petter Selasky #define XHCI_TRB_2_IRQ_GET(x) (((x) >> 22) & 0x3FF) 24213540260SHans Petter Selasky #define XHCI_TRB_2_IRQ_SET(x) (((x) & 0x3FF) << 22) 24313540260SHans Petter Selasky #define XHCI_TRB_2_STREAM_GET(x) (((x) >> 16) & 0xFFFF) 24413540260SHans Petter Selasky #define XHCI_TRB_2_STREAM_SET(x) (((x) & 0xFFFF) << 16) 24513540260SHans Petter Selasky 24613540260SHans Petter Selasky volatile uint32_t dwTrb3; 24713540260SHans Petter Selasky #define XHCI_TRB_3_TYPE_GET(x) (((x) >> 10) & 0x3F) 24813540260SHans Petter Selasky #define XHCI_TRB_3_TYPE_SET(x) (((x) & 0x3F) << 10) 24913540260SHans Petter Selasky #define XHCI_TRB_3_CYCLE_BIT (1U << 0) 25013540260SHans Petter Selasky #define XHCI_TRB_3_TC_BIT (1U << 1) /* command ring only */ 25113540260SHans Petter Selasky #define XHCI_TRB_3_ENT_BIT (1U << 1) /* transfer ring only */ 25213540260SHans Petter Selasky #define XHCI_TRB_3_ISP_BIT (1U << 2) 25313540260SHans Petter Selasky #define XHCI_TRB_3_NSNOOP_BIT (1U << 3) 25413540260SHans Petter Selasky #define XHCI_TRB_3_CHAIN_BIT (1U << 4) 25513540260SHans Petter Selasky #define XHCI_TRB_3_IOC_BIT (1U << 5) 25613540260SHans Petter Selasky #define XHCI_TRB_3_IDT_BIT (1U << 6) 25713540260SHans Petter Selasky #define XHCI_TRB_3_TBC_GET(x) (((x) >> 7) & 3) 25813540260SHans Petter Selasky #define XHCI_TRB_3_TBC_SET(x) (((x) & 3) << 7) 25913540260SHans Petter Selasky #define XHCI_TRB_3_BEI_BIT (1U << 9) 26013540260SHans Petter Selasky #define XHCI_TRB_3_DCEP_BIT (1U << 9) 26113540260SHans Petter Selasky #define XHCI_TRB_3_PRSV_BIT (1U << 9) 26213540260SHans Petter Selasky #define XHCI_TRB_3_BSR_BIT (1U << 9) 26313540260SHans Petter Selasky #define XHCI_TRB_3_TRT_MASK (3U << 16) 26413540260SHans Petter Selasky #define XHCI_TRB_3_TRT_NONE (0U << 16) 26513540260SHans Petter Selasky #define XHCI_TRB_3_TRT_OUT (2U << 16) 26613540260SHans Petter Selasky #define XHCI_TRB_3_TRT_IN (3U << 16) 26713540260SHans Petter Selasky #define XHCI_TRB_3_DIR_IN (1U << 16) 26813540260SHans Petter Selasky #define XHCI_TRB_3_TLBPC_GET(x) (((x) >> 16) & 0xF) 26913540260SHans Petter Selasky #define XHCI_TRB_3_TLBPC_SET(x) (((x) & 0xF) << 16) 27013540260SHans Petter Selasky #define XHCI_TRB_3_EP_GET(x) (((x) >> 16) & 0x1F) 27113540260SHans Petter Selasky #define XHCI_TRB_3_EP_SET(x) (((x) & 0x1F) << 16) 27213540260SHans Petter Selasky #define XHCI_TRB_3_FRID_GET(x) (((x) >> 20) & 0x7FF) 27313540260SHans Petter Selasky #define XHCI_TRB_3_FRID_SET(x) (((x) & 0x7FF) << 20) 27413540260SHans Petter Selasky #define XHCI_TRB_3_ISO_SIA_BIT (1U << 31) 27513540260SHans Petter Selasky #define XHCI_TRB_3_SUSP_EP_BIT (1U << 23) 27613540260SHans Petter Selasky #define XHCI_TRB_3_SLOT_GET(x) (((x) >> 24) & 0xFF) 27713540260SHans Petter Selasky #define XHCI_TRB_3_SLOT_SET(x) (((x) & 0xFF) << 24) 27813540260SHans Petter Selasky 27913540260SHans Petter Selasky /* Commands */ 28013540260SHans Petter Selasky #define XHCI_TRB_TYPE_RESERVED 0x00 28113540260SHans Petter Selasky #define XHCI_TRB_TYPE_NORMAL 0x01 28213540260SHans Petter Selasky #define XHCI_TRB_TYPE_SETUP_STAGE 0x02 28313540260SHans Petter Selasky #define XHCI_TRB_TYPE_DATA_STAGE 0x03 28413540260SHans Petter Selasky #define XHCI_TRB_TYPE_STATUS_STAGE 0x04 28513540260SHans Petter Selasky #define XHCI_TRB_TYPE_ISOCH 0x05 28613540260SHans Petter Selasky #define XHCI_TRB_TYPE_LINK 0x06 28713540260SHans Petter Selasky #define XHCI_TRB_TYPE_EVENT_DATA 0x07 28813540260SHans Petter Selasky #define XHCI_TRB_TYPE_NOOP 0x08 28913540260SHans Petter Selasky #define XHCI_TRB_TYPE_ENABLE_SLOT 0x09 29013540260SHans Petter Selasky #define XHCI_TRB_TYPE_DISABLE_SLOT 0x0A 29113540260SHans Petter Selasky #define XHCI_TRB_TYPE_ADDRESS_DEVICE 0x0B 29213540260SHans Petter Selasky #define XHCI_TRB_TYPE_CONFIGURE_EP 0x0C 29313540260SHans Petter Selasky #define XHCI_TRB_TYPE_EVALUATE_CTX 0x0D 29413540260SHans Petter Selasky #define XHCI_TRB_TYPE_RESET_EP 0x0E 29513540260SHans Petter Selasky #define XHCI_TRB_TYPE_STOP_EP 0x0F 29613540260SHans Petter Selasky #define XHCI_TRB_TYPE_SET_TR_DEQUEUE 0x10 29713540260SHans Petter Selasky #define XHCI_TRB_TYPE_RESET_DEVICE 0x11 29813540260SHans Petter Selasky #define XHCI_TRB_TYPE_FORCE_EVENT 0x12 29913540260SHans Petter Selasky #define XHCI_TRB_TYPE_NEGOTIATE_BW 0x13 30013540260SHans Petter Selasky #define XHCI_TRB_TYPE_SET_LATENCY_TOL 0x14 30113540260SHans Petter Selasky #define XHCI_TRB_TYPE_GET_PORT_BW 0x15 30213540260SHans Petter Selasky #define XHCI_TRB_TYPE_FORCE_HEADER 0x16 30313540260SHans Petter Selasky #define XHCI_TRB_TYPE_NOOP_CMD 0x17 30413540260SHans Petter Selasky 30513540260SHans Petter Selasky /* Events */ 30613540260SHans Petter Selasky #define XHCI_TRB_EVENT_TRANSFER 0x20 30713540260SHans Petter Selasky #define XHCI_TRB_EVENT_CMD_COMPLETE 0x21 30813540260SHans Petter Selasky #define XHCI_TRB_EVENT_PORT_STS_CHANGE 0x22 30913540260SHans Petter Selasky #define XHCI_TRB_EVENT_BW_REQUEST 0x23 31013540260SHans Petter Selasky #define XHCI_TRB_EVENT_DOORBELL 0x24 31113540260SHans Petter Selasky #define XHCI_TRB_EVENT_HOST_CTRL 0x25 31213540260SHans Petter Selasky #define XHCI_TRB_EVENT_DEVICE_NOTIFY 0x26 31313540260SHans Petter Selasky #define XHCI_TRB_EVENT_MFINDEX_WRAP 0x27 31413540260SHans Petter Selasky 31513540260SHans Petter Selasky /* Error codes */ 31613540260SHans Petter Selasky #define XHCI_TRB_ERROR_INVALID 0x00 31713540260SHans Petter Selasky #define XHCI_TRB_ERROR_SUCCESS 0x01 31813540260SHans Petter Selasky #define XHCI_TRB_ERROR_DATA_BUF 0x02 31913540260SHans Petter Selasky #define XHCI_TRB_ERROR_BABBLE 0x03 32013540260SHans Petter Selasky #define XHCI_TRB_ERROR_XACT 0x04 32113540260SHans Petter Selasky #define XHCI_TRB_ERROR_TRB 0x05 32213540260SHans Petter Selasky #define XHCI_TRB_ERROR_STALL 0x06 32313540260SHans Petter Selasky #define XHCI_TRB_ERROR_RESOURCE 0x07 32413540260SHans Petter Selasky #define XHCI_TRB_ERROR_BANDWIDTH 0x08 32513540260SHans Petter Selasky #define XHCI_TRB_ERROR_NO_SLOTS 0x09 32613540260SHans Petter Selasky #define XHCI_TRB_ERROR_STREAM_TYPE 0x0A 32713540260SHans Petter Selasky #define XHCI_TRB_ERROR_SLOT_NOT_ON 0x0B 32813540260SHans Petter Selasky #define XHCI_TRB_ERROR_ENDP_NOT_ON 0x0C 32913540260SHans Petter Selasky #define XHCI_TRB_ERROR_SHORT_PKT 0x0D 33013540260SHans Petter Selasky #define XHCI_TRB_ERROR_RING_UNDERRUN 0x0E 33113540260SHans Petter Selasky #define XHCI_TRB_ERROR_RING_OVERRUN 0x0F 33213540260SHans Petter Selasky #define XHCI_TRB_ERROR_VF_RING_FULL 0x10 33313540260SHans Petter Selasky #define XHCI_TRB_ERROR_PARAMETER 0x11 33413540260SHans Petter Selasky #define XHCI_TRB_ERROR_BW_OVERRUN 0x12 33513540260SHans Petter Selasky #define XHCI_TRB_ERROR_CONTEXT_STATE 0x13 33613540260SHans Petter Selasky #define XHCI_TRB_ERROR_NO_PING_RESP 0x14 33713540260SHans Petter Selasky #define XHCI_TRB_ERROR_EV_RING_FULL 0x15 33813540260SHans Petter Selasky #define XHCI_TRB_ERROR_INCOMPAT_DEV 0x16 33913540260SHans Petter Selasky #define XHCI_TRB_ERROR_MISSED_SERVICE 0x17 34013540260SHans Petter Selasky #define XHCI_TRB_ERROR_CMD_RING_STOP 0x18 34113540260SHans Petter Selasky #define XHCI_TRB_ERROR_CMD_ABORTED 0x19 34213540260SHans Petter Selasky #define XHCI_TRB_ERROR_STOPPED 0x1A 34313540260SHans Petter Selasky #define XHCI_TRB_ERROR_LENGTH 0x1B 34413540260SHans Petter Selasky #define XHCI_TRB_ERROR_BAD_MELAT 0x1D 34513540260SHans Petter Selasky #define XHCI_TRB_ERROR_ISOC_OVERRUN 0x1F 34613540260SHans Petter Selasky #define XHCI_TRB_ERROR_EVENT_LOST 0x20 34713540260SHans Petter Selasky #define XHCI_TRB_ERROR_UNDEFINED 0x21 34813540260SHans Petter Selasky #define XHCI_TRB_ERROR_INVALID_SID 0x22 34913540260SHans Petter Selasky #define XHCI_TRB_ERROR_SEC_BW 0x23 35013540260SHans Petter Selasky #define XHCI_TRB_ERROR_SPLIT_XACT 0x24 35113540260SHans Petter Selasky } __aligned(4); 35213540260SHans Petter Selasky 35313540260SHans Petter Selasky struct xhci_dev_endpoint_trbs { 35407222474SHans Petter Selasky struct xhci_trb trb[(XHCI_MAX_STREAMS * 35507222474SHans Petter Selasky XHCI_MAX_TRANSFERS) + XHCI_MAX_STREAMS]; 35613540260SHans Petter Selasky }; 35713540260SHans Petter Selasky 358454035baSHans Petter Selasky #if (USB_PAGE_SIZE < 4096) 359f8808726SHans Petter Selasky #error "The XHCI driver needs a pagesize above or equal to 4K" 360454035baSHans Petter Selasky #endif 361454035baSHans Petter Selasky 362454035baSHans Petter Selasky /* Define the maximum payload which we will handle in a single TRB */ 363454035baSHans Petter Selasky #define XHCI_TD_PAYLOAD_MAX 65536 /* bytes */ 364454035baSHans Petter Selasky 365454035baSHans Petter Selasky /* Define the maximum payload of a single scatter-gather list element */ 366454035baSHans Petter Selasky #define XHCI_TD_PAGE_SIZE \ 367454035baSHans Petter Selasky ((USB_PAGE_SIZE < XHCI_TD_PAYLOAD_MAX) ? USB_PAGE_SIZE : XHCI_TD_PAYLOAD_MAX) 368454035baSHans Petter Selasky 369454035baSHans Petter Selasky /* Define the maximum length of the scatter-gather list */ 370454035baSHans Petter Selasky #define XHCI_TD_PAGE_NBUF \ 371454035baSHans Petter Selasky (((XHCI_TD_PAYLOAD_MAX + XHCI_TD_PAGE_SIZE - 1) / XHCI_TD_PAGE_SIZE) + 1) 37213540260SHans Petter Selasky 37313540260SHans Petter Selasky struct xhci_td { 374454035baSHans Petter Selasky /* one LINK TRB has been added to the TRB array */ 37513540260SHans Petter Selasky struct xhci_trb td_trb[XHCI_TD_PAGE_NBUF + 1]; 37613540260SHans Petter Selasky 37713540260SHans Petter Selasky /* 37813540260SHans Petter Selasky * Extra information needed: 37913540260SHans Petter Selasky */ 38013540260SHans Petter Selasky uint64_t td_self; 38113540260SHans Petter Selasky struct xhci_td *next; 38213540260SHans Petter Selasky struct xhci_td *alt_next; 38313540260SHans Petter Selasky struct xhci_td *obj_next; 38413540260SHans Petter Selasky struct usb_page_cache *page_cache; 38513540260SHans Petter Selasky uint32_t len; 38613540260SHans Petter Selasky uint32_t remainder; 38713540260SHans Petter Selasky uint8_t ntrb; 38813540260SHans Petter Selasky uint8_t status; 38913540260SHans Petter Selasky } __aligned(XHCI_TRB_ALIGN); 39013540260SHans Petter Selasky 39113540260SHans Petter Selasky struct xhci_command { 39213540260SHans Petter Selasky struct xhci_trb trb; 39313540260SHans Petter Selasky TAILQ_ENTRY(xhci_command) entry; 39413540260SHans Petter Selasky }; 39513540260SHans Petter Selasky 39613540260SHans Petter Selasky struct xhci_event_ring_seg { 39713540260SHans Petter Selasky volatile uint64_t qwEvrsTablePtr; 39813540260SHans Petter Selasky volatile uint32_t dwEvrsTableSize; 39913540260SHans Petter Selasky volatile uint32_t dwEvrsReserved; 40013540260SHans Petter Selasky }; 40113540260SHans Petter Selasky 40213540260SHans Petter Selasky struct xhci_hw_root { 40313540260SHans Petter Selasky struct xhci_event_ring_seg hwr_ring_seg[XHCI_MAX_RSEG]; 40413540260SHans Petter Selasky struct { 40513540260SHans Petter Selasky volatile uint64_t dummy; 40613540260SHans Petter Selasky } __aligned(64) padding; 40713540260SHans Petter Selasky struct xhci_trb hwr_events[XHCI_MAX_EVENTS]; 40813540260SHans Petter Selasky struct xhci_trb hwr_commands[XHCI_MAX_COMMANDS]; 40913540260SHans Petter Selasky }; 41013540260SHans Petter Selasky 411e036ee6cSHans Petter Selasky CTASSERT(sizeof(struct xhci_hw_root) == XHCI_PAGE_SIZE); 412e036ee6cSHans Petter Selasky 41313540260SHans Petter Selasky struct xhci_endpoint_ext { 41413540260SHans Petter Selasky struct xhci_trb *trb; 415a5cf1aaaSHans Petter Selasky struct usb_xfer *xfer[XHCI_MAX_TRANSFERS * XHCI_MAX_STREAMS]; 41613540260SHans Petter Selasky struct usb_page_cache *page_cache; 41713540260SHans Petter Selasky uint64_t physaddr; 418a5cf1aaaSHans Petter Selasky uint8_t trb_used[XHCI_MAX_STREAMS]; 419a5cf1aaaSHans Petter Selasky uint8_t trb_index[XHCI_MAX_STREAMS]; 42013540260SHans Petter Selasky uint8_t trb_halted; 42113540260SHans Petter Selasky uint8_t trb_running; 422cfa00b0dSHans Petter Selasky uint8_t trb_ep_mode; 42359ca674eSHans Petter Selasky uint8_t trb_ep_maxp; 42413540260SHans Petter Selasky }; 42513540260SHans Petter Selasky 42613540260SHans Petter Selasky enum { 42713540260SHans Petter Selasky XHCI_ST_DISABLED, 42813540260SHans Petter Selasky XHCI_ST_ENABLED, 42913540260SHans Petter Selasky XHCI_ST_DEFAULT, 43013540260SHans Petter Selasky XHCI_ST_ADDRESSED, 43113540260SHans Petter Selasky XHCI_ST_CONFIGURED, 43213540260SHans Petter Selasky XHCI_ST_MAX 43313540260SHans Petter Selasky }; 43413540260SHans Petter Selasky 43513540260SHans Petter Selasky struct xhci_hw_dev { 43613540260SHans Petter Selasky struct usb_page_cache device_pc; 43713540260SHans Petter Selasky struct usb_page_cache input_pc; 43807222474SHans Petter Selasky struct usb_page_cache endpoint_pc[XHCI_MAX_ENDPOINTS]; 43913540260SHans Petter Selasky 44013540260SHans Petter Selasky struct usb_page device_pg; 44113540260SHans Petter Selasky struct usb_page input_pg; 44207222474SHans Petter Selasky struct usb_page endpoint_pg[XHCI_MAX_ENDPOINTS]; 44313540260SHans Petter Selasky 44413540260SHans Petter Selasky struct xhci_endpoint_ext endp[XHCI_MAX_ENDPOINTS]; 44513540260SHans Petter Selasky 4467ba6c62fSHans Petter Selasky uint32_t ep_configured; 4477ba6c62fSHans Petter Selasky 44813540260SHans Petter Selasky uint8_t state; 44913540260SHans Petter Selasky uint8_t nports; 45013540260SHans Petter Selasky uint8_t tt; 4515e184962SHans Petter Selasky uint8_t context_num; 45213540260SHans Petter Selasky }; 45313540260SHans Petter Selasky 45413540260SHans Petter Selasky struct xhci_hw_softc { 45513540260SHans Petter Selasky struct usb_page_cache root_pc; 45613540260SHans Petter Selasky struct usb_page_cache ctx_pc; 45713540260SHans Petter Selasky struct usb_page_cache scratch_pc[XHCI_MAX_SCRATCHPADS]; 45813540260SHans Petter Selasky 45913540260SHans Petter Selasky struct usb_page root_pg; 46013540260SHans Petter Selasky struct usb_page ctx_pg; 46113540260SHans Petter Selasky struct usb_page scratch_pg[XHCI_MAX_SCRATCHPADS]; 46213540260SHans Petter Selasky 46313540260SHans Petter Selasky struct xhci_hw_dev devs[XHCI_MAX_DEVICES + 1]; 46413540260SHans Petter Selasky }; 46513540260SHans Petter Selasky 46613540260SHans Petter Selasky struct xhci_config_desc { 46713540260SHans Petter Selasky struct usb_config_descriptor confd; 46813540260SHans Petter Selasky struct usb_interface_descriptor ifcd; 46913540260SHans Petter Selasky struct usb_endpoint_descriptor endpd; 47013540260SHans Petter Selasky struct usb_endpoint_ss_comp_descriptor endpcd; 47113540260SHans Petter Selasky } __packed; 47213540260SHans Petter Selasky 47313540260SHans Petter Selasky struct xhci_bos_desc { 47413540260SHans Petter Selasky struct usb_bos_descriptor bosd; 47513540260SHans Petter Selasky struct usb_devcap_usb2ext_descriptor usb2extd; 47613540260SHans Petter Selasky struct usb_devcap_ss_descriptor usbdcd; 47713540260SHans Petter Selasky struct usb_devcap_container_id_descriptor cidd; 47813540260SHans Petter Selasky } __packed; 47913540260SHans Petter Selasky 48013540260SHans Petter Selasky union xhci_hub_desc { 48113540260SHans Petter Selasky struct usb_status stat; 48213540260SHans Petter Selasky struct usb_port_status ps; 48313540260SHans Petter Selasky struct usb_hub_ss_descriptor hubd; 48413540260SHans Petter Selasky uint8_t temp[128]; 48513540260SHans Petter Selasky }; 48613540260SHans Petter Selasky 4874c5d1323SHans Petter Selasky typedef int (xhci_port_route_t)(device_t, uint32_t, uint32_t); 4884c5d1323SHans Petter Selasky 489447c418dSBjoern A. Zeeb enum xhci_quirks { 490447c418dSBjoern A. Zeeb XHCI_QUIRK_DISABLE_PORT_PED = 0x00000001, 491*332af8c2SStephen J. Kiernan XHCI_QUIRK_DMA_32B = 0x00000002, 492447c418dSBjoern A. Zeeb }; 493447c418dSBjoern A. Zeeb 49413540260SHans Petter Selasky struct xhci_softc { 49513540260SHans Petter Selasky struct xhci_hw_softc sc_hw; 49613540260SHans Petter Selasky /* base device */ 49713540260SHans Petter Selasky struct usb_bus sc_bus; 4989b3a48eeSHans Petter Selasky /* configure message */ 49913540260SHans Petter Selasky struct usb_bus_msg sc_config_msg[2]; 50013540260SHans Petter Selasky 50197d729cfSHans Petter Selasky struct usb_callout sc_callout; 50297d729cfSHans Petter Selasky 5034c5d1323SHans Petter Selasky xhci_port_route_t *sc_port_route; 5044c5d1323SHans Petter Selasky 50513540260SHans Petter Selasky union xhci_hub_desc sc_hub_desc; 50613540260SHans Petter Selasky 50713540260SHans Petter Selasky struct cv sc_cmd_cv; 50813540260SHans Petter Selasky struct sx sc_cmd_sx; 50913540260SHans Petter Selasky 51013540260SHans Petter Selasky struct usb_device *sc_devices[XHCI_MAX_DEVICES]; 51113540260SHans Petter Selasky struct resource *sc_io_res; 51213540260SHans Petter Selasky struct resource *sc_irq_res; 5132245b38fSAndrew Turner struct resource *sc_msix_res; 51413540260SHans Petter Selasky 51513540260SHans Petter Selasky void *sc_intr_hdl; 51613540260SHans Petter Selasky bus_size_t sc_io_size; 51713540260SHans Petter Selasky bus_space_tag_t sc_io_tag; 51813540260SHans Petter Selasky bus_space_handle_t sc_io_hdl; 51913540260SHans Petter Selasky /* last pending command address */ 52013540260SHans Petter Selasky uint64_t sc_cmd_addr; 52113540260SHans Petter Selasky /* result of command */ 52213540260SHans Petter Selasky uint32_t sc_cmd_result[2]; 52313540260SHans Petter Selasky /* copy of cmd register */ 52413540260SHans Petter Selasky uint32_t sc_cmd; 52513540260SHans Petter Selasky /* worst case exit latency */ 52613540260SHans Petter Selasky uint32_t sc_exit_lat_max; 52713540260SHans Petter Selasky 52813540260SHans Petter Selasky /* offset to operational registers */ 52913540260SHans Petter Selasky uint32_t sc_oper_off; 53013540260SHans Petter Selasky /* offset to capability registers */ 53113540260SHans Petter Selasky uint32_t sc_capa_off; 53213540260SHans Petter Selasky /* offset to runtime registers */ 53313540260SHans Petter Selasky uint32_t sc_runt_off; 53413540260SHans Petter Selasky /* offset to doorbell registers */ 53513540260SHans Petter Selasky uint32_t sc_door_off; 53613540260SHans Petter Selasky 53713540260SHans Petter Selasky /* chip specific */ 53813540260SHans Petter Selasky uint16_t sc_erst_max; 53913540260SHans Petter Selasky uint16_t sc_event_idx; 54013540260SHans Petter Selasky uint16_t sc_command_idx; 5418237c62bSHans Petter Selasky uint16_t sc_imod_default; 54213540260SHans Petter Selasky 543bbd41717SHans Petter Selasky /* number of scratch pages */ 544bbd41717SHans Petter Selasky uint16_t sc_noscratch; 545bbd41717SHans Petter Selasky 54613540260SHans Petter Selasky uint8_t sc_event_ccs; 54713540260SHans Petter Selasky uint8_t sc_command_ccs; 54813540260SHans Petter Selasky /* number of XHCI device slots */ 54913540260SHans Petter Selasky uint8_t sc_noslot; 55013540260SHans Petter Selasky /* number of ports on root HUB */ 55113540260SHans Petter Selasky uint8_t sc_noport; 55213540260SHans Petter Selasky /* root HUB device configuration */ 55313540260SHans Petter Selasky uint8_t sc_conf; 554dd7ea6c2SHans Petter Selasky /* step status stage of all control transfers */ 555dd7ea6c2SHans Petter Selasky uint8_t sc_ctlstep; 55630c6f4baSHans Petter Selasky /* root HUB port event bitmap, max 256 ports */ 55730c6f4baSHans Petter Selasky uint8_t sc_hub_idata[32]; 55813540260SHans Petter Selasky 559c1338c65SHans Petter Selasky /* size of context */ 560c1338c65SHans Petter Selasky uint8_t sc_ctx_is_64_byte; 561c1338c65SHans Petter Selasky 56233cbbf26SHans Petter Selasky /* deconfiguring USB device is not fully supported */ 56333cbbf26SHans Petter Selasky uint8_t sc_no_deconfigure; 56433cbbf26SHans Petter Selasky 565d038463bSHans Petter Selasky /* Isochronous Scheduling Threshold */ 566d038463bSHans Petter Selasky uint8_t sc_ist; 567d038463bSHans Petter Selasky 56813540260SHans Petter Selasky /* vendor string for root HUB */ 56913540260SHans Petter Selasky char sc_vendor[16]; 570447c418dSBjoern A. Zeeb 571447c418dSBjoern A. Zeeb /* XHCI quirks. */ 572447c418dSBjoern A. Zeeb uint32_t sc_quirks; 57313540260SHans Petter Selasky }; 57413540260SHans Petter Selasky 57513540260SHans Petter Selasky #define XHCI_CMD_LOCK(sc) sx_xlock(&(sc)->sc_cmd_sx) 57613540260SHans Petter Selasky #define XHCI_CMD_UNLOCK(sc) sx_xunlock(&(sc)->sc_cmd_sx) 57713540260SHans Petter Selasky #define XHCI_CMD_ASSERT_LOCKED(sc) sx_assert(&(sc)->sc_cmd_sx, SA_LOCKED) 57813540260SHans Petter Selasky 57913540260SHans Petter Selasky /* prototypes */ 58013540260SHans Petter Selasky 58197d729cfSHans Petter Selasky uint8_t xhci_use_polling(void); 58213540260SHans Petter Selasky usb_error_t xhci_halt_controller(struct xhci_softc *); 583f515174bSHans Petter Selasky usb_error_t xhci_reset_controller(struct xhci_softc *); 5842ac11c11SHans Petter Selasky usb_error_t xhci_init(struct xhci_softc *, device_t, uint8_t); 58513540260SHans Petter Selasky usb_error_t xhci_start_controller(struct xhci_softc *); 58613540260SHans Petter Selasky void xhci_interrupt(struct xhci_softc *); 58713540260SHans Petter Selasky void xhci_uninit(struct xhci_softc *); 58831e34625SAndrew Turner int xhci_pci_attach(device_t); 58931e34625SAndrew Turner 59031e34625SAndrew Turner DECLARE_CLASS(xhci_pci_driver); 59113540260SHans Petter Selasky 59213540260SHans Petter Selasky #endif /* _XHCI_H_ */ 593