mainboard/google/sarien: skip tpm check when !verstage

The TPM driver isn't loaded in other stages but verstage so when we try
to communicate with the TPM it fails. We don't need to communicate with
it anyway since the TPM won't continue to tell us that recovery was
requested, only the first query responds with the recovery request.

BRANCH=none
BUG=b:129150074,b:123360379
TEST=1)boot arcada without recovery and notice that the "tpm transaction
failed" log lines are no longer present. 2) boot into recovery using the
ESC refresh power key combination and verify that the recovery reason
was "recovery button pressed"

Change-Id: I13284483d069ed50b0d16b36d0120d006485f7f4
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/32030
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
This commit is contained in:
Jett Rink 2019-03-22 14:41:42 -06:00 committed by Patrick Georgi
parent 2d22d335dc
commit 837f655291
1 changed files with 19 additions and 14 deletions

View File

@ -30,7 +30,6 @@ enum rec_mode_state {
REC_MODE_NOT_REQUESTED,
REC_MODE_REQUESTED,
};
static enum rec_mode_state saved_rec_mode;
void fill_lb_gpios(struct lb_gpios *gpios)
{
@ -84,25 +83,31 @@ int get_write_protect_state(void)
int get_recovery_mode_switch(void)
{
enum rec_mode_state state = saved_rec_mode;
uint8_t recovery_button_state = 0;
static enum rec_mode_state saved_rec_mode = REC_MODE_UNINITIALIZED;
enum rec_mode_state state = REC_MODE_NOT_REQUESTED;
uint8_t cr50_state = 0;
/* Check the global variable first. */
if (state == REC_MODE_NOT_REQUESTED)
return 0;
else if (state == REC_MODE_REQUESTED)
return 1;
/* Check cached state, since TPM will only tell us the first time */
if (saved_rec_mode != REC_MODE_UNINITIALIZED)
return saved_rec_mode == REC_MODE_REQUESTED;
state = REC_MODE_NOT_REQUESTED;
/*
* Read one-time recovery request from cr50 in verstage only since
* the TPM driver won't be set up in time for other stages like romstage
* and the value from the TPM would be wrong anyway since the verstage
* read would have cleared the value on the TPM.
*
* The TPM recovery request is passed between stages through the
* vboot_get_shared_data or cbmem depending on stage.
*/
if (ENV_VERSTAGE &&
tlcl_cr50_get_recovery_button(&cr50_state) == TPM_SUCCESS &&
cr50_state)
state = REC_MODE_REQUESTED;
/* Read state from the GPIO controlled by servo. */
if (cros_get_gpio_value(CROS_GPIO_REC))
state = REC_MODE_REQUESTED;
/* Read one-time recovery request from cr50. */
else if (tlcl_cr50_get_recovery_button(&recovery_button_state)
== TPM_SUCCESS)
state = recovery_button_state ?
REC_MODE_REQUESTED : REC_MODE_NOT_REQUESTED;
/* Store the state in case this is called again in verstage. */
saved_rec_mode = state;