1 /* SPDX-License-Identifier: BSD-3-Clause */
3 #include <console/console.h>
4 #include <security/tpm/tis.h>
8 static unsigned int tpm_is_open
;
13 const char *device_name
;
15 { 0x15d1, 0x001b, "SLB9670" },
16 { 0x1ae0, 0x0028, "CR50" },
17 { 0x104a, 0x0000, "ST33HTPH2E32" },
20 static const char *tis_get_dev_name(struct tpm2_info
*info
)
24 for (i
= 0; i
< ARRAY_SIZE(dev_map
); i
++)
25 if ((dev_map
[i
].vid
== info
->vendor_id
) &&
26 (dev_map
[i
].did
== info
->device_id
))
27 return dev_map
[i
].device_name
;
34 printk(BIOS_ERR
, "%s() called twice.\n", __func__
);
44 * Do we need to do something here, like waiting for a
45 * transaction to stop?
56 struct tpm2_info info
;
58 if (spi_setup_slave(CONFIG_DRIVER_TPM_SPI_BUS
,
59 CONFIG_DRIVER_TPM_SPI_CHIP
, &spi
)) {
60 printk(BIOS_ERR
, "Failed to setup TPM SPI slave\n");
64 if (tpm2_init(&spi
)) {
65 printk(BIOS_ERR
, "Failed to initialize TPM SPI interface\n");
71 printk(BIOS_INFO
, "Initialized TPM device %s revision %d\n",
72 tis_get_dev_name(&info
), info
.revision
);
77 int tis_sendrecv(const uint8_t *sendbuf
, size_t sbuf_size
,
78 uint8_t *recvbuf
, size_t *rbuf_len
)
80 int len
= tpm2_process_command(sendbuf
, sbuf_size
, recvbuf
, *rbuf_len
);