From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 52AAF20945C1A for ; Fri, 8 Sep 2017 00:20:06 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 08 Sep 2017 00:22:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,360,1500966000"; d="scan'208";a="149574858" Received: from zwei4-mobl1.ccr.corp.intel.com ([10.239.193.132]) by fmsmga006.fm.intel.com with ESMTP; 08 Sep 2017 00:22:57 -0700 From: zwei4 To: edk2-devel@lists.01.org Date: Fri, 8 Sep 2017 15:22:48 +0800 Message-Id: <20170908072248.23540-2-david.wei@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20170908072248.23540-1-david.wei@intel.com> References: <20170908072248.23540-1-david.wei@intel.com> Subject: [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 2/2] BroxtonPlatformPkg: RTC initialize X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 07:20:06 -0000 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 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.
+ + 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; +} -- 2.14.1.windows.1