public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: zwei4 <david.wei@intel.com>
To: edk2-devel@lists.01.org
Subject: [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 1/2] Clean up CMOS code.
Date: Fri,  8 Sep 2017 15:22:47 +0800	[thread overview]
Message-ID: <20170908072248.23540-1-david.wei@intel.com> (raw)

Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: zwei4 <david.wei@intel.com>
---
 .../Library/BaseSerialPortLib/BaseSerialPortLib.c  | 69 +++-------------------
 .../BaseSerialPortLib/BaseSerialPortLib.inf        |  3 +-
 .../BaseSerialPortLib/BaseSerialPortLibNoInit.c    | 46 ++-------------
 .../BaseSerialPortLib/BaseSerialPortLibNoInit.inf  |  3 +-
 .../Library/PlatformSecLib/Vtf0PlatformSecLib.inf  |  1 -
 .../Common/PlatformSettings/PlatformDxe/Platform.c | 25 --------
 .../PlatformSettings/PlatformDxe/PlatformDxe.inf   |  1 -
 .../PlatformDsc/LibraryClasses.IA32.PEI.dsc        |  1 -
 .../PlatformDsc/LibraryClasses.dsc                 |  6 --
 .../PlatformDsc/PcdsFixedAtBuild.dsc               |  2 -
 10 files changed, 15 insertions(+), 142 deletions(-)

diff --git a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
index 5fc9d8c71..2c63f9878 100644
--- a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
+++ b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
@@ -1,7 +1,7 @@
 /** @file
   Serial I/O Port library functions with no library constructor/destructor.
 
-  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -18,9 +18,7 @@
 #include <Library/IoLib.h>
 #include <Library/PcdLib.h>
 #include <Library/SerialPortLib.h>
-#include <Library/SerialPortParameterLib.h>
 #include <Library/PlatformHookLib.h>
-#include <Library/CmosAccessLib.h>
 #include <Library/ScSerialIoUartLib.h>
 
 #ifdef TRACE_HUB_DEBUGLIB_USAGE
@@ -104,13 +102,12 @@ UARTInitialize (
   //
   // Calculate divisor for baud generator
   //
-  BaudRate = GetSerialPortBaudRate ();
+  BaudRate = PcdGet32 (PcdSerialBaudRate);
   if ((BaudRate == 0) || ((BaudRate % 9600) != 0)) {
     //
     // If Serail Baud Rate is not valid, set it to the default value
     //
     BaudRate = PcdGet32 (PcdSerialBaudRate);
-    SetSerialPortBaudRate (BaudRate);
   }
   Divisor = MAX_BAUD_RATE / BaudRate;
 
@@ -174,23 +171,8 @@ SerialPortInitialize (
   VOID
   )
 {
-  UINT8  CmosStatusCodeFlags;
 
-  CmosStatusCodeFlags = GetDebugInterface ();
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || (CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
-    CmosStatusCodeFlags = STATUS_CODE_USE_SERIALIO | STATUS_CODE_CMOS_VALID;
-    SetDebugInterface (CmosStatusCodeFlags);
-  }
-  //
-  // no init for MEM
-  //
-
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-    PchSerialIoUartInit (PcdGet8 (PcdSerialIoUartNumber), TRUE, 115200, 3, FALSE);
-  }
-  //
-  // no init for TRACEHUB
-  //
+  PchSerialIoUartInit (PcdGet8 (PcdSerialIoUartNumber), TRUE, 115200, 3, FALSE);
 
   return RETURN_SUCCESS;
 }
@@ -307,19 +289,8 @@ SerialPortWrite (
   IN UINTN     NumberOfBytes
   )
 {
-  UINT8    CmosStatusCodeFlags;
 
-  CmosStatusCodeFlags = GetDebugInterface ();
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || (CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
-    //
-    // invalid cmos value, it means action was attempted before Init
-    //
-    return RETURN_NOT_READY;
-  }
-
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-    PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes);
-  }
+  PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes);
 
   return RETURN_SUCCESS;
 }
@@ -399,21 +370,9 @@ SerialPortRead (
   IN  UINTN     NumberOfBytes
   )
 {
-  UINT8    CmosStatusCodeFlags;
-
-  CmosStatusCodeFlags = GetDebugInterface ();
 
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || (CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
-    //
-    // invalid cmos value, it means action was attempted before Init
-    //
-    return RETURN_NOT_READY;
-  }
-
-
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-    PchSerialIoUartIn (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes, FALSE);
-  }
+  PchSerialIoUartIn (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes, FALSE);
+ 
   return RETURN_SUCCESS;
 }
 
@@ -475,23 +434,11 @@ SerialPortPoll (
   VOID
   )
 {
-  UINT8     CmosStatusCodeFlags;
-  BOOLEAN   Status;
-
-  CmosStatusCodeFlags = GetDebugInterface ();
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || (CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
 
-    //
-    // invalid cmos value, it means action was attempted before Init
-    //
-    return FALSE;
-  }
+  BOOLEAN   Status;
 
   Status = FALSE;
-
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-    Status |= PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber));
-  }
+  Status |= PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber));
 
   return Status;
 }
diff --git a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.inf b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.inf
index 0e78ab288..5ea0c4657 100644
--- a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.inf
+++ b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Component description file for Serial I/O Port library functions.
 #
-#  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -32,7 +32,6 @@
   IoLib
   PciLib
   TimerLib
-  SerialPortParameterLib
   PchSerialIoUartLib
 
 [Packages]
diff --git a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.c b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.c
index e7e8179d1..f9e96338b 100644
--- a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.c
+++ b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.c
@@ -1,7 +1,7 @@
 /** @file
   Serial I/O Port library functions with no library constructor/destructor.
 
-  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -198,21 +198,8 @@ SerialPortWrite (
   IN UINTN     NumberOfBytes
   )
 {
-  UINT8   CmosStatusCodeFlags;
 
-  CmosStatusCodeFlags = GetDebugInterface ();
-
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || (CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
-
-    //
-    // invalid cmos value, it means action was attempted before Init
-    //
-    return RETURN_NOT_READY;
-  }
-
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-    PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes);
-  }
+  PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes);
 
   return RETURN_SUCCESS;
 }
@@ -293,21 +280,9 @@ SerialPortRead (
   IN  UINTN     NumberOfBytes
   )
 {
-  UINT8    CmosStatusCodeFlags;
-
-  CmosStatusCodeFlags = GetDebugInterface ();
 
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || (CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
-
-    //
-    // invalid cmos value, it means action was attempted before Init
-    //
-    return RETURN_NOT_READY;
-  }
+  PchSerialIoUartIn (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes, FALSE);
 
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-    PchSerialIoUartIn (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes, FALSE);
-  }
   return RETURN_SUCCESS;
 }
 
@@ -369,23 +344,12 @@ SerialPortPoll (
   VOID
   )
 {
-  UINT8     CmosStatusCodeFlags;
-  BOOLEAN   Status;
-
-  CmosStatusCodeFlags = GetDebugInterface ();
-  if ((!(CmosStatusCodeFlags & STATUS_CODE_CMOS_VALID)) || (CmosStatusCodeFlags & STATUS_CODE_CMOS_INVALID)) {
 
-    //
-    // invalid cmos value, it means action was attempted before Init
-    //
-    return FALSE;
-  }
+  BOOLEAN   Status;
 
   Status = FALSE;
 
-  if (CmosStatusCodeFlags & STATUS_CODE_USE_SERIALIO) {
-    Status |= PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber));
-  }
+  Status |= PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber));
 
   return Status;
 }
diff --git a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.inf b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.inf
index 8120ff26d..6a9cf86b2 100644
--- a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.inf
+++ b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Component description file for Serial I/O Port library functions.
 #
-#  Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -32,7 +32,6 @@
   IoLib
   PciLib
   TimerLib
-  SerialPortParameterLib
   PchSerialIoUartLib
 
 [Packages]
diff --git a/Platform/BroxtonPlatformPkg/Common/Library/PlatformSecLib/Vtf0PlatformSecLib.inf b/Platform/BroxtonPlatformPkg/Common/Library/PlatformSecLib/Vtf0PlatformSecLib.inf
index 0ef6ccee2..0b9fb453a 100644
--- a/Platform/BroxtonPlatformPkg/Common/Library/PlatformSecLib/Vtf0PlatformSecLib.inf
+++ b/Platform/BroxtonPlatformPkg/Common/Library/PlatformSecLib/Vtf0PlatformSecLib.inf
@@ -63,7 +63,6 @@
 [LibraryClasses]
   PerformanceLib
   LocalApicLib
-  CmosAccessLib
   DebugLib
 
 [Pcd.common]
diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c
index 7733dd0ac..abe635d90 100644
--- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c
+++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c
@@ -255,30 +255,6 @@ EnableAcpiCallback (
 }
 
 
-#if (ENBDT_PF_ENABLE == 1) //BXTP
-VOID
-EFIAPI
-CheckCmosBatteryLost (
-  VOID
-  )
-{
-  UINT8                 Buffer8 = 0;
-
-  if (!CheckCmosBatteryStatus ()) {
-    Buffer8 = MmioRead8 (PMC_BASE_ADDRESS + R_PMC_GEN_PMCON_1);
-
-    //
-    // CMOS Battery then clear status
-    //
-    if (Buffer8 & B_PMC_GEN_PMCON_RTC_PWR_STS) {
-      Buffer8 &= ~B_PMC_GEN_PMCON_RTC_PWR_STS;
-      MmioWrite8 (PMC_BASE_ADDRESS + R_PMC_GEN_PMCON_1, Buffer8);
-    }
-  }
-}
-#endif //#if (ENBDT_PF_ENABLE == 1) //BXTP
-
-
 VOID
 PlatformScInitBeforeBoot (
   VOID
@@ -877,7 +853,6 @@ InitializePlatform (
   }
 
 #if (ENBDT_PF_ENABLE == 1) //BXTP
-  CheckCmosBatteryLost ();
 
 #ifdef SENSOR_INFO_VAR_SUPPORT
   InitializeSensorInfoVariable (); // Initialize Sensor Info variable
diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
index 37eaf4623..7516a1548 100644
--- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
+++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
@@ -65,7 +65,6 @@
   DxeSaPolicyLib
   ConfigBlockLib
   GpioLib
-  BasePlatformCmosLib
 
 [Guids]
   gEfiBiosIdGuid
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.IA32.PEI.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.IA32.PEI.dsc
index d4617aa42..7fa43ea83 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.IA32.PEI.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.IA32.PEI.dsc
@@ -61,7 +61,6 @@
   FspPolicyInitLib|$(PLATFORM_PACKAGE_COMMON)/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf
   FspWrapperPlatformResetLib|$(PLATFORM_PACKAGE_COMMON)/FspSupport/Library/PeiFspWrapperPlatformResetLib/PeiFspWrapperPlatformResetLib.inf
 
-  BasePlatformCmosLib|$(PLATFORM_PACKAGE_COMMON)/Library/PlatformCmosLib/PlatformCmosLib.inf
   DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
   Tcg2PhysicalPresenceLib|SecurityPkg/Library/PeiTcg2PhysicalPresenceLib/PeiTcg2PhysicalPresenceLib.inf
 
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.dsc
index a1023764e..a4bc20973 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.dsc
@@ -113,8 +113,6 @@
    SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
    SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
    IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf
-   CmosAccessLib|$(PLATFORM_PACKAGE_COMMON)/Library/BaseCmosAccessLib/BaseCmosAccessLib.inf
-   BaseCmosAccessLib|$(PLATFORM_PACKAGE_COMMON)/Library/BaseCmosAccessLib/BaseCmosAccessLib.inf
    PostCodeLib|$(PLATFORM_PACKAGE_COMMON)/Library/BasePostCodeLibPort80Ex/BasePostCodeLibPort80Ex.inf
    DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
    !if $(USB_ENABLE) == TRUE
@@ -155,7 +153,6 @@
    # Platform
    #
    ResetSystemLib|$(PLATFORM_PACKAGE_COMMON)/Library/ResetSystemLib/ResetSystemLib.inf
-   PlatformCmosLib|$(PLATFORM_PACKAGE_COMMON)/Library/PlatformCmosLib/PlatformCmosLib.inf
    PlatformPostCodeMapLib|$(PLATFORM_PACKAGE_COMMON)/Library/BasePlatformPostCodeMapLib/BasePlatformPostCodeMapLib.inf
    TimerLib|$(PLATFORM_PACKAGE_COMMON)/Library/IntelScAcpiTimerLib/IntelScAcpiTimerLib.inf
 
@@ -190,7 +187,6 @@
 
    PchSerialIoUartLib|$(PLATFORM_SI_PACKAGE)/SouthCluster/Library/PeiDxeSmmPchSerialIoUartLib/PeiDxeSmmPchSerialIoUartLib.inf
    PchSerialIoLib|$(PLATFORM_SI_PACKAGE)/SouthCluster/Library/PeiDxeSmmPchSerialIoLib/PeiDxeSmmPchSerialIoLib.inf
-   SerialPortParameterLib|$(PLATFORM_PACKAGE_COMMON)/Library/BaseSerialPortParameterLibCmos/BaseSerialPortParameterLibCmos.inf
 
    BiosIdLib|$(PLATFORM_PACKAGE_COMMON)/Library/BiosIdLib/BiosIdLib.inf
    CpuIA32Lib|$(PLATFORM_PACKAGE_COMMON)/Library/CpuIA32Lib/CpuIA32Lib.inf
@@ -235,8 +231,6 @@
    !endif
    SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
 
-   BasePlatformCmosLib|$(PLATFORM_PACKAGE_COMMON)/Library/PlatformCmosLib/PlatformCmosLib.inf
-
    PmicLib|$(PLATFORM_PACKAGE_COMMON)/Library/PmicLib/PmicLibNull.inf
 
    #
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
index 793e285ae..b7cefdca0 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
@@ -76,8 +76,6 @@
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBiosVideoCheckVbeEnable|TRUE
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBiosVideoCheckVgaEnable|TRUE
 
-  #Overrides the CMOS Flag to disable ISA serial debug
-  gClientCommonModuleTokenSpaceGuid.PcdStatusCodeFlagsCmosIndex|0x5C
   gEfiBxtTokenSpaceGuid.PcdPmcGcrBaseAddress|0xFE043000
 
   !if $(SOURCE_DEBUG_ENABLE) == TRUE
-- 
2.14.1.windows.1



             reply	other threads:[~2017-09-08  7:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-08  7:22 zwei4 [this message]
2017-09-08  7:22 ` [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 2/2] BroxtonPlatformPkg: RTC initialize zwei4

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=20170908072248.23540-1-david.wei@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