From nobody Tue Jan 14 22:36:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1513075113062823.4556206563723; Tue, 12 Dec 2017 02:38:33 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 89EB1220EE107; Tue, 12 Dec 2017 02:33:51 -0800 (PST) Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A615E220EE107 for ; Tue, 12 Dec 2017 02:33:49 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id a41so20597431wra.6 for ; Tue, 12 Dec 2017 02:38:28 -0800 (PST) Received: from localhost.localdomain ([160.171.158.223]) by smtp.gmail.com with ESMTPSA id b16sm21279762wrd.69.2017.12.12.02.38.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 02:38:25 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.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=3TL11bag/iZYHBcdSH5KCpn14J17x6tyE5z4O+tavlw=; b=fqR5O+5gzjsWUkBFGxQdoVWYa/Pt/27gK8DSDpkb/2wEbet0E07gjvRMrQfO9v8O5L WEL7XWm/KBNg76wq2ftVJG/3chsYfoM1OE1b91YmHedT98XSHrOTo7FzflJgMZWG4Qkv LVZbTmARL9fC7QlQgfu6Xn/1yMPW5mtVivzwg= 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=3TL11bag/iZYHBcdSH5KCpn14J17x6tyE5z4O+tavlw=; b=V915iPRuiOfcJeXRPKuAp7u63RNQS2N1wNilFbk1XXh1q3/qh2UdeZEN/B6OclffwU ydj/txOBpUBvn8oGJalJ97DsjY4NaiYhMo/+/gag66xqFdgHeHg81CxLpR/0f5NeJrT7 V9p6/pZShbdY1bnFHOwrwyEhRpVhuF4u1C3lu68VNg08UsdUpiruqi8PwWykas525TId E5Flqwbmpe8uTqKmB+vbFfKc580JaMqIsr+ZNn0zNovJBDjJh51hhh3WETnG69KBXKqP +0kRqWSPsCKBmA88XPDrr1yQMlqKfkGOGQm5KVVlOvHOE/RxtlQSJtuxeq3enVj84g1W koPg== X-Gm-Message-State: AKGB3mIkRHqcGQJTeyGHvO5gIvIvQLwQHaiZ1WYRdU9KcNeWZA/CJJvc GEehf9pk0FD5cixaZPjIw5XIUt6DT2s= X-Google-Smtp-Source: ACJfBotgL/x1eIGIoOoTARBN6s2l/13QdFgD7Ddn+rkwgvDVnkRFKExwcwOYnqKm6ESyD97MNZLXqQ== X-Received: by 10.223.156.202 with SMTP id h10mr1700685wre.174.1513075106702; Tue, 12 Dec 2017 02:38:26 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 12 Dec 2017 10:38:04 +0000 Message-Id: <20171212103807.18836-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171212103807.18836-1-ard.biesheuvel@linaro.org> References: <20171212103807.18836-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms 5/8] Silicon/SynQuacer: disable PCI RC #0 DT node if disabled X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.thompson@linaro.org, masami.hiramatsu@linaro.org, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If PCIe RC #0 is not enabled (due to the fact that the slot is not populated), set its DT node 'status' property to 'disabled' so that the OS will not attempt to attach to it. This means we will need to switch from the default DtPlatformDtbLoaderLib to a special one for our platform. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Platform/Socionext/DeveloperBox/DeveloperBox.dsc = | 8 +- Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc = | 3 +- Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoad= erLib.c | 94 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDtbLoad= erLib.inf | 42 +++++++++ 4 files changed, 141 insertions(+), 6 deletions(-) diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/So= cionext/DeveloperBox/DeveloperBox.dsc index 5ec26f9cdd34..80728fedbc20 100644 --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc @@ -160,7 +160,8 @@ [LibraryClasses.common.DXE_CORE] PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerform= anceLib.inf =20 [LibraryClasses.common.DXE_DRIVER] - DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefa= ult/DxeDtPlatformDtbLoaderLibDefault.inf + DtPlatformDtbLoaderLib|Silicon/Socionext/SynQuacer/Library/SynQuacerDtbL= oaderLib/SynQuacerDtbLoaderLib.inf + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.= inf =20 @@ -611,10 +612,7 @@ [Components.common] # # Console preference selection # - EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf { - - FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf - } + EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf =20 # # DT support diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc b= /Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc index bc8ddd452d4b..c71425664bdc 100644 --- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc +++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc @@ -159,7 +159,8 @@ [LibraryClasses.common.DXE_CORE] PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerform= anceLib.inf =20 [LibraryClasses.common.DXE_DRIVER] - DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefa= ult/DxeDtPlatformDtbLoaderLibDefault.inf + DtPlatformDtbLoaderLib|Silicon/Socionext/SynQuacer/Library/SynQuacerDtbL= oaderLib/SynQuacerDtbLoaderLib.inf + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.= inf =20 diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQ= uacerDtbLoaderLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoade= rLib/SynQuacerDtbLoaderLib.c new file mode 100644 index 000000000000..a93a6027e64d --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDt= bLoaderLib.c @@ -0,0 +1,94 @@ +/** @file +* +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD License +* which accompanies this distribution. The full text of the license may = be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +* +**/ + +#include + +#include +#include +#include +#include +#include + +#define DTB_PADDING 64 + +STATIC +VOID +DisableDtNode ( + IN VOID *Dtb, + IN CONST CHAR8 *NodePath + ) +{ + INT32 Node; + INT32 Rc; + + Node =3D 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 =3D fdt_setprop_string (Dtb, Node, "status", "disabled"); + 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. + + @param[out] Dtb Pointer to the DTB copy + @param[out] DtbSize Size of the DTB copy + + @retval EFI_SUCCESS Operation completed successfully + @retval EFI_NOT_FOUND No suitable DTB image could be locat= ed + @retval EFI_OUT_OF_RESOURCES No pool memory available + +**/ +EFI_STATUS +EFIAPI +DtPlatformLoadDtb ( + OUT VOID **Dtb, + OUT UINTN *DtbSize + ) +{ + EFI_STATUS Status; + VOID *OrigDtb; + VOID *CopyDtb; + UINTN OrigDtbSize; + + Status =3D GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, + EFI_SECTION_RAW, 0, &OrigDtb, &OrigDtbSize); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + CopyDtb =3D AllocateCopyPool (OrigDtbSize + DTB_PADDING, OrigDtb); + if (CopyDtb =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (!(PcdGet8 (PcdPcieEnableMask) & BIT0)) { + DisableDtNode (CopyDtb, "/pcie@60000000"); + } + if (!(PcdGet8 (PcdPcieEnableMask) & BIT1)) { + DisableDtNode (CopyDtb, "/pcie@70000000"); + } + + *Dtb =3D CopyDtb; + *DtbSize =3D OrigDtbSize + DTB_PADDING; + + return EFI_SUCCESS; +} diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQ= uacerDtbLoaderLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoa= derLib/SynQuacerDtbLoaderLib.inf new file mode 100644 index 000000000000..e1f564f73078 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerDtbLoaderLib/SynQuacerDt= bLoaderLib.inf @@ -0,0 +1,42 @@ +/** @file +* +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD License +* which accompanies this distribution. The full text of the license may = be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +* +**/ + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D SynQuacerDtbLoaderLib + FILE_GUID =3D 59df69c4-8724-4e49-8974-d0691364338c + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D DtPlatformDtbLoaderLib|DXE_DRIVER + +[Sources] + SynQuacerDtbLoaderLib.c + +[Packages] + MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + BaseLib + DebugLib + DxeServicesLib + FdtLib + MemoryAllocationLib + +[Pcd] + gSynQuacerTokenSpaceGuid.PcdPcieEnableMask + +[Guids] + gDtPlatformDefaultDtbFileGuid --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel