diff options
author | Jon Murphy <jpmurphy@google.com> | 2023-09-05 11:38:59 -0600 |
---|---|---|
committer | Raul Rangel <rrangel@chromium.org> | 2023-09-28 16:54:50 +0000 |
commit | db4e93ba1a927527f4a095aa8395c31c87d2438d (patch) | |
tree | 09adefa390fa34a2120ba57bc75af1470ee72508 | |
parent | d7b8dc9cf5978809912dcffefce2eda5937c9653 (diff) |
drivers/tpm: Add return codes to TPM driver
Add additional failure mode reporting to the TPM driver to provide
additional visibility into what failures are occurring.
BUG=b:296439237
TEST=Verify code paths on Skyrim, ensure behavior is unchanged.
BRANCH=None
Change-Id: I77a653201acf1bddc1ed1e2af701c8d3dd4f0606
Signed-off-by: Jon Murphy <jpmurphy@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/77491
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jan Samek <jan.samek@siemens.com>
-rw-r--r-- | src/drivers/i2c/tpm/cr50.c | 18 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tpm.c | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c index d207f2b20b..3351ca2700 100644 --- a/src/drivers/i2c/tpm/cr50.c +++ b/src/drivers/i2c/tpm/cr50.c @@ -61,7 +61,7 @@ static struct tpm_inf_dev tpm_dev; static tpm_result_t cr50_i2c_read(uint8_t addr, uint8_t *buffer, size_t len) { if (tpm_dev.addr == 0) - return TPM_CB_FAIL; + return TPM_CB_INVALID_ARG; /* Clear interrupt before starting transaction */ cr50_plat_irq_status(); @@ -69,17 +69,17 @@ static tpm_result_t cr50_i2c_read(uint8_t addr, uint8_t *buffer, size_t len) /* Send the register address byte to the TPM */ if (i2c_write_raw(tpm_dev.bus, tpm_dev.addr, &addr, 1)) { printk(BIOS_ERR, "%s: Address write failed\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_COMMUNICATION_ERROR; } /* Wait for TPM to be ready with response data */ if (cr50_wait_tpm_ready() != CB_SUCCESS) - return TPM_CB_FAIL; + return TPM_CB_TIMEOUT; /* Read response data from the TPM */ if (i2c_read_raw(tpm_dev.bus, tpm_dev.addr, buffer, len)) { printk(BIOS_ERR, "%s: Read response failed\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_COMMUNICATION_ERROR; } return TPM_SUCCESS; @@ -115,11 +115,11 @@ static tpm_result_t cr50_i2c_write(uint8_t addr, const uint8_t *buffer, size_t l /* Send write request buffer with address */ if (i2c_write_raw(tpm_dev.bus, tpm_dev.addr, tpm_dev.buf, len + 1)) { printk(BIOS_ERR, "%s: Error writing to TPM\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_COMMUNICATION_ERROR; } /* Wait for TPM to be ready */ - return cr50_wait_tpm_ready() == CB_SUCCESS ? TPM_SUCCESS : TPM_CB_FAIL; + return cr50_wait_tpm_ready() == CB_SUCCESS ? TPM_SUCCESS : TPM_CB_TIMEOUT; } /* @@ -276,7 +276,7 @@ static tpm_result_t cr50_i2c_wait_burststs(uint8_t mask, size_t *burst, int *sta printk(BIOS_ERR, "%s: Timeout reading burst and status with error %#x\n", __func__, rc); if (rc) return rc; - return TPM_CB_TIMEOUT; + return TPM_CB_COMMUNICATION_ERROR; } static int cr50_i2c_tis_recv(uint8_t *buf, size_t buf_len) @@ -464,7 +464,7 @@ static tpm_result_t cr50_i2c_probe(uint32_t *did_vid) printk(BIOS_ERR, "DID_VID 0x%08x not recognized\n", *did_vid); return TPM_CB_FAIL; } - return rc; + return TPM_CB_COMMUNICATION_ERROR; } tpm_result_t tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr) @@ -474,7 +474,7 @@ tpm_result_t tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t d if (dev_addr == 0) { printk(BIOS_ERR, "%s: missing device address\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_INVALID_ARG; } tpm_dev.bus = bus; diff --git a/src/drivers/i2c/tpm/tpm.c b/src/drivers/i2c/tpm/tpm.c index 4dbefb44f3..91c310b8f3 100644 --- a/src/drivers/i2c/tpm/tpm.c +++ b/src/drivers/i2c/tpm/tpm.c @@ -498,7 +498,7 @@ tpm_result_t tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t d if (dev_addr == 0) { printk(BIOS_ERR, "%s: missing device address\n", __func__); - return TPM_CB_FAIL; + return TPM_CB_INVALID_ARG; } tpm_dev.chip_type = UNKNOWN; |