31 Status = Ehc->PciIo->Mem.Read (
40 if (EFI_ERROR (Status)) {
41 DEBUG ((DEBUG_ERROR,
"EhcReadCapRegister: Pci Io read error - %r at %d\n", Status, Offset));
67 Status = Ehc->PciIo->Mem.Read (
71 Ehc->DebugPortOffset + Offset,
76 if (EFI_ERROR (Status)) {
77 DEBUG ((DEBUG_ERROR,
"EhcReadDbgRegister: Pci Io read error - %r at %d\n", Status, Offset));
106 IN CONST UINT8 *PortNumber OPTIONAL
111 if (Ehc->DebugPortNum == 0) {
121 if ((PortNumber !=
NULL) && (*PortNumber != Ehc->DebugPortNum - 1)) {
133 return (State & USB_DEBUG_PORT_IN_USE_MASK) == USB_DEBUG_PORT_IN_USE_MASK;
155 ASSERT (Ehc->CapLen != 0);
157 Status = Ehc->PciIo->Mem.Read (
161 Ehc->CapLen + Offset,
166 if (EFI_ERROR (Status)) {
167 DEBUG ((DEBUG_ERROR,
"EhcReadOpReg: Pci Io Read error - %r at %d\n", Status, Offset));
191 ASSERT (Ehc->CapLen != 0);
193 Status = Ehc->PciIo->Mem.Write (
197 Ehc->CapLen + Offset,
202 if (EFI_ERROR (Status)) {
203 DEBUG ((DEBUG_ERROR,
"EhcWriteOpReg: Pci Io Write error: %r at %d\n", Status, Offset));
270 IN BOOLEAN WaitToSet,
276 for (Index = 0; Index < Timeout / EHC_SYNC_POLL_INTERVAL + 1; Index++) {
277 if (EHC_REG_BIT_IS_SET (Ehc, Offset, Bit) == WaitToSet) {
281 gBS->Stall (EHC_SYNC_POLL_INTERVAL);
304 DEBUG ((DEBUG_INFO,
"EhcClearLegacySupport: called to clear legacy support\n"));
307 ExtendCap = (Ehc->HcCapParams >> 8) & 0xFF;
309 PciIo->Pci.
Read (PciIo, EfiPciIoWidthUint32, ExtendCap, 1, &Value);
310 PciIo->Pci.
Read (PciIo, EfiPciIoWidthUint32, ExtendCap + 0x4, 1, &Value);
312 PciIo->Pci.
Read (PciIo, EfiPciIoWidthUint32, ExtendCap, 1, &Value);
313 Value |= (0x1 << 24);
314 PciIo->Pci.
Write (PciIo, EfiPciIoWidthUint32, ExtendCap, 1, &Value);
317 while (TimeOut-- != 0) {
320 PciIo->Pci.
Read (PciIo, EfiPciIoWidthUint32, ExtendCap, 1, &Value);
322 if ((Value & 0x01010000) == 0x01000000) {
327 PciIo->Pci.
Read (PciIo, EfiPciIoWidthUint32, ExtendCap, 1, &Value);
328 PciIo->Pci.
Read (PciIo, EfiPciIoWidthUint32, ExtendCap + 0x4, 1, &Value);
360 Data &= ~USBSTS_INTACK_MASK;
446 return EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT);
463 return EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_SYS_ERROR);
487 if (!EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT)) {
490 if (EFI_ERROR (Status)) {
579 if (Ehc->PeriodFrame !=
NULL) {
585 if (EFI_ERROR (Status)) {
602 if (Ehc->HcStructParams & HCSP_PPC) {
603 for (Index = 0; Index < (UINT8)(Ehc->HcStructParams & HCSP_NPORTS); Index++) {
608 RegVal =
EhcReadOpReg (Ehc, (UINT32)(EHC_PORT_STAT_OFFSET + (4 * Index)));
609 RegVal &= ~PORTSC_CHANGE_MASK;
610 RegVal |= PORTSC_POWER;
611 EhcWriteOpReg (Ehc, (UINT32)(EHC_PORT_STAT_OFFSET + (4 * Index)), RegVal);
618 gBS->Stall (EHC_ROOT_PORT_RECOVERY_STALL);
623 EhcSetOpRegBit (Ehc, EHC_CONFIG_FLAG_OFFSET, CONFIGFLAG_ROUTE_EHC);
627 if (EFI_ERROR (Status)) {
628 DEBUG ((DEBUG_ERROR,
"EhcInitHC: failed to enable period schedule\n"));
634 if (EFI_ERROR (Status)) {
635 DEBUG ((DEBUG_ERROR,
"EhcInitHC: failed to enable async schedule\n"));
EFI_STATUS EhcInitSched(IN USB2_HC_DEV *Ehc)
VOID EhcFreeSched(IN USB2_HC_DEV *Ehc)
VOID EhcClearOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
EFI_STATUS EhcResetHC(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
UINT32 EhcReadDbgRegister(IN CONST USB2_HC_DEV *Ehc, IN UINT32 Offset)
EFI_STATUS EhcEnablePeriodSchd(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
VOID EhcWriteOpReg(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Data)
EFI_STATUS EhcInitHC(IN USB2_HC_DEV *Ehc)
EFI_STATUS EhcSetAndWaitDoorBell(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
EFI_STATUS EhcEnableAsyncSchd(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
VOID EhcSetOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
BOOLEAN EhcIsHalt(IN USB2_HC_DEV *Ehc)
EFI_STATUS EhcHaltHC(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
VOID EhcClearLegacySupport(IN USB2_HC_DEV *Ehc)
UINT32 EhcReadCapRegister(IN USB2_HC_DEV *Ehc, IN UINT32 Offset)
BOOLEAN EhcIsSysError(IN USB2_HC_DEV *Ehc)
EFI_STATUS EhcRunHC(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
EFI_STATUS EhcWaitOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit, IN BOOLEAN WaitToSet, IN UINT32 Timeout)
UINT32 EhcReadOpReg(IN USB2_HC_DEV *Ehc, IN UINT32 Offset)
VOID EhcAckAllInterrupt(IN USB2_HC_DEV *Ehc)
BOOLEAN EhcIsDebugPortInUse(IN CONST USB2_HC_DEV *Ehc, IN CONST UINT8 *PortNumber OPTIONAL)
#define DEBUG(Expression)
EFI_PCI_IO_PROTOCOL_CONFIG Read
EFI_PCI_IO_PROTOCOL_CONFIG Write