mb/google/brya: Create rull variant
[coreboot2.git] / src / drivers / i2c / tpm / tpm.h
blobba78a422903114c3746aab7ef294aadf8dd91d4b
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /*
4 * Description:
5 * Device driver for TCG/TCPA TPM (trusted platform module).
6 * Specifications at www.trustedcomputinggroup.org
8 * It is based on the Linux kernel driver tpm.c from Leendert van
9 * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall.
12 #ifndef __DRIVERS_TPM_SLB9635_I2C_TPM_H__
13 #define __DRIVERS_TPM_SLB9635_I2C_TPM_H__
15 #include <security/tpm/tis.h>
16 #include <security/tpm/tss_errors.h>
17 #include <stdint.h>
19 enum tpm_timeout {
20 TPM_TIMEOUT = 1, /* msecs */
23 /* Size of external transmit buffer (used for stack buffer in tpm_sendrecv) */
24 #define TPM_BUFSIZE 1260
26 /* Number of bytes in the TPM header */
27 #define TPM_HEADER_SIZE 10
29 /* Index of fields in TPM command buffer */
30 #define TPM_CMD_SIZE_BYTE 2
31 #define TPM_CMD_ORDINAL_BYTE 6
33 /* Index of Count field in TPM response buffer */
34 #define TPM_RSP_SIZE_BYTE 2
35 #define TPM_RSP_RC_BYTE 6
37 #define TPM_ACCESS(l) (0x0000 | ((l) << 4))
38 #define TPM_STS(l) (0x0001 | ((l) << 4))
39 #define TPM_DATA_FIFO(l) (0x0005 | ((l) << 4))
40 #define TPM_DID_VID(l) (0x0006 | ((l) << 4))
42 struct tpm_chip {
43 uint8_t req_complete_mask;
44 uint8_t req_complete_val;
45 uint8_t req_canceled;
47 int (*recv)(uint8_t *buf, size_t len);
48 int (*send)(uint8_t *buf, size_t len);
49 void (*cancel)(void);
50 uint8_t (*status)(void);
53 /* ---------- Interface for TPM vendor ------------ */
55 tpm_result_t tpm_vendor_probe(unsigned int bus, uint32_t addr, enum tpm_family *family);
57 tpm_result_t tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr);
59 tis_sendrecv_fn i2c_tis_probe(enum tpm_family *family);
61 #endif /* __DRIVERS_TPM_SLB9635_I2C_TPM_H__ */