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