diff options
author | Sergii Dmytruk <sergii.dmytruk@3mdeb.com> | 2022-11-01 00:48:43 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-04-16 13:52:14 +0000 |
commit | 3e5cefcc45d7ef7da9fd9b6ecc499a05f8134039 (patch) | |
tree | 676b2369f6559b7d0028aaafc0c9b84af798ade6 /src/drivers | |
parent | 7c75f8e5b2c3877487b424a1523c1e2a0caa4111 (diff) |
security/tpm: support compiling in multiple TPM drivers
Starting from here CONFIG_TPM1 and CONFIG_TPM2 are no longer mutually
exclusive.
Change-Id: I44c5a1d825afe414c2f5c2c90f4cfe41ba9bef5f
Ticket: https://ticket.coreboot.org/issues/433
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/69162
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/crb/tis.c | 2 | ||||
-rw-r--r-- | src/drivers/crb/tpm.h | 3 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tis.c | 2 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tis_atmel.c | 4 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tpm.h | 2 | ||||
-rw-r--r-- | src/drivers/pc80/tpm/tis.c | 10 | ||||
-rw-r--r-- | src/drivers/pc80/tpm/tpm.h | 10 | ||||
-rw-r--r-- | src/drivers/spi/tpm/tis.c | 2 | ||||
-rw-r--r-- | src/drivers/spi/tpm/tpm.h | 3 |
9 files changed, 30 insertions, 8 deletions
diff --git a/src/drivers/crb/tis.c b/src/drivers/crb/tis.c index 1b398f74f4..3893917118 100644 --- a/src/drivers/crb/tis.c +++ b/src/drivers/crb/tis.c @@ -46,7 +46,7 @@ static tpm_result_t crb_tpm_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, u return TPM_SUCCESS; } -tis_sendrecv_fn tis_probe(enum tpm_family *family) +tis_sendrecv_fn crb_tis_probe(enum tpm_family *family) { struct crb_tpm_info info; diff --git a/src/drivers/crb/tpm.h b/src/drivers/crb/tpm.h index fbe390167d..aaf63a4a35 100644 --- a/src/drivers/crb/tpm.h +++ b/src/drivers/crb/tpm.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause */ /* This is a driver for a Command Response Buffer Interface */ +#include <security/tpm/tis.h> #include <security/tpm/tss_errors.h> /* CRB driver */ @@ -65,3 +66,5 @@ void crb_tpm_get_info(struct crb_tpm_info *crb_tpm_info); size_t crb_tpm_process_command(const void *tpm2_command, size_t command_size, void *tpm2_response, size_t max_response); bool crb_tpm_is_active(void); + +tis_sendrecv_fn crb_tis_probe(enum tpm_family *family); diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c index fd09240494..1fba61a12f 100644 --- a/src/drivers/i2c/tpm/tis.c +++ b/src/drivers/i2c/tpm/tis.c @@ -118,7 +118,7 @@ static tpm_result_t i2c_tpm_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, return TPM_SUCCESS; } -tis_sendrecv_fn tis_probe(enum tpm_family *family) +tis_sendrecv_fn i2c_tis_probe(enum tpm_family *family) { if (tpm_vendor_probe(CONFIG_DRIVER_TPM_I2C_BUS, CONFIG_DRIVER_TPM_I2C_ADDR, family)) return NULL; diff --git a/src/drivers/i2c/tpm/tis_atmel.c b/src/drivers/i2c/tpm/tis_atmel.c index a0bbf33fc4..ad5e7f37b7 100644 --- a/src/drivers/i2c/tpm/tis_atmel.c +++ b/src/drivers/i2c/tpm/tis_atmel.c @@ -12,6 +12,8 @@ #include <timer.h> #include <types.h> +#include "tpm.h" + #define RECV_TIMEOUT (1 * 1000) /* 1 second */ #define XMIT_TIMEOUT (1 * 1000) /* 1 second */ #define SLEEP_DURATION 1000 /* microseconds */ @@ -107,7 +109,7 @@ static tpm_result_t i2c_tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, return TPM_SUCCESS; } -tis_sendrecv_fn tis_probe(enum tpm_family *family) +tis_sendrecv_fn i2c_tis_probe(enum tpm_family *family) { /* * Can't query version or really anything as the device doesn't support diff --git a/src/drivers/i2c/tpm/tpm.h b/src/drivers/i2c/tpm/tpm.h index 46935e2495..ba78a42290 100644 --- a/src/drivers/i2c/tpm/tpm.h +++ b/src/drivers/i2c/tpm/tpm.h @@ -56,4 +56,6 @@ tpm_result_t tpm_vendor_probe(unsigned int bus, uint32_t addr, enum tpm_family * tpm_result_t tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr); +tis_sendrecv_fn i2c_tis_probe(enum tpm_family *family); + #endif /* __DRIVERS_TPM_SLB9635_I2C_TPM_H__ */ diff --git a/src/drivers/pc80/tpm/tis.c b/src/drivers/pc80/tpm/tis.c index 568065c654..f922714381 100644 --- a/src/drivers/pc80/tpm/tis.c +++ b/src/drivers/pc80/tpm/tis.c @@ -24,7 +24,9 @@ #include <device/pnp.h> #include <drivers/tpm/tpm_ppi.h> #include <timer.h> + #include "chip.h" +#include "tpm.h" #define PREFIX "lpc_tpm: " @@ -374,7 +376,7 @@ static tpm_result_t tis_command_ready(u8 locality) * Returns TPM_SUCCESS on success (the device is found or was found during * an earlier invocation) or TPM_CB_FAIL if the device is not found. */ -static tpm_result_t pc80_tis_probe(enum tpm_family *family) +static tpm_result_t pc80_tpm_probe(enum tpm_family *family) { static enum tpm_family tpm_family; @@ -718,7 +720,7 @@ static tpm_result_t pc80_tpm_sendrecv(const uint8_t *sendbuf, size_t send_size, } /* - * tis_probe() + * pc80_tis_probe() * * Probe for the TPM device and set it up for use within locality 0. * @@ -726,9 +728,9 @@ static tpm_result_t pc80_tpm_sendrecv(const uint8_t *sendbuf, size_t send_size, * * Returns pointer to send-receive function on success or NULL on failure. */ -tis_sendrecv_fn tis_probe(enum tpm_family *family) +tis_sendrecv_fn pc80_tis_probe(enum tpm_family *family) { - if (pc80_tis_probe(family)) + if (pc80_tpm_probe(family)) return NULL; if (pc80_tis_open()) diff --git a/src/drivers/pc80/tpm/tpm.h b/src/drivers/pc80/tpm/tpm.h new file mode 100644 index 0000000000..db71e03900 --- /dev/null +++ b/src/drivers/pc80/tpm/tpm.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef DRIVERS_PC80_TPM_TPM_H +#define DRIVERS_PC80_TPM_TPM_H + +#include <security/tpm/tis.h> + +tis_sendrecv_fn pc80_tis_probe(enum tpm_family *family); + +#endif /* DRIVERS_PC80_TPM_TPM_H */ diff --git a/src/drivers/spi/tpm/tis.c b/src/drivers/spi/tpm/tis.c index 89ea985da8..b954a123f0 100644 --- a/src/drivers/spi/tpm/tis.c +++ b/src/drivers/spi/tpm/tis.c @@ -40,7 +40,7 @@ static tpm_result_t tpm_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, return TPM_SUCCESS; } -tis_sendrecv_fn tis_probe(enum tpm_family *family) +tis_sendrecv_fn spi_tis_probe(enum tpm_family *family) { struct spi_slave spi; struct tpm2_info info; diff --git a/src/drivers/spi/tpm/tpm.h b/src/drivers/spi/tpm/tpm.h index 0d238e8011..d6e0e74227 100644 --- a/src/drivers/spi/tpm/tpm.h +++ b/src/drivers/spi/tpm/tpm.h @@ -4,6 +4,7 @@ #define __COREBOOT_SRC_DRIVERS_SPI_TPM_TPM_H #include <drivers/tpm/cr50.h> +#include <security/tpm/tis.h> #include <security/tpm/tss_errors.h> #include <stddef.h> #include <spi-generic.h> @@ -44,4 +45,6 @@ size_t tpm2_process_command(const void *tpm2_command, size_t command_size, /* Get information about previously initialized TPM device. */ void tpm2_get_info(struct tpm2_info *info); +tis_sendrecv_fn spi_tis_probe(enum tpm_family *family); + #endif /* ! __COREBOOT_SRC_DRIVERS_SPI_TPM_TPM_H */ |