MdeModulePkg/UsbBusPei: Improve PEI USB enumeration

Unlike DXE USB enumeration that enumerates all changed ports on timer
interrupt, PEI USB Enumeration runs once at the driver entry point.
USB3.x devices initially appear in USB2.0 ports. When the USB2.0 port is
reset, the USB3.x device disappears from the USB2.0 port and appears on the
USB3.0 port. The USB3.x device won't be enumerated if the USB2.0 port
number is greater than the USB3.0 port number. Re-enumerate USB to make
sure USB3.x devices in this case.

Signed-off-by: Phil Noh <Phil.Noh@amd.com>
This commit is contained in:
Phil Noh 2025-02-10 18:51:35 -06:00 committed by Liming Gao
parent bc664d1830
commit 0192f2d7cb
1 changed files with 172 additions and 163 deletions

View File

@ -1,6 +1,7 @@
/** @file
The module to produce Usb Bus PPI.
Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.<BR>
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@ -428,6 +429,7 @@ PeiUsbEnumeration (
UINT8 CurrentAddress;
UINTN InterfaceIndex;
UINTN EndpointIndex;
UINT8 UsbEnumLoop;
CurrentAddress = 0;
if (Usb2HcPpi != NULL) {
@ -449,6 +451,12 @@ PeiUsbEnumeration (
DEBUG ((DEBUG_INFO, "PeiUsbEnumeration: NumOfRootPort: %x\n", NumOfRootPort));
//
// USB3.x devices initially appear in USB2.0 ports. When the USB2.0 port is reset, the USB3.x device disappears
// from the USB2.0 port and appears on the USB3.0 port. The USB3.x device won't be enumerated if the USB2.0 port
// number is greater than the USB3.0 port number. Re-enumerate USB to make sure USB3.x devices in this case.
//
for (UsbEnumLoop = 0; UsbEnumLoop < 2; UsbEnumLoop++) {
for (Index = 0; Index < NumOfRootPort; Index++) {
//
// First get root port status to detect changes happen
@ -643,6 +651,7 @@ PeiUsbEnumeration (
}
}
}
}
return EFI_SUCCESS;
}