diff mbox

[edk2,1/3] ArmPlatformPkg: remove VExpress system clock from PL031 driver

Message ID 1430331729-7367-2-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel April 29, 2015, 6:22 p.m. UTC
The PL031 RTC driver library is used by the implementation of the
GetTime/SetTime Runtime Services. This is why it registers its MMIO
registers as requiring runtime remapping.

However, in some cases, it calls into the VExpress sysconfig library
to access a platform specific battery backed clock, and the MMIO
registers of that hardware block are not accessible at runtime.
Furthermore, adding runtime remapping of those registers is problematic,
since they control all kinds of system features like clocks and
regulators, which means it needs to be accessible by the OS as well.

So the only reasonable way around it is to remove the sysconfig
accesses completely. If such functionality is still required at
boot time, it will need to be readded to a boot-time specific
clock driver instead.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 .../PL031RealTimeClockLib/PL031RealTimeClockLib.c  | 31 +---------------------
 .../PL031RealTimeClockLib.inf                      |  1 -
 2 files changed, 1 insertion(+), 31 deletions(-)
diff mbox

Patch

diff --git a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
index 52ba48992b83..d31434e248ab 100644
--- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
+++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
@@ -23,7 +23,6 @@ 
 #include <Library/RealTimeClockLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/PcdLib.h>
-#include <Library/ArmPlatformSysConfigLib.h>
 #include <Library/DxeServicesTableLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiRuntimeServicesTableLib.h>
@@ -269,21 +268,7 @@  LibGetTime (
   }
 
   // Snapshot the time as early in the function call as possible
-  // On some platforms we may have access to a battery backed up hardware clock.
-  // If such RTC exists try to use it first.
-  Status = ArmPlatformSysConfigGet (SYS_CFG_RTC, &EpochSeconds);
-  if (Status == EFI_UNSUPPORTED) {
-    // Battery backed up hardware RTC does not exist, revert to PL031
-    EpochSeconds = MmioRead32 (mPL031RtcBase + PL031_RTC_DR_DATA_REGISTER);
-    Status = EFI_SUCCESS;
-  } else if (EFI_ERROR (Status)) {
-    // Battery backed up hardware RTC exists but could not be read due to error. Abort.
-    goto EXIT;
-  } else {
-    // Battery backed up hardware RTC exists and we read the time correctly from it.
-    // Now sync the PL031 to the new time.
-    MmioWrite32 (mPL031RtcBase + PL031_RTC_LR_LOAD_REGISTER, EpochSeconds);
-  }
+  EpochSeconds = MmioRead32 (mPL031RtcBase + PL031_RTC_DR_DATA_REGISTER);
 
   // Ensure Time is a valid pointer
   if (Time == NULL) {
@@ -476,20 +461,6 @@  LibSetTime (
     EpochSeconds -= SEC_PER_HOUR;
   }
 
-  // On some platforms we may have access to a battery backed up hardware clock.
-  //
-  // If such RTC exists then it must be updated first, before the PL031,
-  // to minimise any time drift. This is important because the battery backed-up
-  // RTC maintains the master time for the platform across reboots.
-  //
-  // If such RTC does not exist then the following function returns UNSUPPORTED.
-  Status = ArmPlatformSysConfigSet (SYS_CFG_RTC, EpochSeconds);
-  if ((EFI_ERROR (Status)) && (Status != EFI_UNSUPPORTED)){
-    // Any status message except SUCCESS and UNSUPPORTED indicates a hardware failure.
-    goto EXIT;
-  }
-
-
   // Set the PL031
   MmioWrite32 (mPL031RtcBase + PL031_RTC_LR_LOAD_REGISTER, EpochSeconds);
 
diff --git a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
index 3a98fc757e3d..ba8ece6f7306 100644
--- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
+++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
@@ -34,7 +34,6 @@ 
   UefiLib
   DebugLib
   PcdLib
-  ArmPlatformSysConfigLib
   DxeServicesTableLib
   UefiRuntimeLib