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 | * |
| 16 | * |
| 17 | * See file CREDITS for list of people who contributed to this |
| 18 | * project. |
| 19 | * |
| 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 |
| 23 | * License. |
| 24 | * |
| 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. |
| 29 | * |
| 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, |
| 33 | * MA 02111-1307 USA |
| 34 | */ |
| 35 | |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 36 | #ifndef _TPM_PRIVATE_H_ |
| 37 | #define _TPM_PRIVATE_H_ |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 38 | |
| 39 | #include <linux/compiler.h> |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 40 | #include <linux/types.h> |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 41 | |
| 42 | enum tpm_timeout { |
| 43 | TPM_TIMEOUT = 5, /* msecs */ |
| 44 | }; |
| 45 | |
| 46 | /* Size of external transmit buffer (used in tpm_transmit)*/ |
| 47 | #define TPM_BUFSIZE 4096 |
| 48 | |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 49 | /* Index of Count field in TPM response buffer */ |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 50 | #define TPM_RSP_SIZE_BYTE 2 |
| 51 | #define TPM_RSP_RC_BYTE 6 |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 52 | |
| 53 | struct tpm_chip; |
| 54 | |
| 55 | struct tpm_vendor_specific { |
| 56 | const u8 req_complete_mask; |
| 57 | const u8 req_complete_val; |
| 58 | const u8 req_canceled; |
| 59 | int irq; |
| 60 | int (*recv) (struct tpm_chip *, u8 *, size_t); |
| 61 | int (*send) (struct tpm_chip *, u8 *, size_t); |
| 62 | void (*cancel) (struct tpm_chip *); |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 63 | u8(*status) (struct tpm_chip *); |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 64 | int locality; |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 65 | unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* msec */ |
| 66 | unsigned long duration[3]; /* msec */ |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | struct tpm_chip { |
| 70 | int is_open; |
| 71 | struct tpm_vendor_specific vendor; |
| 72 | }; |
| 73 | |
| 74 | struct tpm_input_header { |
| 75 | __be16 tag; |
| 76 | __be32 length; |
| 77 | __be32 ordinal; |
| 78 | } __packed; |
| 79 | |
| 80 | struct tpm_output_header { |
| 81 | __be16 tag; |
| 82 | __be32 length; |
| 83 | __be32 return_code; |
| 84 | } __packed; |
| 85 | |
| 86 | struct timeout_t { |
| 87 | __be32 a; |
| 88 | __be32 b; |
| 89 | __be32 c; |
| 90 | __be32 d; |
| 91 | } __packed; |
| 92 | |
| 93 | struct duration_t { |
| 94 | __be32 tpm_short; |
| 95 | __be32 tpm_medium; |
| 96 | __be32 tpm_long; |
| 97 | } __packed; |
| 98 | |
| 99 | union cap_t { |
| 100 | struct timeout_t timeout; |
| 101 | struct duration_t duration; |
| 102 | }; |
| 103 | |
| 104 | struct tpm_getcap_params_in { |
| 105 | __be32 cap; |
| 106 | __be32 subcap_size; |
| 107 | __be32 subcap; |
| 108 | } __packed; |
| 109 | |
| 110 | struct tpm_getcap_params_out { |
| 111 | __be32 cap_size; |
| 112 | union cap_t cap; |
| 113 | } __packed; |
| 114 | |
| 115 | union tpm_cmd_header { |
| 116 | struct tpm_input_header in; |
| 117 | struct tpm_output_header out; |
| 118 | }; |
| 119 | |
| 120 | union tpm_cmd_params { |
| 121 | struct tpm_getcap_params_out getcap_out; |
| 122 | struct tpm_getcap_params_in getcap_in; |
| 123 | }; |
| 124 | |
| 125 | struct tpm_cmd_t { |
| 126 | union tpm_cmd_header header; |
| 127 | union tpm_cmd_params params; |
| 128 | } __packed; |
| 129 | |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 130 | struct tpm_chip *tpm_register_hardware(const struct tpm_vendor_specific *); |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 131 | |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 132 | int tpm_vendor_init(uint32_t dev_addr); |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 133 | |
Simon Glass | f90acf1 | 2015-05-04 11:30:59 -0600 | [diff] [blame] | 134 | struct udevice; |
| 135 | int tpm_vendor_init_dev(struct udevice *dev); |
| 136 | |
Tom Wai-Hong Tam | 1b393db | 2013-04-12 11:04:37 +0000 | [diff] [blame] | 137 | void tpm_vendor_cleanup(struct tpm_chip *chip); |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 138 | |
Rong Chang | f626799 | 2013-04-12 10:44:57 +0000 | [diff] [blame] | 139 | |
| 140 | #endif |