public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>
To: devel@edk2.groups.io
Cc: leif.lindholm@linaro.org, graeme.gregory@linaro.org,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH edk2-platforms v2 1/2] Platform/96Boards: add ACPI support to mezzanine/LS connector driver
Date: Thu,  2 May 2019 11:58:53 +0200	[thread overview]
Message-ID: <20190502095854.6989-2-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20190502095854.6989-1-ard.biesheuvel@linaro.org>

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.biesheuvel@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


  reply	other threads:[~2019-05-02  9:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-02  9:58 [PATCH edk2-platforms v2 0/2] enable Secure96 mezzanine on ACPI systems Ard Biesheuvel
2019-05-02  9:58 ` Ard Biesheuvel [this message]
2019-05-02  9:58 ` [PATCH edk2-platforms v2 2/2] Platform/Secure96Dxe: add ACPI description of the LEDs and I2C peripherals Ard Biesheuvel
2019-05-02 15:40 ` [PATCH edk2-platforms v2 0/2] enable Secure96 mezzanine on ACPI systems Leif Lindholm
2019-05-03 14:06   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190502095854.6989-2-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox