blob: 666c21eb81ab35e94a56c9a28bce47b56e35bf88 [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 *
Rijo Thomas9b67d082019-12-04 11:48:58 +05305 * Copyright (C) 2017-2019 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
Rijo Thomas9b67d082019-12-04 11:48:58 +053010#ifndef __SEV_DEV_H__
11#define __SEV_DEV_H__
Brijesh Singh2a6170d2017-12-04 10:57:28 -060012
13#include <linux/device.h>
Brijesh Singh2a6170d2017-12-04 10:57:28 -060014#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>
Brijesh Singh200664d2017-12-04 10:57:28 -060024#include <linux/psp-sev.h>
25#include <linux/miscdevice.h>
Brijesh Singhec310ca2019-11-12 13:58:34 -060026#include <linux/capability.h>
Brijesh Singh2a6170d2017-12-04 10:57:28 -060027
Rijo Thomasb93566f2019-12-04 11:48:59 +053028#define SEV_CMD_COMPLETE BIT(1)
29#define SEV_CMDRESP_CMD_SHIFT 16
30#define SEV_CMDRESP_IOC BIT(0)
Brijesh Singh2a6170d2017-12-04 10:57:28 -060031
Brijesh Singh200664d2017-12-04 10:57:28 -060032struct sev_misc_dev {
33 struct kref refcount;
34 struct miscdevice misc;
35};
36
Rijo Thomasb93566f2019-12-04 11:48:59 +053037struct sev_device {
Brijesh Singh2a6170d2017-12-04 10:57:28 -060038 struct device *dev;
Rijo Thomasb93566f2019-12-04 11:48:59 +053039 struct psp_device *psp;
Brijesh Singh2a6170d2017-12-04 10:57:28 -060040
41 void __iomem *io_regs;
Brijesh Singh200664d2017-12-04 10:57:28 -060042
Rijo Thomas6eb0cc72019-12-04 11:49:00 +053043 struct sev_vdata *vdata;
44
Rijo Thomasb93566f2019-12-04 11:48:59 +053045 int state;
46 unsigned int int_rcvd;
47 wait_queue_head_t int_queue;
48 struct sev_misc_dev *misc;
Janakarajan Natarajanedd303f2018-05-25 15:23:29 -050049
50 u8 api_major;
51 u8 api_minor;
52 u8 build;
Sean Christopherson8347b992021-04-06 15:49:48 -070053
54 void *cmd_buf;
Brijesh Singh2a6170d2017-12-04 10:57:28 -060055};
56
Rijo Thomasb93566f2019-12-04 11:48:59 +053057int sev_dev_init(struct psp_device *psp);
58void sev_dev_destroy(struct psp_device *psp);
59
60void sev_pci_init(void);
61void sev_pci_exit(void);
62
Rijo Thomas9b67d082019-12-04 11:48:58 +053063#endif /* __SEV_DEV_H */