summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2016-12-08 18:21:45 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-12-09 21:48:46 -0800
commit1b5bb68b8b70503eaaf8ad822cf7b4187f275093 (patch)
treec2df2e5dd192326984b27d71c462e4f8c50be714
parentb19c81b0b622df55583e920c9d9bc041e90dbcf3 (diff)
downloadchrome-ec-1b5bb68b8b70503eaaf8ad822cf7b4187f275093.tar.gz
g: remove the impact of deep sleep resumes from the rolling reboot count
Deep sleep needs to be considered a normal behavior and should not add to the rollback count. This change subtracts one from the reset count when the system sees that it just resumed from deep sleep. Ideally the rollback counter would be able to verify the TPM functionality and detect rolling reboots. With this change the rollback counter will only be able to detect rolling reboots, but it fixes the false positives for rolling reboots we were seeing before. BUG=chrome-os-partner:60449 BRANCH=none TEST=manual check the reset counter turn off the AP wait for cr50 to enter deep sleep plug in suzyq check it resumes from deep sleep and that the reset counter still has the same value Change-Id: Ie8490c29636403b409b2a3f0912a5b312d23bc24 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/418321 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--board/cr50/board.c17
-rw-r--r--chip/g/system.c2
2 files changed, 19 insertions, 0 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c
index 0f801de447..5f434a032d 100644
--- a/board/cr50/board.c
+++ b/board/cr50/board.c
@@ -258,9 +258,26 @@ static void configure_board_specific_gpios(void)
}
}
+void decrement_retry_counter(void)
+{
+ uint32_t counter = GREG32(PMU, LONG_LIFE_SCRATCH0);
+
+ if (counter) {
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 1);
+ GREG32(PMU, LONG_LIFE_SCRATCH0) = counter - 1;
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0);
+ }
+}
+
/* Initialize board. */
static void board_init(void)
{
+ /*
+ * Deep sleep resets should be considered valid and should not impact
+ * the rolling reboot count.
+ */
+ if (system_get_reset_flags() & RESET_FLAG_HIBERNATE)
+ decrement_retry_counter();
configure_board_specific_gpios();
init_pmu();
init_interrupts();
diff --git a/chip/g/system.c b/chip/g/system.c
index 61129984d4..85fcf63774 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -34,6 +34,8 @@ static void check_reset_cause(void)
/* This register is cleared by reading it */
uint32_t g_exitpd = GR_PMU_EXITPD_SRC;
+ flags |= RESET_FLAG_HIBERNATE;
+
if (g_exitpd & GC_PMU_EXITPD_SRC_PIN_PD_EXIT_MASK)
flags |= RESET_FLAG_WAKE_PIN;
if (g_exitpd & GC_PMU_EXITPD_SRC_UTMI_SUSPEND_N_MASK)