Re: [edk2] [Patch] Vlv2DeviceRefCodePkg/Vlv2TbltDevicePkg: Reset BIOS Setup when Jumper is present on Turbot.

2015-12-03 Thread He, Tim
Reviewed-by: Tim He  

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of lushifex
Sent: Thursday, December 03, 2015 6:15 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch] Vlv2DeviceRefCodePkg/Vlv2TbltDevicePkg: Reset BIOS 
Setup when Jumper is present on Turbot.

Signed-off-by: lushifex 
---
 .../SouthCluster/Include/Library/PchPlatformLib.h  |   9 ++
 Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c  |  19 ++--
 .../MultiPlatformLib/BoardClkGens/BoardClkGens.c   |   6 +-
 .../MultiPlatformLib/BoardClkGens/BoardClkGens.h   |   2 +
 .../MultiPlatformLib/BoardGpios/BoardGpios.c   |  15 +++
 .../MultiPlatformLib/BoardGpios/BoardGpios.h   |   1 +
 .../Library/MultiPlatformLib/MultiPlatformLib.inf  |   1 +
 .../Library/PchPlatformLib/PchPlatformLibrary.c| 108 +
 .../Library/PlatformBdsLib/BdsPlatform.c   |  29 --
 .../Library/PlatformBdsLib/PlatformBdsLib.inf  |   1 +
 Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c|   8 +-
 Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf  |   1 +
 Vlv2TbltDevicePkg/PlatformDxe/ExI.c|   8 +-
 Vlv2TbltDevicePkg/PlatformDxe/Platform.c   |  51 +-
 .../PlatformGopPolicy/PlatformGopPolicy.c  |   9 +-
 .../PlatformGopPolicy/PlatformGopPolicy.inf|   3 +
 .../PlatformInfoDxe/PlatformInfoDxe.c  |   9 +-
 .../PlatformInfoDxe/PlatformInfoDxe.inf|   1 +
 Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c   |   6 +-
 .../PlatformInitPei/PlatformEarlyInit.c|   7 +-
 Vlv2TbltDevicePkg/PlatformPei/BootMode.c   |  16 +++
 Vlv2TbltDevicePkg/PlatformPei/Platform.c   |   7 +-
 Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf  |   1 +
 .../PlatformSetupDxe/PlatformSetupDxe.inf  |   1 +
 .../PlatformSetupDxe/SetupInfoRecords.c|   7 +-
 Vlv2TbltDevicePkg/PlatformSmm/Platform.c   |  15 ++-
 26 files changed, 300 insertions(+), 41 deletions(-)

diff --git 
a/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h
 
b/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h
index 8f0ca02..9651f94 100644
--- 
a/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h
+++ b/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/P
+++ chPlatformLib.h
@@ -115,7 +115,16 @@ PchAlternateAccessMode (
 
   @retval NONE
 
 **/
 ;
+UINT32
+DetectTurbotBoard (
+VOID
+  );
+
+UINT32
+DetectGpioPinValue (
+VOID
+  );
 
 #endif
diff --git a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c 
b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
index 2ff14ec..a7e54e3 100644
--- a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
+++ b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
@@ -646,10 +646,11 @@ OnReadyToBoot (
   SYSTEM_CONFIGURATIONSetupVarBuffer;
   UINTN   VariableSize;
   EFI_PLATFORM_CPU_INFO   *PlatformCpuInfoPtr = NULL;
   EFI_PLATFORM_CPU_INFO   PlatformCpuInfo;
   EFI_PEI_HOB_POINTERS  GuidHob;
+  UINT32  DxeGpioValue;
 
   if (mFirstNotify) {
 return;
   }
 
@@ -684,10 +685,12 @@ OnReadyToBoot (
 
   if ((PlatformCpuInfoPtr != NULL)) {
 CopyMem(&PlatformCpuInfo, PlatformCpuInfoPtr, 
sizeof(EFI_PLATFORM_CPU_INFO));
   }
 
+  DxeGpioValue = DetectGpioPinValue();
+
   //
   // Update the ACPI parameter blocks finally.
   //
   VariableSize = sizeof (SYSTEM_CONFIGURATION);
   Status = gRT->GetVariable (
@@ -695,12 +698,12 @@ OnReadyToBoot (
   &mSystemConfigurationGuid,
   NULL,
   &VariableSize,
   &SetupVarBuffer
   );
-  if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
-//The setup variable is corrupted
+  if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION) || 
DxeGpioValue == 0) {
+//The setup variable is corrupted or detect GPIO_S5_17 Pin is low
 VariableSize = sizeof(SYSTEM_CONFIGURATION);
 Status = gRT->GetVariable(
   L"SetupRecovery",
   &mSystemConfigurationGuid,
   NULL,
@@ -794,10 +797,11 @@ AcpiPlatformEntryPoint (
   EFI_MP_SERVICES_PROTOCOL  *MpService;
   UINTN MaximumNumberOfCPUs;
   UINTN NumberOfEnabledCPUs;
   UINT32Data32;
   PCH_STEPPING  pchStepping;
+  UINT32DxeGpioValue;
 
   mFirstNotify  = FALSE;
 
   TableVersion  = EFI_ACPI_TABLE_VERSION_2_0;
   Instance  = 0;
@@ -813,11 +817,12 @@ AcpiPlatformEntryPoint (
   if (GuidHob.Raw != NULL) {
 if ((GuidHob.Raw = GetNextGuidHob (&gEfiPlatformInfoGuid, GuidHob.Raw)) != 
NULL) {
   mPlatformInfo = GET_GUID_HOB_DATA (GuidHob.Guid);
 }
   }
-
+  
+  DxeGpioValue = DetectGpioPinValue();
   //
   // Search for the 

[edk2] [Patch] Vlv2DeviceRefCodePkg/Vlv2TbltDevicePkg: Reset BIOS Setup when Jumper is present on Turbot.

2015-12-03 Thread lushifex
Signed-off-by: lushifex 
---
 .../SouthCluster/Include/Library/PchPlatformLib.h  |   9 ++
 Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c  |  19 ++--
 .../MultiPlatformLib/BoardClkGens/BoardClkGens.c   |   6 +-
 .../MultiPlatformLib/BoardClkGens/BoardClkGens.h   |   2 +
 .../MultiPlatformLib/BoardGpios/BoardGpios.c   |  15 +++
 .../MultiPlatformLib/BoardGpios/BoardGpios.h   |   1 +
 .../Library/MultiPlatformLib/MultiPlatformLib.inf  |   1 +
 .../Library/PchPlatformLib/PchPlatformLibrary.c| 108 +
 .../Library/PlatformBdsLib/BdsPlatform.c   |  29 --
 .../Library/PlatformBdsLib/PlatformBdsLib.inf  |   1 +
 Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c|   8 +-
 Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf  |   1 +
 Vlv2TbltDevicePkg/PlatformDxe/ExI.c|   8 +-
 Vlv2TbltDevicePkg/PlatformDxe/Platform.c   |  51 +-
 .../PlatformGopPolicy/PlatformGopPolicy.c  |   9 +-
 .../PlatformGopPolicy/PlatformGopPolicy.inf|   3 +
 .../PlatformInfoDxe/PlatformInfoDxe.c  |   9 +-
 .../PlatformInfoDxe/PlatformInfoDxe.inf|   1 +
 Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c   |   6 +-
 .../PlatformInitPei/PlatformEarlyInit.c|   7 +-
 Vlv2TbltDevicePkg/PlatformPei/BootMode.c   |  16 +++
 Vlv2TbltDevicePkg/PlatformPei/Platform.c   |   7 +-
 Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf  |   1 +
 .../PlatformSetupDxe/PlatformSetupDxe.inf  |   1 +
 .../PlatformSetupDxe/SetupInfoRecords.c|   7 +-
 Vlv2TbltDevicePkg/PlatformSmm/Platform.c   |  15 ++-
 26 files changed, 300 insertions(+), 41 deletions(-)

diff --git 
a/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h
 
b/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h
index 8f0ca02..9651f94 100644
--- 
a/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h
+++ 
b/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h
@@ -115,7 +115,16 @@ PchAlternateAccessMode (
 
   @retval NONE
 
 **/
 ;
+UINT32
+DetectTurbotBoard (
+VOID
+  );
+
+UINT32
+DetectGpioPinValue (
+VOID
+  );
 
 #endif
diff --git a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c 
b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
index 2ff14ec..a7e54e3 100644
--- a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
+++ b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
@@ -646,10 +646,11 @@ OnReadyToBoot (
   SYSTEM_CONFIGURATIONSetupVarBuffer;
   UINTN   VariableSize;
   EFI_PLATFORM_CPU_INFO   *PlatformCpuInfoPtr = NULL;
   EFI_PLATFORM_CPU_INFO   PlatformCpuInfo;
   EFI_PEI_HOB_POINTERS  GuidHob;
+  UINT32  DxeGpioValue;
 
   if (mFirstNotify) {
 return;
   }
 
@@ -684,10 +685,12 @@ OnReadyToBoot (
 
   if ((PlatformCpuInfoPtr != NULL)) {
 CopyMem(&PlatformCpuInfo, PlatformCpuInfoPtr, 
sizeof(EFI_PLATFORM_CPU_INFO));
   }
 
+  DxeGpioValue = DetectGpioPinValue();
+
   //
   // Update the ACPI parameter blocks finally.
   //
   VariableSize = sizeof (SYSTEM_CONFIGURATION);
   Status = gRT->GetVariable (
@@ -695,12 +698,12 @@ OnReadyToBoot (
   &mSystemConfigurationGuid,
   NULL,
   &VariableSize,
   &SetupVarBuffer
   );
-  if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
-//The setup variable is corrupted
+  if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION) || 
DxeGpioValue == 0) {
+//The setup variable is corrupted or detect GPIO_S5_17 Pin is low
 VariableSize = sizeof(SYSTEM_CONFIGURATION);
 Status = gRT->GetVariable(
   L"SetupRecovery",
   &mSystemConfigurationGuid,
   NULL,
@@ -794,10 +797,11 @@ AcpiPlatformEntryPoint (
   EFI_MP_SERVICES_PROTOCOL  *MpService;
   UINTN MaximumNumberOfCPUs;
   UINTN NumberOfEnabledCPUs;
   UINT32Data32;
   PCH_STEPPING  pchStepping;
+  UINT32DxeGpioValue;
 
   mFirstNotify  = FALSE;
 
   TableVersion  = EFI_ACPI_TABLE_VERSION_2_0;
   Instance  = 0;
@@ -813,11 +817,12 @@ AcpiPlatformEntryPoint (
   if (GuidHob.Raw != NULL) {
 if ((GuidHob.Raw = GetNextGuidHob (&gEfiPlatformInfoGuid, GuidHob.Raw)) != 
NULL) {
   mPlatformInfo = GET_GUID_HOB_DATA (GuidHob.Guid);
 }
   }
-
+  
+  DxeGpioValue = DetectGpioPinValue();
   //
   // Search for the Memory Configuration GUID HOB.  If it is not present, then
   // there's nothing we can do. It may not exist on the update path.
   //
   VarSize = sizeof(SYSTEM_CONFIGURATION);
@@ -826,12 +831,12 @@ AcpiPlatformEntryPoint (
   &mSystemConfigurationGuid,
   NULL,
   &VarSize,
   &mSystemConfigurati