summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip/g/system.c16
-rw-r--r--common/tpm_registers.c3
-rw-r--r--include/system.h8
3 files changed, 27 insertions, 0 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index 9bc3a26b8e..461f05a462 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -353,6 +353,22 @@ int system_process_retry_counter(void)
*/
return corrupt_other_header(other);
}
+
+int system_rolling_reboot_suspected(void)
+{
+ if (GREG32(PMU, LONG_LIFE_SCRATCH0) > 50) {
+ /*
+ * The chip has restarted 50 times without the restart counter
+ * cleared. There must be something wrong going, the chip is
+ * likely in rolling reboot.
+ */
+ ccprintf("%s: Try powercycling to clear this condition.\n",
+ __func__);
+ return 1;
+ }
+
+ return 0;
+}
#endif
uint32_t system_get_board_properties(void)
diff --git a/common/tpm_registers.c b/common/tpm_registers.c
index 94b1636b0a..6811c1d758 100644
--- a/common/tpm_registers.c
+++ b/common/tpm_registers.c
@@ -571,6 +571,9 @@ static void call_extension_command(struct tpm_cmd_header *tpmh,
void tpm_task(void)
{
+ if (system_rolling_reboot_suspected())
+ return;
+
tpm_init();
sps_tpm_enable();
while (1) {
diff --git a/include/system.h b/include/system.h
index 1c04ee3404..7b08683ac0 100644
--- a/include/system.h
+++ b/include/system.h
@@ -489,4 +489,12 @@ uint32_t system_get_board_properties(void);
*/
uint32_t system_board_properties_callback(void);
+/**
+ * A function provided by some platforms to hint that something is going
+ * wrong.
+ *
+ * @return a boolean, set to True if rolling reboot condition is suspected.
+ */
+int system_rolling_reboot_suspected(void);
+
#endif /* __CROS_EC_SYSTEM_H */