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