1*b886d83cSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2132f7629SAshley Lai /* 3132f7629SAshley Lai * Copyright (C) 2012 IBM Corporation 4132f7629SAshley Lai * 51a0f1b27SAshley Lai * Author: Ashley Lai <ashleydlai@gmail.com> 6132f7629SAshley Lai * 7132f7629SAshley Lai * Maintained by: <tpmdd-devel@lists.sourceforge.net> 8132f7629SAshley Lai * 9132f7629SAshley Lai * Device driver for TCG/TCPA TPM (trusted platform module). 10132f7629SAshley Lai * Specifications at www.trustedcomputinggroup.org 11132f7629SAshley Lai */ 12132f7629SAshley Lai 13132f7629SAshley Lai #ifndef __TPM_IBMVTPM_H__ 14132f7629SAshley Lai #define __TPM_IBMVTPM_H__ 15132f7629SAshley Lai 16132f7629SAshley Lai /* vTPM Message Format 1 */ 17132f7629SAshley Lai struct ibmvtpm_crq { 18132f7629SAshley Lai u8 valid; 19132f7629SAshley Lai u8 msg; 2062dfd912Sjmlatten@linux.vnet.ibm.com __be16 len; 2162dfd912Sjmlatten@linux.vnet.ibm.com __be32 data; 2262dfd912Sjmlatten@linux.vnet.ibm.com __be64 reserved; 23132f7629SAshley Lai } __attribute__((packed, aligned(8))); 24132f7629SAshley Lai 25132f7629SAshley Lai struct ibmvtpm_crq_queue { 26132f7629SAshley Lai struct ibmvtpm_crq *crq_addr; 27132f7629SAshley Lai u32 index; 28132f7629SAshley Lai u32 num_entry; 29132f7629SAshley Lai }; 30132f7629SAshley Lai 31132f7629SAshley Lai struct ibmvtpm_dev { 32132f7629SAshley Lai struct device *dev; 33132f7629SAshley Lai struct vio_dev *vdev; 34132f7629SAshley Lai struct ibmvtpm_crq_queue crq_queue; 35132f7629SAshley Lai dma_addr_t crq_dma_handle; 36132f7629SAshley Lai u32 rtce_size; 37132f7629SAshley Lai void __iomem *rtce_buf; 38132f7629SAshley Lai dma_addr_t rtce_dma_handle; 39132f7629SAshley Lai spinlock_t rtce_lock; 40b5666502SAshley Lai wait_queue_head_t wq; 41b5666502SAshley Lai u16 res_len; 42132f7629SAshley Lai u32 vtpm_version; 436674ff14SStefan Berger bool tpm_processing_cmd; 44132f7629SAshley Lai }; 45132f7629SAshley Lai 46132f7629SAshley Lai #define CRQ_RES_BUF_SIZE PAGE_SIZE 47132f7629SAshley Lai 48132f7629SAshley Lai /* Initialize CRQ */ 49132f7629SAshley Lai #define INIT_CRQ_CMD 0xC001000000000000LL /* Init cmd */ 50132f7629SAshley Lai #define INIT_CRQ_COMP_CMD 0xC002000000000000LL /* Init complete cmd */ 51132f7629SAshley Lai #define INIT_CRQ_RES 0x01 /* Init respond */ 52132f7629SAshley Lai #define INIT_CRQ_COMP_RES 0x02 /* Init complete respond */ 53132f7629SAshley Lai #define VALID_INIT_CRQ 0xC0 /* Valid command for init crq */ 54132f7629SAshley Lai 55132f7629SAshley Lai /* vTPM CRQ response is the message type | 0x80 */ 56132f7629SAshley Lai #define VTPM_MSG_RES 0x80 57132f7629SAshley Lai #define IBMVTPM_VALID_CMD 0x80 58132f7629SAshley Lai 59132f7629SAshley Lai /* vTPM CRQ message types */ 60132f7629SAshley Lai #define VTPM_GET_VERSION 0x01 61132f7629SAshley Lai #define VTPM_GET_VERSION_RES (0x01 | VTPM_MSG_RES) 62132f7629SAshley Lai 63132f7629SAshley Lai #define VTPM_TPM_COMMAND 0x02 64132f7629SAshley Lai #define VTPM_TPM_COMMAND_RES (0x02 | VTPM_MSG_RES) 65132f7629SAshley Lai 66132f7629SAshley Lai #define VTPM_GET_RTCE_BUFFER_SIZE 0x03 67132f7629SAshley Lai #define VTPM_GET_RTCE_BUFFER_SIZE_RES (0x03 | VTPM_MSG_RES) 68132f7629SAshley Lai 69132f7629SAshley Lai #define VTPM_PREPARE_TO_SUSPEND 0x04 70132f7629SAshley Lai #define VTPM_PREPARE_TO_SUSPEND_RES (0x04 | VTPM_MSG_RES) 71132f7629SAshley Lai 72132f7629SAshley Lai #endif 73