xref: /openbmc/linux/drivers/usb/host/xhci-caps.h (revision 66e56efc)
1*66e56efcSFrank Li /* SPDX-License-Identifier: GPL-2.0 */
2*66e56efcSFrank Li 
3*66e56efcSFrank Li /* hc_capbase bitmasks */
4*66e56efcSFrank Li /* bits 7:0 - how long is the Capabilities register */
5*66e56efcSFrank Li #define HC_LENGTH(p)		XHCI_HC_LENGTH(p)
6*66e56efcSFrank Li /* bits 31:16	*/
7*66e56efcSFrank Li #define HC_VERSION(p)		(((p) >> 16) & 0xffff)
8*66e56efcSFrank Li 
9*66e56efcSFrank Li /* HCSPARAMS1 - hcs_params1 - bitmasks */
10*66e56efcSFrank Li /* bits 0:7, Max Device Slots */
11*66e56efcSFrank Li #define HCS_MAX_SLOTS(p)	(((p) >> 0) & 0xff)
12*66e56efcSFrank Li #define HCS_SLOTS_MASK		0xff
13*66e56efcSFrank Li /* bits 8:18, Max Interrupters */
14*66e56efcSFrank Li #define HCS_MAX_INTRS(p)	(((p) >> 8) & 0x7ff)
15*66e56efcSFrank Li /* bits 24:31, Max Ports - max value is 0x7F = 127 ports */
16*66e56efcSFrank Li #define HCS_MAX_PORTS(p)	(((p) >> 24) & 0x7f)
17*66e56efcSFrank Li 
18*66e56efcSFrank Li /* HCSPARAMS2 - hcs_params2 - bitmasks */
19*66e56efcSFrank Li /* bits 0:3, frames or uframes that SW needs to queue transactions
20*66e56efcSFrank Li  * ahead of the HW to meet periodic deadlines */
21*66e56efcSFrank Li #define HCS_IST(p)		(((p) >> 0) & 0xf)
22*66e56efcSFrank Li /* bits 4:7, max number of Event Ring segments */
23*66e56efcSFrank Li #define HCS_ERST_MAX(p)		(((p) >> 4) & 0xf)
24*66e56efcSFrank Li /* bits 21:25 Hi 5 bits of Scratchpad buffers SW must allocate for the HW */
25*66e56efcSFrank Li /* bit 26 Scratchpad restore - for save/restore HW state - not used yet */
26*66e56efcSFrank Li /* bits 27:31 Lo 5 bits of Scratchpad buffers SW must allocate for the HW */
27*66e56efcSFrank Li #define HCS_MAX_SCRATCHPAD(p)   ((((p) >> 16) & 0x3e0) | (((p) >> 27) & 0x1f))
28*66e56efcSFrank Li 
29*66e56efcSFrank Li /* HCSPARAMS3 - hcs_params3 - bitmasks */
30*66e56efcSFrank Li /* bits 0:7, Max U1 to U0 latency for the roothub ports */
31*66e56efcSFrank Li #define HCS_U1_LATENCY(p)	(((p) >> 0) & 0xff)
32*66e56efcSFrank Li /* bits 16:31, Max U2 to U0 latency for the roothub ports */
33*66e56efcSFrank Li #define HCS_U2_LATENCY(p)	(((p) >> 16) & 0xffff)
34*66e56efcSFrank Li 
35*66e56efcSFrank Li /* HCCPARAMS - hcc_params - bitmasks */
36*66e56efcSFrank Li /* true: HC can use 64-bit address pointers */
37*66e56efcSFrank Li #define HCC_64BIT_ADDR(p)	((p) & (1 << 0))
38*66e56efcSFrank Li /* true: HC can do bandwidth negotiation */
39*66e56efcSFrank Li #define HCC_BANDWIDTH_NEG(p)	((p) & (1 << 1))
40*66e56efcSFrank Li /* true: HC uses 64-byte Device Context structures
41*66e56efcSFrank Li  * FIXME 64-byte context structures aren't supported yet.
42*66e56efcSFrank Li  */
43*66e56efcSFrank Li #define HCC_64BYTE_CONTEXT(p)	((p) & (1 << 2))
44*66e56efcSFrank Li /* true: HC has port power switches */
45*66e56efcSFrank Li #define HCC_PPC(p)		((p) & (1 << 3))
46*66e56efcSFrank Li /* true: HC has port indicators */
47*66e56efcSFrank Li #define HCS_INDICATOR(p)	((p) & (1 << 4))
48*66e56efcSFrank Li /* true: HC has Light HC Reset Capability */
49*66e56efcSFrank Li #define HCC_LIGHT_RESET(p)	((p) & (1 << 5))
50*66e56efcSFrank Li /* true: HC supports latency tolerance messaging */
51*66e56efcSFrank Li #define HCC_LTC(p)		((p) & (1 << 6))
52*66e56efcSFrank Li /* true: no secondary Stream ID Support */
53*66e56efcSFrank Li #define HCC_NSS(p)		((p) & (1 << 7))
54*66e56efcSFrank Li /* true: HC supports Stopped - Short Packet */
55*66e56efcSFrank Li #define HCC_SPC(p)		((p) & (1 << 9))
56*66e56efcSFrank Li /* true: HC has Contiguous Frame ID Capability */
57*66e56efcSFrank Li #define HCC_CFC(p)		((p) & (1 << 11))
58*66e56efcSFrank Li /* Max size for Primary Stream Arrays - 2^(n+1), where n is bits 12:15 */
59*66e56efcSFrank Li #define HCC_MAX_PSA(p)		(1 << ((((p) >> 12) & 0xf) + 1))
60*66e56efcSFrank Li /* Extended Capabilities pointer from PCI base - section 5.3.6 */
61*66e56efcSFrank Li #define HCC_EXT_CAPS(p)		XHCI_HCC_EXT_CAPS(p)
62*66e56efcSFrank Li 
63*66e56efcSFrank Li #define CTX_SIZE(_hcc)		(HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32)
64*66e56efcSFrank Li 
65*66e56efcSFrank Li /* db_off bitmask - bits 0:1 reserved */
66*66e56efcSFrank Li #define	DBOFF_MASK	(~0x3)
67*66e56efcSFrank Li 
68*66e56efcSFrank Li /* run_regs_off bitmask - bits 0:4 reserved */
69*66e56efcSFrank Li #define	RTSOFF_MASK	(~0x1f)
70*66e56efcSFrank Li 
71*66e56efcSFrank Li /* HCCPARAMS2 - hcc_params2 - bitmasks */
72*66e56efcSFrank Li /* true: HC supports U3 entry Capability */
73*66e56efcSFrank Li #define	HCC2_U3C(p)		((p) & (1 << 0))
74*66e56efcSFrank Li /* true: HC supports Configure endpoint command Max exit latency too large */
75*66e56efcSFrank Li #define	HCC2_CMC(p)		((p) & (1 << 1))
76*66e56efcSFrank Li /* true: HC supports Force Save context Capability */
77*66e56efcSFrank Li #define	HCC2_FSC(p)		((p) & (1 << 2))
78*66e56efcSFrank Li /* true: HC supports Compliance Transition Capability */
79*66e56efcSFrank Li #define	HCC2_CTC(p)		((p) & (1 << 3))
80*66e56efcSFrank Li /* true: HC support Large ESIT payload Capability > 48k */
81*66e56efcSFrank Li #define	HCC2_LEC(p)		((p) & (1 << 4))
82*66e56efcSFrank Li /* true: HC support Configuration Information Capability */
83*66e56efcSFrank Li #define	HCC2_CIC(p)		((p) & (1 << 5))
84*66e56efcSFrank Li /* true: HC support Extended TBC Capability, Isoc burst count > 65535 */
85*66e56efcSFrank Li #define	HCC2_ETC(p)		((p) & (1 << 6))
86