Kaynağa Gözat

Silicon/SynQuacer/PlatformDxe: add ACPI device node for OP-TEE if present

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@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Ard Biesheuvel 4 yıl önce
ebeveyn
işleme
c5a2065ee8

+ 1 - 0
Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc

@@ -68,6 +68,7 @@
   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

+ 23 - 0
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)
+}

+ 28 - 6
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
@@ -279,11 +282,22 @@ InstallAcpiTables (
     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));
+  if (mEmmcSsdtSize > 0) {
+    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));
+    }
+  }
+
+  if (mTos0SsdtSize > 0) {
+    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));
+    }
   }
 }
 
@@ -397,10 +411,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
       //

+ 2 - 0
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[];

+ 2 - 0
Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf

@@ -19,6 +19,7 @@
 [Sources]
   Emmc.asl
   Emmc.c
+  Optee.asl
   Pci.c
   PlatformDxe.c
   PlatformDxeHii.uni
@@ -46,6 +47,7 @@
   IoLib
   MemoryAllocationLib
   NonDiscoverableDeviceRegistrationLib
+  OpteeLib
   PcdLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint