From d57df3843be8676f705aa7597c9cbdbba8bb8a94 Mon Sep 17 00:00:00 2001 From: lushifex Date: Thu, 30 Nov 2017 13:22:39 +0800 Subject: Set eMMCHost Speed. Add a temporary platform workaround to downgrade eMMC host from HS400 to HS200 on MinnowBoard 3 FAB B and MinnowBoard 3 Next Pre-production board. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: lushifex --- .../BensonGlacier/BoardInitPostMem/BoardInit.c | 9 ++++-- .../BoardInitPostMem/BoardInitPostMem.inf | 1 + .../Board/LeafHill/BoardInitPostMem/BoardInit.c | 28 +++++++++++++++++ .../LeafHill/BoardInitPostMem/BoardInitPostMem.inf | 1 + .../MinnowBoard3/BoardInitPostMem/BoardInit.c | 35 ++++++++++++++++++++++ .../MinnowBoard3/BoardInitPostMem/BoardInitMiscs.h | 7 +++++ .../BoardInitPostMem/BoardInitPostMem.inf | 1 + .../MinnowBoard3Next/BoardInitPostMem/BoardInit.c | 35 ++++++++++++++++++++++ .../BoardInitPostMem/BoardInitMiscs.h | 7 +++++ .../BoardInitPostMem/BoardInitPostMem.inf | 1 + .../PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf | 1 + .../PeiFspPolicyInitLib/PeiFspScPolicyInitLib.c | 3 +- .../PeiPolicyUpdateLib/PeiPolicyUpdateLib.inf | 1 + .../Library/PeiPolicyUpdateLib/PeiScPolicyUpdate.c | 2 +- Platform/BroxtonPlatformPkg/PlatformPkg.dec | 2 ++ 15 files changed, 130 insertions(+), 4 deletions(-) diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c index 28fc529228..74245de123 100644 --- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c +++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c @@ -58,13 +58,13 @@ BensonGlacierPostMemInitCallback ( VariableSize = sizeof (SYSTEM_CONFIGURATION); ZeroMem (&SystemConfiguration, sizeof (SYSTEM_CONFIGURATION)); - (*PeiServices)->LocatePpi ( + (*PeiServices)->LocatePpi ( (CONST EFI_PEI_SERVICES **)PeiServices, &gEfiPeiReadOnlyVariable2PpiGuid, 0, NULL, (VOID **) &VariableServices - ); + ); VariableServices->GetVariable ( VariableServices, @@ -129,6 +129,11 @@ BensonGlacierPostMemInitCallback ( // MaxPkgCState = MAX_PKG_CSTATE_C2; PcdSet8 (PcdMaxPkgCState, (UINT8) MaxPkgCState); + + // + // Set PcdeMMCHostMaxSpeed + // + PcdSet8 (PcdeMMCHostMaxSpeed, (UINT8) (SystemConfiguration.ScceMMCHostMaxSpeed)); // // Add init steps here diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf index e15e612939..0f1d555637 100644 --- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf +++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf @@ -66,6 +66,7 @@ gPlatformModuleTokenSpaceGuid.PcdSueCreek gPlatformModuleTokenSpaceGuid.PcdMaxPkgCState gPlatformModuleTokenSpaceGuid.PcdTi3100AudioCodecEnable + gPlatformModuleTokenSpaceGuid.PcdeMMCHostMaxSpeed [Guids] gEfiPlatformInfoGuid diff --git a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInit.c index 8051b0021b..4bd93d1670 100644 --- a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInit.c +++ b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInit.c @@ -59,6 +59,29 @@ LeafHillPostMemInitCallback ( UINT8 ResetType; UINTN BufferSize; UINT8 MaxPkgCState; + UINTN VariableSize; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; + SYSTEM_CONFIGURATION SystemConfiguration; + + VariableSize = sizeof (SYSTEM_CONFIGURATION); + ZeroMem (&SystemConfiguration, sizeof (SYSTEM_CONFIGURATION)); + + (*PeiServices)->LocatePpi ( + (CONST EFI_PEI_SERVICES **)PeiServices, + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **) &VariableServices + ); + + VariableServices->GetVariable ( + VariableServices, + PLATFORM_SETUP_VARIABLE_NAME, + &gEfiSetupVariableGuid, + NULL, + &VariableSize, + &SystemConfiguration + ); Status = PeiServicesLocatePpi ( &gBoardPostMemInitDoneGuid, @@ -106,6 +129,11 @@ LeafHillPostMemInitCallback ( // MaxPkgCState = MAX_PKG_CSTATE_C2; PcdSet8 (PcdMaxPkgCState, (UINT8) MaxPkgCState); + + // + // Set PcdeMMCHostMaxSpeed + // + PcdSet8 (PcdeMMCHostMaxSpeed, (UINT8) (SystemConfiguration.ScceMMCHostMaxSpeed)); // // Add init steps here diff --git a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInitPostMem.inf b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInitPostMem.inf index 526e90357d..0f11b1c11e 100644 --- a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInitPostMem.inf +++ b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPostMem/BoardInitPostMem.inf @@ -63,6 +63,7 @@ gPlatformModuleTokenSpaceGuid.PcdBoardVbtFileGuid gPlatformModuleTokenSpaceGuid.PcdSueCreek gPlatformModuleTokenSpaceGuid.PcdMaxPkgCState + gPlatformModuleTokenSpaceGuid.PcdeMMCHostMaxSpeed [Guids] gEfiPlatformInfoGuid diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInit.c index 6ee7e3d3ff..c1ee6b9c98 100644 --- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInit.c +++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInit.c @@ -59,6 +59,30 @@ MinnowBoard3PostMemInitCallback ( UINT8 ResetType; UINT8 BtDevice; UINTN BufferSize; + UINT8 MaxSpeed; + UINTN VariableSize; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; + SYSTEM_CONFIGURATION SystemConfiguration; + + VariableSize = sizeof (SYSTEM_CONFIGURATION); + ZeroMem (&SystemConfiguration, sizeof (SYSTEM_CONFIGURATION)); + + (*PeiServices)->LocatePpi ( + (CONST EFI_PEI_SERVICES **)PeiServices, + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **) &VariableServices + ); + + VariableServices->GetVariable ( + VariableServices, + PLATFORM_SETUP_VARIABLE_NAME, + &gEfiSetupVariableGuid, + NULL, + &VariableSize, + &SystemConfiguration + ); Status = PeiServicesLocatePpi ( &gBoardPostMemInitDoneGuid, @@ -112,6 +136,17 @@ MinnowBoard3PostMemInitCallback ( // PcdSetBool (PcdLogoDisplay, TRUE); + // + // Set PcdeMMCHostMaxSpeed + // + if ((SystemConfiguration.ScceMMCHostMaxSpeed == 0) || (SystemConfiguration.ScceMMCHostMaxSpeed == 1)) { + MaxSpeed = EMMC_HS200_MODE; + PcdSet8 (PcdeMMCHostMaxSpeed, (UINT8) MaxSpeed); + } else { + MaxSpeed = EMMC_DDR50_MODE; + PcdSet8 (PcdeMMCHostMaxSpeed, (UINT8) MaxSpeed); + } + // // Add init steps here // diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInitMiscs.h b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInitMiscs.h index 37faf87493..3392a0341d 100644 --- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInitMiscs.h +++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInitMiscs.h @@ -94,6 +94,13 @@ #define SUBSYSTEM_DEVICE_ID 0x1234 #define SUBSYSTEM_SVID_SSID (SUBSYSTEM_VENDOR_ID + (SUBSYSTEM_DEVICE_ID << 16)) +// +// eMMCHostMaxSpeed identifier. +// +#define EMMC_HS400_MODE 0x00 +#define EMMC_HS200_MODE 0x01 +#define EMMC_DDR50_MODE 0x02 + EFI_STATUS Minnow3GetPlatformInfoHob ( IN CONST EFI_PEI_SERVICES **PeiServices, diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInitPostMem.inf b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInitPostMem.inf index 665a557696..801c47f141 100644 --- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInitPostMem.inf +++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPostMem/BoardInitPostMem.inf @@ -62,6 +62,7 @@ gPlatformModuleTokenSpaceGuid.PcdSueCreek gPlatformModuleTokenSpaceGuid.PcdLogoDisplay gPlatformModuleTokenSpaceGuid.PcdBtDevice + gPlatformModuleTokenSpaceGuid.PcdeMMCHostMaxSpeed [Guids] gEfiPlatformInfoGuid diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInit.c index cf8523adf2..cafc777fba 100644 --- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInit.c +++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInit.c @@ -58,6 +58,30 @@ MinnowBoard3NextPostMemInitCallback ( UINT8 FabId; UINT8 ResetType; UINTN BufferSize; + UINT8 MaxSpeed; + UINTN VariableSize; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; + SYSTEM_CONFIGURATION SystemConfiguration; + + VariableSize = sizeof (SYSTEM_CONFIGURATION); + ZeroMem (&SystemConfiguration, sizeof (SYSTEM_CONFIGURATION)); + + (*PeiServices)->LocatePpi ( + (CONST EFI_PEI_SERVICES **)PeiServices, + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **) &VariableServices + ); + + VariableServices->GetVariable ( + VariableServices, + PLATFORM_SETUP_VARIABLE_NAME, + &gEfiSetupVariableGuid, + NULL, + &VariableSize, + &SystemConfiguration + ); Status = PeiServicesLocatePpi ( &gBoardPostMemInitDoneGuid, @@ -97,6 +121,17 @@ MinnowBoard3NextPostMemInitCallback ( BufferSize = sizeof (EFI_GUID); PcdSetPtr(PcdBoardVbtFileGuid, &BufferSize, (UINT8 *)&gPeiMinnow3NextVbtGuid); + // + // Set PcdeMMCHostMaxSpeed + // + if ((SystemConfiguration.ScceMMCHostMaxSpeed == 0) || (SystemConfiguration.ScceMMCHostMaxSpeed == 1)) { + MaxSpeed = EMMC_HS200_MODE; + PcdSet8 (PcdeMMCHostMaxSpeed, (UINT8) MaxSpeed); + } else { + MaxSpeed = EMMC_DDR50_MODE; + PcdSet8 (PcdeMMCHostMaxSpeed, (UINT8) MaxSpeed); + } + // // Add init steps here // diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInitMiscs.h b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInitMiscs.h index fd4d08646c..c1ced3491e 100644 --- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInitMiscs.h +++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInitMiscs.h @@ -87,6 +87,13 @@ #define SUBSYSTEM_DEVICE_ID 0x1234 #define SUBSYSTEM_SVID_SSID (SUBSYSTEM_VENDOR_ID + (SUBSYSTEM_DEVICE_ID << 16)) +// +// eMMCHostMaxSpeed identifier. +// +#define EMMC_HS400_MODE 0x00 +#define EMMC_HS200_MODE 0x01 +#define EMMC_DDR50_MODE 0x02 + EFI_STATUS Minnow3NextGetPlatformInfoHob ( IN CONST EFI_PEI_SERVICES **PeiServices, diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInitPostMem.inf b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInitPostMem.inf index be32f93ec1..1a4cc28736 100644 --- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInitPostMem.inf +++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Next/BoardInitPostMem/BoardInitPostMem.inf @@ -60,6 +60,7 @@ gPlatformModuleTokenSpaceGuid.PcdFabId gPlatformModuleTokenSpaceGuid.PcdResetType gPlatformModuleTokenSpaceGuid.PcdBoardVbtFileGuid + gPlatformModuleTokenSpaceGuid.PcdeMMCHostMaxSpeed [Guids] gEfiPlatformInfoGuid diff --git a/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf b/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf index 5ce0cc255a..8c1648d760 100644 --- a/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf +++ b/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf @@ -86,6 +86,7 @@ gPlatformModuleTokenSpaceGuid.PcdResetType gPlatformModuleTokenSpaceGuid.PcdBoardVbtFileGuid gPlatformModuleTokenSpaceGuid.PcdMaxPkgCState + gPlatformModuleTokenSpaceGuid.PcdeMMCHostMaxSpeed [Ppis] gSiPolicyPpiGuid ## CONSUMES diff --git a/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspScPolicyInitLib.c b/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspScPolicyInitLib.c index cf3eef2f27..1a6666ebc1 100644 --- a/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspScPolicyInitLib.c +++ b/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspScPolicyInitLib.c @@ -615,7 +615,8 @@ PeiFspScPolicyInit ( FspsUpd->FspsConfig.UfsEnabled = 0; FspsUpd->FspsConfig.eMMCEnabled = SystemConfiguration->ScceMMCEnabled; FspsUpd->FspsConfig.SdioEnabled = SystemConfiguration->SccSdioEnabled; - FspsUpd->FspsConfig.eMMCHostMaxSpeed = SystemConfiguration->ScceMMCHostMaxSpeed; + FspsUpd->FspsConfig.eMMCHostMaxSpeed = (UINT8) PcdGet8 (PcdeMMCHostMaxSpeed); + FspsUpd->FspsConfig.GppLock = SystemConfiguration->GPPLock; FspsUpd->FspsConfig.SdioTxCmdCntl = 0x505; FspsUpd->FspsConfig.SdioTxDataCntl1 = 0xE; diff --git a/Platform/BroxtonPlatformPkg/Common/Library/PeiPolicyUpdateLib/PeiPolicyUpdateLib.inf b/Platform/BroxtonPlatformPkg/Common/Library/PeiPolicyUpdateLib/PeiPolicyUpdateLib.inf index d1f8cc2793..d5f0a1b8df 100644 --- a/Platform/BroxtonPlatformPkg/Common/Library/PeiPolicyUpdateLib/PeiPolicyUpdateLib.inf +++ b/Platform/BroxtonPlatformPkg/Common/Library/PeiPolicyUpdateLib/PeiPolicyUpdateLib.inf @@ -82,6 +82,7 @@ gEfiBxtTokenSpaceGuid.PcdPmcGcrBaseAddress gPlatformModuleTokenSpaceGuid.PcdResetType gPlatformModuleTokenSpaceGuid.PcdMaxPkgCState + gPlatformModuleTokenSpaceGuid.PcdeMMCHostMaxSpeed [FixedPcd] gPlatformModuleTokenSpaceGuid.PcdFlashAreaSize diff --git a/Platform/BroxtonPlatformPkg/Common/Library/PeiPolicyUpdateLib/PeiScPolicyUpdate.c b/Platform/BroxtonPlatformPkg/Common/Library/PeiPolicyUpdateLib/PeiScPolicyUpdate.c index 9d2c028c75..d9a991ca64 100644 --- a/Platform/BroxtonPlatformPkg/Common/Library/PeiPolicyUpdateLib/PeiScPolicyUpdate.c +++ b/Platform/BroxtonPlatformPkg/Common/Library/PeiPolicyUpdateLib/PeiScPolicyUpdate.c @@ -705,7 +705,7 @@ UpdatePeiScPolicy ( ScsConfig->UfsEnable = 0; ScsConfig->EmmcEnable = SystemConfiguration.ScceMMCEnabled; ScsConfig->SdioEnable = SystemConfiguration.SccSdioEnabled; - ScsConfig->EmmcHostMaxSpeed = SystemConfiguration.ScceMMCHostMaxSpeed; + ScsConfig->EmmcHostMaxSpeed = (UINT8) PcdGet8 (PcdeMMCHostMaxSpeed); ScsConfig->GppLock = SystemConfiguration.GPPLock; ScsConfig->SccEmmcTraceLength = SCC_EMMC_LONG_TRACE_LEN; diff --git a/Platform/BroxtonPlatformPkg/PlatformPkg.dec b/Platform/BroxtonPlatformPkg/PlatformPkg.dec index 7c189a92f5..f61331f16e 100644 --- a/Platform/BroxtonPlatformPkg/PlatformPkg.dec +++ b/Platform/BroxtonPlatformPkg/PlatformPkg.dec @@ -197,6 +197,8 @@ gPlatformModuleTokenSpaceGuid.PcdUpdatePcieConfigFunc|2|UINT64|0x8000001A ## SerialIo Uart Configuration #gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber|2|UINT8|0x8000001B + ## This PCD used to select eMMCHostMaxSpeed + gPlatformModuleTokenSpaceGuid.PcdeMMCHostMaxSpeed|0x00|UINT8|0x8000001C ## MemoryCheck value for checking memory before boot OS. ## To save the boot performance, the default MemoryCheck is set to 0. gClientCommonModuleTokenSpaceGuid.PcdPlatformMemoryCheck|0|UINT8|0x40000005 -- cgit v1.2.3