[edk2-devel] [PATCH edk2-platforms 2/2] Silicon/SynQuacer/PlatformDxe: add ACPI device node for OP-TEE if present

Ard Biesheuvel via Groups.Io ard.biesheuvel=linaro.org at groups.io
Fri Nov 29 10:47:16 UTC 2019


In order to allow the OS to discover the presence of OP-TEE also when
booting via ACPI, expose a PRP0001 ACPI device node in this case with
OP-TEE's DT compatible string attached.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel at linaro.org>
---
 Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc    |  1 +
 Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Optee.asl       | 23 ++++++++++++++++++++
 Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c   | 20 ++++++++++++++++-
 Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h   |  2 ++
 Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf |  2 ++
 5 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc
index ab1ab6f2de60..968378d5ee5b 100644
--- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc
+++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc
@@ -68,6 +68,7 @@ [LibraryClasses.common]
   ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
   ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
   ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
+  OpteeLib|ArmPkg/Library/OpteeLib/OpteeLib.inf
 
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
   BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Optee.asl b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Optee.asl
new file mode 100644
index 000000000000..cd506211ab1e
--- /dev/null
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Optee.asl
@@ -0,0 +1,23 @@
+/** @file
+  Copyright (c) 2019, Linaro Ltd. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+DefinitionBlock ("SsdtTOS0.aml", "SSDT", 1, "SNI", "SynQTOS0",
+                 FixedPcdGet32 (PcdAcpiDefaultOemRevision)) {
+  Scope (_SB) {
+    Device (TOS0) {
+      Name (_HID, "PRP0001")
+      Name (_UID, 0x0)
+      Name (_DSD, Package () {
+        ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+        Package () {
+          Package (2) { "compatible", "linaro,optee-tz" },
+          Package (2) { "method", "smc" },
+        }
+      })
+    }
+  } // Scope (_SB)
+}
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
index c9cc37dd2478..138030135986 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
@@ -116,6 +116,9 @@ STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mI2c1Desc[] = {
 STATIC EFI_ACPI_DESCRIPTION_HEADER      *mEmmcSsdt;
 STATIC UINTN                            mEmmcSsdtSize;
 
+STATIC EFI_ACPI_DESCRIPTION_HEADER      *mTos0Ssdt;
+STATIC UINTN                            mTos0SsdtSize;
+
 STATIC VOID                             *mAcpiTableEventRegistration;
 
 STATIC
@@ -285,6 +288,13 @@ InstallAcpiTables (
     DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table for eMMC - %r\n",
       __FUNCTION__, Status));
   }
+
+  Status = AcpiTable->InstallAcpiTable (AcpiTable, mTos0Ssdt, mTos0SsdtSize,
+                        &TableKey);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table for OP-TEE - %r\n",
+      __FUNCTION__, Status));
+  }
 }
 
 EFI_STATUS
@@ -397,10 +407,18 @@ PlatformDxeEntryPoint (
         mEmmcSsdt = Ssdt;
         mEmmcSsdtSize = SsdtSize;
         break;
+
+      case TOS0_TABLE_ID:
+        if (!IsOpteePresent ()) {
+          break;
+        }
+        mTos0Ssdt = Ssdt;
+        mTos0SsdtSize = SsdtSize;
+        break;
       }
     }
 
-    if (mEmmcSsdtSize > 0) {
+    if (mEmmcSsdtSize > 0 || mTos0SsdtSize > 0) {
       //
       // Register for the ACPI table protocol if we found any SSDTs to install
       //
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h
index c08659f7a796..692654687869 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h
@@ -23,6 +23,7 @@
 #include <Library/IoLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/NonDiscoverableDeviceRegistrationLib.h>
+#include <Library/OpteeLib.h>
 #include <Library/PcdLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiLib.h>
@@ -36,6 +37,7 @@
 #include <Protocol/SdMmcOverride.h>
 
 #define EMMC_TABLE_ID     SIGNATURE_64('S','y','n','Q','e','M','M','C')
+#define TOS0_TABLE_ID     SIGNATURE_64('S','y','n','Q','T','O','S','0')
 
 extern UINT8                             PlatformDxeHiiBin[];
 extern UINT8                             PlatformDxeStrings[];
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
index ae9f8712f0d2..57f2d071c14e 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
@@ -19,6 +19,7 @@ [Defines]
 [Sources]
   Emmc.asl
   Emmc.c
+  Optee.asl
   Pci.c
   PlatformDxe.c
   PlatformDxeHii.uni
@@ -46,6 +47,7 @@ [LibraryClasses]
   IoLib
   MemoryAllocationLib
   NonDiscoverableDeviceRegistrationLib
+  OpteeLib
   PcdLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#51509): https://edk2.groups.io/g/devel/message/51509
Mute This Topic: https://groups.io/mt/64339743/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list