[coreboot-gerrit] Patch set updated for coreboot: rtc: Force negative edge on SET after battery replacement

Marshall Dawson (marshalldawson3rd@gmail.com) gerrit at coreboot.org
Mon Nov 14 19:01:17 CET 2016


Marshall Dawson (marshalldawson3rd at gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17370

-gerrit

commit 3368064b6793fbce4e8450e7f23b736a1e0ff680
Author: Marshall Dawson <marshalldawson3rd at gmail.com>
Date:   Sat Nov 5 18:47:51 2016 -0600

    rtc: Force negative edge on SET after battery replacement
    
    After the RTC coin cell has been replaced, the Update Cycle Inhibit
    bit must see at least one low transition to ensure the RTC counts.
    The reset value for this bit is undefined. Examples have been observed
    where batteries are installed on a manufacturing line, the bit's state
    comes up low, but the RTC does not count.
    
    Change-Id: I05f61efdf941297fa9ec90136124b0c8fe0639c6
    Signed-off-by: Marshall Dawson <marshalldawson3rd at gmail.com>
---
 src/drivers/pc80/rtc/mc146818rtc.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c
index c3026a4..adbc611 100644
--- a/src/drivers/pc80/rtc/mc146818rtc.c
+++ b/src/drivers/pc80/rtc/mc146818rtc.c
@@ -95,7 +95,7 @@ static void cmos_set_checksum(int range_start, int range_end, int cks_loc)
 #ifndef __SMM__
 void cmos_init(bool invalid)
 {
-	bool cmos_invalid = invalid;
+	bool cmos_invalid;
 	bool checksum_invalid = false;
 	bool clear_cmos;
 	size_t i;
@@ -114,11 +114,11 @@ void cmos_init(bool invalid)
 
 	printk(BIOS_DEBUG, "RTC Init\n");
 
-	if (IS_ENABLED(CONFIG_USE_OPTION_TABLE)) {
-		/* See if there has been a CMOS power problem. */
-		x = cmos_read(RTC_VALID);
-		cmos_invalid = !(x & RTC_VRT);
+	/* See if there has been a CMOS power problem. */
+	x = cmos_read(RTC_VALID);
+	cmos_invalid = !(x & RTC_VRT);
 
+	if (IS_ENABLED(CONFIG_USE_OPTION_TABLE)) {
 		/* See if there is a CMOS checksum error */
 		checksum_invalid = !cmos_checksum_valid(PC_CKS_RANGE_START,
 						PC_CKS_RANGE_END, PC_CKS_LOC);
@@ -128,6 +128,9 @@ void cmos_init(bool invalid)
 		clear_cmos = true;
 	}
 
+	if (cmos_invalid || invalid)
+		cmos_write(cmos_read(RTC_CONTROL) | RTC_SET, RTC_CONTROL);
+
 	if (invalid || cmos_invalid || checksum_invalid) {
 		if (clear_cmos) {
 			cmos_write(0, 0x01);



More information about the coreboot-gerrit mailing list