Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 1 | /* |
| 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 Glass | 4cd7b78 | 2015-08-22 18:31:22 -0600 | [diff] [blame] | 16 | * SPDX-License-Identifier: GPL-2.0 |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 17 | */ |
| 18 | |
Simon Glass | 4cd7b78 | 2015-08-22 18:31:22 -0600 | [diff] [blame] | 19 | #ifndef _TPM_TIS_I2C_H |
| 20 | #define _TPM_TIS_I2C_H |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 21 | |
| 22 | #include <linux/compiler.h> |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 23 | #include <linux/types.h> |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 24 | |
| 25 | enum 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 Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 32 | /* Index of Count field in TPM response buffer */ |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 33 | #define TPM_RSP_SIZE_BYTE 2 |
| 34 | #define TPM_RSP_RC_BYTE 6 |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 35 | |
| 36 | struct tpm_chip; |
| 37 | |
Simon Glass | 7c73537 | 2015-08-22 18:31:24 -0600 | [diff] [blame^] | 38 | struct tpm_chip { |
| 39 | int is_open; |
| 40 | u8 req_complete_mask; |
| 41 | u8 req_complete_val; |
| 42 | u8 req_canceled; |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 43 | int irq; |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 44 | int locality; |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 45 | unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* msec */ |
| 46 | unsigned long duration[3]; /* msec */ |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 49 | struct tpm_input_header { |
| 50 | __be16 tag; |
| 51 | __be32 length; |
| 52 | __be32 ordinal; |
| 53 | } __packed; |
| 54 | |
| 55 | struct tpm_output_header { |
| 56 | __be16 tag; |
| 57 | __be32 length; |
| 58 | __be32 return_code; |
| 59 | } __packed; |
| 60 | |
| 61 | struct timeout_t { |
| 62 | __be32 a; |
| 63 | __be32 b; |
| 64 | __be32 c; |
| 65 | __be32 d; |
| 66 | } __packed; |
| 67 | |
| 68 | struct duration_t { |
| 69 | __be32 tpm_short; |
| 70 | __be32 tpm_medium; |
| 71 | __be32 tpm_long; |
| 72 | } __packed; |
| 73 | |
| 74 | union cap_t { |
| 75 | struct timeout_t timeout; |
| 76 | struct duration_t duration; |
| 77 | }; |
| 78 | |
| 79 | struct tpm_getcap_params_in { |
| 80 | __be32 cap; |
| 81 | __be32 subcap_size; |
| 82 | __be32 subcap; |
| 83 | } __packed; |
| 84 | |
| 85 | struct tpm_getcap_params_out { |
| 86 | __be32 cap_size; |
| 87 | union cap_t cap; |
| 88 | } __packed; |
| 89 | |
| 90 | union tpm_cmd_header { |
| 91 | struct tpm_input_header in; |
| 92 | struct tpm_output_header out; |
| 93 | }; |
| 94 | |
| 95 | union tpm_cmd_params { |
| 96 | struct tpm_getcap_params_out getcap_out; |
| 97 | struct tpm_getcap_params_in getcap_in; |
| 98 | }; |
| 99 | |
| 100 | struct tpm_cmd_t { |
| 101 | union tpm_cmd_header header; |
| 102 | union tpm_cmd_params params; |
| 103 | } __packed; |
| 104 | |
Simon Glass | f90acf1 | 2015-05-04 11:30:59 -0600 | [diff] [blame] | 105 | struct udevice; |
Simon Glass | 3a3f8e9 | 2015-08-22 18:31:17 -0600 | [diff] [blame] | 106 | int tpm_vendor_init(struct udevice *dev); |
Simon Glass | f90acf1 | 2015-05-04 11:30:59 -0600 | [diff] [blame] | 107 | |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 108 | void tpm_vendor_cleanup(struct tpm_chip *chip); |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 109 | |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 110 | #endif |