1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * AMD Platform Security Processor (PSP) interface driver
5 * Copyright (C) 2017-2019 Advanced Micro Devices, Inc.
7 * Author: Brijesh Singh <brijesh.singh@amd.com>
13 #include <linux/device.h>
14 #include <linux/list.h>
15 #include <linux/bits.h>
16 #include <linux/interrupt.h>
17 #include <linux/mutex.h>
18 #include <linux/psp.h>
22 #define MAX_PSP_NAME_LEN 16
24 extern struct psp_device *psp_master;
26 typedef void (*psp_irq_handler_t)(int, void *, unsigned int);
29 struct list_head entry;
31 struct psp_vdata *vdata;
32 char name[MAX_PSP_NAME_LEN];
37 void __iomem *io_regs;
38 struct mutex mailbox_mutex;
40 psp_irq_handler_t sev_irq_handler;
45 void *platform_access_data;
48 unsigned int capability;
51 void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler,
53 void psp_clear_sev_irq_handler(struct psp_device *psp);
55 struct psp_device *psp_get_master_device(void);
57 #define PSP_CAPABILITY_SEV BIT(0)
58 #define PSP_CAPABILITY_TEE BIT(1)
59 #define PSP_CAPABILITY_PSP_SECURITY_REPORTING BIT(7)
61 #define PSP_CAPABILITY_PSP_SECURITY_OFFSET 8
63 * The PSP doesn't directly store these bits in the capability register
64 * but instead copies them from the results of query command.
66 * The offsets from the query command are below, and shifted when used.
68 #define PSP_SECURITY_FUSED_PART BIT(0)
69 #define PSP_SECURITY_DEBUG_LOCK_ON BIT(2)
70 #define PSP_SECURITY_TSME_STATUS BIT(5)
71 #define PSP_SECURITY_ANTI_ROLLBACK_STATUS BIT(7)
72 #define PSP_SECURITY_RPMC_PRODUCTION_ENABLED BIT(8)
73 #define PSP_SECURITY_RPMC_SPIROM_AVAILABLE BIT(9)
74 #define PSP_SECURITY_HSP_TPM_AVAILABLE BIT(10)
75 #define PSP_SECURITY_ROM_ARMOR_ENFORCED BIT(11)
78 * enum psp_cmd - PSP mailbox commands
79 * @PSP_CMD_TEE_RING_INIT: Initialize TEE ring buffer
80 * @PSP_CMD_TEE_RING_DESTROY: Destroy TEE ring buffer
81 * @PSP_CMD_MAX: Maximum command id
84 PSP_CMD_TEE_RING_INIT = 1,
85 PSP_CMD_TEE_RING_DESTROY = 2,
89 int psp_mailbox_command(struct psp_device *psp, enum psp_cmd cmd, void *cmdbuff,
90 unsigned int timeout_msecs, unsigned int *cmdresp);
92 #endif /* __PSP_DEV_H */