summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2016-07-06 17:15:38 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-07 14:38:18 -0700
commit46a9a118429f0a785c7ad29ade950c1e3c867440 (patch)
treec6429d2c112212ce7adeaf65a26f573a6332d787 /common
parent3af46154582c73a3de992a123c65af0b952ed664 (diff)
downloadchrome-ec-46a9a118429f0a785c7ad29ade950c1e3c867440.tar.gz
HACK: cr50: make sure manufacturing sequence is invoked only once
While the proper manufacturing initialization is in the works, we need to be able to initialized the device, but do not want to run manufacturing process on every reboot. Let's store the state in the lowest location of the NVRAM, this patch will be reverted when the proper initialization procedure is in place. BRANCH=none BUG=chrome-os-partner:50115 TEST=used the device in Kevin. Observed that factory initialization sequence was invoked only on the first boot, the following boots had no problems reading rollback counters. Change-Id: I812cbad4d91db47de76ecfa5a14c56ae9c0efdab Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/358680 Reviewed-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/tpm_registers.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/common/tpm_registers.c b/common/tpm_registers.c
index 24c56ca475..bb07a32330 100644
--- a/common/tpm_registers.c
+++ b/common/tpm_registers.c
@@ -12,6 +12,7 @@
#include "byteorder.h"
#include "console.h"
#include "extension.h"
+#include "nvmem.h"
#include "printf.h"
#include "signed_header.h"
#include "system.h"
@@ -448,6 +449,9 @@ void tpm_register_get(uint32_t regaddr, uint8_t *dest, uint32_t data_size)
static void tpm_init(void)
{
+ uint32_t saved_value;
+ const uint32_t manufacturing_done = 0x12344321;
+
set_tpm_state(tpm_state_idle);
tpm_.regs.access = tpm_reg_valid_sts;
tpm_.regs.sts = (tpm_family_tpm2 << tpm_family_shift) |
@@ -455,9 +459,24 @@ static void tpm_init(void)
/* TPM2 library functions. */
_plat__Signal_PowerOn();
- /* TODO(ngm): CRBUG/50115, initialize state expected by TPM2
- * compliance tests. */
- TPM_Manufacture(1);
+
+
+ /*
+ * TODO(ngm): CRBUG/50115, initialize state expected by TPM2
+ * compliance tests.
+ *
+ * Until it is done properly, use location at offset 0 in the generic
+ * section of NVRAM to store the manufacturing status. Otherwise the
+ * NV RAM is wiped out on every reboot.
+ */
+ nvmem_read(0, sizeof(saved_value), &saved_value, NVMEM_CR50);
+ if (saved_value != manufacturing_done) {
+ TPM_Manufacture(1);
+ saved_value = manufacturing_done;
+ nvmem_write(0, sizeof(saved_value), &saved_value, NVMEM_CR50);
+ nvmem_commit();
+ }
+
_TPM_Init();
_plat__SetNvAvail();
}