Due to the nature of USB init on the Pi platforms, commit
c8000ecccc83b728baf04ced2fedb870bc3bc1b3 introduced a regression
with regards to ensuring that USB devices are operational by the
time the console is up.
This commit fixes this by adding explicit calls to connect USB
controllers before console initialization.
Note that trying to connect a non existent device (e.g. PCI bus
on the Pi 3) is harmless so there's no need to guard these calls
according to the devices effectively supported by the platform.
Signed-off-by: Pete Batard <[email protected]>
---
Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c |
31 ++++++++++++++++++++
Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
| 1 +
2 files changed, 32 insertions(+)
diff --git
a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
index 253614a646c1..d347c733855d 100644
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
@@ -314,6 +314,30 @@ AddOutput (
ReportText));
}
+/**
+ This CALLBACK_FUNCTION attempts to connect a handle
non-recursively, asking
+ the matching driver to produce all first-level child handles.
+**/
+STATIC
+VOID
+EFIAPI
+Connect (
+ IN EFI_HANDLE Handle,
+ IN CONST CHAR16 *ReportText
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->ConnectController (
+ Handle, // ControllerHandle
+ NULL, // DriverImageHandle
+ NULL, // RemainingDevicePath -- produce all
children
+ FALSE // Recursive
+ );
+ DEBUG ((EFI_ERROR (Status) ? EFI_D_ERROR : EFI_D_VERBOSE, "%a:
%s: %r\n",
+ __FUNCTION__, ReportText, Status));
+}
+
STATIC
INTN
PlatformRegisterBootOption (
@@ -617,6 +641,13 @@ PlatformBootManagerBeforeConsole (
// Dispatch deferred images after EndOfDxe event and ReadyToLock
installation.
//
EfiBootManagerDispatchDeferredImages ();
+
+ //
+ // Ensure that USB is initialized by connecting the PCI root
bridge so
+ // that the xHCI PCI controller gets enumerated (Pi 4) or by
connecting
+ // to the DesignWare USB OTG controller directly.
+ FilterAndProcess (&gEfiPciRootBridgeIoProtocolGuid, NULL, Connect);
+ FilterAndProcess (&gEfiUsb2HcProtocolGuid, NULL, Connect);