summaryrefslogtreecommitdiff
path: root/board/cr50/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/cr50/board.c')
-rw-r--r--board/cr50/board.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c
index c967871c8e..1bb6ce46ec 100644
--- a/board/cr50/board.c
+++ b/board/cr50/board.c
@@ -450,6 +450,27 @@ int is_ec_rst_asserted(void)
return GREAD(RBOX, ASSERT_EC_RST);
}
+void nvmem_wipe_or_reboot(void)
+{
+ /*
+ * Blindly zapping the TPM space while the AP is awake and poking at it
+ * will bork the TPM task and the AP itself, so force the whole system
+ * off by holding the EC in reset.
+ */
+ assert_ec_rst();
+
+ /*
+ * If we can't clear the NVMEM or can't reset the TPM task, something
+ * is unexpectedly wrong. To be safe, let's reboot the Cr50 (which also
+ * reboots the EC and AP).
+ */
+ if (nvmem_setup(0) != EC_SUCCESS || tpm_reset() != 1)
+ system_reset(SYSTEM_RESET_HARD);
+
+ /* Wipe & reset is complete. Allow the EC and AP to reboot */
+ deassert_ec_rst();
+}
+
void nvmem_compute_sha(uint8_t *p_buf, int num_bytes,
uint8_t *p_sha, int sha_len)
{