From 4ee03170e058313477b8f0bbfc81d093a6197d98 Mon Sep 17 00:00:00 2001 From: Sergii Dmytruk Date: Thu, 22 Dec 2022 19:35:25 +0200 Subject: Revert "security/tpm/: turn tis_{init,open} into tis_probe" This reverts commit d43154486d27323f64334203e9bc8baf08af6845. From CB:68991: This causes CraterLake boot up process to die. Investigation in progress. Change-Id: I4a6c11b0e638a891108fe230bdaea92d5fbca020 Signed-off-by: Sergii Dmytruk Reviewed-on: https://review.coreboot.org/c/coreboot/+/71205 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh Tested-by: siemens-bot Reviewed-by: Felix Held --- src/drivers/spi/tpm/tis.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/drivers/spi') diff --git a/src/drivers/spi/tpm/tis.c b/src/drivers/spi/tpm/tis.c index 310b1c09ea..b9b2a4a5cb 100644 --- a/src/drivers/spi/tpm/tis.c +++ b/src/drivers/spi/tpm/tis.c @@ -5,6 +5,8 @@ #include "tpm.h" +static unsigned int tpm_is_open; + static const struct { uint16_t vid; uint16_t did; @@ -27,20 +29,16 @@ static const char *tis_get_dev_name(struct tpm2_info *info) return "Unknown"; } -static int tpm_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, - uint8_t *recvbuf, size_t *rbuf_len) +int tis_open(void) { - int len = tpm2_process_command(sendbuf, sbuf_size, recvbuf, *rbuf_len); - - if (len == 0) + if (tpm_is_open) { + printk(BIOS_ERR, "%s() called twice.\n", __func__); return -1; - - *rbuf_len = len; - + } return 0; } -tis_sendrecv_fn tis_probe(void) +int tis_init(void) { struct spi_slave spi; struct tpm2_info info; @@ -48,12 +46,12 @@ tis_sendrecv_fn tis_probe(void) if (spi_setup_slave(CONFIG_DRIVER_TPM_SPI_BUS, CONFIG_DRIVER_TPM_SPI_CHIP, &spi)) { printk(BIOS_ERR, "Failed to setup TPM SPI slave\n"); - return NULL; + return -1; } if (tpm2_init(&spi)) { printk(BIOS_ERR, "Failed to initialize TPM SPI interface\n"); - return NULL; + return -1; } tpm2_get_info(&info); @@ -61,5 +59,18 @@ tis_sendrecv_fn tis_probe(void) printk(BIOS_INFO, "Initialized TPM device %s revision %d\n", tis_get_dev_name(&info), info.revision); - return &tpm_sendrecv; + return 0; +} + +int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, + uint8_t *recvbuf, size_t *rbuf_len) +{ + int len = tpm2_process_command(sendbuf, sbuf_size, recvbuf, *rbuf_len); + + if (len == 0) + return -1; + + *rbuf_len = len; + + return 0; } -- cgit v1.2.3