tpm_ibmvtpm.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 IBM Corporation
  4. *
  5. * Author: Ashley Lai <[email protected]>
  6. *
  7. * Maintained by: <[email protected]>
  8. *
  9. * Device driver for TCG/TCPA TPM (trusted platform module).
  10. * Specifications at www.trustedcomputinggroup.org
  11. */
  12. #ifndef __TPM_IBMVTPM_H__
  13. #define __TPM_IBMVTPM_H__
  14. /* vTPM Message Format 1 */
  15. struct ibmvtpm_crq {
  16. u8 valid;
  17. u8 msg;
  18. __be16 len;
  19. __be32 data;
  20. __be64 reserved;
  21. } __attribute__((packed, aligned(8)));
  22. struct ibmvtpm_crq_queue {
  23. struct ibmvtpm_crq *crq_addr;
  24. u32 index;
  25. u32 num_entry;
  26. wait_queue_head_t wq;
  27. };
  28. struct ibmvtpm_dev {
  29. struct device *dev;
  30. struct vio_dev *vdev;
  31. struct ibmvtpm_crq_queue crq_queue;
  32. dma_addr_t crq_dma_handle;
  33. u32 rtce_size;
  34. void __iomem *rtce_buf;
  35. dma_addr_t rtce_dma_handle;
  36. spinlock_t rtce_lock;
  37. wait_queue_head_t wq;
  38. u16 res_len;
  39. u32 vtpm_version;
  40. u8 tpm_processing_cmd;
  41. };
  42. #define CRQ_RES_BUF_SIZE PAGE_SIZE
  43. /* Initialize CRQ */
  44. #define INIT_CRQ_CMD 0xC001000000000000LL /* Init cmd */
  45. #define INIT_CRQ_COMP_CMD 0xC002000000000000LL /* Init complete cmd */
  46. #define INIT_CRQ_RES 0x01 /* Init respond */
  47. #define INIT_CRQ_COMP_RES 0x02 /* Init complete respond */
  48. #define VALID_INIT_CRQ 0xC0 /* Valid command for init crq */
  49. /* vTPM CRQ response is the message type | 0x80 */
  50. #define VTPM_MSG_RES 0x80
  51. #define IBMVTPM_VALID_CMD 0x80
  52. /* vTPM CRQ message types */
  53. #define VTPM_GET_VERSION 0x01
  54. #define VTPM_GET_VERSION_RES (0x01 | VTPM_MSG_RES)
  55. #define VTPM_TPM_COMMAND 0x02
  56. #define VTPM_TPM_COMMAND_RES (0x02 | VTPM_MSG_RES)
  57. #define VTPM_GET_RTCE_BUFFER_SIZE 0x03
  58. #define VTPM_GET_RTCE_BUFFER_SIZE_RES (0x03 | VTPM_MSG_RES)
  59. #define VTPM_PREPARE_TO_SUSPEND 0x04
  60. #define VTPM_PREPARE_TO_SUSPEND_RES (0x04 | VTPM_MSG_RES)
  61. #endif