public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guo, Mang" <mang.guo@intel.com>
To: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 10/1 BroxtonPlatformPkg: Disable NPK based on DciEn
Date: Thu, 24 Aug 2017 03:19:38 +0000	[thread overview]
Message-ID: <22D2C85ED001C54AA20BFE3B0E4751D15253FC95@shsmsx102.ccr.corp.intel.com> (raw)

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



                 reply	other threads:[~2017-08-24  3:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=22D2C85ED001C54AA20BFE3B0E4751D15253FC95@shsmsx102.ccr.corp.intel.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