blob: 7a87beb2d7d0bc345f5530c09b9c3e15042bfa20 [file] [log] [blame]
Stefan Bergerdfbc8852015-03-23 14:22:15 -04001#ifndef TPM_DRIVERS_H
2#define TPM_DRIVERS_H
3
4#include "types.h" // u32
5
6
7enum tpmDurationType {
8 TPM_DURATION_TYPE_SHORT = 0,
9 TPM_DURATION_TYPE_MEDIUM,
10 TPM_DURATION_TYPE_LONG,
11};
12
Kevin O'Connor2df70282015-11-28 13:43:22 -050013int tpmhw_probe(void);
14int tpmhw_is_present(void);
15struct tpm_req_header;
16u32 tpmhw_transmit(u8 locty, struct tpm_req_header *req,
17 void *respbuffer, u32 *respbufferlen,
18 enum tpmDurationType to_t);
19void tpmhw_set_timeouts(u32 timeouts[4], u32 durations[3]);
Stefan Bergerdfbc8852015-03-23 14:22:15 -040020
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 Bergerec42c8d2015-11-21 14:54:41 -050054/*
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 Bergerdfbc8852015-03-23 14:22:15 -040061
62enum 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 Bergerec42c8d2015-11-21 14:54:41 -050069/*
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 Bergerdfbc8852015-03-23 14:22:15 -040076
77#endif /* TPM_DRIVERS_H */