xref: /openbmc/linux/drivers/char/tpm/tpm_ibmvtpm.h (revision 132f7629474424418a5cdd666796ad3cfa4dc0c5)
1*132f7629SAshley Lai /*
2*132f7629SAshley Lai  * Copyright (C) 2012 IBM Corporation
3*132f7629SAshley Lai  *
4*132f7629SAshley Lai  * Author: Ashley Lai <adlai@us.ibm.com>
5*132f7629SAshley Lai  *
6*132f7629SAshley Lai  * Maintained by: <tpmdd-devel@lists.sourceforge.net>
7*132f7629SAshley Lai  *
8*132f7629SAshley Lai  * Device driver for TCG/TCPA TPM (trusted platform module).
9*132f7629SAshley Lai  * Specifications at www.trustedcomputinggroup.org
10*132f7629SAshley Lai  *
11*132f7629SAshley Lai  * This program is free software; you can redistribute it and/or
12*132f7629SAshley Lai  * modify it under the terms of the GNU General Public License as
13*132f7629SAshley Lai  * published by the Free Software Foundation, version 2 of the
14*132f7629SAshley Lai  * License.
15*132f7629SAshley Lai  *
16*132f7629SAshley Lai  */
17*132f7629SAshley Lai 
18*132f7629SAshley Lai #ifndef __TPM_IBMVTPM_H__
19*132f7629SAshley Lai #define __TPM_IBMVTPM_H__
20*132f7629SAshley Lai 
21*132f7629SAshley Lai /* vTPM Message Format 1 */
22*132f7629SAshley Lai struct ibmvtpm_crq {
23*132f7629SAshley Lai 	u8 valid;
24*132f7629SAshley Lai 	u8 msg;
25*132f7629SAshley Lai 	u16 len;
26*132f7629SAshley Lai 	u32 data;
27*132f7629SAshley Lai 	u64 reserved;
28*132f7629SAshley Lai } __attribute__((packed, aligned(8)));
29*132f7629SAshley Lai 
30*132f7629SAshley Lai struct ibmvtpm_crq_queue {
31*132f7629SAshley Lai 	struct ibmvtpm_crq *crq_addr;
32*132f7629SAshley Lai 	u32 index;
33*132f7629SAshley Lai 	u32 num_entry;
34*132f7629SAshley Lai };
35*132f7629SAshley Lai 
36*132f7629SAshley Lai struct ibmvtpm_dev {
37*132f7629SAshley Lai 	struct device *dev;
38*132f7629SAshley Lai 	struct vio_dev *vdev;
39*132f7629SAshley Lai 	struct ibmvtpm_crq_queue crq_queue;
40*132f7629SAshley Lai 	dma_addr_t crq_dma_handle;
41*132f7629SAshley Lai 	spinlock_t lock;
42*132f7629SAshley Lai 	struct tasklet_struct tasklet;
43*132f7629SAshley Lai 	u32 rtce_size;
44*132f7629SAshley Lai 	void __iomem *rtce_buf;
45*132f7629SAshley Lai 	dma_addr_t rtce_dma_handle;
46*132f7629SAshley Lai 	spinlock_t rtce_lock;
47*132f7629SAshley Lai 	struct ibmvtpm_crq crq_res;
48*132f7629SAshley Lai 	u32 vtpm_version;
49*132f7629SAshley Lai };
50*132f7629SAshley Lai 
51*132f7629SAshley Lai #define CRQ_RES_BUF_SIZE	PAGE_SIZE
52*132f7629SAshley Lai 
53*132f7629SAshley Lai /* Initialize CRQ */
54*132f7629SAshley Lai #define INIT_CRQ_CMD		0xC001000000000000LL /* Init cmd */
55*132f7629SAshley Lai #define INIT_CRQ_COMP_CMD	0xC002000000000000LL /* Init complete cmd */
56*132f7629SAshley Lai #define INIT_CRQ_RES		0x01	/* Init respond */
57*132f7629SAshley Lai #define INIT_CRQ_COMP_RES	0x02	/* Init complete respond */
58*132f7629SAshley Lai #define VALID_INIT_CRQ		0xC0	/* Valid command for init crq */
59*132f7629SAshley Lai 
60*132f7629SAshley Lai /* vTPM CRQ response is the message type | 0x80 */
61*132f7629SAshley Lai #define VTPM_MSG_RES		0x80
62*132f7629SAshley Lai #define IBMVTPM_VALID_CMD	0x80
63*132f7629SAshley Lai 
64*132f7629SAshley Lai /* vTPM CRQ message types */
65*132f7629SAshley Lai #define VTPM_GET_VERSION			0x01
66*132f7629SAshley Lai #define VTPM_GET_VERSION_RES			(0x01 | VTPM_MSG_RES)
67*132f7629SAshley Lai 
68*132f7629SAshley Lai #define VTPM_TPM_COMMAND			0x02
69*132f7629SAshley Lai #define VTPM_TPM_COMMAND_RES			(0x02 | VTPM_MSG_RES)
70*132f7629SAshley Lai 
71*132f7629SAshley Lai #define VTPM_GET_RTCE_BUFFER_SIZE		0x03
72*132f7629SAshley Lai #define VTPM_GET_RTCE_BUFFER_SIZE_RES		(0x03 | VTPM_MSG_RES)
73*132f7629SAshley Lai 
74*132f7629SAshley Lai #define VTPM_PREPARE_TO_SUSPEND			0x04
75*132f7629SAshley Lai #define VTPM_PREPARE_TO_SUSPEND_RES		(0x04 | VTPM_MSG_RES)
76*132f7629SAshley Lai 
77*132f7629SAshley Lai #endif
78