Patrick Georgi | 593124d | 2020-05-10 19:44:08 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
Vadim Bendebury | e31d243 | 2016-04-09 18:33:49 -0700 | [diff] [blame] | 2 | |
| 3 | #ifndef __COREBOOT_SRC_DRIVERS_SPI_TPM_TPM_H |
| 4 | #define __COREBOOT_SRC_DRIVERS_SPI_TPM_TPM_H |
| 5 | |
Tim Wawrzynczak | 6b8599f | 2022-02-14 16:04:21 -0700 | [diff] [blame] | 6 | #include <drivers/tpm/cr50.h> |
Sergii Dmytruk | 3e5cefc | 2022-11-01 00:48:43 +0200 | [diff] [blame^] | 7 | #include <security/tpm/tis.h> |
Jon Murphy | d7b8dc9 | 2023-09-05 11:36:43 -0600 | [diff] [blame] | 8 | #include <security/tpm/tss_errors.h> |
Vadim Bendebury | e31d243 | 2016-04-09 18:33:49 -0700 | [diff] [blame] | 9 | #include <stddef.h> |
| 10 | #include <spi-generic.h> |
| 11 | |
Tim Wawrzynczak | 6b8599f | 2022-02-14 16:04:21 -0700 | [diff] [blame] | 12 | #define TPM_LOCALITY_0_SPI_BASE 0x00d40000 |
| 13 | |
Vadim Bendebury | e31d243 | 2016-04-09 18:33:49 -0700 | [diff] [blame] | 14 | /* |
Martin Roth | 3e25f85 | 2023-09-04 15:37:07 -0600 | [diff] [blame] | 15 | * A TPM device descriptor, values read from the appropriate device registers |
Vadim Bendebury | e31d243 | 2016-04-09 18:33:49 -0700 | [diff] [blame] | 16 | * are cached here. |
| 17 | */ |
| 18 | struct tpm2_info { |
| 19 | uint16_t vendor_id; |
| 20 | uint16_t device_id; |
| 21 | uint16_t revision; |
| 22 | }; |
| 23 | |
| 24 | /* |
| 25 | * Initialize a TPM2 device: read its id, claim locality of zero, verify that |
| 26 | * this indeed is a TPM2 device. Use the passed in handle to access the right |
| 27 | * SPI port. |
| 28 | * |
| 29 | * Return 0 on success, non-zero on failure. |
| 30 | */ |
Jon Murphy | d7b8dc9 | 2023-09-05 11:36:43 -0600 | [diff] [blame] | 31 | tpm_result_t tpm2_init(struct spi_slave *spi_if); |
Vadim Bendebury | e31d243 | 2016-04-09 18:33:49 -0700 | [diff] [blame] | 32 | |
Vadim Bendebury | e31d243 | 2016-04-09 18:33:49 -0700 | [diff] [blame] | 33 | /* |
| 34 | * Each command processing consists of sending the command to the TPM, by |
| 35 | * writing it into the FIFO register, then polling the status register until |
| 36 | * the TPM is ready to respond, then reading the response from the FIFO |
Martin Roth | 3e25f85 | 2023-09-04 15:37:07 -0600 | [diff] [blame] | 37 | * register. The size of the response can be gleaned from the 6 byte header. |
Vadim Bendebury | e31d243 | 2016-04-09 18:33:49 -0700 | [diff] [blame] | 38 | * |
| 39 | * This function places the response into the tpm2_response buffer and returns |
| 40 | * the size of the response. |
| 41 | */ |
| 42 | size_t tpm2_process_command(const void *tpm2_command, size_t command_size, |
| 43 | void *tpm2_response, size_t max_response); |
| 44 | |
| 45 | /* Get information about previously initialized TPM device. */ |
| 46 | void tpm2_get_info(struct tpm2_info *info); |
| 47 | |
Sergii Dmytruk | 3e5cefc | 2022-11-01 00:48:43 +0200 | [diff] [blame^] | 48 | tis_sendrecv_fn spi_tis_probe(enum tpm_family *family); |
| 49 | |
Vadim Bendebury | e31d243 | 2016-04-09 18:33:49 -0700 | [diff] [blame] | 50 | #endif /* ! __COREBOOT_SRC_DRIVERS_SPI_TPM_TPM_H */ |