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