blob: f5afeccf42a1a28d926c60bca94cc33518a2e4c4 [file] [log] [blame]
Brijesh Singh2a6170d2017-12-04 10:57:28 -06001/*
2 * AMD Platform Security Processor (PSP) interface driver
3 *
Hook, Garyfa5cd1c2018-12-18 15:48:29 +00004 * Copyright (C) 2017-2018 Advanced Micro Devices, Inc.
Brijesh Singh2a6170d2017-12-04 10:57:28 -06005 *
6 * Author: Brijesh Singh <brijesh.singh@amd.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __PSP_DEV_H__
14#define __PSP_DEV_H__
15
16#include <linux/device.h>
17#include <linux/pci.h>
18#include <linux/spinlock.h>
19#include <linux/mutex.h>
20#include <linux/list.h>
21#include <linux/wait.h>
22#include <linux/dmapool.h>
23#include <linux/hw_random.h>
24#include <linux/bitops.h>
25#include <linux/interrupt.h>
26#include <linux/irqreturn.h>
27#include <linux/dmaengine.h>
Brijesh Singh200664d2017-12-04 10:57:28 -060028#include <linux/psp-sev.h>
29#include <linux/miscdevice.h>
Brijesh Singh2a6170d2017-12-04 10:57:28 -060030
31#include "sp-dev.h"
32
Tom Lendacky03af9122018-07-03 12:11:52 -050033#define PSP_CMD_COMPLETE BIT(1)
Brijesh Singh200664d2017-12-04 10:57:28 -060034
Brijesh Singh2a6170d2017-12-04 10:57:28 -060035#define PSP_CMDRESP_CMD_SHIFT 16
36#define PSP_CMDRESP_IOC BIT(0)
37#define PSP_CMDRESP_RESP BIT(31)
38#define PSP_CMDRESP_ERR_MASK 0xffff
39
40#define MAX_PSP_NAME_LEN 16
41
Brijesh Singh200664d2017-12-04 10:57:28 -060042struct sev_misc_dev {
43 struct kref refcount;
44 struct miscdevice misc;
45};
46
Brijesh Singh2a6170d2017-12-04 10:57:28 -060047struct psp_device {
48 struct list_head entry;
49
50 struct psp_vdata *vdata;
51 char name[MAX_PSP_NAME_LEN];
52
53 struct device *dev;
54 struct sp_device *sp;
55
56 void __iomem *io_regs;
Brijesh Singh200664d2017-12-04 10:57:28 -060057
58 int sev_state;
59 unsigned int sev_int_rcvd;
60 wait_queue_head_t sev_int_queue;
61 struct sev_misc_dev *sev_misc;
62 struct sev_user_data_status status_cmd_buf;
63 struct sev_data_init init_cmd_buf;
Janakarajan Natarajanedd303f2018-05-25 15:23:29 -050064
65 u8 api_major;
66 u8 api_minor;
67 u8 build;
Brijesh Singh2a6170d2017-12-04 10:57:28 -060068};
69
70#endif /* __PSP_DEV_H */