diff options
author | Yu-Ping Wu <yupingso@chromium.org> | 2022-05-17 09:33:18 +0800 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2022-06-08 00:28:27 +0000 |
commit | ae1e702e7b10ea2695be706ae53013b5b0817cb3 (patch) | |
tree | c7b408f7ae21d0ab048c4a272c390263f1849109 /src/drivers/i2c/tpm/cr50.c | |
parent | 20b58bc882c40b80584cb0d035acbda8daf95ed0 (diff) |
drivers/tpm/cr50: Add TPM IRQ timeout Kconfig option
The current 10ms timeout for SPI TPM IRQ is not enough for platforms
using ti50 (such as corsola). Therefore, introduce a new Kconfig option
'GOOGLE_TPM_IRQ_TIMEOUT_MS'.
For platforms using cr50, we need to support legacy pre-ready-IRQ cr50
factory images during the initial boot, so the timeout remains 100ms for
I2C TPM and 10ms for SPI TPM. For all the other platforms using ti50,
the default timeout is increased to 750ms, as suggested by the ti50 team
(apronin@google.com).
BUG=b:232327704
TEST=emerge-corsola coreboot
BRANCH=none
Change-Id: I8dbb919e4a421a99a994913613a33738a49f5956
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64412
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/drivers/i2c/tpm/cr50.c')
-rw-r--r-- | src/drivers/i2c/tpm/cr50.c | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c index 0130b93169..696533969c 100644 --- a/src/drivers/i2c/tpm/cr50.c +++ b/src/drivers/i2c/tpm/cr50.c @@ -34,7 +34,6 @@ #define CR50_TIMEOUT_LONG_MS 2000 /* Long timeout while waiting for TPM */ #define CR50_TIMEOUT_SHORT_MS 2 /* Short timeout during transactions */ #define CR50_TIMEOUT_NOIRQ_MS 20 /* Timeout for TPM ready without IRQ */ -#define CR50_TIMEOUT_IRQ_MS 100 /* Timeout for TPM ready with IRQ */ #define CR50_DID_VID 0x00281ae0L #define TI50_DID_VID 0x504a6666L @@ -60,21 +59,6 @@ __weak int tis_plat_irq_status(void) return 1; } -/* Wait for interrupt to indicate the TPM is ready */ -static int cr50_i2c_wait_tpm_ready(void) -{ - struct stopwatch sw; - - stopwatch_init_msecs_expire(&sw, CR50_TIMEOUT_IRQ_MS); - - while (!tis_plat_irq_status()) - if (stopwatch_expired(&sw)) { - printk(BIOS_ERR, "Cr50 i2c TPM IRQ timeout!\n"); - return -1; - } - return 0; -} - /* * cr50_i2c_read() - read from TPM register * @@ -103,7 +87,7 @@ static int cr50_i2c_read(uint8_t addr, uint8_t *buffer, size_t len) } /* Wait for TPM to be ready with response data */ - if (cr50_i2c_wait_tpm_ready() < 0) + if (cr50_wait_tpm_ready() != CB_SUCCESS) return -1; /* Read response data from the TPM */ @@ -149,7 +133,7 @@ static int cr50_i2c_write(uint8_t addr, const uint8_t *buffer, size_t len) } /* Wait for TPM to be ready */ - return cr50_i2c_wait_tpm_ready(); + return cr50_wait_tpm_ready() == CB_SUCCESS ? 0 : -1; } /* |