From patchwork Tue Jul 31 11:02:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 143182 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp5181861ljj; Tue, 31 Jul 2018 04:02:48 -0700 (PDT) X-Received: by 2002:a17:902:e3:: with SMTP id a90-v6mr20363474pla.227.1533034968291; Tue, 31 Jul 2018 04:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533034968; cv=none; d=google.com; s=arc-20160816; b=pUWidBmXJ2x35EwT3hqLEGTLPwrBA7o5qJlnSIzGsEyV1PN156Acbx4BaW45NadSMm luQpFi98rms+4UlXayisg4JVerJB0r2n0vCGIASyKeXQcFIKYMCDBpJrc4h/8xUCHoX5 NgZknbgU9GfGjsx/XqGP79ORinF3LbQaNUIJLaZ7mODVjsZBqABgS7CM5wj/A9aNfvoq Up3JxIemmXi+XrkC2CRTrfB+BKgE7bzrdW3qorD+ttoYf4W/OnvdZ34q2jAi5aHk1Kjd nrjzc/PxNGux/jLks9+k6XPHyouGY8u+7KQ8TuRJQVyAOO4BBTQQs8ra9q1/iPVudp1j T2gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=oZVBcHd82wBPnZuRxaOPywqJW5JovGK2k4CkWaW9Xo8=; b=j2n/Gd0ijNThnLV7a6iFr2XJZ14oSgNSjxvJm0lO0Hulhgujw+T/KAoIn2YmRKVAtY JcikVFlEufLd/u318X+6/7uYDs4hy98WIruaISXbRrugXbyGDnqj4vp6vyEDmZKwPm+f +qvZwM8ZjYKpmN0BpX6W/fWKMIF7ZrbcdkRCczcRaFJVOLE8s8uznv1pHTugv/uHb4/T 1a00xWHYHYVVKSldbGK5omidH0q2JqRpGD1vAC8rxFmmvuRBVq1iLVciSrYJ3teKqilD QE5XQ/GErFk5A2W6PkTOrJ/REnQU+LsLY7wcnDGMsnCy7gZ/dZFGXNaqstJykV5LLiPC vGmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gWQoSeR0; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id l18-v6sor3010858pgi.73.2018.07.31.04.02.48 for (Google Transport Security); Tue, 31 Jul 2018 04:02:48 -0700 (PDT) Received-SPF: pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gWQoSeR0; spf=pass (google.com: domain of sumit.garg@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=sumit.garg@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oZVBcHd82wBPnZuRxaOPywqJW5JovGK2k4CkWaW9Xo8=; b=gWQoSeR0oEXSD0oblJNE47YpCnzt6N1fpHCRPMrSyqd+J+lCxx9H//L/qy4dOq4sxZ yJVvJZkh3aYDdr3GDm0w2DaYkGxTpIdZTrFJsgXn6JQ2Et166jtO65jU3rBV5rQSsisx S7BNJD6iv4vjdcej41qEKPxB/MnyG2Iu9YVZ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oZVBcHd82wBPnZuRxaOPywqJW5JovGK2k4CkWaW9Xo8=; b=MjAvYZK+wlN5R9mB8QUTPHxo1jXM46sosCfGt4PTSP2oQiXfo4dZf++b+tpC091UDC xHLJyQzYFakjVK249ikKPvn9HN9RbXm+wYE8T51EFg/Vz1ggKiluUiESaoABD21yremU PDOZuSOtzm5ewLz7aBujqas45wEjD8b3+E0TcfnOVGefrdXdDPr0UjfmBDV36V6XajSe Bh1cOLTE/1/UuyONUURTMbl6hrpdiv2ts7hvZanGs+d6Dwy09Vzcf0PgrxbZlOvOwKbN aJsChg5juP0aF2vOwqlqfACcYlRfqOv7uQlA+12MEjYsq7DkMQbCG1lR2ZgcN8n5BvMV sKbg== X-Gm-Message-State: AOUpUlH1AKKm0CEKyv+IEZ55+fWoUoUdcNKxTKTuAIzotPh+C/WpEQ9e 8WcYoR4jb/9teFYIvFs4kCVX/KlE X-Google-Smtp-Source: AAOMgpfK0DDFXl2Xk6eHj1xqatZ3EkVyrDI7bQw1bGWI5+9OHEIQ2/wh6wQaDOkdY/vV5NZ9TnprjA== X-Received: by 2002:a63:b605:: with SMTP id j5-v6mr20373985pgf.437.1533034967915; Tue, 31 Jul 2018 04:02:47 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([117.255.223.217]) by smtp.gmail.com with ESMTPSA id e126-v6sm28240972pfg.31.2018.07.31.04.02.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jul 2018 04:02:47 -0700 (PDT) From: Sumit Garg To: daniel.thompson@linaro.org, ard.biesheuvel@linaro.org Cc: patches@linaro.org, Sumit Garg Subject: [edk2][PATCH edk2-platforms 1/1] Silicon/SynQuacer: add optional OP-TEE DT node Date: Tue, 31 Jul 2018 16:32:15 +0530 Message-Id: <1533034935-21530-2-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533034935-21530-1-git-send-email-sumit.garg@linaro.org> References: <1533034935-21530-1-git-send-email-sumit.garg@linaro.org> OP-TEE is optional on Developerbox controlled via SCP firmware. To check if we need to delete OP-TEE DT node, we use "IsOpteePresent" OpteeLib api. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sumit Garg --- Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 1 + .../Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi | 7 ++++++ .../SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c | 28 ++++++++++++++++++++++ .../SynQuacerDtbLoaderLib.inf | 2 ++ 4 files changed, 38 insertions(+) -- 2.7.4 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..d109a5742793 100644 --- a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi +++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi @@ -574,6 +574,13 @@ #address-cells = <1>; #size-cells = <0>; }; + + firmware { + optee { + compatible = "linaro,optee-tz"; + method = "smc"; + }; + }; }; #include "SynQuacerCaches.dtsi" diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c index 897d06743708..b16e384262b0 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoaderLib.c @@ -19,6 +19,7 @@ #include #include #include +#include #include // add enough space for three instances of 'status = "disabled"' @@ -47,6 +48,29 @@ DisableDtNode ( } } +STATIC +VOID +DeleteDtNode ( + 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_del_node (Dtb, Node); + if (Rc < 0) { + DEBUG ((DEBUG_ERROR, "%a: failed to delete node 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()) { + DeleteDtNode (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