1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2011 Infineon Technologies
6 * Peter Huewe <huewe.external@infineon.com>
11 * Device driver for TCG/TCPA TPM (trusted platform module).
12 * Specifications at www.trustedcomputinggroup.org
14 * It is based on the Linux kernel driver tpm.c from Leendert van
15 * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall.
18 #ifndef _TPM_TIS_I2C_H
19 #define _TPM_TIS_I2C_H
21 #include <linux/compiler.h>
22 #include <linux/types.h>
26 TIS_SHORT_TIMEOUT_MS
= 750,
27 TIS_LONG_TIMEOUT_MS
= 2000,
28 SLEEP_DURATION_US
= 60,
29 SLEEP_DURATION_LONG_US
= 210,
32 /* Size of external transmit buffer (used in tpm_transmit)*/
33 #define TPM_BUFSIZE 4096
35 /* Index of Count field in TPM response buffer */
36 #define TPM_RSP_SIZE_BYTE 2
37 #define TPM_RSP_RC_BYTE 6
43 unsigned long timeout_a
, timeout_b
, timeout_c
, timeout_d
; /* msec */
47 struct tpm_input_header
{
53 struct tpm_output_header
{
73 struct timeout_t timeout
;
74 struct duration_t duration
;
77 struct tpm_getcap_params_in
{
83 struct tpm_getcap_params_out
{
88 union tpm_cmd_header
{
89 struct tpm_input_header in
;
90 struct tpm_output_header out
;
93 union tpm_cmd_params
{
94 struct tpm_getcap_params_out getcap_out
;
95 struct tpm_getcap_params_in getcap_in
;
99 union tpm_cmd_header header
;
100 union tpm_cmd_params params
;
103 /* Max number of iterations after i2c NAK */
107 * Max number of iterations after i2c NAK for 'long' commands
109 * We need this especially for sending TPM_READY, since the cleanup after the
110 * transtion to the ready state may take some time, but it is unpredictable
111 * how long it will take.
113 #define MAX_COUNT_LONG 50
116 TPM_ACCESS_VALID
= 0x80,
117 TPM_ACCESS_ACTIVE_LOCALITY
= 0x20,
118 TPM_ACCESS_REQUEST_PENDING
= 0x04,
119 TPM_ACCESS_REQUEST_USE
= 0x02,
123 TPM_STS_VALID
= 0x80,
124 TPM_STS_COMMAND_READY
= 0x40,
126 TPM_STS_DATA_AVAIL
= 0x10,
127 TPM_STS_DATA_EXPECT
= 0x08,