blob: 8894c98e6a87dc6aad2e01ef57a29d1467527d2f [file] [log] [blame]
Rong Changf6267992013-04-12 10:44:57 +00001/*
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
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +000036#ifndef _TPM_PRIVATE_H_
37#define _TPM_PRIVATE_H_
Rong Changf6267992013-04-12 10:44:57 +000038
39#include <linux/compiler.h>
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +000040#include <linux/types.h>
Rong Changf6267992013-04-12 10:44:57 +000041
42enum 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
Rong Changf6267992013-04-12 10:44:57 +000049/* Index of Count field in TPM response buffer */
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +000050#define TPM_RSP_SIZE_BYTE 2
51#define TPM_RSP_RC_BYTE 6
Rong Changf6267992013-04-12 10:44:57 +000052
53struct tpm_chip;
54
55struct 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 *);
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +000063 u8(*status) (struct tpm_chip *);
Rong Changf6267992013-04-12 10:44:57 +000064 int locality;
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +000065 unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* msec */
66 unsigned long duration[3]; /* msec */
Rong Changf6267992013-04-12 10:44:57 +000067};
68
69struct tpm_chip {
70 int is_open;
71 struct tpm_vendor_specific vendor;
72};
73
74struct tpm_input_header {
75 __be16 tag;
76 __be32 length;
77 __be32 ordinal;
78} __packed;
79
80struct tpm_output_header {
81 __be16 tag;
82 __be32 length;
83 __be32 return_code;
84} __packed;
85
86struct timeout_t {
87 __be32 a;
88 __be32 b;
89 __be32 c;
90 __be32 d;
91} __packed;
92
93struct duration_t {
94 __be32 tpm_short;
95 __be32 tpm_medium;
96 __be32 tpm_long;
97} __packed;
98
99union cap_t {
100 struct timeout_t timeout;
101 struct duration_t duration;
102};
103
104struct tpm_getcap_params_in {
105 __be32 cap;
106 __be32 subcap_size;
107 __be32 subcap;
108} __packed;
109
110struct tpm_getcap_params_out {
111 __be32 cap_size;
112 union cap_t cap;
113} __packed;
114
115union tpm_cmd_header {
116 struct tpm_input_header in;
117 struct tpm_output_header out;
118};
119
120union tpm_cmd_params {
121 struct tpm_getcap_params_out getcap_out;
122 struct tpm_getcap_params_in getcap_in;
123};
124
125struct tpm_cmd_t {
126 union tpm_cmd_header header;
127 union tpm_cmd_params params;
128} __packed;
129
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +0000130struct tpm_chip *tpm_register_hardware(const struct tpm_vendor_specific *);
Rong Changf6267992013-04-12 10:44:57 +0000131
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +0000132int tpm_vendor_init(uint32_t dev_addr);
Rong Changf6267992013-04-12 10:44:57 +0000133
Simon Glassf90acf12015-05-04 11:30:59 -0600134struct udevice;
135int tpm_vendor_init_dev(struct udevice *dev);
136
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +0000137void tpm_vendor_cleanup(struct tpm_chip *chip);
Rong Changf6267992013-04-12 10:44:57 +0000138
Rong Changf6267992013-04-12 10:44:57 +0000139
140#endif