Merge tag 'tpm-19112021' of https://source.denx.de/u-boot/custodians/u-boot-tpm
TPM1.2 and Atmel fixes
# gpg verification failed.
diff --git a/cmd/tpm-v1.c b/cmd/tpm-v1.c
index 3a7e35d..bf238a9 100644
--- a/cmd/tpm-v1.c
+++ b/cmd/tpm-v1.c
@@ -406,9 +406,9 @@
void *key;
struct udevice *dev;
- rc = get_tpm(&dev);
- if (rc)
- return rc;
+ err = get_tpm(&dev);
+ if (err)
+ return err;
if (argc < 5)
return CMD_RET_USAGE;
@@ -420,7 +420,7 @@
return CMD_RET_FAILURE;
parse_byte_string(argv[4], usage_auth, NULL);
- err = tpm_find_key_sha1(usage_auth, parent_hash, &parent_handle);
+ err = tpm1_find_key_sha1(dev, usage_auth, parent_hash, &parent_handle);
if (err) {
printf("Could not find matching parent key (err = %d)\n", err);
return CMD_RET_FAILURE;
@@ -428,7 +428,7 @@
printf("Found parent key %08x\n", parent_handle);
- err = tpm_load_key2_oiap(parent_handle, key, key_len, usage_auth,
+ err = tpm1_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth,
&key_handle);
if (!err) {
printf("Key handle is 0x%x\n", key_handle);
@@ -582,6 +582,7 @@
static int do_tpm_list(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
+ struct udevice *dev;
int type = 0;
u16 res_count;
u8 buf[288];
@@ -589,6 +590,10 @@
int err;
uint i;
+ err = get_tpm(&dev);
+ if (err)
+ return err;
+
if (argc != 2)
return CMD_RET_USAGE;
@@ -619,7 +624,7 @@
}
/* fetch list of already loaded resources in the TPM */
- err = tpm_get_capability(TPM_CAP_HANDLE, type, buf,
+ err = tpm_get_capability(dev, TPM_CAP_HANDLE, type, buf,
sizeof(buf));
if (err) {
printf("tpm_get_capability returned error %d.\n", err);
diff --git a/drivers/tpm/tpm_atmel_twi.c b/drivers/tpm/tpm_atmel_twi.c
index 2dcc2af..fa4fbec 100644
--- a/drivers/tpm/tpm_atmel_twi.c
+++ b/drivers/tpm/tpm_atmel_twi.c
@@ -52,7 +52,10 @@
*/
static int tpm_atmel_twi_get_desc(struct udevice *dev, char *buf, int size)
{
- return 0;
+ if (size < 50)
+ return -ENOSPC;
+
+ return snprintf(buf, size, "Atmel AT97SC3204T I2C 1.2 TPM (%s)", dev->name);
}
/*
@@ -81,22 +84,15 @@
print_buffer(0, (void *)sendbuf, 1, send_size, 0);
#endif
-#if !CONFIG_IS_ENABLED(DM_I2C)
- res = i2c_write(0x29, 0, 0, (uchar *)sendbuf, send_size);
-#else
res = dm_i2c_write(dev, 0, sendbuf, send_size);
-#endif
if (res) {
printf("i2c_write returned %d\n", res);
return -1;
}
start = get_timer(0);
-#if !CONFIG_IS_ENABLED(DM_I2C)
- while ((res = i2c_read(0x29, 0, 0, recvbuf, 10)))
-#else
+
while ((res = dm_i2c_read(dev, 0, recvbuf, 10)))
-#endif
{
/* TODO Use TIS_TIMEOUT from tpm_tis_infineon.h */
if (get_timer(start) > ATMEL_TPM_TIMEOUT_MS) {
@@ -116,16 +112,11 @@
return -1;
} else {
*recv_len = hdr_recv_len;
-#if !CONFIG_IS_ENABLED(DM_I2C)
- res = i2c_read(0x29, 0, 0, recvbuf, *recv_len);
-#else
res = dm_i2c_read(dev, 0, recvbuf, *recv_len);
-#endif
-
}
}
if (res) {
- printf("i2c_read returned %d (rlen=%d)\n", res, *recv_len);
+ printf("i2c_read returned %d (rlen=%zu)\n", res, *recv_len);
#ifdef DEBUG
print_buffer(0, recvbuf, 1, *recv_len, 0);
#endif
@@ -143,6 +134,7 @@
static int tpm_atmel_twi_probe(struct udevice *dev)
{
+ i2c_set_chip_offset_len(dev, 0);
return 0;
}
diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c
index 8dc1440..22a769c 100644
--- a/lib/tpm-v1.c
+++ b/lib/tpm-v1.c
@@ -840,7 +840,7 @@
unsigned int i;
/* fetch list of already loaded keys in the TPM */
- err = tpm_get_capability(dev, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
+ err = tpm1_get_capability(dev, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
sizeof(buf));
if (err)
return -1;
@@ -852,7 +852,7 @@
/* now search a(/ the) key which we can access with the given auth */
for (i = 0; i < key_count; ++i) {
buf_len = sizeof(buf);
- err = tpm_get_pub_key_oiap(key_handles[i], auth, buf, &buf_len);
+ err = tpm1_get_pub_key_oiap(dev, key_handles[i], auth, buf, &buf_len);
if (err && err != TPM_AUTHFAIL)
return -1;
if (err)