2 * Copyright (C) 2011 Infineon Technologies
5 * Peter Huewe <huewe.external@infineon.com>
10 * Device driver for TCG/TCPA TPM (trusted platform module).
11 * Specifications at www.trustedcomputinggroup.org
13 * It is based on the Linux kernel driver tpm.c from Leendert van
14 * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall.
17 * See file CREDITS for list of people who contributed to this
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
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.
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,
39 #include <linux/compiler.h>
41 #include "compatibility.h"
44 TPM_TIMEOUT = 5, /* msecs */
47 /* Size of external transmit buffer (used in tpm_transmit)*/
48 #define TPM_BUFSIZE 4096
50 /* Index of fields in TPM command buffer */
51 #define TPM_CMD_SIZE_BYTE 2
52 #define TPM_CMD_ORDINAL_BYTE 6
54 /* Index of Count field in TPM response buffer */
55 #define TPM_RSP_SIZE_BYTE 2
56 #define TPM_RSP_RC_BYTE 6
60 struct tpm_vendor_specific {
61 const u8 req_complete_mask;
62 const u8 req_complete_val;
63 const u8 req_canceled;
65 int (*recv) (struct tpm_chip *, u8 *, size_t);
66 int (*send) (struct tpm_chip *, u8 *, size_t);
67 void (*cancel) (struct tpm_chip *);
68 u8(*status) (struct tpm_chip *);
70 unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* msec */
71 unsigned long duration[3]; /* msec */
76 struct tpm_vendor_specific vendor;
79 struct tpm_input_header {
85 struct tpm_output_header {
105 struct timeout_t timeout;
106 struct duration_t duration;
109 struct tpm_getcap_params_in {
115 struct tpm_getcap_params_out {
120 union tpm_cmd_header {
121 struct tpm_input_header in;
122 struct tpm_output_header out;
125 union tpm_cmd_params {
126 struct tpm_getcap_params_out getcap_out;
127 struct tpm_getcap_params_in getcap_in;
131 union tpm_cmd_header header;
132 union tpm_cmd_params params;
136 /* ---------- Interface for TPM vendor ------------ */
138 extern struct tpm_chip *tpm_register_hardware(
139 const struct tpm_vendor_specific *);
141 extern int tpm_vendor_init(uint32_t dev_addr);
143 extern void tpm_vendor_cleanup(struct tpm_chip *chip);
145 /* ---------- Interface for TDDL ------------------- */
148 * if dev_addr != 0 - redefines TPM device address
149 * Returns < 0 on error, 0 on success.
151 extern int tpm_open(uint32_t dev_addr);
153 extern void tpm_close(void);
156 * Transmit bufsiz bytes out of buf to TPM and get results back in buf, too.
157 * Returns < 0 on error, 0 on success.
159 extern ssize_t tpm_transmit(const unsigned char *buf, size_t bufsiz);