Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2012 IBM Corporation
0004  *
0005  * Author: Ashley Lai <ashleydlai@gmail.com>
0006  *
0007  * Maintained by: <tpmdd-devel@lists.sourceforge.net>
0008  *
0009  * Device driver for TCG/TCPA TPM (trusted platform module).
0010  * Specifications at www.trustedcomputinggroup.org
0011  */
0012 
0013 #ifndef __TPM_IBMVTPM_H__
0014 #define __TPM_IBMVTPM_H__
0015 
0016 /* vTPM Message Format 1 */
0017 struct ibmvtpm_crq {
0018     u8 valid;
0019     u8 msg;
0020     __be16 len;
0021     __be32 data;
0022     __be64 reserved;
0023 } __attribute__((packed, aligned(8)));
0024 
0025 struct ibmvtpm_crq_queue {
0026     struct ibmvtpm_crq *crq_addr;
0027     u32 index;
0028     u32 num_entry;
0029     wait_queue_head_t wq;
0030 };
0031 
0032 struct ibmvtpm_dev {
0033     struct device *dev;
0034     struct vio_dev *vdev;
0035     struct ibmvtpm_crq_queue crq_queue;
0036     dma_addr_t crq_dma_handle;
0037     u32 rtce_size;
0038     void __iomem *rtce_buf;
0039     dma_addr_t rtce_dma_handle;
0040     spinlock_t rtce_lock;
0041     wait_queue_head_t wq;
0042     u16 res_len;
0043     u32 vtpm_version;
0044     u8 tpm_processing_cmd;
0045 };
0046 
0047 #define CRQ_RES_BUF_SIZE    PAGE_SIZE
0048 
0049 /* Initialize CRQ */
0050 #define INIT_CRQ_CMD        0xC001000000000000LL /* Init cmd */
0051 #define INIT_CRQ_COMP_CMD   0xC002000000000000LL /* Init complete cmd */
0052 #define INIT_CRQ_RES        0x01    /* Init respond */
0053 #define INIT_CRQ_COMP_RES   0x02    /* Init complete respond */
0054 #define VALID_INIT_CRQ      0xC0    /* Valid command for init crq */
0055 
0056 /* vTPM CRQ response is the message type | 0x80 */
0057 #define VTPM_MSG_RES        0x80
0058 #define IBMVTPM_VALID_CMD   0x80
0059 
0060 /* vTPM CRQ message types */
0061 #define VTPM_GET_VERSION            0x01
0062 #define VTPM_GET_VERSION_RES            (0x01 | VTPM_MSG_RES)
0063 
0064 #define VTPM_TPM_COMMAND            0x02
0065 #define VTPM_TPM_COMMAND_RES            (0x02 | VTPM_MSG_RES)
0066 
0067 #define VTPM_GET_RTCE_BUFFER_SIZE       0x03
0068 #define VTPM_GET_RTCE_BUFFER_SIZE_RES       (0x03 | VTPM_MSG_RES)
0069 
0070 #define VTPM_PREPARE_TO_SUSPEND         0x04
0071 #define VTPM_PREPARE_TO_SUSPEND_RES     (0x04 | VTPM_MSG_RES)
0072 
0073 #endif