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, 28 insertions, 13 deletions
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;
-}