]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/tpm/tpm_tis_i2c.h
2a4ad774293df90be2b272bf39622661f0073173
[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 struct tpm_chip;
37
38 struct tpm_chip {
39         int is_open;
40         u8 req_complete_mask;
41         u8 req_complete_val;
42         u8 req_canceled;
43         int irq;
44         int locality;
45         unsigned long timeout_a, timeout_b, timeout_c, timeout_d;  /* msec */
46         unsigned long duration[3];  /* msec */
47 };
48
49 struct tpm_input_header {
50         __be16 tag;
51         __be32 length;
52         __be32 ordinal;
53 } __packed;
54
55 struct tpm_output_header {
56         __be16 tag;
57         __be32 length;
58         __be32 return_code;
59 } __packed;
60
61 struct timeout_t {
62         __be32 a;
63         __be32 b;
64         __be32 c;
65         __be32 d;
66 } __packed;
67
68 struct duration_t {
69         __be32 tpm_short;
70         __be32 tpm_medium;
71         __be32 tpm_long;
72 } __packed;
73
74 union cap_t {
75         struct timeout_t timeout;
76         struct duration_t duration;
77 };
78
79 struct tpm_getcap_params_in {
80         __be32 cap;
81         __be32 subcap_size;
82         __be32 subcap;
83 } __packed;
84
85 struct tpm_getcap_params_out {
86         __be32 cap_size;
87         union cap_t cap;
88 } __packed;
89
90 union tpm_cmd_header {
91         struct tpm_input_header in;
92         struct tpm_output_header out;
93 };
94
95 union tpm_cmd_params {
96         struct tpm_getcap_params_out getcap_out;
97         struct tpm_getcap_params_in getcap_in;
98 };
99
100 struct tpm_cmd_t {
101         union tpm_cmd_header header;
102         union tpm_cmd_params params;
103 } __packed;
104
105 struct udevice;
106 int tpm_vendor_init(struct udevice *dev);
107
108 void tpm_vendor_cleanup(struct tpm_chip *chip);
109
110 #endif