EricR Lai has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59768 )
Change subject: drivers/i2c/tpm: Add override function for TPM I2C bus ......................................................................
drivers/i2c/tpm: Add override function for TPM I2C bus
Provide a way to let boards can determine which TPM bus to use at runtime.
Signed-off-by: Eric Lai ericr_lai@compal.corp-partner.google.com Change-Id: I658468ed3880de0a6b947c212fa8737956928c57 --- M src/drivers/i2c/tpm/Kconfig M src/drivers/i2c/tpm/tis.c M src/drivers/i2c/tpm/tis_atmel.c M src/drivers/i2c/tpm/tpm.h M src/security/tpm/tis.h 5 files changed, 18 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/68/59768/1
diff --git a/src/drivers/i2c/tpm/Kconfig b/src/drivers/i2c/tpm/Kconfig index df622f0..ea76c06 100644 --- a/src/drivers/i2c/tpm/Kconfig +++ b/src/drivers/i2c/tpm/Kconfig @@ -34,6 +34,9 @@ hex "I2C TPM chip bus" default 0x9 # FIXME, workaround for Kconfig BS depends on I2C_TPM + help + get_tpm_i2c_bus() is now the interface, in case a board uses some information + at runtime to determine which TPM bus to use.
config DRIVER_TPM_I2C_ADDR hex "I2C TPM chip address" diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c index 80de2df..fdbb1de 100644 --- a/src/drivers/i2c/tpm/tis.c +++ b/src/drivers/i2c/tpm/tis.c @@ -28,7 +28,7 @@ return -1; }
- rc = tpm_vendor_init(&chip, CONFIG_DRIVER_TPM_I2C_BUS, + rc = tpm_vendor_init(&chip, get_tpm_i2c_bus(), CONFIG_DRIVER_TPM_I2C_ADDR); if (rc < 0) chip.is_open = 0; @@ -51,7 +51,7 @@
int tis_init(void) { - return tpm_vendor_probe(CONFIG_DRIVER_TPM_I2C_BUS, + return tpm_vendor_probe(get_tpm_i2c_bus(), CONFIG_DRIVER_TPM_I2C_ADDR); }
diff --git a/src/drivers/i2c/tpm/tis_atmel.c b/src/drivers/i2c/tpm/tis_atmel.c index 3a87dec..612a0dc2 100644 --- a/src/drivers/i2c/tpm/tis_atmel.c +++ b/src/drivers/i2c/tpm/tis_atmel.c @@ -60,7 +60,7 @@ /* Send the command to the TPM */ stopwatch_init_msecs_expire(&sw, XMIT_TIMEOUT); while (1) { - status = i2c_write_raw(CONFIG_DRIVER_TPM_I2C_BUS, + status = i2c_write_raw(get_tpm_i2c_bus(), CONFIG_DRIVER_TPM_I2C_ADDR, (uint8_t *)sendbuf, sbuf_size); if ((status < 0) && (!stopwatch_expired(&sw))) @@ -77,7 +77,7 @@ header = (struct tpm_output_header *)recvbuf; stopwatch_init_msecs_expire(&sw, RECV_TIMEOUT); do { - status = i2c_read_raw(CONFIG_DRIVER_TPM_I2C_BUS, + status = i2c_read_raw(get_tpm_i2c_bus(), CONFIG_DRIVER_TPM_I2C_ADDR, recvbuf, hdr_bytes); if (status > 0) break; @@ -97,7 +97,7 @@ hexdump(recvbuf, hdr_bytes);
/* Read the full TPM response */ - status = i2c_read_raw(CONFIG_DRIVER_TPM_I2C_BUS, + status = i2c_read_raw(get_tpm_i2c_bus(), CONFIG_DRIVER_TPM_I2C_ADDR, recvbuf, recv_bytes); if (status < 0) return status; diff --git a/src/drivers/i2c/tpm/tpm.h b/src/drivers/i2c/tpm/tpm.h index eb4fef1..91f1258 100644 --- a/src/drivers/i2c/tpm/tpm.h +++ b/src/drivers/i2c/tpm/tpm.h @@ -63,4 +63,9 @@
void tpm_vendor_cleanup(struct tpm_chip *chip);
+int __weak get_tpm_i2c_bus(void) +{ + return CONFIG_DRIVER_TPM_I2C_BUS; +} + #endif /* __DRIVERS_TPM_SLB9635_I2C_TPM_H__ */ diff --git a/src/security/tpm/tis.h b/src/security/tpm/tis.h index 5b2c001..0c712ef 100644 --- a/src/security/tpm/tis.h +++ b/src/security/tpm/tis.h @@ -84,4 +84,9 @@ */ int tis_plat_irq_status(void);
+/* + * Provide override by the variants + */ +int get_tpm_i2c_bus(void); + #endif /* TIS_H_ */