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