xref: /openbmc/linux/drivers/crypto/ccp/psp-dev.h (revision de528723)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * AMD Platform Security Processor (PSP) interface driver
4  *
5  * Copyright (C) 2017-2018 Advanced Micro Devices, Inc.
6  *
7  * Author: Brijesh Singh <brijesh.singh@amd.com>
8  */
9 
10 #ifndef __PSP_DEV_H__
11 #define __PSP_DEV_H__
12 
13 #include <linux/device.h>
14 #include <linux/spinlock.h>
15 #include <linux/mutex.h>
16 #include <linux/list.h>
17 #include <linux/wait.h>
18 #include <linux/dmapool.h>
19 #include <linux/hw_random.h>
20 #include <linux/bitops.h>
21 #include <linux/interrupt.h>
22 #include <linux/irqreturn.h>
23 #include <linux/dmaengine.h>
24 #include <linux/psp-sev.h>
25 #include <linux/miscdevice.h>
26 
27 #include "sp-dev.h"
28 
29 #define PSP_CMD_COMPLETE		BIT(1)
30 
31 #define PSP_CMDRESP_CMD_SHIFT		16
32 #define PSP_CMDRESP_IOC			BIT(0)
33 #define PSP_CMDRESP_RESP		BIT(31)
34 #define PSP_CMDRESP_ERR_MASK		0xffff
35 
36 #define MAX_PSP_NAME_LEN		16
37 
38 struct sev_misc_dev {
39 	struct kref refcount;
40 	struct miscdevice misc;
41 };
42 
43 struct psp_device {
44 	struct list_head entry;
45 
46 	struct psp_vdata *vdata;
47 	char name[MAX_PSP_NAME_LEN];
48 
49 	struct device *dev;
50 	struct sp_device *sp;
51 
52 	void __iomem *io_regs;
53 
54 	int sev_state;
55 	unsigned int sev_int_rcvd;
56 	wait_queue_head_t sev_int_queue;
57 	struct sev_misc_dev *sev_misc;
58 	struct sev_user_data_status status_cmd_buf;
59 	struct sev_data_init init_cmd_buf;
60 
61 	u8 api_major;
62 	u8 api_minor;
63 	u8 build;
64 };
65 
66 #endif /* __PSP_DEV_H */
67