nsekar@codeaurora.org has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31898
Change subject: TEMP: NOT FOR REVIEW: Mistral: Add board id detection using TPM ......................................................................
TEMP: NOT FOR REVIEW: Mistral: Add board id detection using TPM
This patch adds support to select the board id based on the TPM availability.
Change-Id: Ifa7b17085364bb631f43a133839773033721062d Signed-off-by: Nitheesh Sekar nsekar@codeaurora.org --- M src/drivers/spi/tpm/tis.c M src/drivers/spi/tpm/tpm.c M src/mainboard/google/mistral/boardid.c M src/security/tpm/tis.h M src/soc/qualcomm/qcs405/include/soc/memlayout.ld M src/soc/qualcomm/qcs405/include/soc/symbols.h 6 files changed, 49 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/31898/1
diff --git a/src/drivers/spi/tpm/tis.c b/src/drivers/spi/tpm/tis.c index 40bf27d..9d0f664 100644 --- a/src/drivers/spi/tpm/tis.c +++ b/src/drivers/spi/tpm/tis.c @@ -4,6 +4,8 @@ * found in the LICENSE file. */
+#include <symbols.h> +#include <soc/symbols.h> #include <arch/early_variables.h> #include <console/console.h> #include <string.h> @@ -93,3 +95,13 @@
return 0; } + +unsigned int is_tpm_detected(void) +{ + if (0 == (*_tpm_detection)) + return 0; + else if (1 == (*_tpm_detection)) + return 1; + else + return 0; +} diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c index aad7610..b2484aa0 100644 --- a/src/drivers/spi/tpm/tpm.c +++ b/src/drivers/spi/tpm/tpm.c @@ -15,6 +15,8 @@ * Specification Revision 00.43". */
+#include <symbols.h> +#include <soc/symbols.h> #include <arch/early_variables.h> #include <assert.h> #include <commonlib/endian.h> @@ -457,10 +459,13 @@ }
if (!retries) { + *_tpm_detection = 0; printk(BIOS_ERR, "\n%s: Failed to connect to the TPM\n", __func__); return -1; } + else + *_tpm_detection = 1;
printk(BIOS_INFO, " done!\n");
diff --git a/src/mainboard/google/mistral/boardid.c b/src/mainboard/google/mistral/boardid.c index b86f84e..66309c0 100644 --- a/src/mainboard/google/mistral/boardid.c +++ b/src/mainboard/google/mistral/boardid.c @@ -17,6 +17,7 @@ #include <gpio.h> #include <console/console.h> #include <stdlib.h> +#include <security/tpm/tis.h>
/* * Mistral boards dedicate to the board ID three GPIOs in ternary mode: 105, 106 @@ -32,8 +33,22 @@ [1] = GPIO(106), [0] = GPIO(105)};
- bid = gpio_binary_first_base3_value(pins, ARRAY_SIZE(pins)); - printk(BIOS_INFO, "Board ID %d\n", bid); + if (0 == is_tpm_detected()) { + bid = 25; /* Assign 25 for EVB boards */ + printk(BIOS_DEBUG, "EVB Board ID: %d\n", bid); + } else { + bid = 0; /* Assign 0 for Proto boards */ + + /* The board id assigned for Proto boards is 0. + * Since gpios are not wired in the initial phase, + * we will get 0 whihch is a coincidence. + * To make sure it starts working, after gpios are + * wired, reassign the value read from gpios to id. + */ + bid = gpio_binary_first_base3_value(pins, ARRAY_SIZE(pins)); + + printk(BIOS_DEBUG, "Proto Board ID: %d\n", bid); + }
return bid; } diff --git a/src/security/tpm/tis.h b/src/security/tpm/tis.h index c410838..dd2f348 100644 --- a/src/security/tpm/tis.h +++ b/src/security/tpm/tis.h @@ -97,4 +97,14 @@ */ int tis_plat_irq_status(void);
+/* + * This function is_tpm_detected() sets tpm_detection value to be 1 upon TPM detection. + * The value is writted to the specific region of SRAM which will retain + * the TPM Detection information between various stages of the bootloader. + * + * Returns 0 if TPM is not detected + * Returns 1 if TPM is detected + */ +unsigned int is_tpm_detected(void); + #endif /* TIS_H_ */ diff --git a/src/soc/qualcomm/qcs405/include/soc/memlayout.ld b/src/soc/qualcomm/qcs405/include/soc/memlayout.ld index c23f651..585abf5 100644 --- a/src/soc/qualcomm/qcs405/include/soc/memlayout.ld +++ b/src/soc/qualcomm/qcs405/include/soc/memlayout.ld @@ -39,6 +39,7 @@ TIMESTAMP(0x8C50000, 1K) PRERAM_CBMEM_CONSOLE(0x8C50400, 32K) PRERAM_CBFS_CACHE(0x8C58400, 70K) + REGION(tpm_detection, 0x8CFD000, 0x8, 0x10) BSRAM_END(0x8D80000)
DRAM_START(0x80000000) diff --git a/src/soc/qualcomm/qcs405/include/soc/symbols.h b/src/soc/qualcomm/qcs405/include/soc/symbols.h index 45e6988..ce6e7cb 100644 --- a/src/soc/qualcomm/qcs405/include/soc/symbols.h +++ b/src/soc/qualcomm/qcs405/include/soc/symbols.h @@ -23,4 +23,8 @@ DECLARE_REGION(bsram); DECLARE_REGION(dram_reserved);
+extern u8 _tpm_detection[]; +extern u8 _etpm_detection[]; +#define _tpm_detection_size (_etpm_detection - _tpm_detection) + #endif // _SOC_QUALCOMM_QCS405_SYMBOLS_H_
Patrick Georgi has uploaded a new patch set (#2) to the change originally created by nsekar@codeaurora.org. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
tpm: Add API to query TPM presence
Change-Id: Ifa7b17085364bb631f43a133839773033721062d Signed-off-by: Nitheesh Sekar nsekar@codeaurora.org --- M src/drivers/spi/tpm/tpm.c M src/security/tpm/tis.h 2 files changed, 29 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/31898/2
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 2:
(2 comments)
https://review.coreboot.org/#/c/31898/2/src/drivers/spi/tpm/tpm.c File src/drivers/spi/tpm/tpm.c:
https://review.coreboot.org/#/c/31898/2/src/drivers/spi/tpm/tpm.c@470 PS2, Line 470: else else should follow close brace '}'
https://review.coreboot.org/#/c/31898/2/src/security/tpm/tis.h File src/security/tpm/tis.h:
https://review.coreboot.org/#/c/31898/2/src/security/tpm/tis.h@101 PS2, Line 101: * This function is_tpm_detected() sets tpm_detection value to be 1 upon TPM detection. line over 80 characters
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 2:
Nitheesh, since this fell our of your patch queue, I took the liberty to repurpose it slightly:
I split out the board side handling and also moved it away from using a memory layout region of its own.
The reason was that we need the is_tpm_detected() function in the new follow up commit that decides what to do with the recovery switch.
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/#/c/31898/3/src/drivers/spi/tpm/tpm.c File src/drivers/spi/tpm/tpm.c:
https://review.coreboot.org/#/c/31898/3/src/drivers/spi/tpm/tpm.c@470 PS3, Line 470: else else should follow close brace '}'
https://review.coreboot.org/#/c/31898/3/src/security/tpm/tis.h File src/security/tpm/tis.h:
https://review.coreboot.org/#/c/31898/3/src/security/tpm/tis.h@101 PS3, Line 101: * This function is_tpm_detected() sets tpm_detection value to be 1 upon TPM detection. line over 80 characters
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 4:
(2 comments)
https://review.coreboot.org/#/c/31898/4/src/drivers/spi/tpm/tpm.c File src/drivers/spi/tpm/tpm.c:
https://review.coreboot.org/#/c/31898/4/src/drivers/spi/tpm/tpm.c@470 PS4, Line 470: else else should follow close brace '}'
https://review.coreboot.org/#/c/31898/4/src/security/tpm/tis.h File src/security/tpm/tis.h:
https://review.coreboot.org/#/c/31898/4/src/security/tpm/tis.h@101 PS4, Line 101: * This function is_tpm_detected() sets tpm_detection value to be 1 upon TPM detection. line over 80 characters
Patrick Georgi has uploaded a new patch set (#5) to the change originally created by Nitheesh Sekar. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
tpm: Add API to query TPM presence
Change-Id: Ifa7b17085364bb631f43a133839773033721062d Signed-off-by: Nitheesh Sekar nsekar@codeaurora.org --- M src/drivers/spi/tpm/tpm.c M src/security/tpm/tis.h 2 files changed, 27 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/31898/5
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 5:
(2 comments)
https://review.coreboot.org/#/c/31898/5/src/drivers/spi/tpm/tpm.c File src/drivers/spi/tpm/tpm.c:
https://review.coreboot.org/#/c/31898/5/src/drivers/spi/tpm/tpm.c@468 PS5, Line 468: else else should follow close brace '}'
https://review.coreboot.org/#/c/31898/5/src/security/tpm/tis.h File src/security/tpm/tis.h:
https://review.coreboot.org/#/c/31898/5/src/security/tpm/tis.h@101 PS5, Line 101: * This function is_tpm_detected() sets tpm_detection value to be 1 upon TPM detection. line over 80 characters
Nitheesh Sekar has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 5:
Hi Patrick, The new implementation for "tpm presence query" is broken. We use the TPM presence to differentiate between EVB and Proto boards(refer CB:32271) The board_id in the libsysinfo stucture gets filled even before the TPM probe happens in the Ramstage. Hence, the dts for EVB boards is selected consistently in depthcharge because of the wrong board id.
Thanks, Nitheesh Sekar
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 6:
(2 comments)
https://review.coreboot.org/#/c/31898/6/src/drivers/spi/tpm/tpm.c File src/drivers/spi/tpm/tpm.c:
https://review.coreboot.org/#/c/31898/6/src/drivers/spi/tpm/tpm.c@468 PS6, Line 468: else else should follow close brace '}'
https://review.coreboot.org/#/c/31898/6/src/security/tpm/tis.h File src/security/tpm/tis.h:
https://review.coreboot.org/#/c/31898/6/src/security/tpm/tis.h@101 PS6, Line 101: * This function is_tpm_detected() sets tpm_detection value to be 1 upon TPM detection. line over 80 characters
Patrick Georgi has uploaded a new patch set (#7) to the change originally created by Nitheesh Sekar. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
tpm: Add API to query TPM presence
Change-Id: Ifa7b17085364bb631f43a133839773033721062d Signed-off-by: Nitheesh Sekar nsekar@codeaurora.org --- M src/drivers/spi/tpm/tpm.c M src/security/tpm/tis.h 2 files changed, 28 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/31898/7
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 7:
(2 comments)
https://review.coreboot.org/#/c/31898/5/src/drivers/spi/tpm/tpm.c File src/drivers/spi/tpm/tpm.c:
https://review.coreboot.org/#/c/31898/5/src/drivers/spi/tpm/tpm.c@468 PS5, Line 468: else
else should follow close brace '}'
Done
https://review.coreboot.org/#/c/31898/5/src/security/tpm/tis.h File src/security/tpm/tis.h:
https://review.coreboot.org/#/c/31898/5/src/security/tpm/tis.h@101 PS5, Line 101: * This function is_tpm_detected() sets tpm_detection value to be 1 upon TPM detection.
line over 80 characters
Done
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 7:
Patch Set 5:
Hi Patrick, The new implementation for "tpm presence query" is broken. We use the TPM presence to differentiate between EVB and Proto boards(refer CB:32271) The board_id in the libsysinfo stucture gets filled even before the TPM probe happens in the Ramstage. Hence, the dts for EVB boards is selected consistently in depthcharge because of the wrong board id.
Thanks, Nitheesh Sekar
https://review.coreboot.org/c/coreboot/+/32271/8/src/mainboard/google/mistra... should ensure that the TPM is initialized early enough. There are other issues that prevent me from completely testing it right now, but the preliminary results look good so I put it out there. please test with that update.
Philipp Deppenwiese has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 8: Code-Review-1
This needs to be implemented by all TIS drivers
Christian Walter has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Patch Set 8:
(1 comment)
https://review.coreboot.org/c/coreboot/+/31898/8/src/drivers/spi/tpm/tpm.c File src/drivers/spi/tpm/tpm.c:
https://review.coreboot.org/c/coreboot/+/31898/8/src/drivers/spi/tpm/tpm.c@7... PS8, Line 739: int tpm_present = car_get_var(tpm_detected); You could shorten it down to something like: if (car_get_var(tpm_detected) == 1) return 1; else return 0;
Patrick Georgi has uploaded a new patch set (#10) to the change originally created by Nitheesh Sekar. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
tpm: Add API to query TPM presence
Change-Id: Ifa7b17085364bb631f43a133839773033721062d Signed-off-by: Nitheesh Sekar nsekar@codeaurora.org --- M src/drivers/spi/tpm/tpm.c M src/security/tpm/tis.h 2 files changed, 28 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/31898/10
Patrick Georgi has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/31898 )
Change subject: tpm: Add API to query TPM presence ......................................................................
Abandoned
won't be finished here