From c6b041a12e56f32be37b809357225e762b070117 Mon Sep 17 00:00:00 2001 From: "Jes B. Klinke" Date: Tue, 19 Apr 2022 14:00:33 -0700 Subject: tpm: Refactor TPM Kconfig dimensions Break TPM related Kconfig into the following dimensions: TPM transport support: config CRB_TPM config I2C_TPM config SPI_TPM config MEMORY_MAPPED_TPM (new) TPM brand, not defining any of these is valid, and result in "generic" support: config TPM_ATMEL (new) config TPM_GOOGLE (new) config TPM_GOOGLE_CR50 (new, implies TPM_GOOGLE) config TPM_GOOGLE_TI50 (new to be used later, implies TPM_GOOGLE) What protocol the TPM chip supports: config MAINBOARD_HAS_TPM1 config MAINBOARD_HAS_TPM2 What the user chooses to compile (restricted by the above): config NO_TPM config TPM1 config TPM2 The following Kconfigs will be replaced as indicated: config TPM_CR50 -> TPM_GOOGLE config MAINBOARD_HAS_CRB_TPM -> CRB_TPM config MAINBOARD_HAS_I2C_TPM_ATMEL -> I2C_TPM && TPM_ATMEL config MAINBOARD_HAS_I2C_TPM_CR50 -> I2C_TPM && TPM_GOOGLE config MAINBOARD_HAS_I2C_TPM_GENERIC -> I2C_TPM && !TPM_GOOGLE && !TPM_ATMEL config MAINBOARD_HAS_LPC_TPM -> MEMORY_MAPPED_TPM config MAINBOARD_HAS_SPI_TPM -> SPI_TPM && !TPM_GOOGLE && !TPM_ATMEL config MAINBOARD_HAS_SPI_TPM_CR50 -> SPI_TPM && TPM_GOOGLE Signed-off-by: Jes B. Klinke Change-Id: I4656b2b90363b8dfd008dc281ad591862fe2cc9e Reviewed-on: https://review.coreboot.org/c/coreboot/+/63424 Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu Reviewed-by: Tim Wawrzynczak Reviewed-by: Julius Werner --- src/drivers/crb/Kconfig | 10 ++-------- src/drivers/crb/Makefile.inc | 8 +++----- src/drivers/i2c/tpm/Kconfig | 29 +++++++---------------------- src/drivers/i2c/tpm/Makefile.inc | 30 ++++++++++-------------------- src/drivers/pc80/tpm/Kconfig | 6 +++--- src/drivers/pc80/tpm/Makefile.inc | 8 +++----- src/drivers/spi/tpm/Kconfig | 14 -------------- src/drivers/spi/tpm/Makefile.inc | 8 +++----- src/drivers/spi/tpm/tpm.c | 6 +++--- src/drivers/tpm/Makefile.inc | 10 +++++----- 10 files changed, 39 insertions(+), 90 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/crb/Kconfig b/src/drivers/crb/Kconfig index bfd8be06d6..b65176ea89 100644 --- a/src/drivers/crb/Kconfig +++ b/src/drivers/crb/Kconfig @@ -1,17 +1,11 @@ config CRB_TPM bool + default n help - CRB TPM driver is enabled! + Mainboard has Command Response Buffer support config CRB_TPM_BASE_ADDRESS hex default 0xfed40000 help Base Address of the CRB TPM Command Structure - -config MAINBOARD_HAS_CRB_TPM - bool - default n - select CRB_TPM - help - Mainboard has Command Response Buffer support diff --git a/src/drivers/crb/Makefile.inc b/src/drivers/crb/Makefile.inc index 3f12b36923..5124514cca 100644 --- a/src/drivers/crb/Makefile.inc +++ b/src/drivers/crb/Makefile.inc @@ -1,5 +1,3 @@ -bootblock-$(CONFIG_CRB_TPM) += tis.c tpm.c -verstage-$(CONFIG_CRB_TPM) += tis.c tpm.c -romstage-$(CONFIG_CRB_TPM) += tis.c tpm.c -ramstage-$(CONFIG_CRB_TPM) += tis.c tpm.c -postcar-$(CONFIG_CRB_TPM) += tis.c tpm.c +ifeq ($(CONFIG_CRB_TPM),y) +all-y += tis.c tpm.c +endif diff --git a/src/drivers/i2c/tpm/Kconfig b/src/drivers/i2c/tpm/Kconfig index 0d5f06bbdd..8efcbaf991 100644 --- a/src/drivers/i2c/tpm/Kconfig +++ b/src/drivers/i2c/tpm/Kconfig @@ -3,27 +3,6 @@ config I2C_TPM help I2C TPM driver is enabled! -config MAINBOARD_HAS_I2C_TPM_ATMEL - bool - default n - select I2C_TPM - help - Board has an Atmel I2C TPM support - -config MAINBOARD_HAS_I2C_TPM_CR50 - bool - default n - select I2C_TPM - help - Board has a Cr50 I2C TPM support - -config MAINBOARD_HAS_I2C_TPM_GENERIC - bool - default n - select I2C_TPM - help - Board has a generic I2C TPM support - config MAINBOARD_NEEDS_I2C_TI50_WORKAROUND bool default n @@ -36,7 +15,7 @@ config MAINBOARD_NEEDS_I2C_TI50_WORKAROUND config DRIVER_TIS_DEFAULT bool depends on I2C_TPM - default n if MAINBOARD_HAS_I2C_TPM_ATMEL + default n if TPM_ATMEL default y config DRIVER_TPM_I2C_BUS @@ -58,3 +37,9 @@ config DRIVER_TPM_DISPLAY_TIS_BYTES bool "TPM: Display the TIS transactions to I2C TPM chip" default n depends on I2C_TPM + +config TPM_ATMEL + bool + default n + help + The mainboard has an Atmel TPM chip. diff --git a/src/drivers/i2c/tpm/Makefile.inc b/src/drivers/i2c/tpm/Makefile.inc index 51856fa9f0..ae50f2b342 100644 --- a/src/drivers/i2c/tpm/Makefile.inc +++ b/src/drivers/i2c/tpm/Makefile.inc @@ -1,25 +1,15 @@ -ramstage-$(CONFIG_DRIVER_TIS_DEFAULT) += tis.c -romstage-$(CONFIG_DRIVER_TIS_DEFAULT) += tis.c -verstage-$(CONFIG_DRIVER_TIS_DEFAULT) += tis.c -bootblock-$(CONFIG_DRIVER_TIS_DEFAULT) += tis.c -postcar-$(CONFIG_DRIVER_TIS_DEFAULT) += tis.c +ifeq ($(CONFIG_TPM)$(CONFIG_I2C_TPM),yy) -ramstage-$(CONFIG_MAINBOARD_HAS_I2C_TPM_ATMEL) += tis_atmel.c -romstage-$(CONFIG_MAINBOARD_HAS_I2C_TPM_ATMEL) += tis_atmel.c -verstage-$(CONFIG_MAINBOARD_HAS_I2C_TPM_ATMEL) += tis_atmel.c -bootblock-$(CONFIG_MAINBOARD_HAS_I2C_TPM_ATMEL) += tis_atmel.c -postcar-$(CONFIG_MAINBOARD_HAS_I2C_TPM_ATMEL) += tis_atmel.c +all-$(CONFIG_DRIVER_TIS_DEFAULT) += tis.c -ramstage-$(CONFIG_MAINBOARD_HAS_I2C_TPM_GENERIC) += tpm.c -romstage-$(CONFIG_MAINBOARD_HAS_I2C_TPM_GENERIC) += tpm.c -verstage-$(CONFIG_MAINBOARD_HAS_I2C_TPM_GENERIC) += tpm.c -bootblock-$(CONFIG_MAINBOARD_HAS_I2C_TPM_GENERIC) += tpm.c -postcar-$(CONFIG_MAINBOARD_HAS_I2C_TPM_GENERIC) += tpm.c +ifeq ($(CONFIG_TPM_ATMEL),y) +all-y += tis_atmel.c +else ifeq ($(CONFIG_TPM_GOOGLE),y) +all-y += cr50.c +else +all-y += tpm.c +endif -ramstage-$(CONFIG_MAINBOARD_HAS_I2C_TPM_CR50) += cr50.c -romstage-$(CONFIG_MAINBOARD_HAS_I2C_TPM_CR50) += cr50.c -verstage-$(CONFIG_MAINBOARD_HAS_I2C_TPM_CR50) += cr50.c -bootblock-$(CONFIG_MAINBOARD_HAS_I2C_TPM_CR50) += cr50.c -postcar-$(CONFIG_MAINBOARD_HAS_I2C_TPM_CR50) += cr50.c +endif ramstage-$(CONFIG_DRIVER_I2C_TPM_ACPI) += chip.c diff --git a/src/drivers/pc80/tpm/Kconfig b/src/drivers/pc80/tpm/Kconfig index 4a40b2952f..94920dfc63 100644 --- a/src/drivers/pc80/tpm/Kconfig +++ b/src/drivers/pc80/tpm/Kconfig @@ -1,10 +1,10 @@ -config MAINBOARD_HAS_LPC_TPM +config MEMORY_MAPPED_TPM bool default n help - Board has LPC TPM support + Board has memory mapped TPM support -if MAINBOARD_HAS_LPC_TPM +if MEMORY_MAPPED_TPM config TPM_TIS_BASE_ADDRESS hex diff --git a/src/drivers/pc80/tpm/Makefile.inc b/src/drivers/pc80/tpm/Makefile.inc index 8b2a864ecb..859233712b 100644 --- a/src/drivers/pc80/tpm/Makefile.inc +++ b/src/drivers/pc80/tpm/Makefile.inc @@ -1,5 +1,3 @@ -bootblock-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c -verstage-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c -romstage-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c -ramstage-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c -postcar-$(CONFIG_MAINBOARD_HAS_LPC_TPM) += tis.c +ifeq ($(CONFIG_MEMORY_MAPPED_TPM),y) +all-y += tis.c +endif diff --git a/src/drivers/spi/tpm/Kconfig b/src/drivers/spi/tpm/Kconfig index 8c39a4a44a..7a55318bb0 100644 --- a/src/drivers/spi/tpm/Kconfig +++ b/src/drivers/spi/tpm/Kconfig @@ -12,17 +12,3 @@ config DRIVER_TPM_SPI_CHIP int "Chip Select of the TPM chip on its SPI bus" default 0 depends on SPI_TPM - -config MAINBOARD_HAS_SPI_TPM_CR50 - bool - default n - select MAINBOARD_HAS_SPI_TPM - help - Board has a CR50 SPI TPM - -config MAINBOARD_HAS_SPI_TPM - bool - default n - select SPI_TPM - help - Board has SPI TPM support diff --git a/src/drivers/spi/tpm/Makefile.inc b/src/drivers/spi/tpm/Makefile.inc index 01d3b6641e..023479f0d0 100644 --- a/src/drivers/spi/tpm/Makefile.inc +++ b/src/drivers/spi/tpm/Makefile.inc @@ -1,5 +1,3 @@ -bootblock-$(CONFIG_SPI_TPM) += tis.c tpm.c -verstage-$(CONFIG_SPI_TPM) += tis.c tpm.c -romstage-$(CONFIG_SPI_TPM) += tis.c tpm.c -ramstage-$(CONFIG_SPI_TPM) += tis.c tpm.c -postcar-$(CONFIG_SPI_TPM) += tis.c tpm.c +ifeq ($(CONFIG_TPM)$(CONFIG_SPI_TPM),yy) +all-y += tis.c tpm.c +endif diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c index 43fd933dbf..1462dd9f7f 100644 --- a/src/drivers/spi/tpm/tpm.c +++ b/src/drivers/spi/tpm/tpm.c @@ -104,7 +104,7 @@ static enum cb_err start_transaction(int read_write, size_t bytes, unsigned int static int tpm_sync_needed; static struct stopwatch wake_up_sw; - if (CONFIG(TPM_CR50)) { + if (CONFIG(TPM_GOOGLE)) { /* * First Cr50 access in each coreboot stage where TPM is used will be * prepended by a wake up pulse on the CS line. @@ -186,7 +186,7 @@ static enum cb_err start_transaction(int read_write, size_t bytes, unsigned int */ header_resp.body[3] = 0; - if (CONFIG(TPM_CR50)) + if (CONFIG(TPM_GOOGLE)) ret = spi_xfer(&spi_slave, header.body, sizeof(header.body), NULL, 0); else ret = spi_xfer(&spi_slave, header.body, sizeof(header.body), @@ -497,7 +497,7 @@ int tpm2_init(struct spi_slave *spi_if) tpm_info.vendor_id, tpm_info.device_id, tpm_info.revision); /* Do some cr50-specific things here. */ - if (CONFIG(TPM_CR50) && tpm_info.vendor_id == 0x1ae0) { + if (CONFIG(TPM_GOOGLE) && tpm_info.vendor_id == 0x1ae0) { struct cr50_firmware_version ver; if (tpm_first_access_this_boot()) { diff --git a/src/drivers/tpm/Makefile.inc b/src/drivers/tpm/Makefile.inc index a56c02b666..7f0bbf59b2 100644 --- a/src/drivers/tpm/Makefile.inc +++ b/src/drivers/tpm/Makefile.inc @@ -1,3 +1,5 @@ +ifeq ($(CONFIG_TPM),y) + ramstage-$(CONFIG_TPM_INIT_RAMSTAGE) += tpm.c ifeq ($(CONFIG_TPM_PPI),y) @@ -6,8 +8,6 @@ else ramstage-$(CONFIG_HAVE_ACPI_TABLES) += ppi_stub.c endif -bootblock-$(CONFIG_TPM_CR50) += cr50.c -verstage-$(CONFIG_TPM_CR50) += cr50.c -romstage-$(CONFIG_TPM_CR50) += cr50.c -ramstage-$(CONFIG_TPM_CR50) += cr50.c -postcar-$(CONFIG_TPM_CR50) += cr50.c +all-$(CONFIG_TPM_GOOGLE) += cr50.c + +endif -- cgit v1.2.3