1 /* $OpenBSD: xhcireg.h,v 1.11 2015/01/18 20:35:11 mpi Exp $ */ 2 3 /*- 4 * Copyright (c) 2014 Martin Pieuchot. All rights reserved. 5 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #ifndef _XHCIREG_H_ 30 #define _XHCIREG_H_ 31 32 /* Data Structure Boundary and Alignment Requirement. */ 33 #define XHCI_DCBAA_ALIGN 64 34 #define XHCI_ICTX_ALIGN 64 35 #define XHCI_SCTX_ALIGN 32 36 #define XHCI_OCTX_ALIGN 32 37 #define XHCI_XFER_RING_ALIGN 16 38 #define XHCI_CMDS_RING_ALIGN 64 39 #define XHCI_EVTS_RING_ALIGN 64 40 #define XHCI_RING_BOUNDARY (64 * 1024) 41 #define XHCI_ERST_ALIGN 64 42 #define XHCI_ERST_BOUNDARY 0 43 #define XHCI_SPAD_TABLE_ALIGN 64 44 45 /* XHCI PCI config registers */ 46 #define PCI_CBMEM 0x10 /* configuration base MEM */ 47 48 #define PCI_INTERFACE_XHCI 0x30 49 50 #define PCI_USBREV 0x60 /* RO USB protocol revision */ 51 #define PCI_USBREV_MASK 0xff 52 #define PCI_USBREV_3_0 0x30 /* USB 3.0 */ 53 54 #define PCI_XHCI_FLADJ 0x61 /* RW frame length adjust */ 55 56 #define PCI_XHCI_INTEL_XUSB2PR 0xd0 /* Intel USB2 Port Routing */ 57 #define PCI_XHCI_INTEL_XUSB2PRM 0xd4 /* Intel USB2 Port Routing Mask */ 58 #define PCI_XHCI_INTEL_USB3_PSSEN 0xd8 /* Intel USB3 Port SuperSpeed Enable */ 59 #define PCI_XHCI_INTEL_USB3PRM 0xdc /* Intel USB3 Port Routing Mask */ 60 61 /* XHCI capability registers */ 62 #define XHCI_CAPLENGTH 0x00 /* RO Capability reg. length field */ 63 #define XHCI_RESERVED 0x01 /* Reserved */ 64 #define XHCI_HCIVERSION 0x02 /* RO Interface version number */ 65 #define XHCI_HCIVERSION_0_9 0x0090 /* xHCI version 0.9 */ 66 #define XHCI_HCIVERSION_1_0 0x0100 /* xHCI version 1.0 */ 67 68 #define XHCI_HCSPARAMS1 0x04 /* RO structual parameters 1 */ 69 #define XHCI_HCS1_DEVSLOT_MAX(x)((x) & 0xff) 70 #define XHCI_HCS1_IRQ_MAX(x) (((x) >> 8) & 0x3ff) 71 #define XHCI_HCS1_N_PORTS(x) (((x) >> 24) & 0xff) 72 73 #define XHCI_HCSPARAMS2 0x08 /* RO structual parameters 2 */ 74 #define XHCI_HCS2_IST(x) ((x) & 0xF) 75 #define XHCI_HCS2_ERST_MAX(x) (((x) >> 4) & 0xf) 76 #define XHCI_HCS2_SPR(x) (((x) >> 24) & 0x1) 77 #define XHCI_HCS2_SPB_MAX(x) (((x) >> 27) & 0x7f) 78 79 #define XHCI_HCSPARAMS3 0x0c /* RO structual parameters 3 */ 80 #define XHCI_HCS3_U1_DEL(x) ((x) & 0xff) 81 #define XHCI_HCS3_U2_DEL(x) (((x) >> 16) & 0xffff) 82 83 #define XHCI_HCCPARAMS 0x10 /* RO capability parameters */ 84 #define XHCI_HCC_AC64(x) (((x) >> 0) & 0x1) /* 64-bit capable */ 85 #define XHCI_HCC_BNC(x) (((x) >> 1) & 0x1) /* BW negotiation */ 86 #define XHCI_HCC_CSZ(x) (((x) >> 2) & 0x1) /* Context size */ 87 #define XHCI_HCC_PPC(x) (((x) >> 3) & 0x1) /* Port power control */ 88 #define XHCI_HCC_PIND(x) (((x) >> 4) & 0x1) /* Port indicators */ 89 #define XHCI_HCC_LHRC(x) (((x) >> 5) & 0x1) /* Light HC reset */ 90 #define XHCI_HCC_LTC(x) (((x) >> 6) & 0x1) /* Latency tolerance msg */ 91 #define XHCI_HCC_NSS(x) (((x) >> 7) & 0x1) /* No secondary sid */ 92 #define XHCI_HCC_PAE(x) (((x) >> 8) & 0x1) /* Pase All Event Data */ 93 #define XHCI_HCC_SPC(x) (((x) >> 9) & 0x1) /* Short packet */ 94 #define XHCI_HCC_SEC(x) (((x) >> 10) & 0xf) /* Stopped EDTLA */ 95 #define XHCI_HCC_CFC(x) (((x) >> 11) & 0xf) /* Configuous Frame ID */ 96 #define XHCI_HCC_MAX_PSA_SZ(x) (((x) >> 12) & 0xf) /* Max pri. stream arr. */ 97 #define XHCI_HCC_XECP(x) (((x) >> 16) & 0xffff) /* Ext. capabilities */ 98 99 #define XHCI_DBOFF 0x14 /* RO doorbell offset */ 100 #define XHCI_RTSOFF 0x18 /* RO runtime register space offset */ 101 102 /* 103 * XHCI operational registers. 104 * Offset given by XHCI_CAPLENGTH register. 105 */ 106 #define XHCI_USBCMD 0x00 /* XHCI command */ 107 #define XHCI_CMD_RS 0x00000001 /* RW Run/Stop */ 108 #define XHCI_CMD_HCRST 0x00000002 /* RW Host Controller Reset */ 109 #define XHCI_CMD_INTE 0x00000004 /* RW Interrupter Enable */ 110 #define XHCI_CMD_HSEE 0x00000008 /* RW Host System Error Enable */ 111 #define XHCI_CMD_LHCRST 0x00000080 /* RO/RW Light HC Reset */ 112 #define XHCI_CMD_CSS 0x00000100 /* RW Controller Save State */ 113 #define XHCI_CMD_CRS 0x00000200 /* RW Controller Restore State */ 114 #define XHCI_CMD_EWE 0x00000400 /* RW Enable Wrap Event */ 115 #define XHCI_CMD_EU3S 0x00000800 /* RW Enable U3 MFINDEX Stop */ 116 117 #define XHCI_USBSTS 0x04 /* XHCI status */ 118 #define XHCI_STS_HCH 0x00000001 /* RO - Host Controller Halted */ 119 #define XHCI_STS_HSE 0x00000004 /* RW - Host System Error */ 120 #define XHCI_STS_EINT 0x00000008 /* RW - Event Interrupt */ 121 #define XHCI_STS_PCD 0x00000010 /* RW - Port Change Detect */ 122 #define XHCI_STS_SSS 0x00000100 /* RO - Save State Status */ 123 #define XHCI_STS_RSS 0x00000200 /* RO - Restore State Status */ 124 #define XHCI_STS_SRE 0x00000400 /* RW - Save/Restore Error */ 125 #define XHCI_STS_CNR 0x00000800 /* RO - Controller Not Ready */ 126 #define XHCI_STS_HCE 0x00001000 /* RO - Host Controller Error */ 127 128 #define XHCI_PAGESIZE 0x08 /* XHCI page size mask */ 129 #define XHCI_PAGESIZE_4K 0x00000001 /* 4K Page Size */ 130 #define XHCI_PAGESIZE_8K 0x00000002 /* 8K Page Size */ 131 #define XHCI_PAGESIZE_16K 0x00000004 /* 16K Page Size */ 132 #define XHCI_PAGESIZE_32K 0x00000008 /* 32K Page Size */ 133 #define XHCI_PAGESIZE_64K 0x00000010 /* 64K Page Size */ 134 135 #define XHCI_DNCTRL 0x14 /* XHCI device notification control */ 136 #define XHCI_DNCTRL_MASK(n) (1 << (n)) 137 138 #define XHCI_CRCR_LO 0x18 /* XHCI command ring control */ 139 #define XHCI_CRCR_LO_RCS 0x00000001 /* RW - consumer cycle state */ 140 #define XHCI_CRCR_LO_CS 0x00000002 /* RW - command stop */ 141 #define XHCI_CRCR_LO_CA 0x00000004 /* RW - command abort */ 142 #define XHCI_CRCR_LO_CRR 0x00000008 /* RW - command ring running */ 143 #define XHCI_CRCR_LO_MASK 0x0000000F 144 145 #define XHCI_CRCR_HI 0x1C /* XHCI command ring control */ 146 #define XHCI_DCBAAP_LO 0x30 /* XHCI dev context BA pointer */ 147 #define XHCI_DCBAAP_HI 0x34 /* XHCI dev context BA pointer */ 148 #define XHCI_CONFIG 0x38 149 #define XHCI_CONFIG_SLOTS_MASK 0x000000ff /* RW - nb of device slots enabled */ 150 151 /* 152 * XHCI port status registers. 153 */ 154 #define XHCI_PORTSC(n) (0x3f0 + (0x10 * (n))) /* XHCI port status */ 155 #define XHCI_PS_CCS 0x00000001 /* RO - current connect status */ 156 #define XHCI_PS_PED 0x00000002 /* RW - port enabled / disabled */ 157 #define XHCI_PS_OCA 0x00000008 /* RO - over current active */ 158 #define XHCI_PS_PR 0x00000010 /* RW - port reset */ 159 #define XHCI_PS_GET_PLS(x) (((x) >> 5) & 0xf) /* RW - port link state */ 160 #define XHCI_PS_SET_PLS(x) (((x) & 0xf) << 5) /* RW - port link state */ 161 #define XHCI_PS_PP 0x00000200 /* RW - port power */ 162 #define XHCI_PS_SPEED(x) (((x) >> 10) & 0xf) /* RO - port speed */ 163 #define XHCI_PS_GET_PIC(x) (((x) >> 14) & 0x3) /* RW - port indicator */ 164 #define XHCI_PS_SET_PIC(x) (((x) & 0x3) << 14) /* RW - port indicator */ 165 #define XHCI_PS_LWS 0x00010000 /* RW - link state write strobe */ 166 #define XHCI_PS_CSC 0x00020000 /* RW - connect status change */ 167 #define XHCI_PS_PEC 0x00040000 /* RW - port enable/disable change */ 168 #define XHCI_PS_WRC 0x00080000 /* RW - warm port reset change */ 169 #define XHCI_PS_OCC 0x00100000 /* RW - over-current change */ 170 #define XHCI_PS_PRC 0x00200000 /* RW - port reset change */ 171 #define XHCI_PS_PLC 0x00400000 /* RW - port link state change */ 172 #define XHCI_PS_CEC 0x00800000 /* RW - config error change */ 173 #define XHCI_PS_CAS 0x01000000 /* RO - cold attach status */ 174 #define XHCI_PS_WCE 0x02000000 /* RW - wake on connect enable */ 175 #define XHCI_PS_WDE 0x04000000 /* RW - wake on disconnect enable */ 176 #define XHCI_PS_WOE 0x08000000 /* RW - wake on over-current enable*/ 177 #define XHCI_PS_DR 0x40000000 /* RO - device removable */ 178 #define XHCI_PS_WPR 0x80000000U /* RW - warm port reset */ 179 #define XHCI_PS_CLEAR 0x80ff01ffu /* command bits */ 180 181 #define XHCI_PORTPMSC(n) (0x3f4 + (0x10 * (n))) /* XHCI status & ctrl */ 182 #define XHCI_PM3_U1TO(x) (((x) & 0xff) << 0) /* RW - U1 timeout */ 183 #define XHCI_PM3_U2TO(x) (((x) & 0xff) << 8) /* RW - U2 timeout */ 184 #define XHCI_PM3_FLA 0x00010000 /* RW - Force Link PM Accept */ 185 #define XHCI_PM2_L1S(x) (((x) >> 0) & 0x7) /* RO - L1 status */ 186 #define XHCI_PM2_RWE 0x00000008 /* RW - remote wakup enable */ 187 #define XHCI_PM2_HIRD(x) (((x) & 0xf) << 4) /* RW - resume duration */ 188 #define XHCI_PM2_L1SLOT(x) (((x) & 0xff) << 8) /* RW - L1 device slot */ 189 #define XHCI_PM2_HLE 0x00010000 /* RW - hardware LPM enable */ 190 #define XHCI_PORTLI(n) (0x3f8 + (0x10 * (n))) /* XHCI port link info */ 191 #define XHCI_PORTRSV(n) (0x3fC + (0x10 * (n))) /* XHCI port reserved */ 192 193 /* 194 * XHCI runtime registers. 195 * Offset given by XHCI_CAPLENGTH + XHCI_RTSOFF registers. 196 */ 197 #define XHCI_MFINDEX 0x0000 /* RO - microframe index */ 198 #define XHCI_GET_MFINDEX(x) ((x) & 0x3fff) 199 #define XHCI_IMAN(n) (0x0020 + (0x20 * (n))) /* intr.management */ 200 #define XHCI_IMAN_INTR_PEND 0x00000001 /* RW - interrupt pending */ 201 #define XHCI_IMAN_INTR_ENA 0x00000002 /* RW - interrupt enable */ 202 203 /* XHCI interrupt moderation */ 204 #define XHCI_IMOD(n) (0x0024 + (0x20 * (n))) 205 #define XHCI_IMOD_IVAL_GET(x) (((x) >> 0) & 0xffff) /* 250ns unit */ 206 #define XHCI_IMOD_IVAL_SET(x) (((x) & 0xffff) << 0) /* 250ns unit */ 207 #define XHCI_IMOD_ICNT_GET(x) (((x) >> 16) & 0xffff) /* 250ns unit */ 208 #define XHCI_IMOD_ICNT_SET(x) (((x) & 0xffff) << 16) /* 250ns unit */ 209 #define XHCI_IMOD_DEFAULT 0x000001F4U /* 8000 IRQ/second */ 210 #define XHCI_IMOD_DEFAULT_LP 0x000003E8U /* 4000 IRQ/second */ 211 212 /* XHCI event ring segment table size */ 213 #define XHCI_ERSTSZ(n) (0x0028 + (0x20 * (n))) 214 #define XHCI_ERSTS_SET(x) ((x) & 0xffff) 215 216 /* XHCI event ring segment table BA */ 217 #define XHCI_ERSTBA_LO(n) (0x0030 + (0x20 * (n))) 218 #define XHCI_ERSTBA_HI(n) (0x0034 + (0x20 * (n))) 219 220 /* XHCI event ring dequeue pointer */ 221 #define XHCI_ERDP_LO(n) (0x0038 + (0x20 * (n))) 222 #define XHCI_ERDP_LO_BUSY 0x00000008 /* RW - event handler busy */ 223 #define XHCI_ERDP_HI(n) (0x003c + (0x20 * (n))) 224 225 /* 226 * XHCI doorbell registers. 227 * Offset given by XHCI_CAPLENGTH + XHCI_DBOFF registers. 228 */ 229 #define XHCI_DOORBELL(n) (0x0000 + (4 * (n))) 230 #define XHCI_DB_GET_SID(x) (((x) >> 16) & 0xffff) /* RW - stream ID */ 231 #define XHCI_DB_SET_SID(x) (((x) & 0xffff) << 16) /* RW - stream ID */ 232 233 /* XHCI legacy support */ 234 #define XHCI_XECP_ID(x) ((x) & 0xff) 235 #define XHCI_XECP_NEXT(x) (((x) >> 8) & 0xff) 236 #define XHCI_XECP_BIOS_SEM 0x0002 237 #define XHCI_XECP_OS_SEM 0x0003 238 239 /* XHCI capability ID's */ 240 #define XHCI_ID_USB_LEGACY 0x0001 241 #define XHCI_ID_PROTOCOLS 0x0002 242 #define XHCI_ID_POWER_MGMT 0x0003 243 #define XHCI_ID_VIRTUALIZATION 0x0004 244 #define XHCI_ID_MSG_IRQ 0x0005 245 #define XHCI_ID_USB_LOCAL_MEM 0x0006 246 247 248 struct xhci_erseg { 249 uint64_t er_addr; 250 uint32_t er_size; 251 uint32_t er_rsvd; 252 } __packed; 253 254 255 struct xhci_sctx { 256 uint32_t info_lo; 257 #define XHCI_SCTX_ROUTE(x) ((x) & 0xfffff) 258 #define XHCI_SCTX_SPEED(x) (((x) & 0xf) << 20) 259 #define XHCI_SCTX_MTT(x) (((x) & 0x1) << 25) 260 #define XHCI_SCTX_HUB(x) (((x) & 0x1) << 26) 261 #define XHCI_SCTX_DCI(x) (((x) & 0x1f) << 27) 262 263 uint32_t info_hi; 264 #define XHCI_SCTX_MAX_EL(x) ((x) & 0xffff) 265 #define XHCI_SCTX_RHPORT(x) (((x) & 0xff) << 16) 266 #define XHCI_SCTX_NPORTS(x) (((x) & 0xff) << 24) 267 268 uint32_t tt; 269 #define XHCI_SCTX_TT_HUB_SID(x) ((x) & 0xff) 270 #define XHCI_SCTX_TT_PORT_NUM(x) (((x) & 0xff) << 8) 271 #define XHCI_SCTX_TT_THINK_TIME(x) (((x) & 0x3) << 16) 272 #define XHCI_SCTX_SET_IRQ_TARGET(x) (((x) & 0x3ff) << 22) 273 #define XHCI_SCTX_GET_IRQ_TARGET(x) (((x) >> 22) & 0x3ff) 274 275 uint32_t state; 276 #define XHCI_SCTX_DEV_ADDR(x) ((x) & 0xff) 277 #define XHCI_SCTX_SLOT_STATE(x) (((x) >> 27) & 0x1f) 278 279 uint32_t rsvd[4]; 280 } __packed; 281 282 struct xhci_epctx { 283 uint32_t info_lo; 284 #define XHCI_EPCTX_STATE(x) ((x) & 0x7) 285 #define XHCI_EP_DISABLED 0x0 286 #define XHCI_EP_RUNNING 0x1 287 #define XHCI_EP_HALTED 0x2 288 #define XHCI_EP_STOPPED 0x3 289 #define XHCI_EP_ERROR 0x4 290 #define XHCI_EPCTX_SET_MULT(x) (((x) & 0x3) << 8) 291 #define XHCI_EPCTX_GET_MULT(x) (((x) >> 8) & 0x3) 292 #define XHCI_EPCTX_SET_MAXP_STREAMS(x) (((x) & 0x1F) << 10) 293 #define XHCI_EPCTX_GET_MAXP_STREAMS(x) (((x) >> 10) & 0x1F) 294 #define XHCI_EPCTX_SET_LSA(x) (((x) & 0x1) << 15) 295 #define XHCI_EPCTX_GET_LSA(x) (((x) >> 15) & 0x1) 296 #define XHCI_EPCTX_SET_IVAL(x) (((x) & 0xff) << 16) 297 #define XHCI_EPCTX_GET_IVAL(x) (((x) >> 16) & 0xFF) 298 299 uint32_t info_hi; 300 #define XHCI_EPCTX_SET_CERR(x) (((x) & 0x3) << 1) 301 #define XHCI_EPCTX_SET_EPTYPE(x) (((x) & 0x7) << 3) 302 #define XHCI_EPCTX_GET_EPTYPE(x) (((x) >> 3) & 0x7) 303 #define XHCI_EPCTX_SET_HID(x) (((x) & 0x1) << 7) 304 #define XHCI_EPCTX_GET_HID(x) (((x) >> 7) & 0x1) 305 #define XHCI_EPCTX_SET_MAXB(x) (((x) & 0xff) << 8) 306 #define XHCI_EPCTX_GET_MAXB(x) (((x) >> 8) & 0xff) 307 #define XHCI_EPCTX_SET_MPS(x) (((x) & 0xffff) << 16) 308 #define XHCI_EPCTX_GET_MPS(x) (((x) >> 16) & 0xffff) 309 #define XHCI_SPEED_FULL 1 310 #define XHCI_SPEED_LOW 2 311 #define XHCI_SPEED_HIGH 3 312 #define XHCI_SPEED_SUPER 4 313 314 uint64_t deqp; 315 316 uint32_t txinfo; 317 #define XHCI_EPCTX_AVG_TRB_LEN(x) ((x) & 0xffff) 318 #define XHCI_EPCTX_MAX_ESIT_PAYLOAD(x) (((x) & 0xffff) << 16) 319 320 uint32_t rsvd[3]; 321 } __packed; 322 323 324 struct xhci_inctx { 325 uint32_t drop_flags; 326 uint32_t add_flags; 327 #define XHCI_INCTX_MASK_DCI(n) (0x1 << (n)) 328 329 uint32_t rsvd[6]; 330 } __packed; 331 332 333 struct xhci_trb { 334 uint64_t trb_paddr; 335 #define XHCI_TRB_PORTID(x) (((x) & (0xff << 24)) >> 24) /* Port ID */ 336 #define XHCI_TRB_MAXSIZE (64 * 1024) 337 338 uint32_t trb_status; 339 #define XHCI_TRB_GET_CODE(x) (((x) >> 24) & 0xff) 340 #define XHCI_TRB_TDREM(x) (((x) & 0x1f) << 17) /* TD remaining len. */ 341 #define XHCI_TRB_REMAIN(x) ((x) & 0xffffff) /* Remaining length */ 342 #define XHCI_TRB_LEN(x) ((x) & 0x1ffff) /* Transfer length */ 343 #define XHCI_TRB_INTR(x) (((x) & 0x3ff) << 22) /* MSI-X intr. target */ 344 345 uint32_t trb_flags; 346 #define XHCI_TRB_CYCLE (1 << 0) /* Enqueue point of xfer ring */ 347 #define XHCI_TRB_ENT (1 << 1) /* Evaluate next TRB */ 348 #define XHCI_TRB_LINKSEG XHCI_TRB_ENT /* Link to next segment */ 349 #define XHCI_TRB_ISP (1 << 2) /* Interrupt on short packet */ 350 #define XHCI_TRB_NOSNOOP (1 << 3) /* PCIe no snoop */ 351 #define XHCI_TRB_CHAIN (1 << 4) /* Chained with next TRB */ 352 #define XHCI_TRB_IOC (1 << 5) /* Interrupt On Completion */ 353 #define XHCI_TRB_IDT (1 << 6) /* Immediate DaTa */ 354 #define XHCI_TRB_BSR (1 << 9) 355 #define XHCI_TRB_DIR_IN (1 << 16) 356 #define XHCI_TRB_TRT_OUT (2 << 16) 357 #define XHCI_TRB_TRT_IN (3 << 16) 358 #define XHCI_TRB_GET_EP(x) (((x) >> 16) & 0x1f) 359 #define XHCI_TRB_SET_EP(x) (((x) & 0x1f) << 16) 360 #define XHCI_TRB_GET_SLOT(x) (((x) >> 24) & 0xff) 361 #define XHCI_TRB_SET_SLOT(x) (((x) & 0xff) << 24) 362 } __packed; 363 364 #define XHCI_TRB_FLAGS_BITMASK \ 365 "\20\007IDT\006IOC\005CHAIN\004NOSNOOP\003ISP\002LINKSEG\001CYCLE" 366 367 #define XHCI_TRB_TYPE_MASK 0xfc00 368 #define XHCI_TRB_TYPE(x) (((x) & XHCI_TRB_TYPE_MASK) >> 10) 369 370 /* Transfer Ring Types */ 371 #define XHCI_TRB_TYPE_NORMAL (1 << 10) 372 #define XHCI_TRB_TYPE_SETUP (2 << 10) /* Setup stage (ctrl only) */ 373 #define XHCI_TRB_TYPE_DATA (3 << 10) /* Data stage (ctrl only) */ 374 #define XHCI_TRB_TYPE_STATUS (4 << 10) /* Status stage (ctrl only) */ 375 #define XHCI_TRB_TYPE_ISOCH (5 << 10) 376 #define XHCI_TRB_TYPE_LINK (6 << 10) /* Link next seg. (all+cmd) */ 377 #define XHCI_TRB_TYPE_EVENT (7 << 10) /* Generate event (all) */ 378 #define XHCI_TRB_TYPE_NOOP (8 << 10) /* No-Op (all) */ 379 380 /* Command ring Types */ 381 #define XHCI_CMD_ENABLE_SLOT (9 << 10) 382 #define XHCI_CMD_DISABLE_SLOT (10 << 10) 383 #define XHCI_CMD_ADDRESS_DEVICE (11 << 10) 384 #define XHCI_CMD_CONFIG_EP (12 << 10) 385 #define XHCI_CMD_EVAL_CTX (13 << 10) 386 #define XHCI_CMD_RESET_EP (14 << 10) 387 #define XHCI_CMD_STOP_EP (15 << 10) 388 #define XHCI_CMD_SET_TR_DEQ (16 << 10) 389 #define XHCI_CMD_RESET_DEV (17 << 10) 390 #define XHCI_CMD_FEVENT (18 << 10) 391 #define XHCI_CMD_NEG_BW (19 << 10) /* Negociate bandwith */ 392 #define XHCI_CMD_SET_LT (20 << 10) /* Set latency tolerance */ 393 #define XHCI_CMD_GET_BW (21 << 10) /* Get port bandwith */ 394 #define XHCI_CMD_FHEADER (22 << 10) 395 #define XHCI_CMD_NOOP (23 << 10) /* To test the command ring */ 396 397 /* Event ring Types */ 398 #define XHCI_EVT_XFER (32 << 10) /* Transfer event */ 399 #define XHCI_EVT_CMD_COMPLETE (33 << 10) 400 #define XHCI_EVT_PORT_CHANGE (34 << 10) /* Port status change */ 401 #define XHCI_EVT_BW_REQUEST (35 << 10) 402 #define XHCI_EVT_DOORBELL (36 << 10) 403 #define XHCI_EVT_HOST_CTRL (37 << 10) 404 #define XHCI_EVT_DEVICE_NOTIFY (38 << 10) 405 #define XHCI_EVT_MFINDEX_WRAP (39 << 10) 406 407 /* TRB Completion codes */ 408 #define XHCI_CODE_INVALID 0 /* Producer didn't update the code. */ 409 #define XHCI_CODE_SUCCESS 1 /* Badaboum, plaf, plouf, yeepee! */ 410 #define XHCI_CODE_DATA_BUF 2 /* Overrun or underrun */ 411 #define XHCI_CODE_BABBLE 3 /* Device is "babbling" */ 412 #define XHCI_CODE_TXERR 4 /* USB Transaction error */ 413 #define XHCI_CODE_TRB 5 /* Invalid TRB */ 414 #define XHCI_CODE_STALL 6 /* Stall condition */ 415 #define XHCI_CODE_RESOURCE 7 /* No resource available for the cmd */ 416 #define XHCI_CODE_BANDWIDTH 8 /* Not enough bandwidth for the cmd */ 417 #define XHCI_CODE_NO_SLOTS 9 /* MaxSlots limit reached */ 418 #define XHCI_CODE_STREAM_TYPE 10 /* Stream Context Type value detected */ 419 #define XHCI_CODE_SLOT_NOT_ON 11 /* Related device slot is disabled */ 420 #define XHCI_CODE_ENDP_NOT_ON 12 /* Related enpoint is disabled */ 421 #define XHCI_CODE_SHORT_XFER 13 /* Short packet */ 422 #define XHCI_CODE_RING_UNDERRUN 14 /* Empty ring when transmitting isoc */ 423 #define XHCI_CODE_RING_OVERRUN 15 /* Empty ring when receiving isoc */ 424 #define XHCI_CODE_VF_RING_FULL 16 /* VF's event ring is full */ 425 #define XHCI_CODE_PARAMETER 17 /* Context parameter is invalid */ 426 #define XHCI_CODE_BW_OVERRUN 18 /* TD exceeds the bandwidth */ 427 #define XHCI_CODE_CONTEXT_STATE 19 /* Transition from illegal ctx state */ 428 #define XHCI_CODE_NO_PING_RESP 20 /* Unable to complete periodic xfer */ 429 #define XHCI_CODE_EV_RING_FULL 21 /* Unable to post an evt to the ring */ 430 #define XHCI_CODE_INCOMPAT_DEV 22 /* Device cannot be accessed */ 431 #define XHCI_CODE_MISSED_SRV 23 /* Unable to service isoc EP in ESIT */ 432 #define XHCI_CODE_CMD_RING_STOP 24 /* Command Stop (CS) requested */ 433 #define XHCI_CODE_CMD_ABORTED 25 /* Command Abort (CA) operation */ 434 #define XHCI_CODE_XFER_STOPPED 26 /* xfer terminated by a stop endpoint */ 435 #define XHCI_CODE_XFER_STOPINV 27 /* TRB transfer length invalid */ 436 #define XHCI_CODE_XFER_SHORTPKT 28 /* Stopped before reaching end of TD */ 437 #define XHCI_CODE_MELAT 29 /* Max Exit Latency too large */ 438 #define XHCI_CODE_RESERVED 30 439 #define XHCI_CODE_ISOC_OVERRUN 31 /* IN data buffer < Max ESIT Payload */ 440 #define XHCI_CODE_EVENT_LOST 32 /* Internal overrun - impl. specific */ 441 #define XHCI_CODE_UNDEFINED 33 /* Fatal error - impl. specific */ 442 #define XHCI_CODE_INVALID_SID 34 /* Invalid stream ID received */ 443 #define XHCI_CODE_SEC_BW 35 /* Cannot alloc secondary BW Domain */ 444 #define XHCI_CODE_SPLITERR 36 /* USB2 split transaction */ 445 446 #endif /* _XHCIREG_H_ */ 447