diff --git a/chip/g/system.c b/chip/g/system.c index f904f6fb77..d088da05a8 100644 --- a/chip/g/system.c +++ b/chip/g/system.c @@ -323,11 +323,11 @@ int system_process_retry_counter(void) GREG32(PMU, LONG_LIFE_SCRATCH0) = 0; GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0); + ccprintf("%s:retry counter %d\n", __func__, retry_counter); + if (retry_counter <= RW_BOOT_MAX_RETRY_COUNT) return EC_SUCCESS; - ccprintf("%s:retry counter %d\n", __func__, retry_counter); - if (system_get_image_copy() == SYSTEM_IMAGE_RW) { me = (struct SignedHeader *) get_program_memory_addr(SYSTEM_IMAGE_RW); diff --git a/common/tpm_registers.c b/common/tpm_registers.c index 2d63c61a92..9169416209 100644 --- a/common/tpm_registers.c +++ b/common/tpm_registers.c @@ -568,6 +568,12 @@ void tpm_task(void) CPRINTF("got %d bytes in response\n", response_size); if (response_size && (response_size <= sizeof(tpm_.regs.data_fifo))) { + /* + * TODO(vbendeb): revisit this when + * crosbug.com/p/55667 has been addressed. + */ + if (command_code == TPM2_PCR_Read) + system_process_retry_counter(); #ifdef CONFIG_EXTENSION_COMMAND if (command_code != CONFIG_EXTENSION_COMMAND) #endif diff --git a/include/system.h b/include/system.h index 39bdb95cd0..8d792123ff 100644 --- a/include/system.h +++ b/include/system.h @@ -458,4 +458,12 @@ uintptr_t system_get_fw_reset_vector(uintptr_t base); */ int system_is_reboot_warm(void); +/** + * On systems with protection from a failing RW update: read the retry counter + * and act on it. + * + * @return EC_SUCCESS if no flash write errors were encounterd. + */ +int system_process_retry_counter(void); + #endif /* __CROS_EC_SYSTEM_H */ diff --git a/include/tpm_registers.h b/include/tpm_registers.h index bb08725d43..c7e8dd27a9 100644 --- a/include/tpm_registers.h +++ b/include/tpm_registers.h @@ -40,4 +40,10 @@ struct tpm_cmd_header { uint16_t subcommand_code; /* Not a standard field. */ } __packed; +/* + * The only TPM2 command we care about on the driver level, see + * crosbug.com/p/55667 for detals. + */ +#define TPM2_PCR_Read 0x0000017e + #endif /* __CROS_EC_TPM_REGISTERS_H */