public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "PierreGondois" <pierre.gondois@arm.com>
To: Vivek Gautam <vivek.gautam@arm.com>, devel@edk2.groups.io
Cc: ardb+tianocore@kernel.org, leif@nuviainc.com, Sami.Mujawar@arm.com
Subject: Re: [edk2-platforms][PATCH V2 4/5] Platform/Sgi: Initialize additional UART controllers
Date: Fri, 3 Feb 2023 16:55:47 +0100	[thread overview]
Message-ID: <f8c0ca1e-3553-70f4-4824-1cc08757e5c2@arm.com> (raw)
In-Reply-To: <20230127092338.72056-5-vivek.gautam@arm.com>

Hello Vivek,

On 1/27/23 10:23, Vivek Gautam wrote:
> From: Shriram K <shriram.k@arm.com>
> 
> The IO virtualization block on reference design platforms allow
> connecting SoC expansion 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 <shriram.k@arm.com>
> Signed-off-by: Vivek Gautam <vivek.gautam@arm.com>
> ---
>   Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf  | 10 ++-
>   Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf  |  7 ++-
>   Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c    | 64 +++++++++++++++++++-
>   Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c | 43 ++++++++++++-
>   Platform/ARM/SgiPkg/SgiPlatform.dec                      |  1 +
>   5 files changed, 118 insertions(+), 7 deletions(-)
> 
> diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> index 9d89314a594e..42feadaf5f6f 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 - 2023, 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
> @@ -37,10 +38,17 @@
>     gArmSgiTokenSpaceGuid.PcdVirtioNetSupported
>   
>   [FixedPcd]
> +  gArmSgiTokenSpaceGuid.PcdChipCount
> +  gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlk0Base
> +  gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlkPeriOffset
> +  gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlkUartEnable
> +  gArmSgiTokenSpaceGuid.PcdMaxAddressBitsPerChip
>     gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
>     gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
>     gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress
>     gArmSgiTokenSpaceGuid.PcdVirtioNetSize
>   
> +  gArmPlatformTokenSpaceGuid.PcdSerialDbgUartClkInHz
> +
>   [Depex]
>     TRUE
> diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
> index 1ca7679b4191..4459b20ecb06 100644
> --- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
> +++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
> @@ -1,5 +1,5 @@
>   #
> -#  Copyright (c) 2018 - 2022, Arm Limited. All rights reserved.
> +#  Copyright (c) 2018 - 2023, Arm Limited. All rights reserved.
>   #
>   #  SPDX-License-Identifier: BSD-2-Clause-Patent
>   #
> @@ -41,10 +41,13 @@
>     gArmPlatformTokenSpaceGuid.PcdCoreCount
>     gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase
>   
> -  gArmSgiTokenSpaceGuid.PcdMaxAddressBitsPerChip
>     gArmSgiTokenSpaceGuid.PcdDramBlock2Base
>     gArmSgiTokenSpaceGuid.PcdDramBlock2Size
>     gArmSgiTokenSpaceGuid.PcdGicSize
> +  gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlk0Base
> +  gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlkPeriOffset
> +  gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlkUartEnable
> +  gArmSgiTokenSpaceGuid.PcdMaxAddressBitsPerChip
>   
>     gArmTokenSpaceGuid.PcdSystemMemoryBase
>     gArmTokenSpaceGuid.PcdSystemMemorySize
> diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> index 2f72e7152ff3..b3a998bc1585 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 - 2023, ARM Limited. All rights reserved.
>   *
>   *  SPDX-License-Identifier: BSD-2-Clause-Patent
>   *
> @@ -9,6 +9,9 @@
>   #include <Library/AcpiLib.h>
>   #include <Library/DebugLib.h>
>   #include <Library/HobLib.h>
> +#include <Library/PL011UartLib.h>
> +
> +#include <IoVirtSoCExp.h>
>   #include <SgiPlatform.h>
>   
>   VOID
> @@ -16,6 +19,64 @@ InitVirtioDevices (
>     VOID
>     );
>   
> +/**
> +  Initialize UART controllers connected to IO Virtualization block.
> +
> +  Use PL011UartLib Library to initialize UART controllers that are present in
> +  the SoC expansion block. This SoC expansion block is connected to the IO
> +  virtualization block on Arm infrastructure reference design (RD) platforms.
> +
> +  @retval  None
> +**/
> +STATIC
> +VOID
> +InitIoVirtSocExpBlkUartControllers (VOID)
> +{
> +  EFI_STATUS                 Status;
> +  EFI_PARITY_TYPE            Parity;
> +  EFI_STOP_BITS_TYPE         StopBits;
> +  UINT64                     BaudRate;
> +  UINT32                     ReceiveFifoDepth;
> +  UINT8                      DataBits;
> +  UINT8                      UartIdx;
> +  UINT32                     ChipIdx;
> +  UINT64                     UartAddr;
> +
> +  if (FixedPcdGet32 (PcdIoVirtSocExpBlkUartEnable) == 0)
> +    return;
> +
> +  ReceiveFifoDepth = 0;
> +  Parity = 1;
> +  DataBits = 8;
> +  StopBits = 1;
> +  BaudRate = 115200;
> +
> +  for (ChipIdx = 0; ChipIdx < FixedPcdGet32 (PcdChipCount); ChipIdx++) {
> +    for (UartIdx = 0; UartIdx < 2; UartIdx++) {
> +      UartAddr = SGI_REMOTE_CHIP_MEM_OFFSET(ChipIdx) + UART_START(UartIdx);
> +
> +      Status = PL011UartInitializePort (
> +                 (UINTN)UartAddr,
> +                 FixedPcdGet32 (PcdSerialDbgUartClkInHz),
> +                 &BaudRate,
> +                 &ReceiveFifoDepth,
> +                 &Parity,
> +                 &DataBits,
> +                 &StopBits
> +                 );
> +
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((
> +          DEBUG_ERROR,
> +          "Failed to init PL011_UART%u on IO Virt Block port, status: %r\n",
> +          UartIdx,
> +          Status
> +          ));
> +      }
> +    }
> +  }
> +}
> +
>   EFI_STATUS
>   EFIAPI
>   ArmSgiPkgEntryPoint (
> @@ -32,6 +93,7 @@ ArmSgiPkgEntryPoint (
>     }
>   
>     InitVirtioDevices ();
> +  InitIoVirtSocExpBlkUartControllers ();
>   
>     return Status;
>   }
> diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
> index 8139b75d8ee4..08aa9bf64940 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 - 2023, Arm Limited. All rights reserved.
>   *
>   *  SPDX-License-Identifier: BSD-2-Clause-Patent
>   *
> @@ -13,11 +13,23 @@
>   #include <Library/IoLib.h>
>   #include <Library/MemoryAllocationLib.h>
>   
> +#include <IoVirtSoCExp.h>
>   #include <SgiPlatform.h>
>   
>   // Total number of descriptors, including the final "end-of-table" descriptor.
> -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS                 \
> -          (14 + (FixedPcdGet32 (PcdChipCount) * 2))
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS                                     \
> +          ((14 + (FixedPcdGet32 (PcdChipCount) * 2)) +                         \
> +           (FixedPcdGet32 (PcdIoVirtSocExpBlkUartEnable) *                     \
> +            FixedPcdGet32 (PcdChipCount) * 2))
> +
> +// Memory Map descriptor for IO Virtualization SoC Expansion Block UART
> +#define IO_VIRT_SOC_EXP_BLK_UART_MMAP(UartIdx, ChipIdx)                        \
> +  VirtualMemoryTable[++Index].PhysicalBase =                                   \
> +    SGI_REMOTE_CHIP_MEM_OFFSET(ChipIdx) + UART_START(UartIdx);                 \
> +  VirtualMemoryTable[Index].VirtualBase    =                                   \
> +    SGI_REMOTE_CHIP_MEM_OFFSET(ChipIdx) + UART_START(UartIdx);                 \
> +  VirtualMemoryTable[Index].Length         = SIZE_64KB;                        \
> +  VirtualMemoryTable[Index].Attributes     = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>   
>   /**
>     Returns the Virtual Memory Map of the platform.
> @@ -171,6 +183,31 @@ ArmPlatformGetVirtualMemoryMap (
>     VirtualMemoryTable[Index].Length          = SIZE_64KB;
>     VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>   
> +#if (FixedPcdGet32 (PcdIoVirtSocExpBlkUartEnable) == 1)
> +  // Chip-0 IO Virtualization SoC Expansion Block - UART0
> +  IO_VIRT_SOC_EXP_BLK_UART_MMAP(0, 0)
> +  // Chip-0 IO Virtualization SoC Expansion Block - UART0

NIT: shouldn't it be UART1 ?

> +  IO_VIRT_SOC_EXP_BLK_UART_MMAP(1, 0)
> +#if (FixedPcdGet32 (PcdChipCount) > 1)
> +  // Chip-1 IO Virtualization SoC Expansion Block - UART0
> +  IO_VIRT_SOC_EXP_BLK_UART_MMAP(0, 1)
> +  // Chip-1 IO Virtualization SoC Expansion Block - UART1
> +  IO_VIRT_SOC_EXP_BLK_UART_MMAP(1, 1)
> +#if (FixedPcdGet32 (PcdChipCount) > 2)
> +  // Chip-2 IO Virtualization SoC Expansion Block - UART0
> +  IO_VIRT_SOC_EXP_BLK_UART_MMAP(0, 2)
> +  // Chip-2 IO Virtualization SoC Expansion Block - UART1
> +  IO_VIRT_SOC_EXP_BLK_UART_MMAP(1, 2)
> +#if (FixedPcdGet32 (PcdChipCount) > 3)
> +  // Chip-3 IO Virtualization SoC Expansion Block - UART0
> +  IO_VIRT_SOC_EXP_BLK_UART_MMAP(0, 3)
> +  // Chip-3 IO Virtualization SoC Expansion Block - UART1
> +  IO_VIRT_SOC_EXP_BLK_UART_MMAP(1, 3)
> +#endif
> +#endif
> +#endif
> +#endif
> +
>     // DDR - (2GB - 16MB)
>     VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64 (PcdSystemMemoryBase);
>     VirtualMemoryTable[Index].VirtualBase     = PcdGet64 (PcdSystemMemoryBase);
> diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
> index 407f03c1c3e8..43d350ec48bb 100644
> --- a/Platform/ARM/SgiPkg/SgiPlatform.dec
> +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
> @@ -102,6 +102,7 @@
>     gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlk0Base|0|UINT64|0x0000002B
>     gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlkPeriOffset|0|UINT32|0x0000002C
>     gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlkResourceSize|0|UINT32|0x0000002D
> +  gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlkUartEnable|0|UINT32|0x0000002E

PcdIoVirtSocExpBlkUartEnable isn't set for any platform, is it normal ?

>   
>   [Ppis]
>     gNtFwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }

  reply	other threads:[~2023-02-03 15:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27  9:23 [edk2-platforms][PATCH V2 0/5] Enable SoC expansion block and Virtio-P9 for RD-N2 variants Vivek Kumar Gautam
2023-01-27  9:23 ` [edk2-platforms][PATCH V2 1/5] Platform/Sgi: Add SSDT table for Virtio-P9 Vivek Kumar Gautam
2023-01-27  9:23 ` [edk2-platforms][PATCH V2 2/5] Platform/Sgi: Enable virtio-p9 device on RD-N2 platform variants Vivek Kumar Gautam
2023-01-27  9:23 ` [edk2-platforms][PATCH V2 3/5] Platform/Sgi: Add SSDT table for IO virtualization SoC expansion block Vivek Kumar Gautam
2023-02-03 15:56   ` PierreGondois
2023-02-07  6:59     ` Vivek Kumar Gautam
2023-02-07  8:50       ` PierreGondois
2023-02-10  7:54         ` Vivek Kumar Gautam
2023-01-27  9:23 ` [edk2-platforms][PATCH V2 4/5] Platform/Sgi: Initialize additional UART controllers Vivek Kumar Gautam
2023-02-03 15:55   ` PierreGondois [this message]
2023-02-07  6:10     ` [edk2-devel] " Vivek Kumar Gautam
2023-01-27  9:23 ` [edk2-platforms][PATCH V2 5/5] Platform/Sgi: Enable SoC expansion block for RD-N2 variants Vivek Kumar Gautam
2023-02-03 15:58 ` [edk2-platforms][PATCH V2 0/5] Enable SoC expansion block and Virtio-P9 " PierreGondois
2023-02-07  6:15   ` Vivek Kumar Gautam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f8c0ca1e-3553-70f4-4824-1cc08757e5c2@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox