]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/tpm/tpm_tis_i2c.h
tpm: tpm_tis_i2c: Merge struct tpm into tpm_chip
[karo-tx-uboot.git] / drivers / tpm / tpm_tis_i2c.h
1 /*
2  * Copyright (C) 2011 Infineon Technologies
3  *
4  * Authors:
5  * Peter Huewe <huewe.external@infineon.com>
6  *
7  * Version: 2.1.1
8  *
9  * Description:
10  * Device driver for TCG/TCPA TPM (trusted platform module).
11  * Specifications at www.trustedcomputinggroup.org
12  *
13  * It is based on the Linux kernel driver tpm.c from Leendert van
14  * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall.
15  *
16  * SPDX-License-Identifier:     GPL-2.0
17  */
18
19 #ifndef _TPM_TIS_I2C_H
20 #define _TPM_TIS_I2C_H
21
22 #include <linux/compiler.h>
23 #include <linux/types.h>
24
25 enum tpm_timeout {
26         TPM_TIMEOUT = 5,        /* msecs */
27 };
28
29 /* Size of external transmit buffer (used in tpm_transmit)*/
30 #define TPM_BUFSIZE 4096
31
32 /* Index of Count field in TPM response buffer */
33 #define TPM_RSP_SIZE_BYTE       2
34 #define TPM_RSP_RC_BYTE         6
35
36 /* Max buffer size supported by our tpm */
37 #define TPM_DEV_BUFSIZE         1260
38
39 enum i2c_chip_type {
40         SLB9635,
41         SLB9645,
42         UNKNOWN,
43 };
44
45 struct tpm_chip {
46         bool inited;
47         int is_open;
48         u8 req_complete_mask;
49         u8 req_complete_val;
50         u8 req_canceled;
51         int irq;
52         int locality;
53         unsigned long timeout_a, timeout_b, timeout_c, timeout_d;  /* msec */
54         unsigned long duration[3];  /* msec */
55         struct udevice *dev;
56         u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)];  /* Max buffer size + addr */
57         enum i2c_chip_type chip_type;
58 };
59
60 struct tpm_input_header {
61         __be16 tag;
62         __be32 length;
63         __be32 ordinal;
64 } __packed;
65
66 struct tpm_output_header {
67         __be16 tag;
68         __be32 length;
69         __be32 return_code;
70 } __packed;
71
72 struct timeout_t {
73         __be32 a;
74         __be32 b;
75         __be32 c;
76         __be32 d;
77 } __packed;
78
79 struct duration_t {
80         __be32 tpm_short;
81         __be32 tpm_medium;
82         __be32 tpm_long;
83 } __packed;
84
85 union cap_t {
86         struct timeout_t timeout;
87         struct duration_t duration;
88 };
89
90 struct tpm_getcap_params_in {
91         __be32 cap;
92         __be32 subcap_size;
93         __be32 subcap;
94 } __packed;
95
96 struct tpm_getcap_params_out {
97         __be32 cap_size;
98         union cap_t cap;
99 } __packed;
100
101 union tpm_cmd_header {
102         struct tpm_input_header in;
103         struct tpm_output_header out;
104 };
105
106 union tpm_cmd_params {
107         struct tpm_getcap_params_out getcap_out;
108         struct tpm_getcap_params_in getcap_in;
109 };
110
111 struct tpm_cmd_t {
112         union tpm_cmd_header header;
113         union tpm_cmd_params params;
114 } __packed;
115
116 #endif