summaryrefslogtreecommitdiff
path: root/common/factory_mode.c
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2019-03-05 19:30:27 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-04-05 13:43:57 -0700
commit678bb4526ef19ef9458910d0231722b0de4c5ddf (patch)
treedccb5dc0d61a8a9737a7e18853966acdf99d1668 /common/factory_mode.c
parent45f07e203612b2551d1b32df394bed78ad3a2ff5 (diff)
downloadchrome-ec-678bb4526ef19ef9458910d0231722b0de4c5ddf.tar.gz
cr50: use board_wipe_tpm to clear the tpm
We were clearing the tpm in two different ways. There was one implementation in factory_mode.c and one in wp.c. This change merges the two, so there's only one board_wipe_tpm. While modifying the wipe tpm code from factory_mode.c I noticed the factory_enable_failed stuff is maybe a bit more complicated than necessary. I opened a bug for cleaning that up(b/129956462). It wont be addressed in this change. BUG=none BRANCH=none TEST=Run the processes that wipe the tpm open ccd. enable factory mode from vendor command. run rma open process Change-Id: Ia76df19f7d9e4f308f3f1a7175f130f1ef7249a2 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1535156 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'common/factory_mode.c')
-rw-r--r--common/factory_mode.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/common/factory_mode.c b/common/factory_mode.c
index 1555fc6833..f2ed77cae6 100644
--- a/common/factory_mode.c
+++ b/common/factory_mode.c
@@ -39,10 +39,8 @@ static void factory_enable_failed(void)
ccd_hook_active = 0;
CPRINTS("factory enable failed");
- if (reset_required_) {
+ if (reset_required_)
reset_required_ = 0;
- deassert_ec_rst();
- }
}
DECLARE_DEFERRED(factory_enable_failed);
@@ -65,34 +63,8 @@ static void factory_enable_deferred(void)
{
int rv;
- CPRINTS("%s: reset TPM\n", __func__);
- if (reset_required_)
- assert_ec_rst();
-
- if (tpm_reset_request(1, 1) != EC_SUCCESS) {
- CPRINTS("%s: TPM reset failed\n", __func__);
- /*
- * Attempt to reset TPM failed, let's reboot the device just
- * in case.
- */
- if (!reset_required_)
- assert_ec_rst();
- deassert_ec_rst();
+ if (board_wipe_tpm(reset_required_) != EC_SUCCESS)
return;
- }
-
- /*
- * TPM was wiped out successfully, let's prevent further
- * communications from the AP until next reboot.
- */
- if (!reset_required_)
- tpm_stop();
-
- /*
- * Need this to make sure that CCD state changes are saved in the
- * NVMEM before reboot.
- */
- tpm_reinstate_nvmem_commits();
CPRINTS("%s: TPM reset done, enabling factory mode", __func__);
@@ -103,9 +75,8 @@ static void factory_enable_deferred(void)
if (reset_required_) {
/*
- * Make sure we never end up with the EC held in reset, no
- * matter what prevents the proper factory reset flow from
- * succeeding.
+ * Cr50 will reset once factory mode is enabled. If it hasn't in
+ * TPM_RESET_TIME, declare factory enable failed.
*/
hook_call_deferred(&factory_enable_failed_data, TPM_RESET_TIME);
}