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 | * |
Rijo Thomas | 9b67d08 | 2019-12-04 11:48:58 +0530 | [diff] [blame] | 5 | * Copyright (C) 2017-2019 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 | |
Rijo Thomas | 9b67d08 | 2019-12-04 11:48:58 +0530 | [diff] [blame] | 10 | #ifndef __SEV_DEV_H__ |
| 11 | #define __SEV_DEV_H__ |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 12 | |
| 13 | #include <linux/device.h> |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 14 | #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 Singh | 200664d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 24 | #include <linux/psp-sev.h> |
| 25 | #include <linux/miscdevice.h> |
Brijesh Singh | ec310ca | 2019-11-12 13:58:34 -0600 | [diff] [blame] | 26 | #include <linux/capability.h> |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 27 | |
Rijo Thomas | b93566f | 2019-12-04 11:48:59 +0530 | [diff] [blame] | 28 | #define SEV_CMD_COMPLETE BIT(1) |
| 29 | #define SEV_CMDRESP_CMD_SHIFT 16 |
| 30 | #define SEV_CMDRESP_IOC BIT(0) |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 31 | |
Brijesh Singh | 200664d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 32 | struct sev_misc_dev { |
| 33 | struct kref refcount; |
| 34 | struct miscdevice misc; |
| 35 | }; |
| 36 | |
Rijo Thomas | b93566f | 2019-12-04 11:48:59 +0530 | [diff] [blame] | 37 | struct sev_device { |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 38 | struct device *dev; |
Rijo Thomas | b93566f | 2019-12-04 11:48:59 +0530 | [diff] [blame] | 39 | struct psp_device *psp; |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 40 | |
| 41 | void __iomem *io_regs; |
Brijesh Singh | 200664d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 42 | |
Rijo Thomas | 6eb0cc7 | 2019-12-04 11:49:00 +0530 | [diff] [blame] | 43 | struct sev_vdata *vdata; |
| 44 | |
Rijo Thomas | b93566f | 2019-12-04 11:48:59 +0530 | [diff] [blame] | 45 | int state; |
| 46 | unsigned int int_rcvd; |
| 47 | wait_queue_head_t int_queue; |
| 48 | struct sev_misc_dev *misc; |
Janakarajan Natarajan | edd303f | 2018-05-25 15:23:29 -0500 | [diff] [blame] | 49 | |
| 50 | u8 api_major; |
| 51 | u8 api_minor; |
| 52 | u8 build; |
Sean Christopherson | 8347b99 | 2021-04-06 15:49:48 -0700 | [diff] [blame] | 53 | |
| 54 | void *cmd_buf; |
Brijesh Singh | 2a6170d | 2017-12-04 10:57:28 -0600 | [diff] [blame] | 55 | }; |
| 56 | |
Rijo Thomas | b93566f | 2019-12-04 11:48:59 +0530 | [diff] [blame] | 57 | int sev_dev_init(struct psp_device *psp); |
| 58 | void sev_dev_destroy(struct psp_device *psp); |
| 59 | |
| 60 | void sev_pci_init(void); |
| 61 | void sev_pci_exit(void); |
| 62 | |
Rijo Thomas | 9b67d08 | 2019-12-04 11:48:58 +0530 | [diff] [blame] | 63 | #endif /* __SEV_DEV_H */ |