Make the LS connector mezzanine support code ACPI aware, and invoke the appropriate hook in the driver code to install a SSDT instead of a DT overlay when running on a system that is booting in ACPI mode.
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org> --- Platform/96Boards/Include/Protocol/Mezzanine.h | 21 ++++++++++++ Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c | 35 ++++++++++++++------ Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf | 1 + 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Platform/96Boards/Include/Protocol/Mezzanine.h b/Platform/96Boards/Include/Protocol/Mezzanine.h index 9847649d2ac3..97f43e9a920f 100644 --- a/Platform/96Boards/Include/Protocol/Mezzanine.h +++ b/Platform/96Boards/Include/Protocol/Mezzanine.h @@ -16,6 +16,7 @@ #define _96BOARDS_MEZZANINE_H_ #include <Pi/PiI2c.h> +#include <Protocol/AcpiTable.h> #include <Protocol/SpiConfiguration.h> #define MEZZANINE_PROTOCOL_GUID \ @@ -39,12 +40,32 @@ EFI_STATUS IN OUT VOID *Dtb ); +/** + Install the mezzanine's SSDT table + + @param[in] This Pointer to the MEZZANINE_PROTOCOL instance. + @param[in] Dtb Pointer to the device tree blob + + @return EFI_SUCCESS Operation succeeded. + @return other An error has occurred. +**/ +typedef +EFI_STATUS +(EFIAPI *INSTALL_SSDT_TABLE) ( + IN MEZZANINE_PROTOCOL *This, + IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol + ); + struct _MEZZANINE_PROTOCOL { // // Get the device tree overlay for this mezzanine board // APPLY_DEVICE_TREE_OVERLAY ApplyDeviceTreeOverlay; // + // Install the mezzanine's SSDT table + // + INSTALL_SSDT_TABLE InstallSsdtTable; + // // The number of devices on LS connector I2C bus #0 // UINT32 I2c0NumDevices; diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c index f19d95635056..27044c5da699 100644 --- a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c +++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c @@ -21,6 +21,7 @@ #include <Library/UefiBootServicesTableLib.h> #include <Library/UefiLib.h> #include <Library/UefiRuntimeServicesTableLib.h> +#include <Protocol/AcpiTable.h> #include <Protocol/LsConnector.h> #include <Protocol/Mezzanine.h> @@ -97,7 +98,7 @@ InstallHiiPages ( STATIC VOID EFIAPI -ApplyDeviceTreeOverlay ( +PublishOsDescription ( EFI_EVENT Event, VOID *Context ) @@ -105,11 +106,30 @@ ApplyDeviceTreeOverlay ( VOID *Dtb; MEZZANINE_PROTOCOL *Mezzanine; EFI_STATUS Status; + EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol; + + Status = gBS->LocateProtocol (&g96BoardsMezzanineProtocolGuid, NULL, + (VOID **)&Mezzanine); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: no mezzanine driver active\n", __FUNCTION__)); + return; + } + + Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, + (VOID **)&AcpiProtocol); + if (!EFI_ERROR (Status)) { + Status = Mezzanine->InstallSsdtTable (Mezzanine, AcpiProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table - %r\n", + __FUNCTION__, Status)); + } + return; + } // // Find the DTB in the configuration table array. If it isn't there, just - // bail without an error: we may be running on an ACPI platform even if - // this driver does not support it [yet]. + // bail without an error: the system may be able to proceed even without + // ACPI or DT description, so it isn't up to us to complain about this. // Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &Dtb); if (Status == EFI_NOT_FOUND) { @@ -117,13 +137,6 @@ ApplyDeviceTreeOverlay ( } ASSERT_EFI_ERROR (Status); - Status = gBS->LocateProtocol (&g96BoardsMezzanineProtocolGuid, NULL, - (VOID **)&Mezzanine); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "%a: no mezzanine driver active\n", __FUNCTION__)); - return; - } - Status = Mezzanine->ApplyDeviceTreeOverlay (Mezzanine, Dtb); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_WARN, "%a: failed to apply DT overlay - %r\n", __FUNCTION__, @@ -211,7 +224,7 @@ EntryPoint ( Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, - ApplyDeviceTreeOverlay, + PublishOsDescription, NULL, &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent); diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf index 1bf528ceaa84..20b9637c1923 100644 --- a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf +++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf @@ -46,6 +46,7 @@ [LibraryClasses] [Protocols] g96BoardsLsConnectorProtocolGuid ## PRODUCES g96BoardsMezzanineProtocolGuid ## CONSUMES + gEfiAcpiTableProtocolGuid ## SOMETIMES_CONSUMES [Guids] gEfiEndOfDxeEventGroupGuid -- 2.20.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#39550): https://edk2.groups.io/g/devel/message/39550 Mute This Topic: https://groups.io/mt/31341743/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-