Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * AMD Platform Security Processor (PSP) interface driver
4 *
5 * Copyright (C) 2017-2019 Advanced Micro Devices, Inc.
6 *
7 * Author: Brijesh Singh <brijesh.singh@amd.com>
8 */
9
10#ifndef __PSP_DEV_H__
11#define __PSP_DEV_H__
12
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>
20
21#include "sp-dev.h"
22
23#define MAX_PSP_NAME_LEN 16
24
25extern struct psp_device *psp_master;
26
27typedef void (*psp_irq_handler_t)(int, void *, unsigned int);
28
29union psp_cap_register {
30 unsigned int raw;
31 struct {
32 unsigned int sev :1,
33 tee :1,
34 dbc_thru_ext :1,
35 sfs :1,
36 rsvd1 :3,
37 security_reporting :1,
38 fused_part :1,
39 rsvd2 :1,
40 debug_lock_on :1,
41 rsvd3 :2,
42 tsme_status :1,
43 rsvd4 :1,
44 anti_rollback_status :1,
45 rpmc_production_enabled :1,
46 rpmc_spirom_available :1,
47 hsp_tpm_available :1,
48 rom_armor_enforced :1,
49 rsvd5 :12;
50 };
51};
52
53struct psp_device {
54 struct list_head entry;
55
56 struct psp_vdata *vdata;
57 char name[MAX_PSP_NAME_LEN];
58
59 struct device *dev;
60 struct sp_device *sp;
61
62 void __iomem *io_regs;
63 struct mutex mailbox_mutex;
64
65 psp_irq_handler_t sev_irq_handler;
66 void *sev_irq_data;
67
68 void *sev_data;
69 void *tee_data;
70 void *platform_access_data;
71 void *dbc_data;
72 void *sfs_data;
73
74 union psp_cap_register capability;
75};
76
77void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler,
78 void *data);
79void psp_clear_sev_irq_handler(struct psp_device *psp);
80
81struct psp_device *psp_get_master_device(void);
82
83/**
84 * enum psp_cmd - PSP mailbox commands
85 * @PSP_CMD_TEE_RING_INIT: Initialize TEE ring buffer
86 * @PSP_CMD_TEE_RING_DESTROY: Destroy TEE ring buffer
87 * @PSP_CMD_TEE_EXTENDED_CMD: Extended command
88 * @PSP_CMD_MAX: Maximum command id
89 */
90enum psp_cmd {
91 PSP_CMD_TEE_RING_INIT = 1,
92 PSP_CMD_TEE_RING_DESTROY = 2,
93 PSP_CMD_TEE_EXTENDED_CMD = 14,
94 PSP_CMD_MAX = 15,
95};
96
97int psp_mailbox_command(struct psp_device *psp, enum psp_cmd cmd, void *cmdbuff,
98 unsigned int timeout_msecs, unsigned int *cmdresp);
99
100/**
101 * struct psp_ext_req_buffer_hdr - Structure of the extended command header
102 * @payload_size: total payload size
103 * @sub_cmd_id: extended command ID
104 * @status: status of command execution (out)
105 */
106struct psp_ext_req_buffer_hdr {
107 u32 payload_size;
108 u32 sub_cmd_id;
109 u32 status;
110} __packed;
111
112struct psp_ext_request {
113 struct psp_ext_req_buffer_hdr header;
114 void *buf;
115} __packed;
116
117/**
118 * enum psp_sub_cmd - PSP mailbox sub commands
119 * @PSP_SUB_CMD_DBC_GET_NONCE: Get nonce from DBC
120 * @PSP_SUB_CMD_DBC_SET_UID: Set UID for DBC
121 * @PSP_SUB_CMD_DBC_GET_PARAMETER: Get parameter from DBC
122 * @PSP_SUB_CMD_DBC_SET_PARAMETER: Set parameter for DBC
123 * @PSP_SUB_CMD_SFS_GET_FW_VERS: Get firmware versions for ASP and other MP
124 * @PSP_SUB_CMD_SFS_UPDATE: Command to load, verify and execute SFS package
125 */
126enum psp_sub_cmd {
127 PSP_SUB_CMD_DBC_GET_NONCE = PSP_DYNAMIC_BOOST_GET_NONCE,
128 PSP_SUB_CMD_DBC_SET_UID = PSP_DYNAMIC_BOOST_SET_UID,
129 PSP_SUB_CMD_DBC_GET_PARAMETER = PSP_DYNAMIC_BOOST_GET_PARAMETER,
130 PSP_SUB_CMD_DBC_SET_PARAMETER = PSP_DYNAMIC_BOOST_SET_PARAMETER,
131 PSP_SUB_CMD_SFS_GET_FW_VERS = PSP_SFS_GET_FW_VERSIONS,
132 PSP_SUB_CMD_SFS_UPDATE = PSP_SFS_UPDATE,
133};
134
135int psp_extended_mailbox_cmd(struct psp_device *psp, unsigned int timeout_msecs,
136 struct psp_ext_request *req);
137#endif /* __PSP_DEV_H */