summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-06-13 15:54:32 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-09-14 16:55:35 +0000
commit4535fedbbf9efeb4393638b9d390a907d782b5f5 (patch)
tree3866a675e41c4c6695f824c52291d92212ff70d7
parentf14acff05cf9a033291df953dd1f7f69b0bf6ea3 (diff)
downloadchrome-ec-4535fedbbf9efeb4393638b9d390a907d782b5f5.tar.gz
g: provide an API to set rollback counter to ensure rollback
with the board ID match happening in the RW we need to be able to set the rollback counter to a value which would guarantee a fallback during the next boot. BRANCH=cr50 BUG=b:35586335 TEST=with the rest of the patches verified the ability to set the counter to trigger a fallback on the next reboot. Change-Id: I161f39354e5523121e26e8ad84a791a8b06e5123 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/535976 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit 4af07d9b00e8bf9724d60dfd30d6aa3724565a6f) Reviewed-on: https://chromium-review.googlesource.com/556230 (cherry picked from commit 463215cef2e3c2de66230664e71b8511924a37b2) Reviewed-on: https://chromium-review.googlesource.com/666521
-rw-r--r--chip/g/system.c7
-rw-r--r--chip/g/system_chip.h9
2 files changed, 14 insertions, 2 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index ac9a529d77..8495c43e6c 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -479,6 +479,13 @@ int system_process_retry_counter(void)
return corrupt_header(newer_image);
}
+void system_ensure_rollback(void)
+{
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 1);
+ GREG32(PMU, LONG_LIFE_SCRATCH0) = RW_BOOT_MAX_RETRY_COUNT + 1;
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0);
+}
+
int system_rolling_reboot_suspected(void)
{
if (GREG32(PMU, LONG_LIFE_SCRATCH0) > 50) {
diff --git a/chip/g/system_chip.h b/chip/g/system_chip.h
index 251c2d3007..ce63f3eab8 100644
--- a/chip/g/system_chip.h
+++ b/chip/g/system_chip.h
@@ -57,8 +57,7 @@ int system_battery_cutoff_support_required(void);
*/
void system_update_rollback_mask(void);
-/*
- **
+/**
* Scan INFO1 rollback map and infomap fields of both RW and RW_B image
* headers, and return a string showing how many zeros are there at the base
* of in each of these objects.
@@ -68,4 +67,10 @@ void system_update_rollback_mask(void);
*/
void system_get_rollback_bits(char *value, size_t value_size);
+/**
+ * Set the rollback counter to a value which would ensure a rollback on the
+ * next boot.
+ */
+void system_ensure_rollback(void);
+
#endif /* __CROS_EC_SYSTEM_CHIP_H */