diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2020-01-04 17:38:17 +0200 |
---|---|---|
committer | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2020-01-07 18:39:35 +0000 |
commit | 1a9b7b50c74b028a7be49b870aefafd221bad1cf (patch) | |
tree | 8f9eb7df9bf0b1f189f7b995ab8b48085ad97a9d /src/drivers/pc80/rtc/mc146818rtc.c | |
parent | a0259b427345824abf6b7d80fe66415b47b1cc73 (diff) | |
download | coreboot-1a9b7b50c74b028a7be49b870aefafd221bad1cf.tar.xz |
drivers/pc80/rtc: Clean up some inlined functions
Change-Id: Ie73797b4e9a09605a0685f0b03cb85e9a3be93ad
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38179
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'src/drivers/pc80/rtc/mc146818rtc.c')
-rw-r--r-- | src/drivers/pc80/rtc/mc146818rtc.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c index 2029b1e51f..1d2fc97a74 100644 --- a/src/drivers/pc80/rtc/mc146818rtc.c +++ b/src/drivers/pc80/rtc/mc146818rtc.c @@ -81,6 +81,12 @@ static void cmos_set_checksum(int range_start, int range_end, int cks_loc) cmos_write(((sum >> 0) & 0x0ff), cks_loc + 1); } +/* See if the CMOS error condition has been flagged */ +int cmos_error(void) +{ + return (cmos_read(RTC_VALID) & RTC_VRT) == 0; +} + #define RTC_CONTROL_DEFAULT (RTC_24H) #define RTC_FREQ_SELECT_DEFAULT (RTC_REF_CLCK_32KHZ | RTC_RATE_1024HZ) @@ -90,7 +96,6 @@ static bool __cmos_init(bool invalid) bool checksum_invalid = false; bool clear_cmos; size_t i; - uint8_t x; /* * Avoid clearing pending interrupts and resetting the RTC control @@ -104,8 +109,7 @@ static bool __cmos_init(bool invalid) printk(BIOS_DEBUG, "RTC Init\n"); /* See if there has been a CMOS power problem. */ - x = cmos_read(RTC_VALID); - cmos_invalid = !(x & RTC_VRT); + cmos_invalid = cmos_error(); if (CONFIG(USE_OPTION_TABLE)) { /* See if there is a CMOS checksum error */ @@ -118,7 +122,7 @@ static bool __cmos_init(bool invalid) } if (cmos_invalid || invalid) - cmos_write(cmos_read(RTC_CONTROL) | RTC_SET, RTC_CONTROL); + cmos_disable_rtc(); if (invalid || cmos_invalid || checksum_invalid) { if (clear_cmos) { @@ -407,6 +411,17 @@ enum cb_err set_option(const char *name, void *value) } /* + * Upon return the caller is guaranteed 244 microseconds to complete any + * RTC operations. wait_uip may be called a single time prior to multiple + * accesses, but sequences requiring more time should call wait_uip again. + */ +static void wait_uip(void) +{ + while (cmos_read(RTC_REG_A) & RTC_UIP) + ; +} + +/* * If the CMOS is cleared, the rtc_reg has the invalid date. That * hurts some OSes. Even if we don't set USE_OPTION_TABLE, we need * to make sure the date is valid. |