summaryrefslogtreecommitdiff
path: root/drivers/tpm
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tpm')
-rw-r--r--drivers/tpm/Kconfig15
-rw-r--r--drivers/tpm/Makefile4
-rw-r--r--drivers/tpm/tpm_atmel_twi.c68
-rw-r--r--drivers/tpm/tpm_tis_infineon.c (renamed from drivers/tpm/tpm_tis_i2c.c)5
-rw-r--r--drivers/tpm/tpm_tis_infineon.h (renamed from drivers/tpm/tpm_tis_i2c.h)0
-rw-r--r--drivers/tpm/tpm_tis_lpc.c1
6 files changed, 57 insertions, 36 deletions
diff --git a/drivers/tpm/Kconfig b/drivers/tpm/Kconfig
index 6bc8fdd..31b35f7 100644
--- a/drivers/tpm/Kconfig
+++ b/drivers/tpm/Kconfig
@@ -4,15 +4,6 @@
menu "TPM support"
-config DM_TPM
- bool "Enable driver model for Trusted Platform Module drivers"
- depends on DM && TPM
- help
- Enable driver model for TPMs. The TIS interface (tis_open(),
- tis_sendrecv(), etc.) is then implemented by the TPM uclass. Note
- that even with driver model only a single TPM is currently
- supported, since the tpm library assumes this.
-
config TPM_TIS_SANDBOX
bool "Enable sandbox TPM driver"
depends on SANDBOX
@@ -24,14 +15,14 @@ config TPM_TIS_SANDBOX
config TPM_ATMEL_TWI
bool "Enable Atmel TWI TPM device driver"
- depends on TPM
+ depends on TPM && DM_I2C
help
This driver supports an Atmel TPM device connected on the I2C bus.
The usual tpm operations and the 'tpm' command can be used to talk
to the device using the standard TPM Interface Specification (TIS)
protocol
-config TPM_TIS_I2C
+config TPM_TIS_INFINEON
bool "Enable support for Infineon SLB9635/45 TPMs on I2C"
depends on TPM && DM_I2C
help
@@ -42,7 +33,7 @@ config TPM_TIS_I2C
config TPM_TIS_I2C_BURST_LIMITATION
bool "Enable I2C burst length limitation"
- depends on TPM_TIS_I2C
+ depends on TPM_TIS_INFINEON
help
Some broken TPMs have a limitation on the number of bytes they can
receive in one message. Enable this option to allow you to set this
diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile
index 0d328f8..1d49e95 100644
--- a/drivers/tpm/Makefile
+++ b/drivers/tpm/Makefile
@@ -3,9 +3,9 @@
# SPDX-License-Identifier: GPL-2.0+
#
-obj-$(CONFIG_DM_TPM) += tpm-uclass.o
+obj-$(CONFIG_TPM) += tpm-uclass.o
obj-$(CONFIG_TPM_ATMEL_TWI) += tpm_atmel_twi.o
-obj-$(CONFIG_TPM_TIS_I2C) += tpm_tis_i2c.o
+obj-$(CONFIG_TPM_TIS_INFINEON) += tpm_tis_infineon.o
obj-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o
obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o
diff --git a/drivers/tpm/tpm_atmel_twi.c b/drivers/tpm/tpm_atmel_twi.c
index 205d7a5..2aa9381 100644
--- a/drivers/tpm/tpm_atmel_twi.c
+++ b/drivers/tpm/tpm_atmel_twi.c
@@ -7,51 +7,56 @@
*/
#include <common.h>
+#include <dm.h>
#include <tpm.h>
#include <i2c.h>
#include <asm/unaligned.h>
+#include "tpm_internal.h"
+
#define ATMEL_TPM_TIMEOUT_MS 5000 /* sufficient for anything but
generating/exporting keys */
/*
- * tis_init()
- *
- * Initialize the TPM device. Returns 0 on success or -1 on
- * failure (in case device probing did not succeed).
- */
-int tis_init(void)
-{
- return 0;
-}
-
-/*
- * tis_open()
+ * tpm_atmel_twi_open()
*
* Requests access to locality 0 for the caller. After all commands have been
* completed the caller is supposed to call tis_close().
*
* Returns 0 on success, -1 on failure.
*/
-int tis_open(void)
+static int tpm_atmel_twi_open(struct udevice *dev)
{
return 0;
}
/*
- * tis_close()
+ * tpm_atmel_twi_close()
*
* terminate the currect session with the TPM by releasing the locked
* locality. Returns 0 on success of -1 on failure (in case lock
* removal did not succeed).
*/
-int tis_close(void)
+static int tpm_atmel_twi_close(struct udevice *dev)
+{
+ return 0;
+}
+
+/*
+ * tpm_atmel_twi_get_desc()
+ *
+ * @dev: Device to check
+ * @buf: Buffer to put the string
+ * @size: Maximum size of buffer
+ * @return length of string, or -ENOSPC it no space
+ */
+static int tpm_atmel_twi_get_desc(struct udevice *dev, char *buf, int size)
{
return 0;
}
/*
- * tis_sendrecv()
+ * tpm_atmel_twi_xfer()
*
* Send the requested data to the TPM and then try to get its response
*
@@ -63,8 +68,9 @@ int tis_close(void)
* Returns 0 on success (and places the number of response bytes at recv_len)
* or -1 on failure.
*/
-int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf,
- size_t *recv_len)
+static int tpm_atmel_twi_xfer(struct udevice *dev,
+ const uint8_t *sendbuf, size_t send_size,
+ uint8_t *recvbuf, size_t *recv_len)
{
int res;
unsigned long start;
@@ -83,6 +89,7 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf,
start = get_timer(0);
while ((res = i2c_read(0x29, 0, 0, recvbuf, 10))) {
+ /* TODO Use TIS_TIMEOUT from tpm_tis_infineon.h */
if (get_timer(start) > ATMEL_TPM_TIMEOUT_MS) {
puts("tpm timed out\n");
return -1;
@@ -110,3 +117,28 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf,
return res;
}
+
+static int tpm_atmel_twi_probe(struct udevice *dev)
+{
+ return 0;
+}
+
+static const struct udevice_id tpm_atmel_twi_ids[] = {
+ { .compatible = "atmel,at97sc3204t"},
+ { }
+};
+
+static const struct tpm_ops tpm_atmel_twi_ops = {
+ .open = tpm_atmel_twi_open,
+ .close = tpm_atmel_twi_close,
+ .xfer = tpm_atmel_twi_xfer,
+ .get_desc = tpm_atmel_twi_get_desc,
+};
+
+U_BOOT_DRIVER(tpm_atmel_twi) = {
+ .name = "tpm_atmel_twi",
+ .id = UCLASS_TPM,
+ .of_match = tpm_atmel_twi_ids,
+ .ops = &tpm_atmel_twi_ops,
+ .probe = tpm_atmel_twi_probe,
+};
diff --git a/drivers/tpm/tpm_tis_i2c.c b/drivers/tpm/tpm_tis_infineon.c
index 9afe46c..f57c328 100644
--- a/drivers/tpm/tpm_tis_i2c.c
+++ b/drivers/tpm/tpm_tis_infineon.c
@@ -24,14 +24,13 @@
#include <dm.h>
#include <fdtdec.h>
#include <i2c.h>
-#include <tis.h>
#include <tpm.h>
#include <asm-generic/errno.h>
#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/unaligned/be_byteshift.h>
-#include "tpm_tis_i2c.h"
+#include "tpm_tis_infineon.h"
#include "tpm_internal.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -614,7 +613,7 @@ static const struct udevice_id tpm_tis_i2c_ids[] = {
};
U_BOOT_DRIVER(tpm_tis_i2c) = {
- .name = "tpm_tis_i2c",
+ .name = "tpm_tis_infineon",
.id = UCLASS_TPM,
.of_match = tpm_tis_i2c_ids,
.ops = &tpm_tis_i2c_ops,
diff --git a/drivers/tpm/tpm_tis_i2c.h b/drivers/tpm/tpm_tis_infineon.h
index 3b510d1..3b510d1 100644
--- a/drivers/tpm/tpm_tis_i2c.h
+++ b/drivers/tpm/tpm_tis_infineon.h
diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c
index b41c3ce..257d035 100644
--- a/drivers/tpm/tpm_tis_lpc.c
+++ b/drivers/tpm/tpm_tis_lpc.c
@@ -16,7 +16,6 @@
#include <common.h>
#include <dm.h>
#include <mapmem.h>
-#include <tis.h>
#include <tpm.h>
#include <asm/io.h>