From 57806691194ee7b5509e6992530c4696508ab85c Mon Sep 17 00:00:00 2001 From: zwei4 Date: Thu, 7 Sep 2017 11:35:42 +0800 Subject: BroxtonPlatformPkg: RTC initialize 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 --- .../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 abe635d906..a6d251ded2 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 1475c4cabe..a27277bb75 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 7516a15489..ee8fd5a689 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 0000000000..4b6ab285e4 --- /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.
+ + 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 + +// +// 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; +} -- cgit v1.2.3