diff options
author | Sergii Dmytruk <sergii.dmytruk@3mdeb.com> | 2022-12-22 19:35:25 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-12-23 21:31:11 +0000 |
commit | 4ee03170e058313477b8f0bbfc81d093a6197d98 (patch) | |
tree | c7a86dddbaa044167ac0ba7916cf4ebf76889118 /src/drivers/i2c/tpm | |
parent | 025d20eaebb4680396a7e9e558295d28f7ad0988 (diff) |
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 <sergii.dmytruk@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/71205
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
Tested-by: siemens-bot
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Diffstat (limited to 'src/drivers/i2c/tpm')
-rw-r--r-- | src/drivers/i2c/tpm/cr50.c | 1 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tis.c | 41 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tis_atmel.c | 19 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tpm.c | 2 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tpm.h | 1 |
5 files changed, 44 insertions, 20 deletions
diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c index 593f201e68..d9088233c2 100644 --- a/src/drivers/i2c/tpm/cr50.c +++ b/src/drivers/i2c/tpm/cr50.c @@ -484,6 +484,7 @@ int tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr) cr50_set_board_cfg(); } + chip->is_open = 1; return 0; } diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c index 2cf32f6217..e9bf2cf706 100644 --- a/src/drivers/i2c/tpm/tis.c +++ b/src/drivers/i2c/tpm/tis.c @@ -19,6 +19,32 @@ static struct tpm_chip chip; #define TPM_CMD_COUNT_BYTE 2 #define TPM_CMD_ORDINAL_BYTE 6 +int tis_open(void) +{ + int rc; + + if (chip.is_open) { + printk(BIOS_DEBUG, "%s() called twice.\n", __func__); + return -1; + } + + rc = tpm_vendor_init(&chip, CONFIG_DRIVER_TPM_I2C_BUS, + CONFIG_DRIVER_TPM_I2C_ADDR); + if (rc < 0) + chip.is_open = 0; + + if (rc) + return -1; + + return 0; +} + +int tis_init(void) +{ + return tpm_vendor_probe(CONFIG_DRIVER_TPM_I2C_BUS, + CONFIG_DRIVER_TPM_I2C_ADDR); +} + static ssize_t tpm_transmit(const uint8_t *sbuf, size_t sbufsiz, void *rbuf, size_t rbufsiz) { @@ -81,8 +107,8 @@ out: return rc; } -static int i2c_tpm_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, - uint8_t *recvbuf, size_t *rbuf_len) +int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, + uint8_t *recvbuf, size_t *rbuf_len) { ASSERT(sbuf_size >= 10); @@ -118,14 +144,3 @@ static int i2c_tpm_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, return 0; } - -tis_sendrecv_fn tis_probe(void) -{ - if (tpm_vendor_probe(CONFIG_DRIVER_TPM_I2C_BUS, CONFIG_DRIVER_TPM_I2C_ADDR)) - return NULL; - - if (tpm_vendor_init(&chip, CONFIG_DRIVER_TPM_I2C_BUS, CONFIG_DRIVER_TPM_I2C_ADDR)) - return NULL; - - return &i2c_tpm_sendrecv; -} diff --git a/src/drivers/i2c/tpm/tis_atmel.c b/src/drivers/i2c/tpm/tis_atmel.c index 376586bdfb..669ac68f6c 100644 --- a/src/drivers/i2c/tpm/tis_atmel.c +++ b/src/drivers/i2c/tpm/tis_atmel.c @@ -22,8 +22,18 @@ struct tpm_output_header { uint32_t return_code; } __packed; -static int i2c_tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, - uint8_t *recvbuf, size_t *rbuf_len) +int tis_open(void) +{ + return 0; +} + +int tis_init(void) +{ + return 0; +} + +int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, + uint8_t *recvbuf, size_t *rbuf_len) { size_t hdr_bytes; struct tpm_output_header *header; @@ -102,8 +112,3 @@ static int i2c_tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, /* Successful transfer */ return 0; } - -tis_sendrecv_fn tis_probe(void) -{ - return &i2c_tis_sendrecv; -} diff --git a/src/drivers/i2c/tpm/tpm.c b/src/drivers/i2c/tpm/tpm.c index 7d335e9837..68b7042a64 100644 --- a/src/drivers/i2c/tpm/tpm.c +++ b/src/drivers/i2c/tpm/tpm.c @@ -507,6 +507,8 @@ int tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr) tpm_dev.sleep_short = SLEEP_DURATION; tpm_dev.sleep_long = SLEEP_DURATION_LONG; + chip->is_open = 1; + chip->req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID; chip->req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID; chip->req_canceled = TPM_STS_COMMAND_READY; diff --git a/src/drivers/i2c/tpm/tpm.h b/src/drivers/i2c/tpm/tpm.h index e4ca89397c..d4176cc511 100644 --- a/src/drivers/i2c/tpm/tpm.h +++ b/src/drivers/i2c/tpm/tpm.h @@ -38,6 +38,7 @@ enum tpm_timeout { #define TPM_DID_VID(l) (0x0006 | ((l) << 4)) struct tpm_chip { + int is_open; uint8_t req_complete_mask; uint8_t req_complete_val; uint8_t req_canceled; |