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