summaryrefslogtreecommitdiff
path: root/src/drivers/pc80/rtc
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2017-09-15 11:01:17 -0600
committerAaron Durbin <adurbin@chromium.org>2017-09-20 23:53:23 +0000
commit9fde0d780dd0abd24119ff6f7854b4b5939ce7d2 (patch)
tree2a42e542b93e2dc73712182a634a9483f512cc1a /src/drivers/pc80/rtc
parentaa51cd5c12596b0b6d5f61eb1108091bf3a4fd3f (diff)
vboot: remove init_vbnv_cmos()
Instead of having each potential caller deal with the differences of cmos_init() and init_vbnv_cmos() when VBOOT is enabled put the correct logic within the callee, cmos_init(), for handling the vbnv in CMOS. The internal __cmos_init() routine returns when the CMOS area was cleared. BUG=b:63054105 Change-Id: Ia124bcd61d3ac03e899a4ecf3645fc4b7a558f03 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/21549 Reviewed-by: Furquan Shaikh <furquan@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers/pc80/rtc')
-rw-r--r--src/drivers/pc80/rtc/mc146818rtc.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c
index 0e9a88ab5c..830ff09a59 100644
--- a/src/drivers/pc80/rtc/mc146818rtc.c
+++ b/src/drivers/pc80/rtc/mc146818rtc.c
@@ -26,6 +26,8 @@
#include <rtc.h>
#include <string.h>
#include <cbfs.h>
+#include <vboot/vbnv.h>
+#include <vboot/vbnv_layout.h>
/* There's no way around this include guard. option_table.h is autogenerated */
#if IS_ENABLED(CONFIG_USE_OPTION_TABLE)
@@ -95,7 +97,7 @@ static void cmos_set_checksum(int range_start, int range_end, int cks_loc)
#define RTC_FREQ_SELECT_DEFAULT (RTC_REF_CLCK_32KHZ | RTC_RATE_1024HZ)
#ifndef __SMM__
-void cmos_init(bool invalid)
+static bool __cmos_init(bool invalid)
{
bool cmos_invalid;
bool checksum_invalid = false;
@@ -111,7 +113,7 @@ void cmos_init(bool invalid)
* was due to the RTC alarm.
*/
if (acpi_is_wakeup_s3())
- return;
+ return false;
#endif /* __PRE_RAM__ */
printk(BIOS_DEBUG, "RTC Init\n");
@@ -150,7 +152,8 @@ void cmos_init(bool invalid)
cmos_invalid ? " Power Problem":"",
checksum_invalid ? " Checksum invalid":"",
clear_cmos ? " zeroing cmos":"");
- }
+ } else
+ clear_cmos = false;
/* Setup the real time clock */
cmos_write(RTC_CONTROL_DEFAULT, RTC_CONTROL);
@@ -172,6 +175,31 @@ void cmos_init(bool invalid)
/* Clear any pending interrupts */
cmos_read(RTC_INTR_FLAGS);
+
+ return clear_cmos;
+}
+
+static void cmos_init_vbnv(bool invalid)
+{
+ uint8_t vbnv[VBOOT_VBNV_BLOCK_SIZE];
+
+ /* __cmos_init() will clear vbnv contents when a known rtc failure
+ occurred with !CONFIG_USE_OPTION_TABLE. However, __cmos_init() may
+ clear vbnv data for other internal reasons. For that, always back up
+ the vbnv contents and conditionally save them when __cmos_init()
+ indicates cmos was cleared. */
+ read_vbnv_cmos(vbnv);
+
+ if (__cmos_init(invalid))
+ save_vbnv_cmos(vbnv);
+}
+
+void cmos_init(bool invalid)
+{
+ if (IS_ENABLED(CONFIG_VBOOT_VBNV_CMOS))
+ cmos_init_vbnv(invalid);
+ else
+ __cmos_init(invalid);
}
#endif /* __SMM__ */