From nobody Tue Feb 10 06:26:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86649+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86649+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1644840803; cv=none; d=zohomail.com; s=zohoarc; b=gstZjLbOyVj3dpZ4uz5jvhfX+KPDfPORcJAwO42NZN4GjrIMbmTS/sbYcQjmnx3RUeYMUCbCfP6UZKpDYuBxoYyAkDahY+BTFSaI7xDaWyiZ51Zjm/2E+8Xi2s5rSxodKa5hMCyS7wA/SenKvGeWy+oSmZAIQGq9sLPwwas0kxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644840803; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=TljTg24N7uxqsFJXXoKcuCFV788vi60D/icqpQyun5w=; b=kOqYhllZPIX7idiIhXlk5ZBcOY8azOG3gKCXQFmtveGGgEyAAO7LXc1Fns3qejKrDcPS48kDM8k5yZsIc2+oqUcUSPDaBP7Y2FvnONHGDbo+3h/OsZkqACwfnvzFIT5yYjRjl4IDh+mCQ58x1Qymsx4z5fhNnHOPl+fGavYOkCw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86649+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1644840803481628.4664548974451; Mon, 14 Feb 2022 04:13:23 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id McYoYY1788612xaN6YZXBVsC; Mon, 14 Feb 2022 04:13:23 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.32945.1644840801990936765 for ; Mon, 14 Feb 2022 04:13:22 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7EAF61476; Mon, 14 Feb 2022 04:13:21 -0800 (PST) X-Received: from usa.arm.com (a074945.blr.arm.com [10.162.16.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D4EC63F718; Mon, 14 Feb 2022 04:13:19 -0800 (PST) From: "Vivek Kumar Gautam" To: devel@edk2.groups.io Cc: Sami Mujawar , Ard Biesheuvel , Leif Lindholm , Vivek Gautam Subject: [edk2-devel] [edk2-platforms][PATCH V1 3/6] Platform/Sgi: Initialize additional uart controllers Date: Mon, 14 Feb 2022 17:43:04 +0530 Message-Id: <20220214121307.14608-4-vivek.gautam@arm.com> In-Reply-To: <20220214121307.14608-1-vivek.gautam@arm.com> References: <20220214121307.14608-1-vivek.gautam@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,vivek.gautam@arm.com X-Gm-Message-State: r4QcBbFoetotD0etiHHCQgTqx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1644840803; bh=7+sGO4g05V0FGEVHQ3d7sX7RsCwddFyh5qjHEO97PlI=; h=Cc:Date:From:Reply-To:Subject:To; b=KKe1PeQ3z3jqstMjKHxdWFYGCn2YeG0lbQVytfqHkqSFFi3OKpokG8OGZb+Tuqby1/N 3wgZf+v1XTFJrjEeu4CLoY9ZDjfnWWIfDN6Ifr5ZMzKWKyFJfB81gVCE04QPtyzpIXUh6 l/WsbjYhHcus97zq+Z8HrpengiIri/DRk3k= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1644840804391100006 Content-Type: text/plain; charset="utf-8" From: Shriram K The IO virtualization block on reference design platforms allow connecting non-discoverable devices such as PL011 UART. On platforms that support this, initialize the UART controller connected to the IO virtualization block. Signed-off-by: Shriram K Signed-off-by: Vivek Gautam --- Platform/ARM/SgiPkg/SgiPlatform.dec | 1 + Platform/ARM/SgiPkg/RdN2/RdN2.dsc | 4 ++ Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc | 6 +- Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf | 7 +- Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf | 8 ++- Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c | 73 ++++++++++++= +++++++- Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c | 19 ++++- 7 files changed, 112 insertions(+), 6 deletions(-) diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiP= latform.dec index 6b3e28c3a08e..fa057f6344ee 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.dec +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec @@ -31,6 +31,7 @@ [PcdsFeatureFlag.common] gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001 gArmSgiTokenSpaceGuid.PcdVirtioNetSupported|FALSE|BOOLEAN|0x00000010 + gArmSgiTokenSpaceGuid.PcdIoVirtBlkNonDiscoverable|FALSE|BOOLEAN|0x000000= 50 =20 [PcdsFixedAtBuild] gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002 diff --git a/Platform/ARM/SgiPkg/RdN2/RdN2.dsc b/Platform/ARM/SgiPkg/RdN2/R= dN2.dsc index 49a317a930e0..b4f557805dcf 100644 --- a/Platform/ARM/SgiPkg/RdN2/RdN2.dsc +++ b/Platform/ARM/SgiPkg/RdN2/RdN2.dsc @@ -45,6 +45,10 @@ gArmPlatformTokenSpaceGuid.PcdCoreCount|1 gArmPlatformTokenSpaceGuid.PcdClusterCount|16 =20 +[PcdsFeatureFlag.common] + # IO virtualization block non-discoverable peripherals + gArmSgiTokenSpaceGuid.PcdIoVirtBlkNonDiscoverable|TRUE + ##########################################################################= ###### # # Components Section - list of all EDK II Modules needed by this Platform diff --git a/Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc b/Platform/ARM/SgiPk= g/RdN2Cfg1/RdN2Cfg1.dsc index c26f652cb9e9..4ebb4af3a57d 100644 --- a/Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc +++ b/Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc @@ -1,7 +1,7 @@ ## @file # Platform Description file for RD-N2-Cfg1 platform. # -# Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -47,6 +47,10 @@ gArmPlatformTokenSpaceGuid.PcdCoreCount|1 gArmPlatformTokenSpaceGuid.PcdClusterCount|8 =20 +[PcdsFeatureFlag.common] + # IO virtualization block non-discoverable peripherals + gArmSgiTokenSpaceGuid.PcdIoVirtBlkNonDiscoverable|TRUE + ##########################################################################= ###### # # Components Section - list of all EDK II Modules needed by this Platform diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Plat= form/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf index 9d89314a594e..0b07f01f0a99 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, ARM Limited. All rights reserved. +# Copyright (c) 2018-2022, ARM Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -17,6 +17,7 @@ VirtioDevices.c =20 [Packages] + ArmPlatformPkg/ArmPlatformPkg.dec EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec @@ -35,12 +36,16 @@ [FeaturePcd] gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported gArmSgiTokenSpaceGuid.PcdVirtioNetSupported + gArmSgiTokenSpaceGuid.PcdIoVirtBlkNonDiscoverable =20 [FixedPcd] gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress gArmSgiTokenSpaceGuid.PcdVirtioBlkSize gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress gArmSgiTokenSpaceGuid.PcdVirtioNetSize + gArmPlatformTokenSpaceGuid.PcdSerialDbgUartClkInHz + gArmSgiTokenSpaceGuid.PcdIoVirtBlkUart0Base + gArmSgiTokenSpaceGuid.PcdIoVirtBlkUart1Base =20 [Depex] TRUE diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf b/Plat= form/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf index 22e247ea4fae..6c81543a800d 100644 --- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf +++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf @@ -1,5 +1,5 @@ # -# Copyright (c) 2018-2020, ARM Limited. All rights reserved. +# Copyright (c) 2018-2022, ARM Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -83,6 +83,12 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase =20 + gArmSgiTokenSpaceGuid.PcdIoVirtBlkUart0Base + gArmSgiTokenSpaceGuid.PcdIoVirtBlkUart1Base + +[FeaturePcd] + gArmSgiTokenSpaceGuid.PcdIoVirtBlkNonDiscoverable + [Guids] gArmSgiPlatformIdDescriptorGuid gEfiHobListGuid ## CONSUMES ## SystemTable diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platfo= rm/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c index 2f72e7152ff3..48ef7cd2a59a 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2018, ARM Limited. All rights reserved. +* Copyright (c) 2018-2022, ARM Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -9,6 +9,8 @@ #include #include #include +#include + #include =20 VOID @@ -16,6 +18,74 @@ InitVirtioDevices ( VOID ); =20 +/** + Initialize UART controllers connected to IO Virtualization block. + + Use PL011UartLib Library to initialize UART controllers connected + to x4_0 and x8 port of the IO Virtualization block on infrastructure + reference design (RD) platforms. + + @retval None +**/ +STATIC +VOID +InitIoVirtBlkUartControllers (VOID) +{ + EFI_STATUS Status; + EFI_PARITY_TYPE Parity; + EFI_STOP_BITS_TYPE StopBits; + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + UINT8 DataBits; + + if (!FeaturePcdGet (PcdIoVirtBlkNonDiscoverable)) + return; + + ReceiveFifoDepth =3D 0; + Parity =3D 1; + DataBits =3D 8; + StopBits =3D 1; + BaudRate =3D 115200; + + // Use PL011Uart Library to initialize the x4: PL011_UART0 + Status =3D PL011UartInitializePort ( + (UINTN)FixedPcdGet64 (PcdIoVirtBlkUart0Base), + FixedPcdGet32 (PcdSerialDbgUartClkInHz), + &BaudRate, + &ReceiveFifoDepth, + &Parity, + &DataBits, + &StopBits + ); + + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "Failed to init PL011_UART0 on IO Virt Block port x4_0, status: %r\n= ", + Status + )); + } + + // Use PL011Uart Library to initialize the x8: PL011_UART1 + Status =3D PL011UartInitializePort ( + (UINTN)FixedPcdGet64 (PcdIoVirtBlkUart1Base), + FixedPcdGet32 (PcdSerialDbgUartClkInHz), + &BaudRate, + &ReceiveFifoDepth, + &Parity, + &DataBits, + &StopBits + ); + + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "Failed to init PL011_UART1 on IO Virt Block port x8, status: %r\n", + Status + )); + } +} + EFI_STATUS EFIAPI ArmSgiPkgEntryPoint ( @@ -32,6 +102,7 @@ ArmSgiPkgEntryPoint ( } =20 InitVirtioDevices (); + InitIoVirtBlkUartControllers (); =20 return Status; } diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c b/Pla= tform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c index 8139b75d8ee4..26fd873fa647 100644 --- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c +++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2018-2020, ARM Limited. All rights reserved. +* Copyright (c) 2018-2022, ARM Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -17,7 +17,8 @@ =20 // Total number of descriptors, including the final "end-of-table" descrip= tor. #define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS \ - (14 + (FixedPcdGet32 (PcdChipCount) * 2)) + (14 + (FixedPcdGet32 (PcdChipCount) * 2)) + \ + (FeaturePcdGet (PcdIoVirtBlkNonDiscoverable) * 2) =20 /** Returns the Virtual Memory Map of the platform. @@ -171,6 +172,20 @@ ArmPlatformGetVirtualMemoryMap ( VirtualMemoryTable[Index].Length =3D SIZE_64KB; VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIBUT= E_DEVICE; =20 +#if (FeaturePcdGet (PcdIoVirtBlkNonDiscoverable) =3D=3D true) + // IO Virt Block x4_0: UART0 + VirtualMemoryTable[++Index].PhysicalBase =3D FixedPcdGet64 (PcdIoVirt= BlkUart0Base); + VirtualMemoryTable[Index].VirtualBase =3D FixedPcdGet64 (PcdIoVirt= BlkUart0Base);; + VirtualMemoryTable[Index].Length =3D SIZE_64KB; + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIB= UTE_DEVICE; + + // IO Virt Block x8: UART1 + VirtualMemoryTable[++Index].PhysicalBase =3D FixedPcdGet64 (PcdIoVirt= BlkUart1Base); + VirtualMemoryTable[Index].VirtualBase =3D FixedPcdGet64 (PcdIoVirt= BlkUart1Base); + VirtualMemoryTable[Index].Length =3D SIZE_64KB; + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIB= UTE_DEVICE; +#endif + // DDR - (2GB - 16MB) VirtualMemoryTable[++Index].PhysicalBase =3D PcdGet64 (PcdSystemMemoryB= ase); VirtualMemoryTable[Index].VirtualBase =3D PcdGet64 (PcdSystemMemoryB= ase); --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86649): https://edk2.groups.io/g/devel/message/86649 Mute This Topic: https://groups.io/mt/89134664/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-