[coreboot] New patch to review for coreboot: a9f4c92 RTC: Write build date in BCD when clearing RTC CMOS

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Tue Nov 6 23:51:57 CET 2012


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1709

-gerrit

commit a9f4c92cf0a67e2b357cbf1a01e9f5e41be4b25a
Author: Duncan Laurie <dlaurie at chromium.org>
Date:   Thu Aug 16 16:06:03 2012 -0700

    RTC: Write build date in BCD when clearing RTC CMOS
    
    Check the RTC on boot after RTC battery failure and ensure
    that the reported build date matches what is reported:
    
    > grep ^rtc /proc/driver/rtc
    rtc_time        : 01:00:21
    rtc_date        : 2012-08-16
    
    Change-Id: If23f436796754c68ae6244ef7633ff4fa0a93603
    Signed-off-by: Duncan Laurie <dlaurie at chromium.org>
---
 src/drivers/pc80/mc146818rtc.c | 8 ++++----
 src/include/pc80/mc146818rtc.h | 2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/drivers/pc80/mc146818rtc.c b/src/drivers/pc80/mc146818rtc.c
index d832544..52cfb63 100644
--- a/src/drivers/pc80/mc146818rtc.c
+++ b/src/drivers/pc80/mc146818rtc.c
@@ -84,10 +84,10 @@ static void rtc_update_cmos_date(u8 has_century)
 	cmos_write(0, RTC_CLK_SECOND);
 	cmos_write(0, RTC_CLK_MINUTE);
 	cmos_write(1, RTC_CLK_HOUR);
-	cmos_write(COREBOOT_BUILD_WEEKDAY, RTC_CLK_DAYOFWEEK);
-	cmos_write(COREBOOT_BUILD_DAY, RTC_CLK_DAYOFMONTH);
-	cmos_write(COREBOOT_BUILD_MONTH, RTC_CLK_MINUTE);
-	cmos_write(COREBOOT_BUILD_YEAR, RTC_CLK_YEAR);
+	cmos_write(RTC_TO_BCD(COREBOOT_BUILD_WEEKDAY), RTC_CLK_DAYOFWEEK);
+	cmos_write(RTC_TO_BCD(COREBOOT_BUILD_DAY), RTC_CLK_DAYOFMONTH);
+	cmos_write(RTC_TO_BCD(COREBOOT_BUILD_MONTH), RTC_CLK_MINUTE);
+	cmos_write(RTC_TO_BCD(COREBOOT_BUILD_YEAR), RTC_CLK_YEAR);
 	if (has_century) cmos_write(0x20, RTC_CLK_ALTCENTURY);
 }
 
diff --git a/src/include/pc80/mc146818rtc.h b/src/include/pc80/mc146818rtc.h
index a916761..61b522c 100644
--- a/src/include/pc80/mc146818rtc.h
+++ b/src/include/pc80/mc146818rtc.h
@@ -63,6 +63,8 @@
 # define RTC_24H 0x02		/* 24 hour mode - else hours bit 7 means pm */
 # define RTC_DST_EN 0x01	/* auto switch DST - works f. USA only */
 
+#define RTC_TO_BCD(value) (((value / 10) << 4) | (value % 10))
+
 /**********************************************************************/
 #define RTC_INTR_FLAGS	RTC_REG_C
 /* caution - cleared by read */




More information about the coreboot mailing list