25 #define XHCI_MIN_ALIGN 64 28 #define XHCI_MTU 65536 31 #define XHCI_BAR PCI_BASE_ADDRESS_0 34 #define XHCI_CAP_CAPLENGTH 0x00 37 #define XHCI_CAP_HCIVERSION 0x02 40 #define XHCI_CAP_HCSPARAMS1 0x04 43 #define XHCI_HCSPARAMS1_SLOTS(params) ( ( (params) >> 0 ) & 0xff ) 46 #define XHCI_HCSPARAMS1_INTRS(params) ( ( (params) >> 8 ) & 0x3ff ) 49 #define XHCI_HCSPARAMS1_PORTS(params) ( ( (params) >> 24 ) & 0xff ) 52 #define XHCI_CAP_HCSPARAMS2 0x08 55 #define XHCI_HCSPARAMS2_SCRATCHPADS(params) \ 56 ( ( ( (params) >> 16 ) & 0x3e0 ) | ( ( (params) >> 27 ) & 0x1f ) ) 59 #define XHCI_CAP_HCCPARAMS1 0x10 62 #define XHCI_HCCPARAMS1_ADDR64(params) ( ( (params) >> 0 ) & 0x1 ) 65 #define XHCI_HCCPARAMS1_CSZ_SHIFT(params) ( 5 + ( ( (params) >> 2 ) & 0x1 ) ) 68 #define XHCI_HCCPARAMS1_XECP(params) ( ( ( (params) >> 16 ) & 0xffff ) << 2 ) 71 #define XHCI_CAP_DBOFF 0x14 74 #define XHCI_CAP_RTSOFF 0x18 77 #define XHCI_XECP_ID(xecp) ( ( (xecp) >> 0 ) & 0xff ) 80 #define XHCI_XECP_NEXT(xecp) ( ( ( (xecp) >> 8 ) & 0xff ) << 2 ) 83 #define XHCI_XECP_ID_LEGACY 1 86 #define XHCI_USBLEGSUP_BIOS 0x02 89 #define XHCI_USBLEGSUP_BIOS_OWNED 0x01 92 #define XHCI_USBLEGSUP_OS 0x03 95 #define XHCI_USBLEGSUP_OS_OWNED 0x01 98 #define XHCI_USBLEGSUP_CTLSTS 0x04 101 #define XHCI_XECP_ID_SUPPORTED 2 104 #define XHCI_SUPPORTED_REVISION 0x00 107 #define XHCI_SUPPORTED_REVISION_VER(revision) ( ( (revision) >> 16 ) & 0xffff ) 110 #define XHCI_SUPPORTED_NAME 0x04 113 #define XHCI_SUPPORTED_PORTS 0x08 116 #define XHCI_SUPPORTED_PORTS_OFFSET(ports) ( ( (ports) >> 0 ) & 0xff ) 119 #define XHCI_SUPPORTED_PORTS_COUNT(ports) ( ( (ports) >> 8 ) & 0xff ) 122 #define XHCI_SUPPORTED_PORTS_PSIC(ports) ( ( (ports) >> 28 ) & 0x0f ) 125 #define XHCI_SUPPORTED_SLOT 0x0c 128 #define XHCI_SUPPORTED_SLOT_TYPE(slot) ( ( (slot) >> 0 ) & 0x1f ) 131 #define XHCI_SUPPORTED_PSI(index) ( 0x10 + ( (index) * 4 ) ) 134 #define XHCI_SUPPORTED_PSI_VALUE(psi) ( ( (psi) >> 0 ) & 0x0f ) 137 #define XHCI_SUPPORTED_PSI_MANTISSA(psi) ( ( (psi) >> 16 ) & 0xffff ) 140 #define XHCI_SUPPORTED_PSI_EXPONENT(psi) ( ( (psi) >> 4 ) & 0x03 ) 155 #define XHCI_OP_USBCMD 0x00 158 #define XHCI_USBCMD_RUN 0x00000001UL 161 #define XHCI_USBCMD_HCRST 0x00000002UL 164 #define XHCI_OP_USBSTS 0x04 167 #define XHCI_USBSTS_HCH 0x00000001UL 170 #define XHCI_OP_PAGESIZE 0x08 173 #define XHCI_PAGESIZE(pagesize) ( (pagesize) << 12 ) 176 #define XHCI_OP_DNCTRL 0x14 179 #define XHCI_OP_CRCR 0x18 182 #define XHCI_CRCR_RCS 0x00000001UL 185 #define XHCI_CRCR_CA 0x00000004UL 188 #define XHCI_CRCR_CRR 0x00000008UL 191 #define XHCI_OP_DCBAAP 0x30 194 #define XHCI_OP_CONFIG 0x38 197 #define XHCI_CONFIG_MAX_SLOTS_EN(slots) ( (slots) << 0 ) 200 #define XHCI_CONFIG_MAX_SLOTS_EN_MASK \ 201 XHCI_CONFIG_MAX_SLOTS_EN ( 0xff ) 204 #define XHCI_OP_PORTSC(port) ( 0x400 - 0x10 + ( (port) << 4 ) ) 207 #define XHCI_PORTSC_CCS 0x00000001UL 210 #define XHCI_PORTSC_PED 0x00000002UL 213 #define XHCI_PORTSC_PR 0x00000010UL 216 #define XHCI_PORTSC_PLS(pls) ( (pls) << 5 ) 219 #define XHCI_PORTSC_PLS_DISABLED XHCI_PORTSC_PLS ( 4 ) 222 #define XHCI_PORTSC_PLS_RXDETECT XHCI_PORTSC_PLS ( 5 ) 225 #define XHCI_PORTSC_PLS_MASK XHCI_PORTSC_PLS ( 0xf ) 228 #define XHCI_PORTSC_PP 0x00000200UL 231 #define XHCI_PORT_POWER_DELAY_MS 20 234 #define XHCI_PORTSC_PSIV(portsc) ( ( (portsc) >> 10 ) & 0xf ) 237 #define XHCI_PORTSC_PIC(indicators) ( (indicators) << 14 ) 240 #define XHCI_PORTSC_PIC_MASK XHCI_PORTSC_PIC ( 3 ) 243 #define XHCI_PORTSC_LWS 0x00010000UL 246 #define XHCI_LINK_STATE_DELAY_MS 100 249 #define XHCI_PORTSC_CSC 0x00020000UL 252 #define XHCI_PORTSC_PEC 0x00040000UL 255 #define XHCI_PORTSC_WRC 0x00080000UL 258 #define XHCI_PORTSC_OCC 0x00100000UL 261 #define XHCI_PORTSC_PRC 0x00200000UL 264 #define XHCI_PORTSC_PLC 0x00400000UL 267 #define XHCI_PORTSC_CEC 0x00800000UL 270 #define XHCI_PORTSC_CHANGE \ 271 ( XHCI_PORTSC_CSC | XHCI_PORTSC_PEC | XHCI_PORTSC_WRC | \ 272 XHCI_PORTSC_OCC | XHCI_PORTSC_PRC | XHCI_PORTSC_PLC | \ 284 #define XHCI_PORTSC_PRESERVE ( XHCI_PORTSC_PP | XHCI_PORTSC_PIC_MASK ) 287 #define XHCI_OP_PORTPMSC(port) ( 0x404 - 0x10 + ( (port) << 4 ) ) 290 #define XHCI_OP_PORTLI(port) ( 0x408 - 0x10 + ( (port) << 4 ) ) 293 #define XHCI_OP_PORTHLPMC(port) ( 0x40c - 0x10 + ( (port) << 4 ) ) 296 #define XHCI_RUN_ERSTSZ(intr) ( 0x28 + ( (intr) << 5 ) ) 299 #define XHCI_RUN_ERSTBA(intr) ( 0x30 + ( (intr) << 5 ) ) 302 #define XHCI_RUN_ERDP(intr) ( 0x38 + ( (intr) << 5 ) ) 329 #define XHCI_TRB_C 0x01 332 #define XHCI_TRB_TC 0x02 335 #define XHCI_TRB_CH 0x10 338 #define XHCI_TRB_IOC 0x20 341 #define XHCI_TRB_IDT 0x40 344 #define XHCI_TRB_TYPE(type) ( (type) << 2 ) 347 #define XHCI_TRB_TYPE_MASK XHCI_TRB_TYPE ( 0x3f ) 364 #define XHCI_TRB_NORMAL XHCI_TRB_TYPE ( 1 ) 367 #define XHCI_TD_SIZE(remaining) \ 368 ( ( ( (remaining) <= 0xf ) ? remaining : 0xf ) << 17 ) 387 #define XHCI_TRB_SETUP XHCI_TRB_TYPE ( 2 ) 390 #define XHCI_SETUP_IN 3 393 #define XHCI_SETUP_OUT 2 412 #define XHCI_TRB_DATA XHCI_TRB_TYPE ( 3 ) 415 #define XHCI_DATA_IN 0x01 418 #define XHCI_DATA_OUT 0x00 437 #define XHCI_TRB_STATUS XHCI_TRB_TYPE ( 4 ) 440 #define XHCI_STATUS_IN 0x01 443 #define XHCI_STATUS_OUT 0x00 460 #define XHCI_TRB_LINK XHCI_TRB_TYPE ( 6 ) 463 #define XHCI_TRB_NOP XHCI_TRB_TYPE ( 8 ) 482 #define XHCI_TRB_ENABLE_SLOT XHCI_TRB_TYPE ( 9 ) 501 #define XHCI_TRB_DISABLE_SLOT XHCI_TRB_TYPE ( 10 ) 520 #define XHCI_TRB_ADDRESS_DEVICE XHCI_TRB_TYPE ( 11 ) 523 #define XHCI_TRB_CONFIGURE_ENDPOINT XHCI_TRB_TYPE ( 12 ) 526 #define XHCI_TRB_EVALUATE_CONTEXT XHCI_TRB_TYPE ( 13 ) 545 #define XHCI_TRB_RESET_ENDPOINT XHCI_TRB_TYPE ( 14 ) 564 #define XHCI_TRB_STOP_ENDPOINT XHCI_TRB_TYPE ( 15 ) 583 #define XHCI_TRB_SET_TR_DEQUEUE_POINTER XHCI_TRB_TYPE ( 16 ) 586 #define XHCI_TRB_NOP_CMD XHCI_TRB_TYPE ( 23 ) 609 #define XHCI_TRB_TRANSFER XHCI_TRB_TYPE ( 32 ) 630 #define XHCI_TRB_COMPLETE XHCI_TRB_TYPE ( 33 ) 661 #define XHCI_TRB_PORT_STATUS XHCI_TRB_TYPE ( 34 ) 680 #define XHCI_TRB_HOST_CONTROLLER XHCI_TRB_TYPE ( 37 ) 765 #define XHCI_SLOT_INFO( entries, hub, speed, route ) \ 766 ( ( (entries) << 27 ) | ( (hub) << 26 ) | ( (speed) << 20 ) | (route) ) 809 #define XHCI_ENDPOINT_STATE_MASK 0x07 812 #define XHCI_EP_TYPE(type) ( (type) << 3 ) 815 #define XHCI_EP_TYPE_CONTROL XHCI_EP_TYPE ( 4 ) 818 #define XHCI_EP_TYPE_IN XHCI_EP_TYPE ( 4 ) 821 #define XHCI_EP_TYPE_PERIODIC XHCI_EP_TYPE ( 1 ) 824 #define XHCI_EP_DCS 0x00000001UL 827 #define XHCI_EP0_TRB_LEN 8 889 #define XHCI_DBVAL( target, stream ) ( (target) | ( (stream) << 16 ) ) 925 assert ( fill <= ring->mask );
943 #define XHCI_CTX_SLOT 0 946 #define XHCI_CTX(address) \ 947 ( (address) ? ( ( ( (address) & 0x0f ) << 1 ) | \ 948 ( ( (address) & 0x80 ) >> 7 ) ) : 1 ) 951 #define XHCI_CTX_EP0 XHCI_CTX ( 0x00 ) 954 #define XHCI_CTX_END 32 957 #define XHCI_DCI(ctx) ( (ctx) + 0 ) 960 #define XHCI_ICI(ctx) ( (ctx) + 1 ) 966 #define XHCI_CMD_TRBS_LOG2 2 972 #define XHCI_EVENT_TRBS_LOG2 6 978 #define XHCI_TRANSFER_TRBS_LOG2 6 984 #define XHCI_USBLEGSUP_MAX_WAIT_MS 100 990 #define XHCI_STOP_MAX_WAIT_MS 100 996 #define XHCI_RESET_MAX_WAIT_MS 500 1004 #define XHCI_COMMAND_MAX_WAIT_MS USB_CONTROL_MAX_WAIT_MS 1010 #define XHCI_COMMAND_ABORT_DELAY_MS 500 1016 #define XHCI_PORT_RESET_MAX_WAIT_MS 500 1027 #define XHCI_PCH 0x0001 1030 #define XHCI_PCH_XUSB2PR 0xd0 1033 #define XHCI_PCH_XUSB2PRM 0xd4 1036 #define XHCI_PCH_USB3PSSEN 0xd8 1039 #define XHCI_PCH_USB3PRM 0xdc 1042 #define XHCI_BAD_PSIV 0x0002 uint8_t intf
Interface number.
uint8_t burst
Maximum burst size.
uint32_t reserved
Reserved.
A disable slot transfer request block.
uint32_t reserved_b
Reserved.
uint8_t type
Endpoint type.
A status stage transfer request block.
struct xhci_trb_context context
Input context TRB.
uint64_t command
Command TRB pointer.
A transfer request block.
uint32_t dbval
Doorbell register value.
struct xhci_trb_common common
Common fields.
unsigned int ports
Number of ports.
struct xhci_dcbaa dcbaa
Device context base address array.
uint8_t reserved
Reserved.
uint8_t direction
Direction.
uint64_t data
Data buffer.
static physaddr_t xhci_ring_consumed(struct xhci_trb_ring *ring)
Calculate physical address of most recently consumed TRB.
#define XHCI_CTX_END
End of contexts.
uint32_t reserved_b
Reserved.
uint8_t reserved_c
Reserved.
struct xhci_device * xhci
xHCI device
unsigned int cons
Consumer counter.
void * run
Runtime registers.
A set transfer ring dequeue pointer transfer request block.
size_t len
Length of transfer request blocks.
An input control context.
uint8_t reserved_b
Reserved.
unsigned int port
Root hub port number.
xhci_endpoint_state
Endpoint states.
static unsigned int xhci_ring_fill(struct xhci_trb_ring *ring)
Calculate space used in TRB ring.
A command completion event transfer request block.
struct dma_mapping segment_map
Event ring segment table DMA mapping.
uint8_t state
Endpoint state.
uint8_t reserved_a[3]
Reserved.
struct xhci_trb_transfer transfer
Transfer event.
A port status change transfer request block.
uint16_t trb_len
Average TRB length.
union xhci_trb * pending
Current command (if any)
uint64_t reserved_a
Reserved.
struct xhci_endpoint * endpoint[XHCI_CTX_END]
Endpoints, indexed by context ID.
uint64_t next
Next ring segment.
struct dma_mapping map
DMA mapping.
xhci_completion_code
xHCI completion codes
uint8_t code
Completion code.
struct xhci_trb_disable_slot disable
Disable slot TRB.
uint16_t reserved_c
Reserved.
uint16_t reserved_c
Reserved.
unsigned int route
Route string.
An enable slot transfer request block.
unsigned long long uint64_t
struct usb_bus * bus
USB bus.
struct xhci_trb_enable_slot enable
Enable slot TRB.
struct dma_mapping buffer_map
Buffer DMA mapping.
struct xhci_trb_setup setup
Setup stage TRB.
unsigned int count
Number of page-sized scratchpad buffers.
A data stage transfer request block.
uint8_t code
Completion code.
void * db
Doorbell register.
xhci_default_psi_value
Default PSI values.
uint8_t direction
Transfer direction.
unsigned int psiv
Protocol speed ID.
uint8_t reserved_b[3]
Reserved.
uint8_t endpoint
Endpoint ID.
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Access to external ("user") memory.
uint64_t dequeue
Dequeue pointer.
unsigned int slots
Number of device slots.
uint32_t add
Add context flags.
uint64_t dequeue
Transfer ring dequeue pointer.
struct xhci_scratchpad scratch
Scratchpad buffer.
static unsigned int xhci_ring_remaining(struct xhci_trb_ring *ring)
Calculate space remaining in TRB ring.
uint8_t esit_high
Max ESIT payload high.
uint64_t * array
Scratchpad array.
uint8_t address
USB address.
uint8_t ports
Number of downstream ports.
Endpoint is halted due to a TRB error.
unsigned int type
Endpoint type.
struct xhci_trb_host_controller host
Host controller event.
uint32_t reserved_a
Reserved.
uint64_t input
Input context.
uint16_t reserved_a
Reserved.
struct dma_mapping array_map
Array DMA mapping.
uint8_t endpoint
Endpoint ID.
uint32_t reserved_b
Reserved.
union xhci_trb * trb
Transfer request blocks.
Endpoint is halted due to a USB Halt condition.
uint8_t reserved_c
Reserved.
struct xhci_pch pch
Intel PCH quirk.
uint32_t userptr_t
A pointer to a user buffer.
A reset endpoint transfer request block.
union xhci_trb * trb
Transfer request blocks.
uint32_t drop
Drop context flags.
uint8_t alt
Alternate setting.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
unsigned int ports
Number of ports (if this device is a hub)
uint64_t reserved_a
Reserved.
uint8_t reserved_c
Reserved.
struct xhci_trb_stop_endpoint stop
Stop endpoint TRB.
struct xhci_trb_template template
Template.
unsigned int ctx
Context index.
struct usb_device * usb
USB device.
uint32_t xusb2pr
USB2 port routing register original value.
uint8_t vf
Virtual function ID.
uint64_t reserved_a
Reserved.
uint8_t port
Root hub port number.
uint64_t reserved_a
Reserved.
uint64_t data
Data buffer.
A setup stage transfer request block.
uint16_t mtu
Maximum packet size.
A transfer event transfer request block.
uint8_t direction
Transfer direction.
uint32_t usb3pssen
USB3 port SuperSpeed enable register original value.
uint8_t config
Configuration value.
uint32_t info
Device info.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct xhci_slot * slot
xHCI slot
struct xhci_endpoint_context * context
Endpoint context.
uint32_t reserved_b
Reserved.
uint32_t reserved_a[5]
Reserved.
A context transfer request block.
uint16_t reserved_c
Reserved.
uint64_t reserved_a
Reserved.
int failed
Command mechanism has permanently failed.
uint64_t base
Base address.
A link transfer request block.
A transfer request block.
uint64_t * context
Context base addresses.
Device context base address array.
struct xhci_trb_data data
Data stage TRB.
unsigned int intrs
Number of interrupters.
unsigned int tt_id
Transaction translator slot ID.
unsigned int prod
Producer counter.
struct xhci_trb_complete complete
Command completion event.
struct xhci_trb_set_tr_dequeue_pointer dequeue
Set transfer ring dequeue pointer TRB.
void * cap
Capability registers.
unsigned int xecp
xHCI extended capabilities offset
A normal transfer request block.
int addr64
64-bit addressing capability
A port status change transfer request block.
struct xhci_trb_normal normal
Normal TRB.
uint8_t stream
Stream configuration.
userptr_t buffer
Scratchpad buffer area.
uint64_t reserved_a
Reserved.
struct xhci_trb_reset_endpoint reset
Reset endpoint TRB.
uint32_t reserved
Reserved.
uint8_t code
Completion code.
uint8_t tt_id
TT hub slot ID.
struct usb_endpoint * ep
USB endpoint.
uint64_t reserved_a
Reserved.
struct xhci_event_ring_segment * segment
Event ring segment table.
size_t pagesize
Page size.
Universal Serial Bus (USB)
uint16_t latency
Maximum exit latency.
uint16_t intr
Interrupter target.
A stop endpoint transfer request block.
unsigned int mask
Ring counter mask.
uint8_t interval
Polling interval.
uint8_t reserved_b[7]
Reserved.
uint8_t tt_port
TT port number.
uint32_t reserved_b[4]
Reserved.
struct dma_mapping map
DMA mapping.
uint32_t reserved_b
Reserved.
struct io_buffer ** iobuf
I/O buffers.
unsigned int cons
Consumer counter.
struct xhci_trb_ring ring
Transfer ring.
unsigned int tt_port
Transaction translator port.
struct xhci_slot_context * context
Slot context.
struct dma_mapping map
DMA mapping.
struct xhci_trb_port_status port
Port status changed event.
struct dma_device * dma
DMA device.
uint16_t residual
Residual transfer length.
unsigned int legacy
USB legacy support capability (if present and enabled)
struct xhci_trb_link * link
Link TRB (if applicable)
unsigned int shift
Ring size (log2)
A transfer request block command/transfer ring.
struct xhci_trb_status status
Status stage TRB.
uint16_t reserved
Reserved.
uint32_t reserved[3]
Reserved.
uint64_t transfer
Transfer TRB pointer.
unsigned int csz_shift
Context size shift.
struct usb_setup_packet packet
Setup packet.
void * db
Doorbell registers.
uint8_t reserved
Reserved.
unsigned int interval
Endpoint interval.
uint8_t endpoint
Endpoint ID.
uint8_t code
Completion code.
uint8_t reserved
Reserved.
uint16_t esit_low
Max ESIT payload low.
struct xhci_trb_link link
Link TRB.
struct xhci_slot ** slot
Device slots, indexed by slot ID.
uint32_t count
Number of TRBs.
A transfer request block template.
unsigned int quirks
Quirks.
uint64_t parameter
Parameter.
struct xhci_device * xhci
xHCI device
struct xhci_event_ring event
Event ring.
void * op
Operational registers.
uint16_t reserved_c
Reserved.
uint8_t endpoint
Endpoint ID.
uint8_t reserved_b
Reserved.
struct dma_mapping trb_map
Transfer request blocks DMA mapping.
uint32_t reserved_a
Reserved.
uint32_t reserved_b
Reserved.