From: Sumit Garg <sumit.garg@linaro.org>
To: edk2-devel@lists.01.org
Subject: [PATCH edk2-platforms 1/2] Silicon/SynQuacer: add optional OP-TEE DT node
Date: Fri, 3 Aug 2018 12:11:34 +0530 [thread overview]
Message-ID: <1533278495-25323-2-git-send-email-sumit.garg@linaro.org> (raw)
In-Reply-To: <1533278495-25323-1-git-send-email-sumit.garg@linaro.org>
OP-TEE is optional on Developerbox controlled via SCP firmware. To check
if we need to enable OP-TEE DT node, we use "IsOpteePresent" OpteeLib api.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 1 +
.../Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi | 8 +++++++
.../SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c | 28 ++++++++++++++++++++++
.../SynQuacerDtbLoaderLib.inf | 2 ++
4 files changed, 39 insertions(+)
diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
index fc498eb65217..4ff5df978e8e 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
@@ -76,6 +76,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/DeviceTree/SynQuacer.dtsi b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi
index 37d642e4b237..d6a5f013e58c 100644
--- a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi
+++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi
@@ -574,6 +574,14 @@
#address-cells = <1>;
#size-cells = <0>;
};
+
+ firmware {
+ optee {
+ compatible = "linaro,optee-tz";
+ method = "smc";
+ status = "disabled";
+ };
+ };
};
#include "SynQuacerCaches.dtsi"
diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c
index 897d06743708..77db30c204fe 100644
--- a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c
+++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c
@@ -19,6 +19,7 @@
#include <Library/DebugLib.h>
#include <Library/DxeServicesLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/OpteeLib.h>
#include <Platform/VarStore.h>
// add enough space for three instances of 'status = "disabled"'
@@ -47,6 +48,29 @@ DisableDtNode (
}
}
+STATIC
+VOID
+EnableDtNode (
+ IN VOID *Dtb,
+ IN CONST CHAR8 *NodePath
+ )
+{
+ INT32 Node;
+ INT32 Rc;
+
+ Node = fdt_path_offset (Dtb, NodePath);
+ if (Node < 0) {
+ DEBUG ((DEBUG_ERROR, "%a: failed to locate DT path '%a': %a\n",
+ __FUNCTION__, NodePath, fdt_strerror (Node)));
+ return;
+ }
+ Rc = fdt_setprop_string (Dtb, Node, "status", "okay");
+ if (Rc < 0) {
+ DEBUG ((DEBUG_ERROR, "%a: failed to set status to 'disabled' on '%a': %a\n",
+ __FUNCTION__, NodePath, fdt_strerror (Rc)));
+ }
+}
+
/**
Return a pool allocated copy of the DTB image that is appropriate for
booting the current platform via DT.
@@ -107,6 +131,10 @@ DtPlatformLoadDtb (
DisableDtNode (CopyDtb, "/sdhci@52300000");
}
+ if (IsOpteePresent()) {
+ EnableDtNode (CopyDtb, "/firmware/optee");
+ }
+
*Dtb = CopyDtb;
*DtbSize = CopyDtbSize;
diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf
index 548d62fd5c0a..fd21f7c376ce 100644
--- a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf
+++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.inf
@@ -24,6 +24,7 @@ [Sources]
SynQuacerDtbLoaderLib.c
[Packages]
+ ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
Silicon/Socionext/SynQuacer/SynQuacer.dec
@@ -34,6 +35,7 @@ [LibraryClasses]
DxeServicesLib
FdtLib
MemoryAllocationLib
+ OpteeLib
[Pcd]
gSynQuacerTokenSpaceGuid.PcdPcieEnableMask
--
2.7.4
next prev parent reply other threads:[~2018-08-03 6:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-03 6:41 [PATCH edk2-platforms 0/2] Silicon/SynQuacer: update Device Tree Sumit Garg
2018-08-03 6:41 ` Sumit Garg [this message]
2018-08-03 6:41 ` [PATCH edk2-platforms 2/2] Silicon/SynQuacer: Add status property in PCIe & SDHC DT nodes Sumit Garg
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=1533278495-25323-2-git-send-email-sumit.garg@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