From eb6e08570a46fe641308ff696225acfa1643a5a8 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Mon, 17 Dec 2012 12:59:16 -0800 Subject: link: Workaround for errata 3.2 Reads of HIBRTCC and HIBRTCCSS are not properly synchronized and may return incorrect data. We were re-checking HIBRTC, but not HIBRTCSS. BUG=chrome-os-partner:16864 BRANCH=link TEST=from ec console, do 'rtc' command repeatedly; printed values should be strictly increasing. Change-Id: I3e59dc840316ad36bb4851f03b66a3ae3df5cccd Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/39795 Reviewed-by: Bill Richardson --- chip/lm4/system.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chip/lm4/system.c b/chip/lm4/system.c index eac0c48b0a..130fc34367 100644 --- a/chip/lm4/system.c +++ b/chip/lm4/system.c @@ -189,7 +189,7 @@ void __attribute__((section(".iram.text"))) __enter_hibernate(int hibctl) uint32_t system_get_rtc(uint32_t *ss_ptr) { uint32_t rtc, rtc2; - uint32_t rtcss; + uint32_t rtcss, rtcss2; /* * The hibernate module isn't synchronized, so need to read repeatedly @@ -198,8 +198,9 @@ uint32_t system_get_rtc(uint32_t *ss_ptr) do { rtc = LM4_HIBERNATE_HIBRTCC; rtcss = LM4_HIBERNATE_HIBRTCSS & 0x7fff; + rtcss2 = LM4_HIBERNATE_HIBRTCSS & 0x7fff; rtc2 = LM4_HIBERNATE_HIBRTCC; - } while (rtc != rtc2); + } while (rtc != rtc2 || rtcss != rtcss2); if (ss_ptr) *ss_ptr = rtcss; -- cgit v1.2.1