tpm_private.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. #ifndef _TPM_PRIVATE_H_
  36. #define _TPM_PRIVATE_H_
  37. #include <linux/compiler.h>
  38. #include <linux/types.h>
  39. enum tpm_timeout {
  40. TPM_TIMEOUT = 5, /* msecs */
  41. };
  42. /* Size of external transmit buffer (used in tpm_transmit)*/
  43. #define TPM_BUFSIZE 4096
  44. /* Index of Count field in TPM response buffer */
  45. #define TPM_RSP_SIZE_BYTE 2
  46. #define TPM_RSP_RC_BYTE 6
  47. struct tpm_chip;
  48. struct tpm_vendor_specific {
  49. const u8 req_complete_mask;
  50. const u8 req_complete_val;
  51. const u8 req_canceled;
  52. int irq;
  53. int (*recv) (struct tpm_chip *, u8 *, size_t);
  54. int (*send) (struct tpm_chip *, u8 *, size_t);
  55. void (*cancel) (struct tpm_chip *);
  56. u8(*status) (struct tpm_chip *);
  57. int locality;
  58. unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* msec */
  59. unsigned long duration[3]; /* msec */
  60. };
  61. struct tpm_chip {
  62. int is_open;
  63. struct tpm_vendor_specific vendor;
  64. };
  65. struct tpm_input_header {
  66. __be16 tag;
  67. __be32 length;
  68. __be32 ordinal;
  69. } __packed;
  70. struct tpm_output_header {
  71. __be16 tag;
  72. __be32 length;
  73. __be32 return_code;
  74. } __packed;
  75. struct timeout_t {
  76. __be32 a;
  77. __be32 b;
  78. __be32 c;
  79. __be32 d;
  80. } __packed;
  81. struct duration_t {
  82. __be32 tpm_short;
  83. __be32 tpm_medium;
  84. __be32 tpm_long;
  85. } __packed;
  86. union cap_t {
  87. struct timeout_t timeout;
  88. struct duration_t duration;
  89. };
  90. struct tpm_getcap_params_in {
  91. __be32 cap;
  92. __be32 subcap_size;
  93. __be32 subcap;
  94. } __packed;
  95. struct tpm_getcap_params_out {
  96. __be32 cap_size;
  97. union cap_t cap;
  98. } __packed;
  99. union tpm_cmd_header {
  100. struct tpm_input_header in;
  101. struct tpm_output_header out;
  102. };
  103. union tpm_cmd_params {
  104. struct tpm_getcap_params_out getcap_out;
  105. struct tpm_getcap_params_in getcap_in;
  106. };
  107. struct tpm_cmd_t {
  108. union tpm_cmd_header header;
  109. union tpm_cmd_params params;
  110. } __packed;
  111. struct tpm_chip *tpm_register_hardware(const struct tpm_vendor_specific *);
  112. int tpm_vendor_init(uint32_t dev_addr);
  113. void tpm_vendor_cleanup(struct tpm_chip *chip);
  114. #endif