Debian Codegraph @

src/soc/amd/common/block/psp/psp_def.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #ifndef __AMD_PSP_DEF_H__
4 #define __AMD_PSP_DEF_H__
5
6 #include <types.h>
7 #include <commonlib/helpers.h>
8 #include <amdblocks/psp.h>
9
10 #define CORE_2_PSP_MSG_38_OFFSET 0x10998 /* 4 byte */
11 #define CORE_2_PSP_MSG_38_FUSE_SPL BIT(12)
12 #define CORE_2_PSP_MSG_38_SPL_FUSE_ERROR BIT(13)
13 #define CORE_2_PSP_MSG_38_SPL_ENTRY_ERROR BIT(14)
14 #define CORE_2_PSP_MSG_38_SPL_ENTRY_MISSING BIT(15)
15
16 /* x86 to PSP commands */
17 #define MBOX_BIOS_CMD_SMM_INFO 0x02
18 #define MBOX_BIOS_CMD_SX_INFO 0x03
19 #define MBOX_BIOS_CMD_SX_INFO_SLEEP_TYPE_MAX 0x07
20 #define MBOX_BIOS_CMD_RSM_INFO 0x04
21 #define MBOX_BIOS_CMD_PSP_FTPM_QUERY 0x05
22 #define MBOX_FTPM_CAP_TPM_SUPPORTED (1 << 0)
23 #define MBOX_FTPM_CAP_TPM_REQ_FACTORY_RESET (1 << 1)
24 #define MBOX_FTPM_CAP_FTPM_NEED_RECOVER (1 << 2)
25 #define MBOX_BIOS_CMD_BOOT_DONE 0x06
26 #define MBOX_BIOS_CMD_CLEAR_S3_STS 0x07
27 #define MBOX_BIOS_CMD_S3_DATA_INFO 0x08
28 #define MBOX_BIOS_CMD_NOP 0x09
29 #define MBOX_BIOS_CMD_HSTI_QUERY 0x14
30 #define MBOX_BIOS_CMD_PSB_AUTO_FUSING 0x21
31 #define MBOX_BIOS_CMD_PSP_CAPS_QUERY 0x27
32 #define MBOX_BIOS_CMD_SET_SPL_FUSE 0x2d
33 #define MBOX_BIOS_CMD_SET_RPMC_ADDRESS 0x39
34 #define MBOX_BIOS_CMD_QUERY_SPL_FUSE 0x47
35 #define MBOX_BIOS_CMD_I2C_TPM_ARBITRATION 0x64
36 #define MBOX_BIOS_CMD_ABORT 0xfe
37
38 /* x86 to PSP commands, v1-only */
39 #define MBOX_BIOS_CMD_DRAM_INFO 0x01
40 #define MBOX_BIOS_CMD_SMU_FW 0x19
41 #define MBOX_BIOS_CMD_SMU_FW2 0x1a
42
43 #define SMN_PSP_PUBLIC_BASE 0x3800000
44
45 /* command/response format, BIOS builds this in memory
46 * mbox_buffer_header: generic header
47 * mbox_buffer: command-specific buffer format
48 *
49 * AMD reference code aligns and pads all buffers to 32 bytes.
50 */
51 struct mbox_buffer_header {
52 uint32_t size; /* total size of buffer */
53 uint32_t status; /* command status, filled by PSP if applicable */
54 } __packed;
55
56 /*
57 * x86 to PSP mailbox commands that don't take any parameter or return any data, use the
58 * mbox_default_buffer, while x86 to PSP commands that either pass data to the PSP or get data
59 * returned from the PSP use command-specific buffer definitions. For details on the specific
60 * buffer definitions for the various commands, see NDA document #54267 for the generations
61 * before family 17h and NDA document #55758 for the generations from family 17h on.
62 */
63
64 struct mbox_default_buffer { /* command-response buffer unused by command */
65 struct mbox_buffer_header header;
66 } __packed __aligned(32);
67
68 struct smm_req_buffer {
69 uint64_t smm_base; /* TSEG base */
70 uint64_t smm_mask; /* TSEG mask */
71 uint64_t psp_smm_data_region; /* PSP region in SMM space */
72 uint64_t psp_smm_data_length; /* PSP region length in SMM space */
73 struct smm_trigger_info smm_trig_info;
74 #if CONFIG(SOC_AMD_COMMON_BLOCK_PSP_GEN2)
75 struct smm_register_info smm_reg_info;
76 #endif
77 uint64_t psp_mbox_smm_buffer_address;
78 uint64_t psp_mbox_smm_flag_address;
79 } __packed;
80
81 /* MBOX_BIOS_CMD_SMM_INFO */
82 struct mbox_cmd_smm_info_buffer {
83 struct mbox_buffer_header header;
84 struct smm_req_buffer req;
85 } __packed __aligned(32);
86
87 /* MBOX_BIOS_CMD_SX_INFO */
88 struct mbox_cmd_sx_info_buffer {
89 struct mbox_buffer_header header;
90 uint8_t sleep_type;
91 } __packed __aligned(32);
92
93 /* MBOX_BIOS_CMD_PSP_FTPM_QUERY, MBOX_BIOS_CMD_PSP_CAPS_QUERY */
94 struct mbox_cmd_capability_query_buffer {
95 struct mbox_buffer_header header;
96 uint32_t capabilities;
97 } __packed __aligned(32);
98
99 /* MBOX_BIOS_CMD_HSTI_QUERY */
100 struct mbox_cmd_hsti_query_buffer {
101 struct mbox_buffer_header header;
102 uint32_t state;
103 } __packed __aligned(32);
104
105 /* MBOX_BIOS_CMD_SET_RPMC_ADDRESS */
106 struct mbox_cmd_set_rpmc_address_buffer {
107 struct mbox_buffer_header header;
108 uint32_t address;
109 } __packed __aligned(32);
110
111 /* MBOX_BIOS_CMD_SET_SPL_FUSE */
112 struct mbox_cmd_late_spl_buffer {
113 struct mbox_buffer_header header;
114 uint32_t spl_value;
115 } __packed __aligned(32);
116
117 struct dtpm_config {
118 uint32_t gpio;
119 } __packed;
120
121 enum dtpm_request_type {
122 DTPM_REQUEST_ACQUIRE, /* Acquire I2C bus */
123 DTPM_REQUEST_RELEASE, /* Release I2C bus */
124 DTPM_REQUEST_CONFIG, /* Provide DTPM info */
125 DTPM_REQUEST_MAX,
126 };
127
128 /* MBOX_BIOS_CMD_I2C_TPM_ARBITRATION */
129 struct mbox_cmd_dtpm_config_buffer {
130 struct mbox_buffer_header header;
131 uint32_t request_type;
132 struct dtpm_config config;
133 } __packed __aligned(32);
134
135 #define PSP_INIT_TIMEOUT 10000 /* 10 seconds */
136 #define PSP_CMD_TIMEOUT 1000 /* 1 second */
137
138 #define C2P_BUFFER_MAXSIZE 0xc00 /* Core-to-PSP buffer */
139 #define P2C_BUFFER_MAXSIZE 0x1000 /* PSP-to-core buffer */
140
141 /* PSP to x86 status */
142 enum mbox_p2c_status {
143 MBOX_PSP_SUCCESS = 0x00,
144 MBOX_PSP_INVALID_PARAMETER = 0x01,
145 MBOX_PSP_CRC_ERROR = 0x02,
146 /*
147 * Send to PSP when the requested SPI command in the psp_smi_handler()
148 * handler failed due to an unknown error. The PSP usually doesn't like
149 * seeing this return code and will stop operating.
150 */
151 MBOX_PSP_COMMAND_PROCESS_ERROR = 0x04,
152 MBOX_PSP_UNSUPPORTED = 0x08,
153 MBOX_PSP_SPI_BUSY_ASYNC = 0x0a,
154 /*
155 * Send to PSP when the requested SPI command in the psp_smi_handler()
156 * handler cannot be executed right away. This can happen when the SPI
157 * flash is busy or the SPI controller is busy or being used by ring 0.
158 *
159 * The PSP will raise an SMI later again.
160 */
161 MBOX_PSP_SPI_BUSY = 0x0b,
162 };
163
164 uintptr_t get_psp_mmio_base(void);
165
166 void psp_print_cmd_status(int cmd_status, struct mbox_buffer_header *header);
167
168 /* This command needs to be implemented by the generation specific code. */
169 int send_psp_command(uint32_t command, void *buffer);
170
171 enum cb_err psp_get_ftpm_capabilties(uint32_t *capabilities);
172 enum cb_err psp_get_psp_capabilities(uint32_t *capabilities);
173 enum cb_err psp_get_hsti_state(uint32_t *state);
174 enum cb_err soc_read_c2p38(uint32_t *msg_38_value);
175
176 void enable_psp_smi(void);
177
178 #endif /* __AMD_PSP_DEF_H__ */