Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 2 | /* |
| 3 | * AMD Platform Security Processor (PSP) interface driver |
| 4 | * |
Hook, Gary | fa5cd1c | 2018-12-18 15:48:29 +0000 | [diff] [blame] | 5 | * Copyright (C) 2017-2018 Advanced Micro Devices, Inc. |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 6 | * |
| 7 | * Author: Brijesh Singh <brijesh.singh@amd.com> |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 8 | */ |
| 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 Singh | 200664d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 25 | #include <linux/psp-sev.h> |
| 26 | #include <linux/miscdevice.h> |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 27 | |
| 28 | #include "sp-dev.h" |
| 29 | |
Tom Lendacky | 03af912 | 2018-07-03 12:11:52 -0500 | [diff] [blame] | 30 | #define PSP_CMD_COMPLETE BIT(1) |
Brijesh Singh | 200664d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 31 | |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 32 | #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 Singh | 200664d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 39 | struct sev_misc_dev { |
| 40 | struct kref refcount; |
| 41 | struct miscdevice misc; |
| 42 | }; |
| 43 | |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 44 | struct 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 Singh | 200664d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 54 | |
| 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 Natarajan | edd303f | 2018-05-25 15:23:29 -0500 | [diff] [blame] | 61 | |
| 62 | u8 api_major; |
| 63 | u8 api_minor; |
| 64 | u8 build; |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | #endif /* __PSP_DEV_H */ |