From: Wasim Khan <wasim.k...@nxp.com> Add PlatformDxe to do platform specific work. At present it sets PCDs for PCIe controller based on SoC version, which are used later during initialization of PCIe controller.
Signed-off-by: Wasim Khan <wasim.k...@nxp.com> --- Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf | 35 ++++++++ Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c | 90 ++++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf new file mode 100644 index 000000000000..2514adf1d69d --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf @@ -0,0 +1,35 @@ +## @file +# +# Copyright 2020 NXP +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010019 + BASE_NAME = PlatformDxe + FILE_GUID = C4063EBA-7729-11EA-BC55-0232AC130003 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = PlatformDxeEntryPoint + +[Sources] + PlatformDxe.c + +[Packages] + MdePkg/MdePkg.dec + Silicon/NXP/Chassis3V2/Chassis3V2.dec + Silicon/NXP/LX2160A/LX2160A.dec + Silicon/NXP/NxpQoriqLs.dec + +[LibraryClasses] + PcdLib + UefiDriverEntryPoint + +[Pcd] + gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable + gNxpQoriqLsTokenSpaceGuid.PcdPciLsGen4Ctrl + +[Depex] + TRUE diff --git a/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c new file mode 100644 index 000000000000..0caabb448ec0 --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c @@ -0,0 +1,90 @@ +/** @file +* +* Copyright 2020 NXP +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include <Library/DebugLib.h> +#include <Library/PcdLib.h> +#include <Library/SocLib.h> +#include <Soc.h> + +/** + Set PCDs for PCIe controller based on SoC version. + LX2160-Rev1 and LX2160-Rev2 has different PCIe controller. This function + check the SoC version and set PCDs for PCIe controller which will be + used by PciHostBridgeLib and PciSegmentLib for controller initialization. + + @return EFI_SUCCESS PCDs were set successfully + @return EFI_INVALID_PARAMETER Invalid major version number +**/ +EFI_STATUS +SetPciControllerPcdOptions ( + VOID + ) +{ + UINT32 Svr; + + Svr = SocGetSvr (); + if (SVR_SOC_VER(Svr) == SVR_LX2160A) { + switch (SVR_MAJOR(Svr)) { + case 0x1: + // + // LX2160-Rev1 and LX2160-Rev2 has different PCIe controllers. + // Set PcdPciLsGen4Ctrl to TRUE for LX2160-Rev1, which will be used + // by PciHostBridgeLib and PciSegmentLib to differentiate both controllers + // and perform controller specific initialization. + // + PcdSetBoolS (PcdPciLsGen4Ctrl, TRUE); + break; + case 0x2: + // + // PCIe controller in LX2160-Rev2 supports two methods for config + // transactions. + // 1 - Default (Non ECAM compliant): PCIe controller + // requires target BDF to be written to bit[31:16] of type0/type1 + // outbound window. + // 2 - CFG SHIFT: PCIe controller shifts BDF from bits[27:12] to + // bits[31:16] and supports Enhanced Configuration Address Mapping (ECAM) + // mechanism. + // + // Set PcdPciCfgShiftEnable to TRUE for LX2160-Rev2, which will be used by + // PciHostBridgeLib and PciSegmentLib to enable CFG SHIFT feature on + // PCIe controller and program the iATU windows accordingly. + // + PcdSetBoolS (PcdPciCfgShiftEnable, TRUE); + break; + default: + DEBUG ((DEBUG_ERROR, "%a: Invalid SoC Version 0x%x \n", __FUNCTION__, + SVR_MAJOR(Svr))); + return EFI_INVALID_PARAMETER; + } + } + + return EFI_SUCCESS; +} + +/** + The entry point for PlatformDxe driver. This driver + intends to perform platform specific initialization. + + @param[in] ImageHandle The image handle of the driver. + @param[in] SystemTable The system table. + + @retval EFI_SUCCESS Driver initialization success. + +**/ +EFI_STATUS +EFIAPI +PlatformDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // Set PCDs for PCIe controller + Status = SetPciControllerPcdOptions (); + + return Status; +} -- 2.7.4 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61790): https://edk2.groups.io/g/devel/message/61790 Mute This Topic: https://groups.io/mt/75189880/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-