blob: 3d84ac380bdc2b00905260027b82c0995d447328 [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 Thomasb93566f2019-12-04 11:48:59 +053043 int state;
44 unsigned int int_rcvd;
45 wait_queue_head_t int_queue;
46 struct sev_misc_dev *misc;
Brijesh Singh200664d2017-12-04 10:57:28 -060047 struct sev_user_data_status status_cmd_buf;
48 struct sev_data_init init_cmd_buf;
Janakarajan Natarajanedd303f2018-05-25 15:23:29 -050049
50 u8 api_major;
51 u8 api_minor;
52 u8 build;
Brijesh Singh2a6170d2017-12-04 10:57:28 -060053};
54
Rijo Thomasb93566f2019-12-04 11:48:59 +053055int sev_dev_init(struct psp_device *psp);
56void sev_dev_destroy(struct psp_device *psp);
57
58void sev_pci_init(void);
59void sev_pci_exit(void);
60
Rijo Thomas9b67d082019-12-04 11:48:58 +053061#endif /* __SEV_DEV_H */