From: Wasim Khan <wasim.khan@oss.nxp.com>
To: devel@edk2.groups.io, meenakshi.aggarwal@nxp.com,
vabhav.sharma@nxp.com, V.Sethi@nxp.com, ard.biesheuvel@arm.com,
leif@nuviainc.com, jon@solid-run.com
Cc: Wasim Khan <wasim.khan@nxp.com>
Subject: [PATCH edk2-platforms v2 11/16] Silicon/NXP: PciSegmentLib: Add support PCIe LsGen4 Controller
Date: Tue, 26 May 2020 14:07:16 +0530 [thread overview]
Message-ID: <1590482241-13132-12-git-send-email-wasim.khan@oss.nxp.com> (raw)
In-Reply-To: <1590482241-13132-1-git-send-email-wasim.khan@oss.nxp.com>
From: Wasim Khan <wasim.khan@nxp.com>
PCIe Layerscape Gen4 controller is not ECAM compliant and have
different PCI config space region for bus 0 (Controller space) and
bus[0x1-0xff] on NXP SoCs.
For config transactions for Bus0:
- Config transaction address = PCIe controller address + offset
For config transactions for Bus[0x1-0xff]:
- PCIe IP requires target BDF to be written at bit[31:16] of PCIe
outbound configuration window.
PCIe LsGen4 controller uses paging mechanism to access registers.
To access PCIe CCSR registers which are above 3KB offset, page number
must be set in Bridge Control Register.
Co-authored-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Co-authored-by: Wasim Khan <wasim.khan@nxp.com>
Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
---
Notes:
V2:
- fix typo in commit message
- Removed Signed-off and added Co-authored-by for co-author
- Addressed review comments to:
- Drop outer () while calulating Target
- Use (Bus > 0) instead of (Bus)
Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf | 1 +
Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c | 60 +++++++++++++++++++-
2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf
index 936213dc8a9d..d6d7ea6e3b6b 100755
--- a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf
+++ b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf
@@ -33,3 +33,4 @@ [FixedPcd]
[Pcd]
gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable
+ gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl
diff --git a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c
index e5251ecf0dd8..09ce620ef988 100755
--- a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c
+++ b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c
@@ -35,6 +35,58 @@ typedef enum {
ASSERT (((A) & (0xffff0000f0000000ULL | (M))) == 0)
static BOOLEAN CfgShiftEnable;
+static BOOLEAN PciLsGen4Ctrl;
+
+STATIC
+VOID
+PcieCfgSetTarget (
+ IN EFI_PHYSICAL_ADDRESS Dbi,
+ IN UINT32 Target)
+{
+ PciLsGen4Write32 ((UINTN)Dbi, PAB_AXI_AMAP_PEX_WIN_L(0), Target);
+ PciLsGen4Write32 ((UINTN)Dbi, PAB_AXI_AMAP_PEX_WIN_H(0), 0);
+}
+
+/**
+ Function to return PCIe Physical Address(PCIe view) or Controller
+ Address(CPU view) for NXP Layerscape Gen4 SoC
+
+ @param Address Address passed from bus layer.
+ @param Segment Segment number for Root Complex.
+ @param Offset Config space register offset.
+ @param Bus PCIe Bus number.
+
+ @return Return PCIe CPU or Controller address.
+
+**/
+STATIC
+UINT64
+PciLsGen4GetConfigBase (
+ IN UINT64 Address,
+ IN UINT16 Segment,
+ IN UINT16 Offset,
+ IN UINT8 Bus
+ )
+{
+ UINT32 Target;
+
+ if (Bus > 0) {
+ Target = (((Address >> 20) & 0xFF) << 24) |
+ (((Address >> 15) & 0x1F) << 19) |
+ (((Address >> 12) & 0x7) << 16);
+
+ PcieCfgSetTarget ((PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF* Segment), Target);
+ return PCI_SEG0_MMIO_MEMBASE + Offset + PCI_BASE_DIFF * Segment;
+ } else {
+ if (Offset < INDIRECT_ADDR_BNDRY) {
+ PciLsGen4SetPg (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment, 0);
+ return (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment + Offset);
+ }
+ PciLsGen4SetPg (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment, OFFSET_TO_PAGE_IDX (Offset));
+ Offset = OFFSET_TO_PAGE_ADDR (Offset);
+ return (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment + Offset);
+ }
+}
STATIC
UINT64
@@ -129,7 +181,12 @@ PciSegmentLibGetConfigBase (
UINT8 Bus;
Bus = ((UINT32)Address >> 20) & 0xff;
- return PciLsGetConfigBase (Address, Segment, Offset, Bus);
+
+ if (PciLsGen4Ctrl) {
+ return PciLsGen4GetConfigBase (Address, Segment, Offset, Bus);
+ } else {
+ return PciLsGetConfigBase (Address, Segment, Offset, Bus);
+ }
}
/**
@@ -620,5 +677,6 @@ PciSegLibInit (
)
{
CfgShiftEnable = CFG_SHIFT_ENABLE;
+ PciLsGen4Ctrl = PCI_LS_GEN4_CTRL;
return EFI_SUCCESS;
}
--
2.7.4
next prev parent reply other threads:[~2020-05-26 8:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-26 8:37 [PATCH edk2-platforms v2 00/16] Add PCIe Support Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 01/16] Silicon/NXP/NxpQoriqLs.dec: Add PCIe related PCDs Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 02/16] Silicon/NXP: LS1043A: Define " Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 03/16] Silicon/NXP: Implement PciHostBridgeLib support Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 04/16] Silicon/NXP: PciHostBridgeLib: CFG Shift feature support for PCIeLS Ctrl Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 05/16] Silicon/NXP: PciHostBridgeLib: Setup PCIe LsGen4 Controller and ATU Windows Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 06/16] Silicon/NXP: PciHostBridgeLib: add Workaround for A-011451 Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 07/16] Silicon/NXP: PciHostBridgeLib: Dump Layerscale Gen4 ATU windows Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 08/16] Silicon/NXP: PciHostBridgeLib: Dump Layerscale iATU windows Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 09/16] Silicon/NXP: Implement PciSegmentLib for PCIe Layerscape Controller Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 10/16] Silicon/NXP: PciSegmentLib: Add ECAM config support for PCIe LS Controller Wasim Khan
2020-05-26 8:37 ` Wasim Khan [this message]
2020-05-26 8:37 ` [PATCH edk2-platforms v2 12/16] Silicon/NXP: PciSegmentLib: LsGen4Ctrl: Add Workaround for A-011264 Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 13/16] Silicon/NXP/Drivers: Implement PciCpuIo2Dxe Driver Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 14/16] Platform/NXP: LS1043aRdbPkg: Enable NetworkPkg Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 15/16] Platform/NXP: LS1043aRdbPkg: Enable PCIE support Wasim Khan
2020-05-26 8:37 ` [PATCH edk2-platforms v2 16/16] Platform/NXP: LS1043aRdbPkg : Increase fv image size Wasim Khan
2020-05-26 9:53 ` [PATCH edk2-platforms v2 00/16] Add PCIe Support Ard Biesheuvel
2020-05-26 10:17 ` Ard Biesheuvel
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=1590482241-13132-12-git-send-email-wasim.khan@oss.nxp.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