summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2016-09-22 19:40:05 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-23 21:09:18 -0700
commita6525c9791b5530d41fc5600c27aabdc010cfb5a (patch)
treee489ccbb3e5bb21eafd80fac84792894aa9d3616
parent6dc71775f85921fd729fdf87066acccc6b4497f6 (diff)
downloadchrome-ec-a6525c9791b5530d41fc5600c27aabdc010cfb5a.tar.gz
npcx: Selectively filter WDT reset in reset_flags
NPCX reboots by triggering the watchdog which in turn causes the watchdog reset flag to be set as one of the system-wide reset_flags. However, other software can confuse the presence of the watchdog reset flag as a panic. This patch selectively sets the watchdog reset flag only if we're not explicitly doing a soft or hard reset or waking from hibernate. Patch created by Mulin Chao <mlchao@nuvoton.com> BUG=chrome-os-partner:56594 BRANCH=none TEST=panic reset no longer observed Change-Id: I016b59ffda4f6334cf41e196960edcbb87f6c049 Signed-off-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/388853 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
-rw-r--r--chip/npcx/system.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/chip/npcx/system.c b/chip/npcx/system.c
index 9123d52896..4c350b85ec 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -160,7 +160,12 @@ void system_set_rtc(uint32_t seconds)
void system_check_reset_cause(void)
{
uint32_t hib_wake_flags = bbram_data_read(BBRM_DATA_INDEX_WAKE);
- uint32_t flags = 0;
+ uint32_t flags = bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS);
+
+ /* Clear saved reset flags in bbram */
+ bbram_data_write(BBRM_DATA_INDEX_SAVED_RESET_FLAGS, 0);
+ /* Clear saved hibernate wake flag in bbram , too */
+ bbram_data_write(BBRM_DATA_INDEX_WAKE, 0);
/* Use scratch bit to check power on reset or VCC1_RST reset */
if (!IS_BIT_SET(NPCX_RSTCTL, NPCX_RSTCTL_VCC1_RST_SCRATCH)) {
@@ -189,24 +194,27 @@ void system_check_reset_cause(void)
SET_BIT(NPCX_RSTCTL, NPCX_RSTCTL_DBGRST_STS);
}
+ /* Reset by hibernate */
+ if (hib_wake_flags & HIBERNATE_WAKE_PIN)
+ flags |= RESET_FLAG_WAKE_PIN | RESET_FLAG_HIBERNATE;
+ else if (hib_wake_flags & HIBERNATE_WAKE_MTC)
+ flags |= RESET_FLAG_RTC_ALARM | RESET_FLAG_HIBERNATE;
+
/* Watchdog Reset */
if (IS_BIT_SET(NPCX_T0CSR, NPCX_T0CSR_WDRST_STS)) {
- flags |= RESET_FLAG_WATCHDOG;
+ /*
+ * Don't set RESET_FLAG_WATCHDOG flag if watchdog is issued by
+ * system_reset or hibernate in order to distinguish reset cause
+ * is panic reason or not.
+ */
+ if (!(flags & (RESET_FLAG_SOFT | RESET_FLAG_HARD |
+ RESET_FLAG_HIBERNATE)))
+ flags |= RESET_FLAG_WATCHDOG;
+
/* Clear watchdog reset status initially*/
SET_BIT(NPCX_T0CSR, NPCX_T0CSR_WDRST_STS);
}
- if ((hib_wake_flags & HIBERNATE_WAKE_PIN))
- flags |= RESET_FLAG_WAKE_PIN;
- else if ((hib_wake_flags & HIBERNATE_WAKE_MTC))
- flags |= RESET_FLAG_RTC_ALARM;
-
- /* Restore then clear saved reset flags */
- flags |= bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS);
- bbram_data_write(BBRM_DATA_INDEX_SAVED_RESET_FLAGS, 0);
- /* Clear saved hibernate wake flag, too */
- bbram_data_write(BBRM_DATA_INDEX_WAKE, 0);
-
system_set_reset_flags(flags);
}