From bfabe62a6e5cdd9e29394b12737c5ed9bd080036 Mon Sep 17 00:00:00 2001 From: Lijian Zhao Date: Wed, 6 Sep 2017 16:47:17 -0700 Subject: soc/intel/common/block: Update common rtc code Move rtc init code into common area and update the implementation for apollolake to avoid build break. Change-Id: I702ce0efba25cb6fde33cc15698ae44312742367 Signed-off-by: Lijian Zhao Reviewed-on: https://review.coreboot.org/21433 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- .../intel/common/block/include/intelblocks/rtc.h | 5 +++++ src/soc/intel/common/block/rtc/Makefile.inc | 2 ++ src/soc/intel/common/block/rtc/rtc.c | 23 +++++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src/soc/intel/common') diff --git a/src/soc/intel/common/block/include/intelblocks/rtc.h b/src/soc/intel/common/block/include/intelblocks/rtc.h index 1556026753..c6507c84f9 100644 --- a/src/soc/intel/common/block/include/intelblocks/rtc.h +++ b/src/soc/intel/common/block/include/intelblocks/rtc.h @@ -18,4 +18,9 @@ void enable_rtc_upper_bank(void); +/* Expect return rtc failed bootlean in case of coin removal */ +int soc_get_rtc_failed(void); + +void rtc_init(void); + #endif /* SOC_INTEL_COMMON_BLOCK_RTC_H */ diff --git a/src/soc/intel/common/block/rtc/Makefile.inc b/src/soc/intel/common/block/rtc/Makefile.inc index 2d2d4e3954..95f665919d 100644 --- a/src/soc/intel/common/block/rtc/Makefile.inc +++ b/src/soc/intel/common/block/rtc/Makefile.inc @@ -1 +1,3 @@ bootblock-$(CONFIG_SOC_INTEL_COMMON_BLOCK_RTC) += rtc.c + +ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_RTC) += rtc.c diff --git a/src/soc/intel/common/block/rtc/rtc.c b/src/soc/intel/common/block/rtc/rtc.c index ea9987074b..04c07687db 100644 --- a/src/soc/intel/common/block/rtc/rtc.c +++ b/src/soc/intel/common/block/rtc/rtc.c @@ -13,9 +13,11 @@ * GNU General Public License for more details. */ -#include #include #include +#include +#include +#include /* RTC PCR configuration */ #define PCR_RTC_CONF 0x3400 @@ -29,3 +31,22 @@ void enable_rtc_upper_bank(void) /* Enable upper 128 bytes of CMOS */ pcr_or32(PID_RTC, PCR_RTC_CONF, PCR_RTC_CONF_UCMOS_EN); } + +__attribute__((weak)) int soc_get_rtc_failed(void) +{ + return 0; +} + +void rtc_init(void) +{ + int rtc_failed; + + rtc_failed = soc_get_rtc_failed(); + /* Ensure the date is set including century byte. */ + cmos_check_update_date(); + + if (IS_ENABLED(CONFIG_VBOOT_VBNV_CMOS)) + init_vbnv_cmos(rtc_failed); + else + cmos_init(rtc_failed); +} -- cgit v1.2.3