| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <drivers/crb/tpm.h> |
| 5 |
#include <drivers/i2c/tpm/tpm.h> |
| 6 |
#include <drivers/pc80/tpm/tpm.h> |
| 7 |
#include <drivers/spi/tpm/tpm.h> |
| 8 |
#include <security/tpm/tis.h> |
| 9 |
#include <security/tpm/tss.h> |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
enum tpm_family tlcl_tpm_family = TPM_UNKNOWN; |
| 17 |
|
| 18 |
tis_sendrecv_fn tlcl_tis_sendrecv; |
| 19 |
|
| 20 |
|
| 21 |
tpm_result_t tlcl_lib_init(void) |
| 22 |
{ |
| 23 |
|
| 24 |
static bool init_done; |
| 25 |
if (init_done) |
| 26 |
return tlcl_tpm_family == TPM_UNKNOWN ? TPM_CB_NO_DEVICE : TPM_SUCCESS; |
| 27 |
|
| 28 |
|
| 29 |
init_done = true; |
| 30 |
|
| 31 |
tlcl_tis_sendrecv = NULL; |
| 32 |
if (CONFIG(CRB_TPM)) |
| 33 |
tlcl_tis_sendrecv = crb_tis_probe(&tlcl_tpm_family); |
| 34 |
if (CONFIG(MEMORY_MAPPED_TPM) && tlcl_tis_sendrecv == NULL) |
| 35 |
tlcl_tis_sendrecv = pc80_tis_probe(&tlcl_tpm_family); |
| 36 |
if (CONFIG(I2C_TPM) && tlcl_tis_sendrecv == NULL) |
| 37 |
tlcl_tis_sendrecv = i2c_tis_probe(&tlcl_tpm_family); |
| 38 |
if (CONFIG(SPI_TPM) && tlcl_tis_sendrecv == NULL) |
| 39 |
tlcl_tis_sendrecv = spi_tis_probe(&tlcl_tpm_family); |
| 40 |
|
| 41 |
if (tlcl_tis_sendrecv == NULL) { |
| 42 |
printk(BIOS_ERR, "%s: TIS probe failed\n", __func__); |
| 43 |
tlcl_tpm_family = TPM_UNKNOWN; |
| 44 |
} else if (tlcl_tpm_family != TPM_1 && tlcl_tpm_family != TPM_2) { |
| 45 |
printk(BIOS_ERR, "%s: TIS probe returned incorrect TPM family: %d\n", __func__, |
| 46 |
tlcl_tpm_family); |
| 47 |
tlcl_tpm_family = TPM_UNKNOWN; |
| 48 |
} |
| 49 |
|
| 50 |
return tlcl_tpm_family == TPM_UNKNOWN ? TPM_CB_NO_DEVICE : TPM_SUCCESS; |
| 51 |
} |