]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/tpm/tpm_private.h
Merge branch 'master' of git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / drivers / tpm / tpm_private.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  *
17  * See file CREDITS for list of people who contributed to this
18  * project.
19  *
20  * This program is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU General Public License as
22  * published by the Free Software Foundation, version 2 of the
23  * License.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33  * MA 02111-1307 USA
34  */
35
36 #ifndef _TPM_PRIVATE_H_
37 #define _TPM_PRIVATE_H_
38
39 #include <linux/compiler.h>
40 #include <linux/types.h>
41
42 enum tpm_timeout {
43         TPM_TIMEOUT = 5,        /* msecs */
44 };
45
46 /* Size of external transmit buffer (used in tpm_transmit)*/
47 #define TPM_BUFSIZE 4096
48
49 /* Index of Count field in TPM response buffer */
50 #define TPM_RSP_SIZE_BYTE       2
51 #define TPM_RSP_RC_BYTE         6
52
53 struct tpm_chip;
54
55 struct tpm_vendor_specific {
56         const u8 req_complete_mask;
57         const u8 req_complete_val;
58         const u8 req_canceled;
59         int irq;
60         int (*recv) (struct tpm_chip *, u8 *, size_t);
61         int (*send) (struct tpm_chip *, u8 *, size_t);
62         void (*cancel) (struct tpm_chip *);
63         u8(*status) (struct tpm_chip *);
64         int locality;
65         unsigned long timeout_a, timeout_b, timeout_c, timeout_d;  /* msec */
66         unsigned long duration[3];  /* msec */
67 };
68
69 struct tpm_chip {
70         int is_open;
71         struct tpm_vendor_specific vendor;
72 };
73
74 struct tpm_input_header {
75         __be16 tag;
76         __be32 length;
77         __be32 ordinal;
78 } __packed;
79
80 struct tpm_output_header {
81         __be16 tag;
82         __be32 length;
83         __be32 return_code;
84 } __packed;
85
86 struct timeout_t {
87         __be32 a;
88         __be32 b;
89         __be32 c;
90         __be32 d;
91 } __packed;
92
93 struct duration_t {
94         __be32 tpm_short;
95         __be32 tpm_medium;
96         __be32 tpm_long;
97 } __packed;
98
99 union cap_t {
100         struct timeout_t timeout;
101         struct duration_t duration;
102 };
103
104 struct tpm_getcap_params_in {
105         __be32 cap;
106         __be32 subcap_size;
107         __be32 subcap;
108 } __packed;
109
110 struct tpm_getcap_params_out {
111         __be32 cap_size;
112         union cap_t cap;
113 } __packed;
114
115 union tpm_cmd_header {
116         struct tpm_input_header in;
117         struct tpm_output_header out;
118 };
119
120 union tpm_cmd_params {
121         struct tpm_getcap_params_out getcap_out;
122         struct tpm_getcap_params_in getcap_in;
123 };
124
125 struct tpm_cmd_t {
126         union tpm_cmd_header header;
127         union tpm_cmd_params params;
128 } __packed;
129
130 struct tpm_chip *tpm_register_hardware(const struct tpm_vendor_specific *);
131
132 int tpm_vendor_init(uint32_t dev_addr);
133
134 void tpm_vendor_cleanup(struct tpm_chip *chip);
135
136
137 #endif