[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 10/1 BroxtonPlatformPkg: Disable NPK based on DciEn

Guo, Mang posted 1 patch 6 years, 7 months ago
Failed in applying to current master (apply log)
.../BensonGlacier/BoardInitPreMem/BoardInitMiscs.c | 56 ++++++++++++++--------
1 file changed, 37 insertions(+), 19 deletions(-)
[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 10/1 BroxtonPlatformPkg: Disable NPK based on DciEn
Posted by Guo, Mang 6 years, 7 months ago
Disable NPK based on DciEn

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Guo Mang <mang.guo@intel.com>
---
 .../BensonGlacier/BoardInitPreMem/BoardInitMiscs.c | 56 ++++++++++++++--------
 1 file changed, 37 insertions(+), 19 deletions(-)

diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInitMiscs.c b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInitMiscs.c
index 0b602bd..afad081 100644
--- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInitMiscs.c
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInitMiscs.c
@@ -36,14 +36,16 @@ BgUpdateFspmUpd (
   IN FSPM_UPD                *FspUpdRgn
   )
 {
-  EFI_PEI_HOB_POINTERS           Hob;
-  EFI_PLATFORM_INFO_HOB          *PlatformInfo = NULL;
-  DRAM_POLICY_PPI                *DramPolicy;
-  EFI_STATUS                     Status;
- MRC_NV_DATA_FRAME                 *MrcNvData;
-
-  MRC_PARAMS_SAVE_RESTORE        *MrcParamsHob;
-  BOOT_VARIABLE_NV_DATA          *BootVariableNvDataHob;
+  EFI_PEI_HOB_POINTERS               Hob;
+  EFI_PLATFORM_INFO_HOB             *PlatformInfo = NULL;
+  DRAM_POLICY_PPI                   *DramPolicy;
+  EFI_STATUS                         Status;
+  MRC_NV_DATA_FRAME                 *MrcNvData;
+  MRC_PARAMS_SAVE_RESTORE           *MrcParamsHob;
+  BOOT_VARIABLE_NV_DATA             *BootVariableNvDataHob;
+  SYSTEM_CONFIGURATION               SystemConfiguration;
+  UINTN                              VariableSize;
+  EFI_PEI_READ_ONLY_VARIABLE2_PPI   *VariablePpi;
 
   Status = (*PeiServices)->LocatePpi (
                              PeiServices,
@@ -115,7 +117,7 @@ BgUpdateFspmUpd (
   FspUpdRgn->FspmConfig.Profile               = 0x0B; // LPDDR4_2400_24_22_22
   FspUpdRgn->FspmConfig.MemoryDown            = 0x01;
   FspUpdRgn->FspmConfig.DualRankSupportEnable = 0x01;
-  
+
   FspUpdRgn->FspmConfig.Ch0_RankEnable        = 0x03; // [0]: Rank 0 [1]: Rank 1
   FspUpdRgn->FspmConfig.Ch0_DeviceWidth       = 0x01; // x16
   FspUpdRgn->FspmConfig.Ch0_DramDensity       = 0x02; // 8Gb
@@ -146,6 +148,31 @@ BgUpdateFspmUpd (
     CopyMem (&(FspUpdRgn->FspmConfig.Ch3_Bit_swizzling), ChSwizzle_BG[3], DRAM_POLICY_NUMBER_BITS * sizeof(UINT8));
   }
 
+  //
+  // Disable NPK based on DciEn
+  //
+  Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, NULL, (VOID **) &VariablePpi);
+  if (!EFI_ERROR (Status)) {
+    VariableSize = sizeof (SYSTEM_CONFIGURATION);
+    Status = VariablePpi->GetVariable (
+                            VariablePpi,
+                            PLATFORM_SETUP_VARIABLE_NAME,
+                            &gEfiSetupVariableGuid,
+                            NULL,
+                            &VariableSize,
+                            &SystemConfiguration
+                            );
+    if (!EFI_ERROR (Status)) {
+      if (SystemConfiguration.DciEn == 0) {
+        FspUpdRgn->FspmConfig.NpkEn = 0;
+      } else if (SystemConfiguration.DciAutoDetect == 1) {
+        FspUpdRgn->FspmConfig.NpkEn = 3;
+      } else {
+        FspUpdRgn->FspmConfig.NpkEn = 1;
+      }
+    }
+  }
+
   return EFI_SUCCESS;
 }
 
@@ -290,16 +317,7 @@ BgDramCreatePolicyDefaults (
     CopyMem (DramPolicy->ChSwizzle, ChSwizlePtr, sizeof (DramPolicy->ChSwizzle));
   }
 
-  Status = VariablePpi->GetVariable (
-                          VariablePpi,
-                          PLATFORM_SETUP_VARIABLE_NAME,
-                          &gEfiSetupVariableGuid,
-                          NULL,
-                          &VariableSize,
-                          &SystemConfiguration
-                          );
-
-  if (!EFI_ERROR (Status)) {
+  if (ReadSetupVars) {
     if (SystemConfiguration.Max2G == 0) {
       DramPolicy->SystemMemorySizeLimit = 0x800;
     }
-- 
2.10.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel