public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@arm.com>
To: Wasim Khan <wasim.khan@oss.nxp.com>,
	devel@edk2.groups.io, meenakshi.aggarwal@nxp.com,
	vabhav.sharma@nxp.com, V.Sethi@nxp.com, leif@nuviainc.com,
	jon@solid-run.com
Cc: Wasim Khan <wasim.khan@nxp.com>
Subject: Re: [PATCH edk2-platforms 04/16] Silicon/NXP: PciHostBridgeLib: CFG Shift feature support for PCIeLS Ctrl
Date: Fri, 22 May 2020 11:22:56 +0200	[thread overview]
Message-ID: <2fa79f8b-2f6a-aed0-e746-1ffa94e1a5d5@arm.com> (raw)
In-Reply-To: <1590102139-16588-5-git-send-email-wasim.khan@oss.nxp.com>

On 5/22/20 1:02 AM, Wasim Khan wrote:
> From: Wasim Khan <wasim.khan@nxp.com>
> 
> PCIe layerscape controller supports CFG Shift feature. It can be
> enabled by setting BIT[28] of iATU Control 2 Register.
> Check PcdPciCfgShiftEnable to enable 'CFG Shift feature' in
> PCIe controller.
> if enable, PCIe layerscape controller shifts BDF from bits[27:12] to
> bits[31:16] and supports Enhanced Configuration Address Mapping (ECAM)
> mechanism.
> 
> PCIe layerscape controller is ECAM complaint for bus[0x1-0xff].
> So create outbound CFG windows from 1MB-256MB (255 buses) for
> type0/type1 configuration access.
> PCIe layerscape controller is Non-ECAM complaint for bus 0.It does
> not support device > 0 on bus 0. PciSegmentLib should handles this
> limitation.
> 
> Signed-off-by: Vabhav Sharma <vabhav.sharma@nxp.com>
> Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
> ---
>   Silicon/NXP/NxpQoriqLs.dec                         |  3 ++
>   .../Library/PciHostBridgeLib/PciHostBridgeLib.inf  |  3 ++
>   Silicon/NXP/Include/Pcie.h                         |  3 ++
>   .../Library/PciHostBridgeLib/PciHostBridgeLib.c    | 35 +++++++++++++++++-----
>   4 files changed, 36 insertions(+), 8 deletions(-)
> 
> diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
> index bafdfd9f4298..293fd773fd3d 100644
> --- a/Silicon/NXP/NxpQoriqLs.dec
> +++ b/Silicon/NXP/NxpQoriqLs.dec
> @@ -36,3 +36,6 @@ [PcdsFixedAtBuild.common]
>     gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x0|UINT32|0x00000502
>     gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x0|UINT32|0x00000503
>     gNxpQoriqLsTokenSpaceGuid.PcdPciDebug|FALSE|BOOLEAN|0x00000504
> +
> +[PcdsDynamic.common]
> +  gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
> diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
> index 5ddb96e4fa6a..98cfb6aee6b0 100644
> --- a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
> +++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
> @@ -38,3 +38,6 @@ [FixedPcd]
>     gNxpQoriqLsTokenSpaceGuid.PcdNumPciController
>     gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase
>     gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg
> +
> +[Pcd]
> +  gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable
> diff --git a/Silicon/NXP/Include/Pcie.h b/Silicon/NXP/Include/Pcie.h
> index d5b5a3884e0a..ae85190180e8 100755
> --- a/Silicon/NXP/Include/Pcie.h
> +++ b/Silicon/NXP/Include/Pcie.h
> @@ -63,6 +63,7 @@
>   #define IATU_UPPER_TARGET_ADDR_OFF_OUTBOUND_0        0x91C
>   #define IATU_VIEWPORT_OUTBOUND                       0x0
>   #define IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN  BIT31
> +#define IATU_ENABLE_CFG_SHIFT_FEATURE                BIT28
>   
>   // ATU Programming
>   #define IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_MEM   0x0
> @@ -82,4 +83,6 @@
>   #define SEG_IO_SIZE               0x10000
>   #define SEG_IO_BUS                0x0
>   
> +#define CFG_SHIFT_ENABLE          (PcdGetBool (PcdPciCfgShiftEnable))
> +
>   #endif
> diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
> index cf872370c7cd..f92863c60868 100644
> --- a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
> +++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
> @@ -259,8 +259,17 @@ PcieOutboundSet (
>     MmioWrite32 (Dbi + IATU_REGION_CTRL_1_OFF_OUTBOUND_0,
>                   (UINT32)Type);
>   
> -  MmioWrite32 (Dbi + IATU_REGION_CTRL_2_OFF_OUTBOUND_0,
> -                IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN);
> +  if (CFG_SHIFT_ENABLE &&
> +     ((Type == IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG0) ||
> +     (Type == IATU_REGION_CTRL_1_OFF_OUTBOUND_0_TYPE_CFG1))) {
> +       MmioWrite32 (Dbi + IATU_REGION_CTRL_2_OFF_OUTBOUND_0,
> +         (IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN |
> +         IATU_ENABLE_CFG_SHIFT_FEATURE)
> +         );
> +  } else {
> +    MmioWrite32 (Dbi + IATU_REGION_CTRL_2_OFF_OUTBOUND_0,
> +                  IATU_REGION_CTRL_2_OFF_OUTBOUND_0_REGION_EN);
> +  }
>   }
>   
>   /**
> @@ -291,12 +300,22 @@ PcieLsSetupAtu (
>     UINT64 Cfg0Size;
>     UINT64 Cfg1Size;
>   
> -  Cfg0BaseAddr = Cfg0Base;
> -  Cfg1BaseAddr = Cfg1Base;
> -  Cfg0BusAddress = SEG_CFG_BUS;
> -  Cfg1BusAddress = SEG_CFG_BUS;
> -  Cfg0Size = SEG_CFG_SIZE;
> -  Cfg1Size = SEG_CFG_SIZE;
> +  if (CFG_SHIFT_ENABLE) {
> +    DEBUG ((DEBUG_INFO, "PCIe: CFG Shit Method Enabled \n"));

Please add the missing 'f'

> +    Cfg0BaseAddr = Cfg0Base + SIZE_1MB;
> +    Cfg1BaseAddr = Cfg0Base + SIZE_2MB;
> +    Cfg0BusAddress = SIZE_1MB;
> +    Cfg1BusAddress = SIZE_2MB;
> +    Cfg0Size = SIZE_1MB;
> +    Cfg1Size = (SIZE_256MB - SIZE_1MB); // 255MB

This logic would be much more self-explanatory if you used a symbolic 
constant 'ECAM_BUS_SIZE' instead of SIZE_1MB (and add a comment that 
type 0 CFG TLPs only go to bus #1)

> +  } else {
> +    Cfg0BaseAddr = Cfg0Base;
> +    Cfg1BaseAddr = Cfg1Base;
> +    Cfg0BusAddress = SEG_CFG_BUS;
> +    Cfg1BusAddress = SEG_CFG_BUS;
> +    Cfg0Size = SEG_CFG_SIZE;
> +    Cfg1Size = SEG_CFG_SIZE;
> +  }
>   
>     // iATU : OUTBOUND WINDOW 1 : CFG0
>     PcieOutboundSet (Pcie,
> 



  reply	other threads:[~2020-05-22  9:23 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21 23:02 [PATCH edk2-platforms 00/16] Add PCIe Support Wasim Khan
2020-05-21 23:02 ` [PATCH edk2-platforms 01/16] Silicon/NXP/NxpQoriqLs.dec: Add PCIe related PCDs Wasim Khan
2020-05-22  9:12   ` Ard Biesheuvel
2020-05-24 18:31     ` Wasim Khan (OSS)
2020-05-26  6:16       ` Ard Biesheuvel
2020-05-21 23:02 ` [PATCH edk2-platforms 02/16] Silicon/NXP: LS1043A: Define " Wasim Khan
2020-05-21 23:02 ` [PATCH edk2-platforms 03/16] Silicon/NXP: Implement PciHostBridgeLib support Wasim Khan
2020-05-22  9:20   ` Ard Biesheuvel
2020-05-21 23:02 ` [PATCH edk2-platforms 04/16] Silicon/NXP: PciHostBridgeLib: CFG Shift feature support for PCIeLS Ctrl Wasim Khan
2020-05-22  9:22   ` Ard Biesheuvel [this message]
2020-05-21 23:02 ` [PATCH edk2-platforms 05/16] Silicon/NXP: PciHostBridgeLib: Setup PCIe LsGen4 Controller and ATU Windows Wasim Khan
2020-05-22  9:24   ` Ard Biesheuvel
2020-05-24 18:31     ` Wasim Khan (OSS)
2020-05-21 23:02 ` [PATCH edk2-platforms 06/16] Silicon/NXP: PciHostBridgeLib: add Workaround for A-011451 Wasim Khan
2020-05-21 23:02 ` [PATCH edk2-platforms 07/16] Silicon/NXP: PciHostBridgeLib: Dump Layerscale Gen4 ATU windows Wasim Khan
2020-05-22  9:33   ` Ard Biesheuvel
2020-05-21 23:02 ` [PATCH edk2-platforms 08/16] Silicon/NXP: PciHostBridgeLib: Dump Layerscale iATU windows Wasim Khan
2020-05-22  9:31   ` Ard Biesheuvel
2020-05-21 23:02 ` [PATCH edk2-platforms 09/16] Silicon/NXP: Implement PciSegmentLib for PCIe Layerscape Controller Wasim Khan
2020-05-22  9:29   ` Ard Biesheuvel
2020-05-24 18:32     ` Wasim Khan (OSS)
2020-05-25  4:30       ` Jon Nettleton
2020-05-25 15:21         ` Wasim Khan (OSS)
2020-05-21 23:02 ` [PATCH edk2-platforms 10/16] Silicon/NXP: PciSegmentLib: Add ECAM config support for PCIe LS Controller Wasim Khan
2020-05-22  9:36   ` Ard Biesheuvel
2020-05-24 18:32     ` Wasim Khan (OSS)
2020-05-21 23:02 ` [PATCH edk2-platforms 11/16] Silicon/NXP: PciSegmentLib: Add support PCIe LsGen4 Controller Wasim Khan
2020-05-22  9:38   ` Ard Biesheuvel
2020-05-24 18:32     ` Wasim Khan (OSS)
2020-05-21 23:02 ` [PATCH edk2-platforms 12/16] Silicon/NXP: PciSegmentLib: LsGen4Ctrl: Add Workaround for A-011264 Wasim Khan
2020-05-22  9:39   ` Ard Biesheuvel
2020-05-24 18:32     ` Wasim Khan (OSS)
2020-05-21 23:02 ` [PATCH edk2-platforms 13/16] Silicon/NXP/Drivers: Implement PciCpuIo2Dxe Driver Wasim Khan
2020-05-22  9:42   ` Ard Biesheuvel
2020-05-21 23:02 ` [PATCH edk2-platforms 14/16] Platform/NXP: LS1043aRdbPkg: Enable NetworkPkg Wasim Khan
2020-05-22  9:42   ` Ard Biesheuvel
2020-05-21 23:02 ` [PATCH edk2-platforms 15/16] Platform/NXP: LS1043aRdbPkg: Enable PCIE support Wasim Khan
2020-05-21 23:02 ` [PATCH edk2-platforms 16/16] Platform/NXP: LS1043aRdbPkg : Increase fv image size Wasim Khan
2020-05-22  9:44   ` Ard Biesheuvel
2020-05-22  9:46 ` [PATCH edk2-platforms 00/16] Add PCIe Support Ard Biesheuvel
2020-05-22 10:58   ` Leif Lindholm
2020-05-24 18:32     ` Wasim Khan (OSS)

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=2fa79f8b-2f6a-aed0-e746-1ffa94e1a5d5@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