TianoCore EDK2 master
Loading...
Searching...
No Matches
XhciReg.c File Reference
#include "Xhci.h"

Go to the source code of this file.

Functions

UINT8 XhcReadCapReg8 (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset)
 
UINT32 XhcReadCapReg (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset)
 
UINT32 XhcReadOpReg (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset)
 
VOID XhcWriteOpReg (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Data)
 
VOID XhcWriteDoorBellReg (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Data)
 
UINT32 XhcReadRuntimeReg (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset)
 
VOID XhcWriteRuntimeReg (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Data)
 
UINT32 XhcReadExtCapReg (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset)
 
VOID XhcWriteExtCapReg (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Data)
 
VOID XhcSetRuntimeRegBit (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Bit)
 
VOID XhcClearRuntimeRegBit (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Bit)
 
VOID XhcSetOpRegBit (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Bit)
 
VOID XhcClearOpRegBit (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Bit)
 
EFI_STATUS XhcWaitOpRegBit (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Bit, IN BOOLEAN WaitToSet, IN UINT32 Timeout)
 
VOID XhcSetBiosOwnership (IN USB_XHCI_INSTANCE *Xhc)
 
VOID XhcClearBiosOwnership (IN USB_XHCI_INSTANCE *Xhc)
 
UINT32 XhcGetCapabilityAddr (IN USB_XHCI_INSTANCE *Xhc, IN UINT8 CapId)
 
UINT32 XhcGetSupportedProtocolCapabilityAddr (IN USB_XHCI_INSTANCE *Xhc, IN UINT8 MajorVersion)
 
UINT32 XhciPsivGetPsid (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 ExtCapOffset, IN UINT8 PortSpeed, IN UINT8 PortNumber)
 
UINT16 XhcCheckUsbPortSpeedUsedPsic (IN USB_XHCI_INSTANCE *Xhc, IN UINT8 PortSpeed, IN UINT8 PortNumber)
 
BOOLEAN XhcIsHalt (IN USB_XHCI_INSTANCE *Xhc)
 
BOOLEAN XhcIsSysError (IN USB_XHCI_INSTANCE *Xhc)
 
VOID XhcSetHsee (IN USB_XHCI_INSTANCE *Xhc)
 
EFI_STATUS XhcResetHC (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Timeout)
 
EFI_STATUS XhcHaltHC (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Timeout)
 
EFI_STATUS XhcRunHC (IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Timeout)
 

Detailed Description

The XHCI register operation routines.

(C) Copyright 2023 Hewlett Packard Enterprise Development LP
Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file XhciReg.c.

Function Documentation

◆ XhcCheckUsbPortSpeedUsedPsic()

UINT16 XhcCheckUsbPortSpeedUsedPsic ( IN USB_XHCI_INSTANCE Xhc,
IN UINT8  PortSpeed,
IN UINT8  PortNumber 
)

Find PortSpeed value match case in XHCI Supported Protocol Capability

Parameters
XhcThe XHCI Instance.
PortSpeedThe Port Speed Field in USB PortSc register
PortNumberThe Port Number (0-indexed)
Returns
The USB Port Speed.

Definition at line 690 of file XhciReg.c.

◆ XhcClearBiosOwnership()

VOID XhcClearBiosOwnership ( IN USB_XHCI_INSTANCE Xhc)

Clear Bios Ownership

Parameters
XhcThe XHCI Instance.

Definition at line 503 of file XhciReg.c.

◆ XhcClearOpRegBit()

VOID XhcClearOpRegBit ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset,
IN UINT32  Bit 
)

Clear one bit of the operational register while keeping other bits.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the operational register.
BitThe bit mask of the register to clear.

Definition at line 406 of file XhciReg.c.

◆ XhcClearRuntimeRegBit()

VOID XhcClearRuntimeRegBit ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset,
IN UINT32  Bit 
)

Clear one bit of the runtime register while keeping other bits.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the runtime register.
BitThe bit mask of the register to set.

Definition at line 362 of file XhciReg.c.

◆ XhcGetCapabilityAddr()

UINT32 XhcGetCapabilityAddr ( IN USB_XHCI_INSTANCE Xhc,
IN UINT8  CapId 
)

Calculate the offset of the XHCI capability.

Parameters
XhcThe XHCI Instance.
CapIdThe XHCI Capability ID.
Returns
The offset of XHCI legacy support capability register.

Definition at line 530 of file XhciReg.c.

◆ XhcGetSupportedProtocolCapabilityAddr()

UINT32 XhcGetSupportedProtocolCapabilityAddr ( IN USB_XHCI_INSTANCE Xhc,
IN UINT8  MajorVersion 
)

Calculate the offset of the xHCI Supported Protocol Capability.

Parameters
XhcThe XHCI Instance.
MajorVersionThe USB Major Version in xHCI Support Protocol Capability Field
Returns
The offset of xHCI Supported Protocol capability register.

Definition at line 570 of file XhciReg.c.

◆ XhcHaltHC()

EFI_STATUS XhcHaltHC ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Timeout 
)

Halt the XHCI host controller.

Parameters
XhcThe XHCI Instance.
TimeoutTime to wait before abort (in millisecond, ms).
Returns
EFI_SUCCESS The XHCI host controller is halt.
EFI_TIMEOUT Failed to halt the XHCI before Timeout.

Definition at line 895 of file XhciReg.c.

◆ XhciPsivGetPsid()

UINT32 XhciPsivGetPsid ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  ExtCapOffset,
IN UINT8  PortSpeed,
IN UINT8  PortNumber 
)

Find PortSpeed value match Protocol Speed ID Value (PSIV).

Parameters
XhcThe XHCI Instance.
ExtCapOffsetThe USB Major Version in xHCI Support Protocol Capability Field
PortSpeedThe Port Speed Field in USB PortSc register
PortNumberThe Port Number (0-indexed)
Returns
The Protocol Speed ID (PSI) from xHCI Supported Protocol capability register.

Definition at line 627 of file XhciReg.c.

◆ XhcIsHalt()

BOOLEAN XhcIsHalt ( IN USB_XHCI_INSTANCE Xhc)

Whether the XHCI host controller is halted.

Parameters
XhcThe XHCI Instance.
Return values
TRUEThe controller is halted.
FALSEIt isn't halted.

Definition at line 771 of file XhciReg.c.

◆ XhcIsSysError()

BOOLEAN XhcIsSysError ( IN USB_XHCI_INSTANCE Xhc)

Whether system error occurred.

Parameters
XhcThe XHCI Instance.
Return values
TRUESystem error happened.
FALSENo system error.

Definition at line 788 of file XhciReg.c.

◆ XhcReadCapReg()

UINT32 XhcReadCapReg ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset 
)

Read 4-bytes width XHCI capability register.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the 4-bytes width capability register.
Returns
The register content read.
Return values
Iferr, return 0xFFFFFFFF.

Definition at line 62 of file XhciReg.c.

◆ XhcReadCapReg8()

UINT8 XhcReadCapReg8 ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset 
)

Read 1-byte width XHCI capability register.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the 1-byte width capability register.
Returns
The register content read.
Return values
Iferr, return 0xFF.

Definition at line 24 of file XhciReg.c.

◆ XhcReadExtCapReg()

UINT32 XhcReadExtCapReg ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset 
)

Read XHCI extended capability register.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the extended capability register.
Returns
The register content read

Definition at line 271 of file XhciReg.c.

◆ XhcReadOpReg()

UINT32 XhcReadOpReg ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset 
)

Read 4-bytes width XHCI Operational register.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the 4-bytes width operational register.
Returns
The register content read.
Return values
Iferr, return 0xFFFFFFFF.

Definition at line 98 of file XhciReg.c.

◆ XhcReadRuntimeReg()

UINT32 XhcReadRuntimeReg ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset 
)

Read XHCI runtime register.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the runtime register.
Returns
The register content read

Definition at line 201 of file XhciReg.c.

◆ XhcResetHC()

EFI_STATUS XhcResetHC ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Timeout 
)

Reset the XHCI host controller.

Parameters
XhcThe XHCI Instance.
TimeoutTime to wait before abort (in millisecond, ms).
Return values
EFI_SUCCESSThe XHCI host controller is reset.
Returns
Others Failed to reset the XHCI before Timeout.

Definition at line 839 of file XhciReg.c.

◆ XhcRunHC()

EFI_STATUS XhcRunHC ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Timeout 
)

Set the XHCI host controller to run.

Parameters
XhcThe XHCI Instance.
TimeoutTime to wait before abort (in millisecond, ms).
Returns
EFI_SUCCESS The XHCI host controller is running.
EFI_TIMEOUT Failed to set the XHCI to run before Timeout.

Definition at line 918 of file XhciReg.c.

◆ XhcSetBiosOwnership()

VOID XhcSetBiosOwnership ( IN USB_XHCI_INSTANCE Xhc)

Set Bios Ownership

Parameters
XhcThe XHCI Instance.

Definition at line 479 of file XhciReg.c.

◆ XhcSetHsee()

VOID XhcSetHsee ( IN USB_XHCI_INSTANCE Xhc)

Set USBCMD Host System Error Enable(HSEE) Bit if PCICMD SERR# Enable Bit is set.

The USBCMD HSEE Bit will be reset to default 0 by USBCMD Host Controller Reset(HCRST). This function is to set USBCMD HSEE Bit if PCICMD SERR# Enable Bit is set.

Parameters
XhcThe XHCI Instance.

Definition at line 805 of file XhciReg.c.

◆ XhcSetOpRegBit()

VOID XhcSetOpRegBit ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset,
IN UINT32  Bit 
)

Set one bit of the operational register while keeping other bits.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the operational register.
BitThe bit mask of the register to set.

Definition at line 384 of file XhciReg.c.

◆ XhcSetRuntimeRegBit()

VOID XhcSetRuntimeRegBit ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset,
IN UINT32  Bit 
)

Set one bit of the runtime register while keeping other bits.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the runtime register.
BitThe bit mask of the register to set.

Definition at line 340 of file XhciReg.c.

◆ XhcWaitOpRegBit()

EFI_STATUS XhcWaitOpRegBit ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset,
IN UINT32  Bit,
IN BOOLEAN  WaitToSet,
IN UINT32  Timeout 
)

Wait the operation register's bit as specified by Bit to become set (or clear).

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the operation register.
BitThe bit of the register to wait for.
WaitToSetWait the bit to set or clear.
TimeoutThe time to wait before abort (in millisecond, ms).
Return values
EFI_SUCCESSThe bit successfully changed by host controller.
EFI_TIMEOUTThe time out occurred.

Definition at line 434 of file XhciReg.c.

◆ XhcWriteDoorBellReg()

VOID XhcWriteDoorBellReg ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset,
IN UINT32  Data 
)

Write the data to the XHCI door bell register.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the door bell register.
DataThe data to write.

Definition at line 167 of file XhciReg.c.

◆ XhcWriteExtCapReg()

VOID XhcWriteExtCapReg ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset,
IN UINT32  Data 
)

Write the data to the XHCI extended capability register.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the extended capability register.
DataThe data to write.

Definition at line 307 of file XhciReg.c.

◆ XhcWriteOpReg()

VOID XhcWriteOpReg ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset,
IN UINT32  Data 
)

Write the data to the 4-bytes width XHCI operational register.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the 4-bytes width operational register.
DataThe data to write.

Definition at line 134 of file XhciReg.c.

◆ XhcWriteRuntimeReg()

VOID XhcWriteRuntimeReg ( IN USB_XHCI_INSTANCE Xhc,
IN UINT32  Offset,
IN UINT32  Data 
)

Write the data to the XHCI runtime register.

Parameters
XhcThe XHCI Instance.
OffsetThe offset of the runtime register.
DataThe data to write.

Definition at line 237 of file XhciReg.c.