summaryrefslogtreecommitdiff
path: root/chip/g/system.c
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2016-09-01 13:23:55 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-02 09:32:24 -0700
commit5ee00611d4a30fc8108a6c4ff3cfa2784457d36f (patch)
treee47a826fcdb7be11bff3aace47fd0b2970f68458 /chip/g/system.c
parent74e60906c4c2d4c3520d3ea221c232b5f29b7e0d (diff)
downloadchrome-ec-5ee00611d4a30fc8108a6c4ff3cfa2784457d36f.tar.gz
g: clear reset_counter after update
If the firmware was just updated clear the reset counter before rebooting. This will ensure that the update can complete even if the TPM isn't being used. BUG=chrome-os-partner:56864 BRANCH=none TEST=Set the reset counter to 7 by running 'rw 0x40000128 1' and 'rw 0x4000012c 7'. Then make sure cr50 can still be updated Change-Id: Ic304fc7a20a4f2af7792f80e970d28e0eb10967e Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/380235 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'chip/g/system.c')
-rw-r--r--chip/g/system.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index 323c258ea8..15640f46e3 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -13,6 +13,7 @@
#include "signed_header.h"
#include "system.h"
#include "task.h"
+#include "upgrade_fw.h"
#include "version.h"
static void check_reset_cause(void)
@@ -86,6 +87,14 @@ void system_pre_init(void)
system_init_board_properties();
#endif
}
+#ifdef BOARD_CR50
+void clear_retry_counter(void)
+{
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 1);
+ GREG32(PMU, LONG_LIFE_SCRATCH0) = 0;
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0);
+}
+#endif
void system_reset(int flags)
{
@@ -96,6 +105,15 @@ void system_reset(int flags)
interrupt_disable();
if (flags & SYSTEM_RESET_HARD) {
+#if defined(BOARD_CR50) && !defined(SECTION_IS_RO)
+ /*
+ * If the system was updated during this boot clear the retry
+ * counter.
+ */
+ if (fw_upgraded())
+ clear_retry_counter();
+#endif
+
/* Reset the full microcontroller */
GR_PMU_GLOBAL_RESET = GC_PMU_GLOBAL_RESET_KEY;
} else {
@@ -333,9 +351,7 @@ int system_process_retry_counter(void)
struct SignedHeader *me, *other;
retry_counter = GREG32(PMU, LONG_LIFE_SCRATCH0);
- GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 1);
- GREG32(PMU, LONG_LIFE_SCRATCH0) = 0;
- GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0);
+ clear_retry_counter();
ccprintf("%s:retry counter %d\n", __func__, retry_counter);