xref: /openbmc/linux/drivers/crypto/ccp/sev-dev.h (revision 1c5c1daf)
19b67d08dSRijo Thomas /* SPDX-License-Identifier: GPL-2.0-only */
29b67d08dSRijo Thomas /*
39b67d08dSRijo Thomas  * AMD Platform Security Processor (PSP) interface driver
49b67d08dSRijo Thomas  *
59b67d08dSRijo Thomas  * Copyright (C) 2017-2019 Advanced Micro Devices, Inc.
69b67d08dSRijo Thomas  *
79b67d08dSRijo Thomas  * Author: Brijesh Singh <brijesh.singh@amd.com>
89b67d08dSRijo Thomas  */
99b67d08dSRijo Thomas 
109b67d08dSRijo Thomas #ifndef __SEV_DEV_H__
119b67d08dSRijo Thomas #define __SEV_DEV_H__
129b67d08dSRijo Thomas 
139b67d08dSRijo Thomas #include <linux/device.h>
149b67d08dSRijo Thomas #include <linux/spinlock.h>
159b67d08dSRijo Thomas #include <linux/mutex.h>
169b67d08dSRijo Thomas #include <linux/list.h>
179b67d08dSRijo Thomas #include <linux/wait.h>
189b67d08dSRijo Thomas #include <linux/dmapool.h>
199b67d08dSRijo Thomas #include <linux/hw_random.h>
209b67d08dSRijo Thomas #include <linux/bitops.h>
219b67d08dSRijo Thomas #include <linux/interrupt.h>
229b67d08dSRijo Thomas #include <linux/irqreturn.h>
239b67d08dSRijo Thomas #include <linux/dmaengine.h>
249b67d08dSRijo Thomas #include <linux/psp-sev.h>
259b67d08dSRijo Thomas #include <linux/miscdevice.h>
269b67d08dSRijo Thomas #include <linux/capability.h>
279b67d08dSRijo Thomas 
28*1c5c1dafSMario Limonciello #define SEV_CMDRESP_CMD			GENMASK(26, 16)
29b93566f1SRijo Thomas #define SEV_CMD_COMPLETE		BIT(1)
30b93566f1SRijo Thomas #define SEV_CMDRESP_IOC			BIT(0)
319b67d08dSRijo Thomas 
329b67d08dSRijo Thomas struct sev_misc_dev {
339b67d08dSRijo Thomas 	struct kref refcount;
349b67d08dSRijo Thomas 	struct miscdevice misc;
359b67d08dSRijo Thomas };
369b67d08dSRijo Thomas 
37b93566f1SRijo Thomas struct sev_device {
389b67d08dSRijo Thomas 	struct device *dev;
39b93566f1SRijo Thomas 	struct psp_device *psp;
409b67d08dSRijo Thomas 
419b67d08dSRijo Thomas 	void __iomem *io_regs;
429b67d08dSRijo Thomas 
436eb0cc72SRijo Thomas 	struct sev_vdata *vdata;
446eb0cc72SRijo Thomas 
45b93566f1SRijo Thomas 	int state;
46b93566f1SRijo Thomas 	unsigned int int_rcvd;
47b93566f1SRijo Thomas 	wait_queue_head_t int_queue;
48b93566f1SRijo Thomas 	struct sev_misc_dev *misc;
499b67d08dSRijo Thomas 
509b67d08dSRijo Thomas 	u8 api_major;
519b67d08dSRijo Thomas 	u8 api_minor;
529b67d08dSRijo Thomas 	u8 build;
538347b994SSean Christopherson 
548347b994SSean Christopherson 	void *cmd_buf;
559b67d08dSRijo Thomas };
569b67d08dSRijo Thomas 
57b93566f1SRijo Thomas int sev_dev_init(struct psp_device *psp);
58b93566f1SRijo Thomas void sev_dev_destroy(struct psp_device *psp);
59b93566f1SRijo Thomas 
60b93566f1SRijo Thomas void sev_pci_init(void);
61b93566f1SRijo Thomas void sev_pci_exit(void);
62b93566f1SRijo Thomas 
639b67d08dSRijo Thomas #endif /* __SEV_DEV_H */
64