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>
This commit is contained in:
Yu-Ping Wu
2022-05-17 09:33:18 +08:00
committed by Julius Werner
parent 20b58bc882
commit ae1e702e7b
6 changed files with 41 additions and 38 deletions

View File

@@ -3,6 +3,7 @@
#include <drivers/spi/tpm/tpm.h>
#include <security/tpm/tis.h>
#include <string.h>
#include <timer.h>
#include <types.h>
#define CR50_DID_VID 0x00281ae0L
@@ -234,3 +235,18 @@ success:
*version = cr50_firmware_version;
return CB_SUCCESS;
}
enum cb_err cr50_wait_tpm_ready(void)
{
struct stopwatch sw;
stopwatch_init_msecs_expire(&sw, CONFIG_GOOGLE_TPM_IRQ_TIMEOUT_MS);
while (!tis_plat_irq_status())
if (stopwatch_expired(&sw)) {
printk(BIOS_ERR, "Cr50 TPM IRQ timeout!\n");
return CB_ERR;
}
return CB_SUCCESS;
}

View File

@@ -21,4 +21,7 @@ enum cb_err cr50_get_firmware_version(struct cr50_firmware_version *version);
/* Set the BOARD_CFG register depending on Cr50 Kconfigs */
enum cb_err cr50_set_board_cfg(void);
/* Wait for IRQ to indicate the TPM is ready */
enum cb_err cr50_wait_tpm_ready(void);
#endif /* __DRIVERS_TPM_CR50_H__ */