From: Wasim Khan <wasim.k...@nxp.com>

PCIe Layerscape controller in LX2160A-Rev2 is not completely
ECAM-compliant. It is non-ECAM only for the root bus (bus 0)
and for any other bus underneath the root bus it does support
ECAM access.
One approach can be to setup the controller in firmware and
expose bus[0x1-0xff] to OS via MCFG and DSDT table.
Introduce PcdPciHideRootPort PCD and set it for LX2160A-Rev2 for this.
Limit the size of CFG0 iATU window (for type0 config transactions)
to 32KB to avoid enumuration of unwanted devices in OS.

Signed-off-by: Wasim Khan <wasim.k...@nxp.com>
---
 Silicon/NXP/NxpQoriqLs.dec                                     |  1 +
 Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf |  1 +
 Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf      |  1 +
 Silicon/NXP/Include/Pcie.h                                     |  1 +
 Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c   | 18 
++++++++++++++++++
 Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c        |  6 +++++-
 6 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
index d09a1ae194be..188a9fe1f382 100644
--- a/Silicon/NXP/NxpQoriqLs.dec
+++ b/Silicon/NXP/NxpQoriqLs.dec
@@ -40,3 +40,4 @@ [PcdsFixedAtBuild.common]
 [PcdsDynamic.common]
   gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable|FALSE|BOOLEAN|0x00000600
   gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl|FALSE|BOOLEAN|0x00000601
+  gNxpQoriqLsTokenSpaceGuid.PcdPciHideRootPort|FALSE|BOOLEAN|0x00000602
diff --git a/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf 
b/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
index 2514adf1d69d..674ba3b298f3 100644
--- a/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
+++ b/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
@@ -30,6 +30,7 @@ [LibraryClasses]
 [Pcd]
   gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable
   gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl
+  gNxpQoriqLsTokenSpaceGuid.PcdPciHideRootPort
 
 [Depex]
   TRUE
diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf 
b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
index 6003da708698..3726ec15317f 100644
--- a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
@@ -42,3 +42,4 @@ [FixedPcd]
 [Pcd]
   gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable
   gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl
+  gNxpQoriqLsTokenSpaceGuid.PcdPciHideRootPort
diff --git a/Silicon/NXP/Include/Pcie.h b/Silicon/NXP/Include/Pcie.h
index b5bf0ff5d1d4..4bc99bb53025 100755
--- a/Silicon/NXP/Include/Pcie.h
+++ b/Silicon/NXP/Include/Pcie.h
@@ -31,6 +31,7 @@
 #define PCI_SEG_PORTIO_MIN        0x0
 #define PCI_SEG_PORTIO_MAX        0xffff
 #define SEG_CFG_SIZE              0x00001000
+#define ECAM_DEVICE_SIZE          SIZE_32KB
 #define ECAM_BUS_SIZE             SIZE_1MB
 #define ECAM_CFG_REGION_SIZE      SIZE_256MB
 #define SEG_MEM_BASE              0x40000000
diff --git a/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c 
b/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c
index 73599aaeb7bf..4733309da47c 100644
--- a/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c
+++ b/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c
@@ -9,6 +9,23 @@
 #include <Soc.h>
 
 /**
+  Hide PCI Root Port for LX2160A-Rev2
+
+**/
+VOID
+HidePciRootPort (
+  VOID
+  )
+{
+  UINT32 Svr;
+
+  Svr = SocGetSvr ();
+  if ((SVR_SOC_VER(Svr) == SVR_LX2160A) && (SVR_MAJOR(Svr) == 0x2)) {
+    PcdSetBoolS (PcdPciHideRootPort, TRUE);
+  }
+}
+
+/**
   Enable PciCfgShift feature for LX2160-Rev2
 
 **/
@@ -53,6 +70,7 @@ PlatformPciInit (
 {
   EnableCfgShift ();
   EnablePciController ();
+  HidePciRootPort ();
 }
 
 /**
diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c 
b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 8bbbaaa6e24d..7f11d7a60256 100644
--- a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -432,7 +432,11 @@ PcieLsSetupAtu (
     Cfg0BusAddress = SIZE_1MB;
     Cfg1BusAddress = SIZE_2MB;
     // Region for type0 CFG transactions (only for bus1)
-    Cfg0Size = ECAM_BUS_SIZE;
+    if (PcdGetBool (PcdPciHideRootPort)) {
+      Cfg0Size = ECAM_DEVICE_SIZE;
+    } else {
+      Cfg0Size = ECAM_BUS_SIZE;
+    }
     // Region for type1 CFG transactions (for bus > 1)
     Cfg1Size = (ECAM_CFG_REGION_SIZE - ECAM_BUS_SIZE); // 255MB
   } else {
-- 
2.7.4


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61049): https://edk2.groups.io/g/devel/message/61049
Mute This Topic: https://groups.io/mt/74793006/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to