From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: vivek.gautam@arm.com) 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) 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-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> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220214121307.14608-1-vivek.gautam@arm.com> References: <20220214121307.14608-1-vivek.gautam@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/Sg= iPlatform.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|0x0000= 0050 =20 [PcdsFixedAtBuild] gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002 diff --git a/Platform/ARM/SgiPkg/RdN2/RdN2.dsc b/Platform/ARM/SgiPkg/RdN2= /RdN2.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 Platfor= m diff --git a/Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc b/Platform/ARM/Sgi= Pkg/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 Platfor= m diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Pl= atform/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/Pl= atform/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/Plat= form/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/P= latform/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" descr= iptor. #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_ATTRIB= UTE_DEVICE; =20 +#if (FeaturePcdGet (PcdIoVirtBlkNonDiscoverable) =3D=3D true) + // IO Virt Block x4_0: UART0 + VirtualMemoryTable[++Index].PhysicalBase =3D FixedPcdGet64 (PcdIoVi= rtBlkUart0Base); + VirtualMemoryTable[Index].VirtualBase =3D FixedPcdGet64 (PcdIoVi= rtBlkUart0Base);; + VirtualMemoryTable[Index].Length =3D SIZE_64KB; + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTR= IBUTE_DEVICE; + + // IO Virt Block x8: UART1 + VirtualMemoryTable[++Index].PhysicalBase =3D FixedPcdGet64 (PcdIoVi= rtBlkUart1Base); + VirtualMemoryTable[Index].VirtualBase =3D FixedPcdGet64 (PcdIoVi= rtBlkUart1Base); + VirtualMemoryTable[Index].Length =3D SIZE_64KB; + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTR= IBUTE_DEVICE; +#endif + // DDR - (2GB - 16MB) VirtualMemoryTable[++Index].PhysicalBase =3D PcdGet64 (PcdSystemMemor= yBase); VirtualMemoryTable[Index].VirtualBase =3D PcdGet64 (PcdSystemMemor= yBase); --=20 2.17.1