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 2/2] Silicon/SynQuacer/PlatformDxe: add ACPI device node for OP-TEE if present
Date: Fri, 29 Nov 2019 11:47:16 +0100	[thread overview]
Message-ID: <20191129104716.819-3-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20191129104716.819-1-ard.biesheuvel@linaro.org>

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>
---
 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


  parent 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 ` [PATCH edk2-platforms 1/2] Silicon/SynQuacer/PlatformDxe: move EMMC SSDT handling to core routine Ard Biesheuvel
2019-12-02 10:26   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-12-02 16:04     ` Ard Biesheuvel
2019-11-29 10:47 ` Ard Biesheuvel [this message]
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-3-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