TianoCore EDK2 master
Loading...
Searching...
No Matches
XhciReg.h
Go to the documentation of this file.
1
10#ifndef _EFI_PEI_XHCI_REG_H_
11#define _EFI_PEI_XHCI_REG_H_
12
13//
14// Capability registers offset
15//
16#define XHC_CAPLENGTH_OFFSET 0x00 // Capability register length offset
17#define XHC_HCIVERSION_OFFSET 0x02 // Interface Version Number 02-03h
18#define XHC_HCSPARAMS1_OFFSET 0x04 // Structural Parameters 1
19#define XHC_HCSPARAMS2_OFFSET 0x08 // Structural Parameters 2
20#define XHC_HCSPARAMS3_OFFSET 0x0c // Structural Parameters 3
21#define XHC_HCCPARAMS_OFFSET 0x10 // Capability Parameters
22#define XHC_DBOFF_OFFSET 0x14 // Doorbell Offset
23#define XHC_RTSOFF_OFFSET 0x18 // Runtime Register Space Offset
24
25//
26// Operational registers offset
27//
28#define XHC_USBCMD_OFFSET 0x0000 // USB Command Register Offset
29#define XHC_USBSTS_OFFSET 0x0004 // USB Status Register Offset
30#define XHC_PAGESIZE_OFFSET 0x0008 // USB Page Size Register Offset
31#define XHC_DNCTRL_OFFSET 0x0014 // Device Notification Control Register Offset
32#define XHC_CRCR_OFFSET 0x0018 // Command Ring Control Register Offset
33#define XHC_DCBAAP_OFFSET 0x0030 // Device Context Base Address Array Pointer Register Offset
34#define XHC_CONFIG_OFFSET 0x0038 // Configure Register Offset
35#define XHC_PORTSC_OFFSET 0x0400 // Port Status and Control Register Offset
36
37//
38// Runtime registers offset
39//
40#define XHC_MFINDEX_OFFSET 0x00 // Microframe Index Register Offset
41#define XHC_IMAN_OFFSET 0x20 // Interrupter X Management Register Offset
42#define XHC_IMOD_OFFSET 0x24 // Interrupter X Moderation Register Offset
43#define XHC_ERSTSZ_OFFSET 0x28 // Event Ring Segment Table Size Register Offset
44#define XHC_ERSTBA_OFFSET 0x30 // Event Ring Segment Table Base Address Register Offset
45#define XHC_ERDP_OFFSET 0x38 // Event Ring Dequeue Pointer Register Offset
46
47//
48// Register Bit Definition
49//
50#define XHC_USBCMD_RUN BIT0 // Run/Stop
51#define XHC_USBCMD_RESET BIT1 // Host Controller Reset
52#define XHC_USBCMD_INTE BIT2 // Interrupter Enable
53#define XHC_USBCMD_HSEE BIT3 // Host System Error Enable
54
55#define XHC_USBSTS_HALT BIT0 // Host Controller Halted
56#define XHC_USBSTS_HSE BIT2 // Host System Error
57#define XHC_USBSTS_EINT BIT3 // Event Interrupt
58#define XHC_USBSTS_PCD BIT4 // Port Change Detect
59#define XHC_USBSTS_SSS BIT8 // Save State Status
60#define XHC_USBSTS_RSS BIT9 // Restore State Status
61#define XHC_USBSTS_SRE BIT10 // Save/Restore Error
62#define XHC_USBSTS_CNR BIT11 // Host Controller Not Ready
63#define XHC_USBSTS_HCE BIT12 // Host Controller Error
64
65#define XHC_PAGESIZE_MASK 0xFFFF // Page Size
66
67#define XHC_CRCR_RCS BIT0 // Ring Cycle State
68#define XHC_CRCR_CS BIT1 // Command Stop
69#define XHC_CRCR_CA BIT2 // Command Abort
70#define XHC_CRCR_CRR BIT3 // Command Ring Running
71
72#define XHC_CONFIG_MASK 0xFF // Max Device Slots Enabled
73
74#define XHC_PORTSC_CCS BIT0 // Current Connect Status
75#define XHC_PORTSC_PED BIT1 // Port Enabled/Disabled
76#define XHC_PORTSC_OCA BIT3 // Over-current Active
77#define XHC_PORTSC_RESET BIT4 // Port Reset
78#define XHC_PORTSC_PLS (BIT5|BIT6|BIT7|BIT8) // Port Link State
79#define XHC_PORTSC_PP BIT9 // Port Power
80#define XHC_PORTSC_PS (BIT10|BIT11|BIT12|BIT13) // Port Speed
81#define XHC_PORTSC_LWS BIT16 // Port Link State Write Strobe
82#define XHC_PORTSC_CSC BIT17 // Connect Status Change
83#define XHC_PORTSC_PEC BIT18 // Port Enabled/Disabled Change
84#define XHC_PORTSC_WRC BIT19 // Warm Port Reset Change
85#define XHC_PORTSC_OCC BIT20 // Over-Current Change
86#define XHC_PORTSC_PRC BIT21 // Port Reset Change
87#define XHC_PORTSC_PLC BIT22 // Port Link State Change
88#define XHC_PORTSC_CEC BIT23 // Port Config Error Change
89#define XHC_PORTSC_CAS BIT24 // Cold Attach Status
90
91#define XHC_HUB_PORTSC_CCS BIT0 // Hub's Current Connect Status
92#define XHC_HUB_PORTSC_PED BIT1 // Hub's Port Enabled/Disabled
93#define XHC_HUB_PORTSC_OCA BIT3 // Hub's Over-current Active
94#define XHC_HUB_PORTSC_RESET BIT4 // Hub's Port Reset
95#define XHC_HUB_PORTSC_PP BIT9 // Hub's Port Power
96#define XHC_HUB_PORTSC_CSC BIT16 // Hub's Connect Status Change
97#define XHC_HUB_PORTSC_PEC BIT17 // Hub's Port Enabled/Disabled Change
98#define XHC_HUB_PORTSC_OCC BIT19 // Hub's Over-Current Change
99#define XHC_HUB_PORTSC_PRC BIT20 // Hub's Port Reset Change
100#define XHC_HUB_PORTSC_BHRC BIT21 // Hub's Port Warm Reset Change
101
102#define XHC_IMAN_IP BIT0 // Interrupt Pending
103#define XHC_IMAN_IE BIT1 // Interrupt Enable
104
105#define XHC_IMODI_MASK 0x0000FFFF // Interrupt Moderation Interval
106#define XHC_IMODC_MASK 0xFFFF0000 // Interrupt Moderation Counter
107
108#pragma pack (1)
109typedef struct {
110 UINT8 MaxSlots; // Number of Device Slots
111 UINT16 MaxIntrs : 11; // Number of Interrupters
112 UINT16 Rsvd : 5;
113 UINT8 MaxPorts; // Number of Ports
114} HCSPARAMS1;
115
116//
117// Structural Parameters 1 Register Bitmap Definition
118//
119typedef union {
120 UINT32 Dword;
121 HCSPARAMS1 Data;
123
124typedef struct {
125 UINT32 Ist : 4; // Isochronous Scheduling Threshold
126 UINT32 Erst : 4; // Event Ring Segment Table Max
127 UINT32 Rsvd : 13;
128 UINT32 ScratchBufHi : 5; // Max Scratchpad Buffers Hi
129 UINT32 Spr : 1; // Scratchpad Restore
130 UINT32 ScratchBufLo : 5; // Max Scratchpad Buffers Lo
131} HCSPARAMS2;
132
133//
134// Structural Parameters 2 Register Bitmap Definition
135//
136typedef union {
137 UINT32 Dword;
138 HCSPARAMS2 Data;
140
141typedef struct {
142 UINT16 Ac64 : 1; // 64-bit Addressing Capability
143 UINT16 Bnc : 1; // BW Negotiation Capability
144 UINT16 Csz : 1; // Context Size
145 UINT16 Ppc : 1; // Port Power Control
146 UINT16 Pind : 1; // Port Indicators
147 UINT16 Lhrc : 1; // Light HC Reset Capability
148 UINT16 Ltc : 1; // Latency Tolerance Messaging Capability
149 UINT16 Nss : 1; // No Secondary SID Support
150 UINT16 Pae : 1; // Parse All Event Data
151 UINT16 Rsvd : 3;
152 UINT16 MaxPsaSize : 4; // Maximum Primary Stream Array Size
153 UINT16 ExtCapReg; // xHCI Extended Capabilities Pointer
154} HCCPARAMS;
155
156//
157// Capability Parameters Register Bitmap Definition
158//
159typedef union {
160 UINT32 Dword;
161 HCCPARAMS Data;
163
164#pragma pack ()
165
166//
167// XHCi Data and Ctrl Structures
168//
169#pragma pack(1)
170typedef struct {
171 UINT8 Pi;
172 UINT8 SubClassCode;
173 UINT8 BaseCode;
174} USB_CLASSC;
175
176typedef struct {
177 UINT8 Length;
178 UINT8 DescType;
179 UINT8 NumPorts;
180 UINT16 HubCharacter;
181 UINT8 PwrOn2PwrGood;
182 UINT8 HubContrCurrent;
183 UINT8 Filler[16];
185#pragma pack()
186
187//
188// Hub Class Feature Selector for Clear Port Feature Request
189// It's the extension of hub class feature selector of USB 2.0 in USB 3.0 Spec.
190// For more details, Please refer to USB 3.0 Spec Table 10-7.
191//
192typedef enum {
193 Usb3PortBHPortReset = 28,
194 Usb3PortBHPortResetChange = 29
195} XHC_PORT_FEATURE;
196
197//
198// Structure to map the hardware port states to the
199// UEFI's port states.
200//
201typedef struct {
202 UINT32 HwState;
203 UINT16 UefiState;
205
206//
207// Structure to map the hardware port states to feature selector for clear port feature request.
208//
209typedef struct {
210 UINT32 HwState;
211 UINT16 Selector;
213
223UINT32
225 IN PEI_XHC_DEV *Xhc,
226 IN UINT32 Offset
227 );
228
237VOID
239 IN PEI_XHC_DEV *Xhc,
240 IN UINT32 Offset,
241 IN UINT32 Data
242 );
243
252VOID
254 IN PEI_XHC_DEV *Xhc,
255 IN UINT32 Offset,
256 IN UINT32 Bit
257 );
258
267VOID
269 IN PEI_XHC_DEV *Xhc,
270 IN UINT32 Offset,
271 IN UINT32 Bit
272 );
273
290 IN PEI_XHC_DEV *Xhc,
291 IN UINT32 Offset,
292 IN UINT32 Bit,
293 IN BOOLEAN WaitToSet,
294 IN UINT32 Timeout
295 );
296
305VOID
307 IN PEI_XHC_DEV *Xhc,
308 IN UINT32 Offset,
309 IN UINT32 Data
310 );
311
321UINT32
323 IN PEI_XHC_DEV *Xhc,
324 IN UINT32 Offset
325 );
326
335VOID
337 IN PEI_XHC_DEV *Xhc,
338 IN UINT32 Offset,
339 IN UINT32 Data
340 );
341
350VOID
352 IN PEI_XHC_DEV *Xhc,
353 IN UINT32 Offset,
354 IN UINT32 Bit
355 );
356
365VOID
367 IN PEI_XHC_DEV *Xhc,
368 IN UINT32 Offset,
369 IN UINT32 Bit
370 );
371
381BOOLEAN
383 IN PEI_XHC_DEV *Xhc
384 );
385
395BOOLEAN
397 IN PEI_XHC_DEV *Xhc
398 );
399
412 IN PEI_XHC_DEV *Xhc,
413 IN UINT32 Timeout
414 );
415
428 IN PEI_XHC_DEV *Xhc,
429 IN UINT32 Timeout
430 );
431
444 IN PEI_XHC_DEV *Xhc,
445 IN UINT32 Timeout
446 );
447
448#endif
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID XhcPeiSetOpRegBit(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Bit)
Definition: XhcPeim.c:114
BOOLEAN XhcPeiIsHalt(IN PEI_XHC_DEV *Xhc)
Definition: XhcPeim.c:325
VOID XhcPeiClearRuntimeRegBit(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Bit)
Definition: XhcPeim.c:302
UINT32 XhcPeiReadOpReg(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset)
Definition: XhcPeim.c:72
EFI_STATUS XhcPeiRunHC(IN PEI_XHC_DEV *Xhc, IN UINT32 Timeout)
Definition: XhcPeim.c:426
EFI_STATUS XhcPeiHaltHC(IN PEI_XHC_DEV *Xhc, IN UINT32 Timeout)
Definition: XhcPeim.c:402
EFI_STATUS XhcPeiWaitOpRegBit(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Bit, IN BOOLEAN WaitToSet, IN UINT32 Timeout)
Definition: XhcPeim.c:164
BOOLEAN XhcPeiIsSysError(IN PEI_XHC_DEV *Xhc)
Definition: XhcPeim.c:342
VOID XhcPeiWriteOpReg(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Data)
Definition: XhcPeim.c:94
VOID XhcPeiSetRuntimeRegBit(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Bit)
Definition: XhcPeim.c:280
UINT32 XhcPeiReadRuntimeReg(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset)
Definition: XhcPeim.c:237
VOID XhcPeiClearOpRegBit(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Bit)
Definition: XhcPeim.c:136
EFI_STATUS XhcPeiResetHC(IN PEI_XHC_DEV *Xhc, IN UINT32 Timeout)
Definition: XhcPeim.c:360
VOID XhcPeiWriteDoorBellReg(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Data)
Definition: XhcPeim.c:216
VOID XhcPeiWriteRuntimeReg(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Data)
Definition: XhcPeim.c:260