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.
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>
19 #include <linux/psp-platform-access.h>
23 #define MAX_PSP_NAME_LEN 16
25 extern struct psp_device *psp_master;
27 typedef void (*psp_irq_handler_t)(int, void *, unsigned int);
29 union psp_cap_register {
36 security_reporting :1,
43 anti_rollback_status :1,
44 rpmc_production_enabled :1,
45 rpmc_spirom_available :1,
47 rom_armor_enforced :1,
53 struct list_head entry;
55 struct psp_vdata *vdata;
56 char name[MAX_PSP_NAME_LEN];
61 void __iomem *io_regs;
62 struct mutex mailbox_mutex;
64 psp_irq_handler_t sev_irq_handler;
69 void *platform_access_data;
72 union psp_cap_register capability;
75 void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler,
77 void psp_clear_sev_irq_handler(struct psp_device *psp);
79 struct psp_device *psp_get_master_device(void);
82 * enum psp_cmd - PSP mailbox commands
83 * @PSP_CMD_TEE_RING_INIT: Initialize TEE ring buffer
84 * @PSP_CMD_TEE_RING_DESTROY: Destroy TEE ring buffer
85 * @PSP_CMD_TEE_EXTENDED_CMD: Extended command
86 * @PSP_CMD_MAX: Maximum command id
89 PSP_CMD_TEE_RING_INIT = 1,
90 PSP_CMD_TEE_RING_DESTROY = 2,
91 PSP_CMD_TEE_EXTENDED_CMD = 14,
95 int psp_mailbox_command(struct psp_device *psp, enum psp_cmd cmd, void *cmdbuff,
96 unsigned int timeout_msecs, unsigned int *cmdresp);
99 * struct psp_ext_req_buffer_hdr - Structure of the extended command header
100 * @payload_size: total payload size
101 * @sub_cmd_id: extended command ID
102 * @status: status of command execution (out)
104 struct psp_ext_req_buffer_hdr {
110 struct psp_ext_request {
111 struct psp_ext_req_buffer_hdr header;
116 * enum psp_sub_cmd - PSP mailbox sub commands
117 * @PSP_SUB_CMD_DBC_GET_NONCE: Get nonce from DBC
118 * @PSP_SUB_CMD_DBC_SET_UID: Set UID for DBC
119 * @PSP_SUB_CMD_DBC_GET_PARAMETER: Get parameter from DBC
120 * @PSP_SUB_CMD_DBC_SET_PARAMETER: Set parameter for DBC
123 PSP_SUB_CMD_DBC_GET_NONCE = PSP_DYNAMIC_BOOST_GET_NONCE,
124 PSP_SUB_CMD_DBC_SET_UID = PSP_DYNAMIC_BOOST_SET_UID,
125 PSP_SUB_CMD_DBC_GET_PARAMETER = PSP_DYNAMIC_BOOST_GET_PARAMETER,
126 PSP_SUB_CMD_DBC_SET_PARAMETER = PSP_DYNAMIC_BOOST_SET_PARAMETER,
129 int psp_extended_mailbox_cmd(struct psp_device *psp, unsigned int timeout_msecs,
130 struct psp_ext_request *req);
131 #endif /* __PSP_DEV_H */