From: Shriram K <shrira...@arm.com> 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 <shrira...@arm.com> Signed-off-by: Vivek Gautam <vivek.gau...@arm.com> --- 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/SgiPlatform.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|0x00000050 [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 +[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/SgiPkg/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.<BR> +# Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -47,6 +47,10 @@ gArmPlatformTokenSpaceGuid.PcdCoreCount|1 gArmPlatformTokenSpaceGuid.PcdClusterCount|8 +[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/Platform/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 [Packages] + ArmPlatformPkg/ArmPlatformPkg.dec EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec @@ -35,12 +36,16 @@ [FeaturePcd] gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported gArmSgiTokenSpaceGuid.PcdVirtioNetSupported + gArmSgiTokenSpaceGuid.PcdIoVirtBlkNonDiscoverable [FixedPcd] gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress gArmSgiTokenSpaceGuid.PcdVirtioBlkSize gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress gArmSgiTokenSpaceGuid.PcdVirtioNetSize + gArmPlatformTokenSpaceGuid.PcdSerialDbgUartClkInHz + gArmSgiTokenSpaceGuid.PcdIoVirtBlkUart0Base + gArmSgiTokenSpaceGuid.PcdIoVirtBlkUart1Base [Depex] TRUE diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf b/Platform/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 + gArmSgiTokenSpaceGuid.PcdIoVirtBlkUart0Base + gArmSgiTokenSpaceGuid.PcdIoVirtBlkUart1Base + +[FeaturePcd] + gArmSgiTokenSpaceGuid.PcdIoVirtBlkNonDiscoverable + [Guids] gArmSgiPlatformIdDescriptorGuid gEfiHobListGuid ## CONSUMES ## SystemTable diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/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 <Library/AcpiLib.h> #include <Library/DebugLib.h> #include <Library/HobLib.h> +#include <Library/PL011UartLib.h> + #include <SgiPlatform.h> VOID @@ -16,6 +18,74 @@ InitVirtioDevices ( VOID ); +/** + 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 = 0; + Parity = 1; + DataBits = 8; + StopBits = 1; + BaudRate = 115200; + + // Use PL011Uart Library to initialize the x4: PL011_UART0 + Status = 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 = 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 ( } InitVirtioDevices (); + InitIoVirtBlkUartControllers (); return Status; } diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c b/Platform/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 @@ // Total number of descriptors, including the final "end-of-table" descriptor. #define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS \ - (14 + (FixedPcdGet32 (PcdChipCount) * 2)) + (14 + (FixedPcdGet32 (PcdChipCount) * 2)) + \ + (FeaturePcdGet (PcdIoVirtBlkNonDiscoverable) * 2) /** Returns the Virtual Memory Map of the platform. @@ -171,6 +172,20 @@ ArmPlatformGetVirtualMemoryMap ( VirtualMemoryTable[Index].Length = SIZE_64KB; VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; +#if (FeaturePcdGet (PcdIoVirtBlkNonDiscoverable) == true) + // IO Virt Block x4_0: UART0 + VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdIoVirtBlkUart0Base); + VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdIoVirtBlkUart0Base);; + VirtualMemoryTable[Index].Length = SIZE_64KB; + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; + + // IO Virt Block x8: UART1 + VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdIoVirtBlkUart1Base); + VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdIoVirtBlkUart1Base); + VirtualMemoryTable[Index].Length = SIZE_64KB; + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; +#endif + // DDR - (2GB - 16MB) VirtualMemoryTable[++Index].PhysicalBase = PcdGet64 (PcdSystemMemoryBase); VirtualMemoryTable[Index].VirtualBase = PcdGet64 (PcdSystemMemoryBase); -- 2.17.1 -=-=-=-=-=-=-=-=-=-=-=- 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/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-