xref: /openbmc/linux/drivers/char/tpm/tpm_ibmvtpm.h (revision 1a0f1b279c2c4e5747a682b055d27d88e35bb632)
1132f7629SAshley Lai /*
2132f7629SAshley Lai  * Copyright (C) 2012 IBM Corporation
3132f7629SAshley Lai  *
4*1a0f1b27SAshley Lai  * Author: Ashley Lai <ashleydlai@gmail.com>
5132f7629SAshley Lai  *
6132f7629SAshley Lai  * Maintained by: <tpmdd-devel@lists.sourceforge.net>
7132f7629SAshley Lai  *
8132f7629SAshley Lai  * Device driver for TCG/TCPA TPM (trusted platform module).
9132f7629SAshley Lai  * Specifications at www.trustedcomputinggroup.org
10132f7629SAshley Lai  *
11132f7629SAshley Lai  * This program is free software; you can redistribute it and/or
12132f7629SAshley Lai  * modify it under the terms of the GNU General Public License as
13132f7629SAshley Lai  * published by the Free Software Foundation, version 2 of the
14132f7629SAshley Lai  * License.
15132f7629SAshley Lai  *
16132f7629SAshley Lai  */
17132f7629SAshley Lai 
18132f7629SAshley Lai #ifndef __TPM_IBMVTPM_H__
19132f7629SAshley Lai #define __TPM_IBMVTPM_H__
20132f7629SAshley Lai 
21132f7629SAshley Lai /* vTPM Message Format 1 */
22132f7629SAshley Lai struct ibmvtpm_crq {
23132f7629SAshley Lai 	u8 valid;
24132f7629SAshley Lai 	u8 msg;
25132f7629SAshley Lai 	u16 len;
26132f7629SAshley Lai 	u32 data;
27132f7629SAshley Lai 	u64 reserved;
28132f7629SAshley Lai } __attribute__((packed, aligned(8)));
29132f7629SAshley Lai 
30132f7629SAshley Lai struct ibmvtpm_crq_queue {
31132f7629SAshley Lai 	struct ibmvtpm_crq *crq_addr;
32132f7629SAshley Lai 	u32 index;
33132f7629SAshley Lai 	u32 num_entry;
34132f7629SAshley Lai };
35132f7629SAshley Lai 
36132f7629SAshley Lai struct ibmvtpm_dev {
37132f7629SAshley Lai 	struct device *dev;
38132f7629SAshley Lai 	struct vio_dev *vdev;
39132f7629SAshley Lai 	struct ibmvtpm_crq_queue crq_queue;
40132f7629SAshley Lai 	dma_addr_t crq_dma_handle;
41132f7629SAshley Lai 	u32 rtce_size;
42132f7629SAshley Lai 	void __iomem *rtce_buf;
43132f7629SAshley Lai 	dma_addr_t rtce_dma_handle;
44132f7629SAshley Lai 	spinlock_t rtce_lock;
45b5666502SAshley Lai 	wait_queue_head_t wq;
46b5666502SAshley Lai 	u16 res_len;
47132f7629SAshley Lai 	u32 vtpm_version;
48132f7629SAshley Lai };
49132f7629SAshley Lai 
50132f7629SAshley Lai #define CRQ_RES_BUF_SIZE	PAGE_SIZE
51132f7629SAshley Lai 
52132f7629SAshley Lai /* Initialize CRQ */
53132f7629SAshley Lai #define INIT_CRQ_CMD		0xC001000000000000LL /* Init cmd */
54132f7629SAshley Lai #define INIT_CRQ_COMP_CMD	0xC002000000000000LL /* Init complete cmd */
55132f7629SAshley Lai #define INIT_CRQ_RES		0x01	/* Init respond */
56132f7629SAshley Lai #define INIT_CRQ_COMP_RES	0x02	/* Init complete respond */
57132f7629SAshley Lai #define VALID_INIT_CRQ		0xC0	/* Valid command for init crq */
58132f7629SAshley Lai 
59132f7629SAshley Lai /* vTPM CRQ response is the message type | 0x80 */
60132f7629SAshley Lai #define VTPM_MSG_RES		0x80
61132f7629SAshley Lai #define IBMVTPM_VALID_CMD	0x80
62132f7629SAshley Lai 
63132f7629SAshley Lai /* vTPM CRQ message types */
64132f7629SAshley Lai #define VTPM_GET_VERSION			0x01
65132f7629SAshley Lai #define VTPM_GET_VERSION_RES			(0x01 | VTPM_MSG_RES)
66132f7629SAshley Lai 
67132f7629SAshley Lai #define VTPM_TPM_COMMAND			0x02
68132f7629SAshley Lai #define VTPM_TPM_COMMAND_RES			(0x02 | VTPM_MSG_RES)
69132f7629SAshley Lai 
70132f7629SAshley Lai #define VTPM_GET_RTCE_BUFFER_SIZE		0x03
71132f7629SAshley Lai #define VTPM_GET_RTCE_BUFFER_SIZE_RES		(0x03 | VTPM_MSG_RES)
72132f7629SAshley Lai 
73132f7629SAshley Lai #define VTPM_PREPARE_TO_SUSPEND			0x04
74132f7629SAshley Lai #define VTPM_PREPARE_TO_SUSPEND_RES		(0x04 | VTPM_MSG_RES)
75132f7629SAshley Lai 
76132f7629SAshley Lai #endif
77