Stefan Berger | dfbc885 | 2015-03-23 14:22:15 -0400 | [diff] [blame] | 1 | #ifndef TPM_DRIVERS_H |
| 2 | #define TPM_DRIVERS_H |
| 3 | |
| 4 | #include "types.h" // u32 |
| 5 | |
| 6 | |
| 7 | enum tpmDurationType { |
| 8 | TPM_DURATION_TYPE_SHORT = 0, |
| 9 | TPM_DURATION_TYPE_MEDIUM, |
| 10 | TPM_DURATION_TYPE_LONG, |
| 11 | }; |
| 12 | |
Kevin O'Connor | 2df7028 | 2015-11-28 13:43:22 -0500 | [diff] [blame^] | 13 | int tpmhw_probe(void); |
| 14 | int tpmhw_is_present(void); |
| 15 | struct tpm_req_header; |
| 16 | u32 tpmhw_transmit(u8 locty, struct tpm_req_header *req, |
| 17 | void *respbuffer, u32 *respbufferlen, |
| 18 | enum tpmDurationType to_t); |
| 19 | void tpmhw_set_timeouts(u32 timeouts[4], u32 durations[3]); |
Stefan Berger | dfbc885 | 2015-03-23 14:22:15 -0400 | [diff] [blame] | 20 | |
| 21 | /* TIS driver */ |
| 22 | /* address of locality 0 (TIS) */ |
| 23 | #define TPM_TIS_BASE_ADDRESS 0xfed40000 |
| 24 | |
| 25 | #define TIS_REG(LOCTY, REG) \ |
| 26 | (void *)(TPM_TIS_BASE_ADDRESS + (LOCTY << 12) + REG) |
| 27 | |
| 28 | /* hardware registers */ |
| 29 | #define TIS_REG_ACCESS 0x0 |
| 30 | #define TIS_REG_INT_ENABLE 0x8 |
| 31 | #define TIS_REG_INT_VECTOR 0xc |
| 32 | #define TIS_REG_INT_STATUS 0x10 |
| 33 | #define TIS_REG_INTF_CAPABILITY 0x14 |
| 34 | #define TIS_REG_STS 0x18 |
| 35 | #define TIS_REG_DATA_FIFO 0x24 |
| 36 | #define TIS_REG_DID_VID 0xf00 |
| 37 | #define TIS_REG_RID 0xf04 |
| 38 | |
| 39 | #define TIS_STS_VALID (1 << 7) /* 0x80 */ |
| 40 | #define TIS_STS_COMMAND_READY (1 << 6) /* 0x40 */ |
| 41 | #define TIS_STS_TPM_GO (1 << 5) /* 0x20 */ |
| 42 | #define TIS_STS_DATA_AVAILABLE (1 << 4) /* 0x10 */ |
| 43 | #define TIS_STS_EXPECT (1 << 3) /* 0x08 */ |
| 44 | #define TIS_STS_RESPONSE_RETRY (1 << 1) /* 0x02 */ |
| 45 | |
| 46 | #define TIS_ACCESS_TPM_REG_VALID_STS (1 << 7) /* 0x80 */ |
| 47 | #define TIS_ACCESS_ACTIVE_LOCALITY (1 << 5) /* 0x20 */ |
| 48 | #define TIS_ACCESS_BEEN_SEIZED (1 << 4) /* 0x10 */ |
| 49 | #define TIS_ACCESS_SEIZE (1 << 3) /* 0x08 */ |
| 50 | #define TIS_ACCESS_PENDING_REQUEST (1 << 2) /* 0x04 */ |
| 51 | #define TIS_ACCESS_REQUEST_USE (1 << 1) /* 0x02 */ |
| 52 | #define TIS_ACCESS_TPM_ESTABLISHMENT (1 << 0) /* 0x01 */ |
| 53 | |
Stefan Berger | ec42c8d | 2015-11-21 14:54:41 -0500 | [diff] [blame] | 54 | /* |
| 55 | * Default TIS timeouts used before getting them from the TPM itself |
| 56 | */ |
| 57 | #define TIS_DEFAULT_TIMEOUT_A 750000 /* us */ |
| 58 | #define TIS_DEFAULT_TIMEOUT_B 2000000 /* us */ |
| 59 | #define TIS_DEFAULT_TIMEOUT_C 750000 /* us */ |
| 60 | #define TIS_DEFAULT_TIMEOUT_D 750000 /* us */ |
Stefan Berger | dfbc885 | 2015-03-23 14:22:15 -0400 | [diff] [blame] | 61 | |
| 62 | enum tisTimeoutType { |
| 63 | TIS_TIMEOUT_TYPE_A = 0, |
| 64 | TIS_TIMEOUT_TYPE_B, |
| 65 | TIS_TIMEOUT_TYPE_C, |
| 66 | TIS_TIMEOUT_TYPE_D, |
| 67 | }; |
| 68 | |
Stefan Berger | ec42c8d | 2015-11-21 14:54:41 -0500 | [diff] [blame] | 69 | /* |
| 70 | * Default command durations used before getting them from the |
| 71 | * TPM itself |
| 72 | */ |
| 73 | #define TPM_DEFAULT_DURATION_SHORT 2000000 /* us */ |
| 74 | #define TPM_DEFAULT_DURATION_MEDIUM 20000000 /* us */ |
| 75 | #define TPM_DEFAULT_DURATION_LONG 60000000 /* us */ |
Stefan Berger | dfbc885 | 2015-03-23 14:22:15 -0400 | [diff] [blame] | 76 | |
| 77 | #endif /* TPM_DRIVERS_H */ |