2 Private Header file for Usb Host Controller PEIM
4 Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions
8 of the BSD License which accompanies this distribution. The
9 full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _EFI_PEI_XHCI_REG_H_
18 #define _EFI_PEI_XHCI_REG_H_
21 // Capability registers offset
23 #define XHC_CAPLENGTH_OFFSET 0x00 // Capability register length offset
24 #define XHC_HCIVERSION_OFFSET 0x02 // Interface Version Number 02-03h
25 #define XHC_HCSPARAMS1_OFFSET 0x04 // Structural Parameters 1
26 #define XHC_HCSPARAMS2_OFFSET 0x08 // Structural Parameters 2
27 #define XHC_HCSPARAMS3_OFFSET 0x0c // Structural Parameters 3
28 #define XHC_HCCPARAMS_OFFSET 0x10 // Capability Parameters
29 #define XHC_DBOFF_OFFSET 0x14 // Doorbell Offset
30 #define XHC_RTSOFF_OFFSET 0x18 // Runtime Register Space Offset
33 // Operational registers offset
35 #define XHC_USBCMD_OFFSET 0x0000 // USB Command Register Offset
36 #define XHC_USBSTS_OFFSET 0x0004 // USB Status Register Offset
37 #define XHC_PAGESIZE_OFFSET 0x0008 // USB Page Size Register Offset
38 #define XHC_DNCTRL_OFFSET 0x0014 // Device Notification Control Register Offset
39 #define XHC_CRCR_OFFSET 0x0018 // Command Ring Control Register Offset
40 #define XHC_DCBAAP_OFFSET 0x0030 // Device Context Base Address Array Pointer Register Offset
41 #define XHC_CONFIG_OFFSET 0x0038 // Configure Register Offset
42 #define XHC_PORTSC_OFFSET 0x0400 // Port Status and Control Register Offset
45 // Runtime registers offset
47 #define XHC_MFINDEX_OFFSET 0x00 // Microframe Index Register Offset
48 #define XHC_IMAN_OFFSET 0x20 // Interrupter X Management Register Offset
49 #define XHC_IMOD_OFFSET 0x24 // Interrupter X Moderation Register Offset
50 #define XHC_ERSTSZ_OFFSET 0x28 // Event Ring Segment Table Size Register Offset
51 #define XHC_ERSTBA_OFFSET 0x30 // Event Ring Segment Table Base Address Register Offset
52 #define XHC_ERDP_OFFSET 0x38 // Event Ring Dequeue Pointer Register Offset
55 // Register Bit Definition
57 #define XHC_USBCMD_RUN BIT0 // Run/Stop
58 #define XHC_USBCMD_RESET BIT1 // Host Controller Reset
59 #define XHC_USBCMD_INTE BIT2 // Interrupter Enable
60 #define XHC_USBCMD_HSEE BIT3 // Host System Error Enable
62 #define XHC_USBSTS_HALT BIT0 // Host Controller Halted
63 #define XHC_USBSTS_HSE BIT2 // Host System Error
64 #define XHC_USBSTS_EINT BIT3 // Event Interrupt
65 #define XHC_USBSTS_PCD BIT4 // Port Change Detect
66 #define XHC_USBSTS_SSS BIT8 // Save State Status
67 #define XHC_USBSTS_RSS BIT9 // Restore State Status
68 #define XHC_USBSTS_SRE BIT10 // Save/Restore Error
69 #define XHC_USBSTS_CNR BIT11 // Host Controller Not Ready
70 #define XHC_USBSTS_HCE BIT12 // Host Controller Error
72 #define XHC_PAGESIZE_MASK 0xFFFF // Page Size
74 #define XHC_CRCR_RCS BIT0 // Ring Cycle State
75 #define XHC_CRCR_CS BIT1 // Command Stop
76 #define XHC_CRCR_CA BIT2 // Command Abort
77 #define XHC_CRCR_CRR BIT3 // Command Ring Running
79 #define XHC_CONFIG_MASK 0xFF // Max Device Slots Enabled
81 #define XHC_PORTSC_CCS BIT0 // Current Connect Status
82 #define XHC_PORTSC_PED BIT1 // Port Enabled/Disabled
83 #define XHC_PORTSC_OCA BIT3 // Over-current Active
84 #define XHC_PORTSC_RESET BIT4 // Port Reset
85 #define XHC_PORTSC_PLS (BIT5|BIT6|BIT7|BIT8) // Port Link State
86 #define XHC_PORTSC_PP BIT9 // Port Power
87 #define XHC_PORTSC_PS (BIT10|BIT11|BIT12) // Port Speed
88 #define XHC_PORTSC_LWS BIT16 // Port Link State Write Strobe
89 #define XHC_PORTSC_CSC BIT17 // Connect Status Change
90 #define XHC_PORTSC_PEC BIT18 // Port Enabled/Disabled Change
91 #define XHC_PORTSC_WRC BIT19 // Warm Port Reset Change
92 #define XHC_PORTSC_OCC BIT20 // Over-Current Change
93 #define XHC_PORTSC_PRC BIT21 // Port Reset Change
94 #define XHC_PORTSC_PLC BIT22 // Port Link State Change
95 #define XHC_PORTSC_CEC BIT23 // Port Config Error Change
96 #define XHC_PORTSC_CAS BIT24 // Cold Attach Status
98 #define XHC_HUB_PORTSC_CCS BIT0 // Hub's Current Connect Status
99 #define XHC_HUB_PORTSC_PED BIT1 // Hub's Port Enabled/Disabled
100 #define XHC_HUB_PORTSC_OCA BIT3 // Hub's Over-current Active
101 #define XHC_HUB_PORTSC_RESET BIT4 // Hub's Port Reset
102 #define XHC_HUB_PORTSC_PP BIT9 // Hub's Port Power
103 #define XHC_HUB_PORTSC_CSC BIT16 // Hub's Connect Status Change
104 #define XHC_HUB_PORTSC_PEC BIT17 // Hub's Port Enabled/Disabled Change
105 #define XHC_HUB_PORTSC_OCC BIT19 // Hub's Over-Current Change
106 #define XHC_HUB_PORTSC_PRC BIT20 // Hub's Port Reset Change
107 #define XHC_HUB_PORTSC_BHRC BIT21 // Hub's Port Warm Reset Change
109 #define XHC_IMAN_IP BIT0 // Interrupt Pending
110 #define XHC_IMAN_IE BIT1 // Interrupt Enable
112 #define XHC_IMODI_MASK 0x0000FFFF // Interrupt Moderation Interval
113 #define XHC_IMODC_MASK 0xFFFF0000 // Interrupt Moderation Counter
118 UINT8 MaxSlots
; // Number of Device Slots
119 UINT16 MaxIntrs
:11; // Number of Interrupters
121 UINT8 MaxPorts
; // Number of Ports
125 // Structural Parameters 1 Register Bitmap Definition
133 UINT32 Ist
:4; // Isochronous Scheduling Threshold
134 UINT32 Erst
:4; // Event Ring Segment Table Max
136 UINT32 ScratchBufHi
:5; // Max Scratchpad Buffers Hi
137 UINT32 Spr
:1; // Scratchpad Restore
138 UINT32 ScratchBufLo
:5; // Max Scratchpad Buffers Lo
142 // Structural Parameters 2 Register Bitmap Definition
150 UINT16 Ac64
:1; // 64-bit Addressing Capability
151 UINT16 Bnc
:1; // BW Negotiation Capability
152 UINT16 Csz
:1; // Context Size
153 UINT16 Ppc
:1; // Port Power Control
154 UINT16 Pind
:1; // Port Indicators
155 UINT16 Lhrc
:1; // Light HC Reset Capability
156 UINT16 Ltc
:1; // Latency Tolerance Messaging Capability
157 UINT16 Nss
:1; // No Secondary SID Support
158 UINT16 Pae
:1; // Parse All Event Data
160 UINT16 MaxPsaSize
:4; // Maximum Primary Stream Array Size
161 UINT16 ExtCapReg
; // xHCI Extended Capabilities Pointer
165 // Capability Parameters Register Bitmap Definition
175 // XHCi Data and Ctrl Structures
190 UINT8 HubContrCurrent
;
192 } EFI_USB_HUB_DESCRIPTOR
;
196 // Hub Class Feature Selector for Clear Port Feature Request
197 // It's the extension of hub class feature selector of USB 2.0 in USB 3.0 Spec.
198 // For more details, Please refer to USB 3.0 Spec Table 10-7.
201 Usb3PortBHPortReset
= 28,
202 Usb3PortBHPortResetChange
= 29
206 // Structure to map the hardware port states to the
207 // UEFI's port states.
212 } USB_PORT_STATE_MAP
;
215 // Structure to map the hardware port states to feature selector for clear port feature request.
220 } USB_CLEAR_PORT_MAP
;
223 Read XHCI Operation register.
225 @param Xhc The XHCI device.
226 @param Offset The operation register offset.
228 @retval the register content read.
238 Write the data to the XHCI operation register.
240 @param Xhc The XHCI device.
241 @param Offset The operation register offset.
242 @param Data The data to write.
253 Set one bit of the operational register while keeping other bits.
255 @param Xhc The XHCI device.
256 @param Offset The offset of the operational register.
257 @param Bit The bit mask of the register to set.
268 Clear one bit of the operational register while keeping other bits.
270 @param Xhc The XHCI device.
271 @param Offset The offset of the operational register.
272 @param Bit The bit mask of the register to clear.
276 XhcPeiClearOpRegBit (
283 Wait the operation register's bit as specified by Bit
284 to be set (or clear).
286 @param Xhc The XHCI device.
287 @param Offset The offset of the operational register.
288 @param Bit The bit of the register to wait for.
289 @param WaitToSet Wait the bit to set or clear.
290 @param Timeout The time to wait before abort (in millisecond, ms).
292 @retval EFI_SUCCESS The bit successfully changed by host controller.
293 @retval EFI_TIMEOUT The time out occurred.
301 IN BOOLEAN WaitToSet
,
306 Read XHCI door bell register.
308 @param Xhc The XHCI device.
309 @param Offset The offset of the door bell register.
311 @return The register content read
315 XhcPeiReadDoorBellReg (
321 Write the data to the XHCI door bell register.
323 @param Xhc The XHCI device.
324 @param Offset The offset of the door bell register.
325 @param Data The data to write.
329 XhcPeiWriteDoorBellReg (
336 Read XHCI runtime register.
338 @param Xhc The XHCI device.
339 @param Offset The offset of the runtime register.
341 @return The register content read
345 XhcPeiReadRuntimeReg (
351 Write the data to the XHCI runtime register.
353 @param Xhc The XHCI device.
354 @param Offset The offset of the runtime register.
355 @param Data The data to write.
359 XhcPeiWriteRuntimeReg (
366 Set one bit of the runtime register while keeping other bits.
368 @param Xhc The XHCI device.
369 @param Offset The offset of the runtime register.
370 @param Bit The bit mask of the register to set.
374 XhcPeiSetRuntimeRegBit (
381 Clear one bit of the runtime register while keeping other bits.
383 @param Xhc The XHCI device.
384 @param Offset The offset of the runtime register.
385 @param Bit The bit mask of the register to set.
389 XhcPeiClearRuntimeRegBit (
396 Check whether Xhc is halted.
398 @param Xhc The XHCI device.
400 @retval TRUE The controller is halted.
401 @retval FALSE The controller isn't halted.
410 Check whether system error occurred.
412 @param Xhc The XHCI device.
414 @retval TRUE System error happened.
415 @retval FALSE No system error.
424 Reset the host controller.
426 @param Xhc The XHCI device.
427 @param Timeout Time to wait before abort (in millisecond, ms).
429 @retval EFI_TIMEOUT The transfer failed due to time out.
430 @retval Others Failed to reset the host.
440 Halt the host controller.
442 @param Xhc The XHCI device.
443 @param Timeout Time to wait before abort.
445 @retval EFI_TIMEOUT Failed to halt the controller before Timeout.
446 @retval EFI_SUCCESS The XHCI is halt.
458 @param Xhc The XHCI device.
459 @param Timeout Time to wait before abort.
461 @retval EFI_SUCCESS The XHCI is running.
462 @retval Others Failed to set the XHCI to run.