summaryrefslogtreecommitdiff
path: root/src/drivers/i2c/tpm/tis.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/i2c/tpm/tis.c')
-rw-r--r--src/drivers/i2c/tpm/tis.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c
index e9bf2cf706..2cf32f6217 100644
--- a/src/drivers/i2c/tpm/tis.c
+++ b/src/drivers/i2c/tpm/tis.c
@@ -19,32 +19,6 @@ 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)
{
@@ -107,8 +81,8 @@ out:
return rc;
}
-int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
- uint8_t *recvbuf, size_t *rbuf_len)
+static int i2c_tpm_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
+ uint8_t *recvbuf, size_t *rbuf_len)
{
ASSERT(sbuf_size >= 10);
@@ -144,3 +118,14 @@ int tis_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;
+}