blob: c5e06c92d40e9eb1c89796ede42ed036b7a5ac5c [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Brijesh Singh2a6170d2017-12-04 10:57:28 -06002/*
3 * AMD Platform Security Processor (PSP) interface driver
4 *
Hook, Garyfa5cd1c2018-12-18 15:48:29 +00005 * Copyright (C) 2017-2018 Advanced Micro Devices, Inc.
Brijesh Singh2a6170d2017-12-04 10:57:28 -06006 *
7 * Author: Brijesh Singh <brijesh.singh@amd.com>
Brijesh Singh2a6170d2017-12-04 10:57:28 -06008 */
9
10#ifndef __PSP_DEV_H__
11#define __PSP_DEV_H__
12
13#include <linux/device.h>
14#include <linux/pci.h>
15#include <linux/spinlock.h>
16#include <linux/mutex.h>
17#include <linux/list.h>
18#include <linux/wait.h>
19#include <linux/dmapool.h>
20#include <linux/hw_random.h>
21#include <linux/bitops.h>
22#include <linux/interrupt.h>
23#include <linux/irqreturn.h>
24#include <linux/dmaengine.h>
Brijesh Singh200664d2017-12-04 10:57:28 -060025#include <linux/psp-sev.h>
26#include <linux/miscdevice.h>
Brijesh Singh2a6170d2017-12-04 10:57:28 -060027
28#include "sp-dev.h"
29
Tom Lendacky03af9122018-07-03 12:11:52 -050030#define PSP_CMD_COMPLETE BIT(1)
Brijesh Singh200664d2017-12-04 10:57:28 -060031
Brijesh Singh2a6170d2017-12-04 10:57:28 -060032#define PSP_CMDRESP_CMD_SHIFT 16
33#define PSP_CMDRESP_IOC BIT(0)
34#define PSP_CMDRESP_RESP BIT(31)
35#define PSP_CMDRESP_ERR_MASK 0xffff
36
37#define MAX_PSP_NAME_LEN 16
38
Brijesh Singh200664d2017-12-04 10:57:28 -060039struct sev_misc_dev {
40 struct kref refcount;
41 struct miscdevice misc;
42};
43
Brijesh Singh2a6170d2017-12-04 10:57:28 -060044struct psp_device {
45 struct list_head entry;
46
47 struct psp_vdata *vdata;
48 char name[MAX_PSP_NAME_LEN];
49
50 struct device *dev;
51 struct sp_device *sp;
52
53 void __iomem *io_regs;
Brijesh Singh200664d2017-12-04 10:57:28 -060054
55 int sev_state;
56 unsigned int sev_int_rcvd;
57 wait_queue_head_t sev_int_queue;
58 struct sev_misc_dev *sev_misc;
59 struct sev_user_data_status status_cmd_buf;
60 struct sev_data_init init_cmd_buf;
Janakarajan Natarajanedd303f2018-05-25 15:23:29 -050061
62 u8 api_major;
63 u8 api_minor;
64 u8 build;
Brijesh Singh2a6170d2017-12-04 10:57:28 -060065};
66
67#endif /* __PSP_DEV_H */