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, Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH edk2-platforms 1/2] Silicon/SynQuacer/PlatformDxe: move EMMC SSDT handling to core routine
Date: Fri, 29 Nov 2019 11:47:15 +0100	[thread overview]
Message-ID: <20191129104716.819-2-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20191129104716.819-1-ard.biesheuvel@linaro.org>

In preparation of adding support for describing the presence of OP-TEE
via a SSDT ACPI table, refactor the existing code so we will be able to
reuse it more easily.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c        | 55 -----------------
 Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 65 ++++++++++++++++++++
 2 files changed, 65 insertions(+), 55 deletions(-)

diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c
index 0d0e5edad901..90b67152c768 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c
@@ -53,10 +53,6 @@
 
 STATIC EFI_HANDLE mSdMmcControllerHandle;
 
-STATIC EFI_ACPI_DESCRIPTION_HEADER      *mSsdt;
-STATIC UINTN                            mSsdtSize;
-STATIC VOID                             *mEventRegistration;
-
 /**
 
   Override function for SDHCI capability bits
@@ -185,31 +181,6 @@ STATIC EDKII_SD_MMC_OVERRIDE mSdMmcOverride = {
   SynQuacerSdMmcNotifyPhase,
 };
 
-STATIC
-VOID
-EFIAPI
-InstallAcpiTable (
-  IN EFI_EVENT                      Event,
-  IN VOID*                          Context
-  )
-{
-  UINTN                             TableKey;
-  EFI_STATUS                        Status;
-  EFI_ACPI_TABLE_PROTOCOL           *AcpiTable;
-
-  Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,
-                  (VOID **)&AcpiTable);
-  if (EFI_ERROR (Status)) {
-    return;
-  }
-
-  Status = AcpiTable->InstallAcpiTable (AcpiTable, mSsdt, mSsdtSize, &TableKey);
-  if (EFI_ERROR (Status)) {
-    DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table for eMMC - %r\n",
-      __FUNCTION__, Status));
-  }
-}
-
 EFI_STATUS
 EFIAPI
 RegisterEmmc (
@@ -218,32 +189,6 @@ RegisterEmmc (
 {
   EFI_STATUS                      Status;
   EFI_HANDLE                      Handle;
-  UINTN                           Index;
-
-  if (mHiiSettings->AcpiPref == ACPIPREF_ACPI) {
-    //
-    // Load the SSDT table from a raw section in this FFS file.
-    //
-    for (Index = 0;; Index++) {
-      Status = GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index,
-                 (VOID **)&mSsdt, &mSsdtSize);
-      if (EFI_ERROR (Status)) {
-        break;
-      }
-
-      if (mSsdt->OemTableId != EMMC_TABLE_ID) {
-        continue;
-      }
-
-      //
-      // Register for the ACPI table protocol
-      //
-      EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CALLBACK,
-        InstallAcpiTable, NULL, &mEventRegistration);
-
-      break;
-    }
-  }
 
   Status = RegisterNonDiscoverableMmioDevice (
              NonDiscoverableDeviceTypeSdhci,
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
index 73cc560fa8d8..c9cc37dd2478 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
@@ -113,6 +113,11 @@ STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mI2c1Desc[] = {
   }
 };
 
+STATIC EFI_ACPI_DESCRIPTION_HEADER      *mEmmcSsdt;
+STATIC UINTN                            mEmmcSsdtSize;
+
+STATIC VOID                             *mAcpiTableEventRegistration;
+
 STATIC
 EFI_STATUS
 RegisterDevice (
@@ -256,6 +261,32 @@ EnableSettingsForm (
   return InstallHiiPages ();
 }
 
+STATIC
+VOID
+EFIAPI
+InstallAcpiTables (
+  IN EFI_EVENT                      Event,
+  IN VOID*                          Context
+  )
+{
+  UINTN                             TableKey;
+  EFI_STATUS                        Status;
+  EFI_ACPI_TABLE_PROTOCOL           *AcpiTable;
+
+  Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,
+                  (VOID **)&AcpiTable);
+  if (EFI_ERROR (Status)) {
+    return;
+  }
+
+  Status = AcpiTable->InstallAcpiTable (AcpiTable, mEmmcSsdt, mEmmcSsdtSize,
+                        &TableKey);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table for eMMC - %r\n",
+      __FUNCTION__, Status));
+  }
+}
+
 EFI_STATUS
 EFIAPI
 PlatformDxeEntryPoint (
@@ -267,6 +298,9 @@ PlatformDxeEntryPoint (
   VOID                            *Dtb;
   UINTN                           DtbSize;
   EFI_HANDLE                      Handle;
+  EFI_ACPI_DESCRIPTION_HEADER     *Ssdt;
+  UINTN                           SsdtSize;
+  UINTN                           Index;
 
   mHiiSettingsVal = PcdGet64 (PcdPlatformSettings);
   mHiiSettings = (SYNQUACER_PLATFORM_VARSTORE_DATA *)&mHiiSettingsVal;
@@ -344,5 +378,36 @@ PlatformDxeEntryPoint (
     ASSERT_EFI_ERROR (Status);
   }
 
+  if (mHiiSettings->AcpiPref == ACPIPREF_ACPI) {
+    //
+    // Load the SSDT tables from a raw section in this FFS file.
+    //
+    for (Index = 0;; Index++) {
+      Status = GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index,
+                 (VOID **)&Ssdt, &SsdtSize);
+      if (EFI_ERROR (Status)) {
+        break;
+      }
+
+      switch (Ssdt->OemTableId) {
+      case EMMC_TABLE_ID:
+        if (mHiiSettings->EnableEmmc != EMMC_ENABLED) {
+          break;
+        }
+        mEmmcSsdt = Ssdt;
+        mEmmcSsdtSize = SsdtSize;
+        break;
+      }
+    }
+
+    if (mEmmcSsdtSize > 0) {
+      //
+      // Register for the ACPI table protocol if we found any SSDTs to install
+      //
+      EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CALLBACK,
+        InstallAcpiTables, NULL, &mAcpiTableEventRegistration);
+    }
+  }
+
   return EFI_SUCCESS;
 }
-- 
2.17.1


  reply	other threads:[~2019-11-29 10:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-29 10:47 [PATCH edk2-platforms 0/2] SynQuacer: expose OP-TEE in ACPI mode Ard Biesheuvel
2019-11-29 10:47 ` Ard Biesheuvel [this message]
2019-12-02 10:26   ` [edk2-devel] [PATCH edk2-platforms 1/2] Silicon/SynQuacer/PlatformDxe: move EMMC SSDT handling to core routine Philippe Mathieu-Daudé
2019-12-02 16:04     ` Ard Biesheuvel
2019-11-29 10:47 ` [PATCH edk2-platforms 2/2] Silicon/SynQuacer/PlatformDxe: add ACPI device node for OP-TEE if present Ard Biesheuvel
2019-11-29 11:29 ` [PATCH edk2-platforms 0/2] SynQuacer: expose OP-TEE in ACPI mode Leif Lindholm
2019-11-29 12:13   ` Ard Biesheuvel
2019-12-02  9:58     ` Ard Biesheuvel
2019-12-02 12:02       ` Leif Lindholm
2019-12-02 14:08         ` Ard Biesheuvel
2019-12-10  8:20           ` 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=20191129104716.819-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