blob: 2a4ad774293df90be2b272bf39622661f0073173 [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 *
Simon Glass4cd7b782015-08-22 18:31:22 -060016 * SPDX-License-Identifier: GPL-2.0
Rong Changf6267992013-04-12 10:44:57 +000017 */
18
Simon Glass4cd7b782015-08-22 18:31:22 -060019#ifndef _TPM_TIS_I2C_H
20#define _TPM_TIS_I2C_H
Rong Changf6267992013-04-12 10:44:57 +000021
22#include <linux/compiler.h>
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +000023#include <linux/types.h>
Rong Changf6267992013-04-12 10:44:57 +000024
25enum 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
Rong Changf6267992013-04-12 10:44:57 +000032/* Index of Count field in TPM response buffer */
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +000033#define TPM_RSP_SIZE_BYTE 2
34#define TPM_RSP_RC_BYTE 6
Rong Changf6267992013-04-12 10:44:57 +000035
36struct tpm_chip;
37
Simon Glass7c735372015-08-22 18:31:24 -060038struct tpm_chip {
39 int is_open;
40 u8 req_complete_mask;
41 u8 req_complete_val;
42 u8 req_canceled;
Rong Changf6267992013-04-12 10:44:57 +000043 int irq;
Rong Changf6267992013-04-12 10:44:57 +000044 int locality;
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +000045 unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* msec */
46 unsigned long duration[3]; /* msec */
Rong Changf6267992013-04-12 10:44:57 +000047};
48
Rong Changf6267992013-04-12 10:44:57 +000049struct tpm_input_header {
50 __be16 tag;
51 __be32 length;
52 __be32 ordinal;
53} __packed;
54
55struct tpm_output_header {
56 __be16 tag;
57 __be32 length;
58 __be32 return_code;
59} __packed;
60
61struct timeout_t {
62 __be32 a;
63 __be32 b;
64 __be32 c;
65 __be32 d;
66} __packed;
67
68struct duration_t {
69 __be32 tpm_short;
70 __be32 tpm_medium;
71 __be32 tpm_long;
72} __packed;
73
74union cap_t {
75 struct timeout_t timeout;
76 struct duration_t duration;
77};
78
79struct tpm_getcap_params_in {
80 __be32 cap;
81 __be32 subcap_size;
82 __be32 subcap;
83} __packed;
84
85struct tpm_getcap_params_out {
86 __be32 cap_size;
87 union cap_t cap;
88} __packed;
89
90union tpm_cmd_header {
91 struct tpm_input_header in;
92 struct tpm_output_header out;
93};
94
95union tpm_cmd_params {
96 struct tpm_getcap_params_out getcap_out;
97 struct tpm_getcap_params_in getcap_in;
98};
99
100struct tpm_cmd_t {
101 union tpm_cmd_header header;
102 union tpm_cmd_params params;
103} __packed;
104
Simon Glassf90acf12015-05-04 11:30:59 -0600105struct udevice;
Simon Glass3a3f8e92015-08-22 18:31:17 -0600106int tpm_vendor_init(struct udevice *dev);
Simon Glassf90acf12015-05-04 11:30:59 -0600107
Tom Wai-Hong Tam1b393db2013-04-12 11:04:37 +0000108void tpm_vendor_cleanup(struct tpm_chip *chip);
Rong Changf6267992013-04-12 10:44:57 +0000109
Rong Changf6267992013-04-12 10:44:57 +0000110#endif