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 2/2] BroxtonPlatformPkg: RTC initialize
Date: Fri,  8 Sep 2017 15:22:48 +0800	[thread overview]
Message-ID: <20170908072248.23540-2-david.wei@intel.com> (raw)
In-Reply-To: <20170908072248.23540-1-david.wei@intel.com>

Force RTC century to 20 in case core driver has failed to
initialize it.

Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: zwei4 <david.wei@intel.com>
---
 .../Common/PlatformSettings/PlatformDxe/Platform.c |  5 +++
 .../PlatformSettings/PlatformDxe/PlatformDxe.h     |  6 +++
 .../PlatformSettings/PlatformDxe/PlatformDxe.inf   |  1 +
 .../Common/PlatformSettings/PlatformDxe/Rtc.c      | 51 ++++++++++++++++++++++
 4 files changed, 63 insertions(+)
 create mode 100644 Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Rtc.c

diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c
index abe635d90..a6d251ded 100644
--- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c
+++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platform.c
@@ -390,6 +390,11 @@ ReadyToBootFunction (
     mPciLanInfo = NULL;
   }
 
+  //
+  // Set RTC century in case RTC core driver failed to initialize it.
+  //
+  AdjustRtcCentury ();
+
   return;
 }
 
diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.h b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.h
index 1475c4cab..a27277bb7 100644
--- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.h
+++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.h
@@ -235,6 +235,12 @@ InitSioPlatformPolicy (
   VOID
   );
 
+VOID
+EFIAPI
+AdjustRtcCentury (
+  VOID
+  );
+
 //
 // Global externs
 //
diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
index 7516a1548..ee8fd5a68 100644
--- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
+++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf
@@ -33,6 +33,7 @@
   PciDevice.c
   IchTcoReset.c
   SensorVar.c
+  Rtc.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Rtc.c b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Rtc.c
new file mode 100644
index 000000000..4b6ab285e
--- /dev/null
+++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Rtc.c
@@ -0,0 +1,51 @@
+/** @file
+  Adjust Default System Time.
+  
+  Copyright (c) 2015 - 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 that accompanies this distribution.  
+  The full text of the license may be found at                                     
+  http://opensource.org/licenses/bsd-license.php.                                  
+                                                                                   
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,            
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    
+                                                                                   
+--*/
+
+#include <PlatformDxe.h>
+
+//
+// Date and time initial values.
+// They are used if the RTC values are invalid during driver initialization
+//
+#define RTC_INIT_SECOND 0
+#define RTC_INIT_MINUTE 0
+#define RTC_INIT_HOUR   0
+
+#define RTC_ADDRESS_CENTURY      50
+
+#define RTC_ADDRESS_REGISTER     0x70
+#define RTC_DATA_REGISTER        0x71
+
+/**
+  Set RTC century to 20 in case RTC core driver failed to initialize it.
+
+**/
+VOID
+EFIAPI
+AdjustRtcCentury (
+  VOID
+  )
+{
+
+  UINT8  Century;
+
+  Century = 20;
+  Century = DecimalToBcd8 (20);
+  IoWrite8 (RTC_ADDRESS_REGISTER, (UINT8) (RTC_ADDRESS_CENTURY | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));
+  IoWrite8 (RTC_DATA_REGISTER, Century);
+  Century = IoRead8(RTC_DATA_REGISTER);
+
+  return;
+}
-- 
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 [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 1/2] Clean up CMOS code zwei4
2017-09-08  7:22 ` zwei4 [this message]

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-2-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