public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org, leif.lindholm@linaro.org
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 08/19] ArmPlatformPkg/PL031RealTimeClockLib: drop ArmPlatformSysConfigLib reference
Date: Wed, 15 Nov 2017 16:56:26 +0000	[thread overview]
Message-ID: <20171115165637.31118-9-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20171115165637.31118-1-ard.biesheuvel@linaro.org>

The PL031 driver implements a VExpress/Juno specific hack to set the
battery backed clock in addition to the PL031. However, none of the
remaining VExpress based hardware we support in EDK2 actuall implements
this feature so we can just remove it, and get rid of the cumbersome
dependency on ArmPlatform.h.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c   | 43 +++-----------------
 ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf |  1 -
 2 files changed, 6 insertions(+), 38 deletions(-)

diff --git a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
index 459dcc0a0519..1334ad446cd9 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>
@@ -38,8 +37,6 @@
 
 #include <Library/TimeBaseLib.h>
 
-#include <ArmPlatform.h>
-
 STATIC BOOLEAN                mPL031Initialized = FALSE;
 STATIC EFI_EVENT              mRtcVirtualAddrChangeEvent;
 STATIC UINTN                  mPL031RtcBase;
@@ -133,6 +130,11 @@ LibGetTime (
   EFI_STATUS  Status = EFI_SUCCESS;
   UINT32      EpochSeconds;
 
+  // Ensure Time is a valid pointer
+  if (Time == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
   // Initialize the hardware if not already done
   if (!mPL031Initialized) {
     Status = InitializePL031 ();
@@ -141,27 +143,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.
-    return Status;
-  } 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);
-  }
-
-  // Ensure Time is a valid pointer
-  if (Time == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
+  EpochSeconds = MmioRead32 (mPL031RtcBase + PL031_RTC_DR_DATA_REGISTER);
 
   // Adjust for the correct time zone
   // The timezone setting also reflects the DST setting of the clock
@@ -235,19 +217,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.
-    return Status;
-  }
-
   // 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 aa06a41d0b2a..a3e4f73e7d05 100644
--- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
+++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf
@@ -34,7 +34,6 @@ [LibraryClasses]
   UefiLib
   DebugLib
   PcdLib
-  ArmPlatformSysConfigLib
   DxeServicesTableLib
   TimeBaseLib
   UefiRuntimeLib
-- 
2.11.0



  parent reply	other threads:[~2017-11-15 16:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 16:56 [PATCH 00/19] ArmPlatformPkg: remove unused or migrated modules Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 01/19] ArmPkg: remove unused ArmGicSecLib library implementation Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 02/19] ArmPlatformPkg: remove ArmPlatformSecLib definition and implementations Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 03/19] ArmPlatformPkg: remove unused DebugSecExtraActionLib library Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 04/19] ArmPlatformPkg: remove ArmTrustedMonitorLib definition and implementation Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 05/19] ArmPlatformPkg: remove ArmGetCpuCountPerCluster () from ArmPlatformLib Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 06/19] ArmPlatformPkg: remove NorFlashArmVExpressLib Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 07/19] ArmPlatformPkg: remove ArmJunoPkg Ard Biesheuvel
2017-11-15 16:56 ` Ard Biesheuvel [this message]
2017-11-15 16:56 ` [PATCH 09/19] ArmPlatformPkg: remove ArmVExpressPkg Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 10/19] ArmPlatformPkg: remove ArmPlatformSysConfigLib library class Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 11/19] ArmPlatformPkg: remove unused PL301Axi driver Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 12/19] ArmPlatformPkg: remove unused PL35x driver Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 13/19] ArmPlatformPkg: remove PL34xDmc driver Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 14/19] ArmPlatformPkg: remove unused PL310 driver Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 15/19] ArmPlatformPkg: remove unused ArmTrustZone driver Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 16/19] ArmPlatformPkg: remove unused SP804 driver and TimerLib implementation Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 17/19] ArmPlatformPkg: remove unused L2X0CacheLibNull library Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 18/19] ArmPlatformPkg: remove EblCmdLib implementation Ard Biesheuvel
2017-11-15 16:56 ` [PATCH 19/19] ArmPlatformPkg: remove BootMonFs and ArmShellCmdRunAxf Ard Biesheuvel
2017-11-25 11:47 ` [PATCH 00/19] ArmPlatformPkg: remove unused or migrated modules Leif Lindholm
2017-11-26 11:04   ` Ard Biesheuvel
2017-12-04 17:24   ` Leif Lindholm

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=20171115165637.31118-9-ard.biesheuvel@linaro.org \
    --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