From a4c4b1c69c8770a45fdd074245c6702b2b9514bf Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 30 Apr 2014 21:41:23 -0700 Subject: [PATCH] elog: Use the RTC driver interface instead of reading CMOS directly. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the RTC driver interface to find the timestamp for events instead of reading the CMOS based RTC directly on x86 or punting on ARM. This makes timestamps available on both architectures, assuming an RTC driver is available. BUG=None TEST=Built and booted on nyan_big and link and verified that the timestamps in the event log were accurate. BRANCH=nyan Original-Change-Id: Id45da53bc7ddfac8dd0978e7f2a3b8bc2c7ea753 Original-Signed-off-by: Gabe Black Original-Reviewed-on: https://chromium-review.googlesource.com/197798 Original-Reviewed-by: David Hendricks Original-Tested-by: Gabe Black Original-Commit-Queue: Gabe Black (cherry picked from commit 493b05e06dd461532c9366fb09025efb3568a975) Signed-off-by: Marc Jones Change-Id: I4fad296ecfeff8987e4a18054661190239245f32 Reviewed-on: http://review.coreboot.org/7891 Reviewed-by: Edward O'Callaghan Reviewed-by: Alexandru Gagniuc Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki --- src/drivers/elog/elog.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index 92d5af3b9e..85198e2145 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -25,6 +25,8 @@ #if CONFIG_ARCH_X86 #include #endif +#include +#include #include #include #include @@ -637,20 +639,15 @@ int elog_init(void) */ static void elog_fill_timestamp(struct event_header *event) { -#if CONFIG_ARCH_X86 - event->second = cmos_read(RTC_CLK_SECOND); - event->minute = cmos_read(RTC_CLK_MINUTE); - event->hour = cmos_read(RTC_CLK_HOUR); - event->day = cmos_read(RTC_CLK_DAYOFMONTH); - event->month = cmos_read(RTC_CLK_MONTH); - event->year = cmos_read(RTC_CLK_YEAR); -#else - /* - * FIXME: We need to abstract the CMOS stuff on non-x86 platforms. - * Until then, use bogus data here to force the values to 0. - */ - event->month = 0xff; -#endif + struct rtc_time time; + + rtc_get(&time); + event->second = bin2bcd(time.sec); + event->minute = bin2bcd(time.min); + event->hour = bin2bcd(time.hour); + event->day = bin2bcd(time.mday); + event->month = bin2bcd(time.mon); + event->year = bin2bcd(time.year) & 0xff; /* Basic sanity check of expected ranges */ if (event->month > 0x12 || event->day > 0x31 || event->hour > 0x23 ||