summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorMarshall Dawson <marshalldawson3rd@gmail.com>2016-11-05 18:31:33 -0600
committerMartin Roth <martinroth@google.com>2016-11-17 23:08:43 +0100
commit5a043fe08d84490356888d236ee7d190aa195217 (patch)
tree80b062db6bc068d06917afbbe0d3410b191b15d2 /src/drivers
parent05abe4351b1d76148a8cc69f817e659fa372a5dd (diff)
downloadcoreboot-5a043fe08d84490356888d236ee7d190aa195217.tar.xz
rtc: Check update-in-progress bit
While the real-time clock updates its count, values may not be correctly read or written. On reads, ensure the UIP bit is clear which guarantees a minimum of 244 microseconds exists before the update begins. Writes already avoid the problem by disabling the RTC count via the SET bit. Change-Id: I39e34493113015d32582f1c280fafa9e97f43a40 Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com> Reviewed-on: https://review.coreboot.org/17369 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/pc80/rtc/mc146818rtc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c
index 5fb9cf695b..c3026a4dbc 100644
--- a/src/drivers/pc80/rtc/mc146818rtc.c
+++ b/src/drivers/pc80/rtc/mc146818rtc.c
@@ -360,6 +360,7 @@ void cmos_check_update_date(void)
u8 year, century;
/* Assume hardware always supports RTC_CLK_ALTCENTURY. */
+ wait_uip();
century = cmos_read(RTC_CLK_ALTCENTURY);
year = cmos_read(RTC_CLK_YEAR);
@@ -388,6 +389,7 @@ int rtc_set(const struct rtc_time *time)
int rtc_get(struct rtc_time *time)
{
+ wait_uip();
time->sec = bcd2bin(cmos_read(RTC_CLK_SECOND));
time->min = bcd2bin(cmos_read(RTC_CLK_MINUTE));
time->hour = bcd2bin(cmos_read(RTC_CLK_HOUR));