summaryrefslogtreecommitdiff
path: root/board/cr50/ap_state.c
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@google.com>2019-01-28 18:24:55 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-06 06:51:00 -0800
commit4aa18870f9a9609749a5a250f94e5ae26e943874 (patch)
tree0531c19c10814beee4c89fb2e32c8d2029278539 /board/cr50/ap_state.c
parent70b2257b4c9d22847574a5128332787909934043 (diff)
downloadchrome-ec-4aa18870f9a9609749a5a250f94e5ae26e943874.tar.gz
cr50: add a closed loop reset function
Add a function that asserts EC_RST_L until TPM_RST_L gets asserted. Disable sleep using SLEEP_MASK_AP_RUN while waiting for the AP reset. Disable tpm communications using tpm_stop until the AP is reset. BUG=b:123544145 BRANCH=cr50 TEST=run 'ecrst cl' on mistral, scarlet, and soraka. Make sure the sleepmask is cleared correctly and the TPM works after the reset is complete. Change-Id: I5971b45b7a69fd24887a7c22ee7984972b7828ae Signed-off-by: Mary Ruthven <mruthven@google.com> Reviewed-on: https://chromium-review.googlesource.com/1444411 Commit-Ready: Mary Ruthven <mruthven@chromium.org> Tested-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'board/cr50/ap_state.c')
-rw-r--r--board/cr50/ap_state.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/board/cr50/ap_state.c b/board/cr50/ap_state.c
index 32064ae07c..7e7d1231d2 100644
--- a/board/cr50/ap_state.c
+++ b/board/cr50/ap_state.c
@@ -4,12 +4,11 @@
*
* AP state machine
*/
-#include "ccd_config.h"
-#include "common.h"
-#include "console.h"
#include "gpio.h"
#include "hooks.h"
+#include "registers.h"
#include "system.h"
+#include "tpm_registers.h"
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
@@ -101,6 +100,7 @@ void set_ap_on(void)
disable_deep_sleep();
}
+static uint8_t waiting_for_ap_reset;
/*
* If TPM_RST_L is asserted, the AP is in reset. Disable all AP functionality
* in 1 second if it remains asserted.
@@ -117,6 +117,34 @@ void tpm_rst_asserted(enum gpio_signal unused)
hook_call_deferred(&deferred_set_ap_off_data, SECOND);
set_state(DEVICE_STATE_DEBOUNCING);
+
+ if (waiting_for_ap_reset) {
+ waiting_for_ap_reset = 0;
+ deassert_ec_rst();
+ enable_sleep(SLEEP_MASK_AP_RUN);
+ }
+}
+
+void board_closed_loop_reset(void)
+{
+ /* Disable sleep while waiting for the reset */
+ disable_sleep(SLEEP_MASK_AP_RUN);
+
+ waiting_for_ap_reset = 1;
+
+ /* Disable AP communications with the TPM until cr50 sees the reset */
+ tpm_stop();
+
+ /* Use EC_RST_L to reset the system */
+ assert_ec_rst();
+
+ /*
+ * DETECT_TPM_RST_L_ASSERTED is edge triggered. If TPM_RST_L is already
+ * low, tpm_rst_asserted wont get called. Alert tpm_rst_asserted
+ * manually if the signal is already low.
+ */
+ if (!gpio_get_level(GPIO_DETECT_TPM_RST_L_ASSERTED))
+ tpm_rst_asserted(GPIO_TPM_RST_L);
}
/**