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>
This commit is contained in:
Vadim Bendebury
2017-06-13 15:54:32 -07:00
committed by chrome-bot
parent dcca1de528
commit 4af07d9b00
2 changed files with 14 additions and 2 deletions

View File

@@ -523,6 +523,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) {

View File

@@ -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 */