blob: b031aa3390b1d23a14d5e38185113d5b2083e72e [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Andrey Petrov04a72c42017-03-01 15:51:57 -08002
3#ifndef SOC_INTEL_COMMON_CSE_H
4#define SOC_INTEL_COMMON_CSE_H
5
Rizwan Qureshib8b8ec82020-03-30 16:52:19 +05306#include <types.h>
V Sowmya338b83c2020-11-11 07:04:13 +05307#include <vb2_api.h>
Andrey Petrov04a72c42017-03-01 15:51:57 -08008
Sridhar Siricillae202e672020-01-07 23:36:40 +05309/* MKHI Command groups */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053010#define MKHI_GROUP_ID_CBM 0x0
11#define MKHI_GROUP_ID_HMRFPO 0x5
Sridhar Siricilla24a974a2020-02-19 14:41:36 +053012#define MKHI_GROUP_ID_GEN 0xff
Sridhar Siricillaf87ff332019-09-12 17:18:20 +053013#define MKHI_GROUP_ID_BUP_COMMON 0xf0
Sean Rhodes69ed3ed2021-04-30 16:38:17 +010014#define MKHI_GROUP_ID_FWCAPS 0x3
Sridhar Siricillae202e672020-01-07 23:36:40 +053015
16/* Global Reset Command ID */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053017#define MKHI_CBM_GLOBAL_RESET_REQ 0xb
Sridhar Siricillae202e672020-01-07 23:36:40 +053018
Sean Rhodes69ed3ed2021-04-30 16:38:17 +010019/* Set State Command ID */
20#define MKHI_SET_ME_DISABLE 0x3
21#define MKHI_SET_ME_ENABLE 0x3
22
Sridhar Siricilla83af7332020-01-08 00:13:21 +053023/* Origin of Global Reset command */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053024#define GR_ORIGIN_BIOS_POST 0x2
Sridhar Siricillae202e672020-01-07 23:36:40 +053025
26/* HMRFPO Command Ids */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053027#define MKHI_HMRFPO_ENABLE 0x1
28#define MKHI_HMRFPO_GET_STATUS 0x3
Sridhar Siricillae202e672020-01-07 23:36:40 +053029
Sridhar Siricilla24a974a2020-02-19 14:41:36 +053030/* Get Firmware Version Command Id */
31#define MKHI_GEN_GET_FW_VERSION 0x2
32
Tim Wawrzynczak9fdd2b22021-06-18 10:34:09 -060033/* MEI bus disable command. Must be sent to MEI client endpoint, not MKHI */
34#define MEI_BUS_DISABLE_COMMAND 0xc
35
Tim Wawrzynczak064ca182021-06-17 12:40:13 -060036/* Set End-of-POST in CSE */
37#define MKHI_END_OF_POST 0xc
38
Sridhar Siricillaf87ff332019-09-12 17:18:20 +053039/* Boot partition info and set boot partition info command ids */
40#define MKHI_BUP_COMMON_GET_BOOT_PARTITION_INFO 0x1c
41#define MKHI_BUP_COMMON_SET_BOOT_PARTITION_INFO 0x1d
Sridhar Siricilla2f6d5552020-04-19 23:39:02 +053042#define MKHI_BUP_COMMON_DATA_CLEAR 0x20
Sridhar Siricillaf87ff332019-09-12 17:18:20 +053043
Bora Guvendikf33c9bf2021-11-05 23:09:25 -070044/* Get boot performance command id */
45#define MKHI_BUP_COMMON_GET_BOOT_PERF_DATA 0x8
46
Sridhar Siricillae202e672020-01-07 23:36:40 +053047/* ME Current Working States */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053048#define ME_HFS1_CWS_NORMAL 0x5
Sridhar Siricillae202e672020-01-07 23:36:40 +053049
50/* ME Current Operation Modes */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053051#define ME_HFS1_COM_NORMAL 0x0
52#define ME_HFS1_COM_SOFT_TEMP_DISABLE 0x3
53#define ME_HFS1_COM_SECOVER_MEI_MSG 0x5
Sridhar Siricillae202e672020-01-07 23:36:40 +053054
Sean Rhodes69ed3ed2021-04-30 16:38:17 +010055/* ME Disable Rule */
56#define ME_DISABLE_RULE_ID 6
57#define ME_DISABLE_RULE_LENGTH 4
58#define ME_DISABLE_COMMAND 0
59#define ME_DISABLE_ATTEMPTS 3
60
Sridhar Siricilla3d277052020-02-06 14:21:49 +053061/* ME Firmware SKU Types */
62#define ME_HFS3_FW_SKU_CONSUMER 0x2
63#define ME_HFS3_FW_SKU_CORPORATE 0x3
Sridhar Siricilla99dbca32020-05-12 21:05:04 +053064#define ME_HFS3_FW_SKU_LITE 0x5
Sridhar Siricilla3d277052020-02-06 14:21:49 +053065
Bora Guvendikf33c9bf2021-11-05 23:09:25 -070066/* Number of cse boot performance data */
67#define NUM_CSE_BOOT_PERF_DATA 64
68
Sridhar Siricilla2cc66912019-08-31 11:20:34 +053069/* HFSTS register offsets in PCI config space */
70enum {
71 PCI_ME_HFSTS1 = 0x40,
72 PCI_ME_HFSTS2 = 0x48,
73 PCI_ME_HFSTS3 = 0x60,
74 PCI_ME_HFSTS4 = 0x64,
75 PCI_ME_HFSTS5 = 0x68,
76 PCI_ME_HFSTS6 = 0x6C,
77};
78
Sridhar Siricillaff072e62019-11-27 14:55:16 +053079/* MKHI Message Header */
Sridhar Siricillaf35eee92019-09-23 19:38:21 +053080struct mkhi_hdr {
81 uint8_t group_id;
82 uint8_t command:7;
83 uint8_t is_resp:1;
84 uint8_t rsvd;
85 uint8_t result;
86} __packed;
87
V Sowmya338b83c2020-11-11 07:04:13 +053088/* CSE FW Version */
89struct fw_version {
90 uint16_t major;
91 uint16_t minor;
92 uint16_t hotfix;
93 uint16_t build;
94} __packed;
95
Johnny Lin72e76672021-10-09 12:35:35 +080096/* ME FW Version */
97struct me_version {
98 uint16_t minor;
99 uint16_t major;
100 uint16_t build;
101 uint16_t hotfix;
102} __packed;
103
104/* ME FW Version response */
105struct me_fw_ver_resp {
106 struct mkhi_hdr hdr;
107 struct me_version code;
108 struct me_version rec;
109 struct me_version fitc;
110} __packed;
111
Sridhar Siricilla6836da22022-02-23 23:36:45 +0530112/* CSE RX and TX error status */
113enum cse_tx_rx_status {
114 /*
115 * Transmission of HECI message is success or
116 * Reception of HECI message is success.
117 */
118 CSE_TX_RX_SUCCESS = 0,
119
120 /* Timeout to send a message to CSE */
121 CSE_TX_ERR_TIMEOUT = 1,
122
123 /* Timeout to receive the response message from CSE */
124 CSE_RX_ERR_TIMEOUT = 2,
125
126 /*
127 * Response length doesn't match with expected
128 * response message length
129 */
130 CSE_RX_ERR_RESP_LEN_MISMATCH = 3,
131
132 /* CSE is not ready during TX flow */
133 CSE_TX_ERR_CSE_NOT_READY = 4,
134
135 /* CSE is not ready during RX flow */
136 CSE_RX_ERR_CSE_NOT_READY = 5,
137
138 /* Invalid input arguments provided for TX API */
139 CSE_TX_ERR_INPUT = 6,
140
141 /* Invalid input arguments provided for RX API */
142 CSE_RX_ERR_INPUT = 7,
143};
144
Tim Wawrzynczake380a432021-06-18 09:54:55 -0600145/* CSE recovery sub-error codes */
146enum csme_failure_reason {
147 /* No error */
148 CSE_NO_ERROR = 0,
149
150 /* Unspecified error */
151 CSE_ERROR_UNSPECIFIED = 1,
152
153 /* CSE fails to boot from RW */
154 CSE_LITE_SKU_RW_JUMP_ERROR = 2,
155
156 /* CSE RW boot partition access error */
157 CSE_LITE_SKU_RW_ACCESS_ERROR = 3,
158
159 /* Fails to set next boot partition as RW */
160 CSE_LITE_SKU_RW_SWITCH_ERROR = 4,
161
162 /* CSE firmware update failure */
163 CSE_LITE_SKU_FW_UPDATE_ERROR = 5,
164
165 /* Fails to communicate with CSE */
166 CSE_COMMUNICATION_ERROR = 6,
167
168 /* Fails to wipe CSE runtime data */
169 CSE_LITE_SKU_DATA_WIPE_ERROR = 7,
170
171 /* CSE RW is not found */
172 CSE_LITE_SKU_RW_BLOB_NOT_FOUND = 8,
173
174 /* CSE CBFS RW SHA-256 mismatch with the provided SHA */
175 CSE_LITE_SKU_RW_BLOB_SHA256_MISMATCH = 9,
176
177 /* CSE CBFS RW metadata is not found */
178 CSE_LITE_SKU_RW_METADATA_NOT_FOUND = 10,
179
180 /* CSE CBFS RW blob layout is not correct */
181 CSE_LITE_SKU_LAYOUT_MISMATCH_ERROR = 11,
Tim Wawrzynczak064ca182021-06-17 12:40:13 -0600182
183 /* Error sending EOP to CSE */
184 CSE_EOP_FAIL = 12,
Krishna Prasad Bhat333edcc2021-11-26 06:52:27 +0530185
186 /* CSE Sub-partition update fail */
187 CSE_LITE_SKU_SUB_PART_UPDATE_FAIL = 13,
188
189 /* CSE sub-partition access failure */
190 CSE_LITE_SKU_SUB_PART_ACCESS_ERR = 14,
191
192 /* CSE CBFS sub-partition access error */
193 CSE_LITE_SKU_SUB_PART_BLOB_ACCESS_ERR = 15,
194
195 /* CSE Lite sub-partition update is not required */
196 CSE_LITE_SKU_SUB_PART_UPDATE_NOT_REQ = 16,
197
198 /* CSE Lite sub-partition layout mismatch error */
199 CSE_LITE_SKU_SUB_PART_LAYOUT_MISMATCH_ERROR = 17,
200
201 /* CSE Lite sub-partition update success */
202 CSE_LITE_SKU_PART_UPDATE_SUCCESS = 18,
Tim Wawrzynczake380a432021-06-18 09:54:55 -0600203};
204
Bora Guvendikf33c9bf2021-11-05 23:09:25 -0700205/* Boot performance data */
206enum cse_boot_perf_data {
207 /* CSME ROM start execution */
208 PERF_DATA_CSME_ROM_START = 0,
209
210 /* EC Boot Load Done (CSME ROM starts main execution) */
211 PERF_DATA_EC_BOOT_LOAD_DONE = 1,
212
213 /* CSME ROM completed execution / CSME RBE started */
214 PERF_DATA_CSME_ROM_COMPLETED = 2,
215
216 /* CSME got ESE Init Done indication from ESE */
217 PERF_DATA_CSME_GOT_ESE_INIT_DONE = 3,
218
219 /* CSME RBE start PMC patch/es loading */
220 PERF_DATA_CSME_RBE_PMC_PATCH_LOADING_START = 4,
221
222 /* CSME RBE completed PMC patch/es loading */
223 PERF_DATA_CSME_RBE_PMC_PATCH_LOADING_COMPLETED = 5,
224
225 /* CSME RBE set "Boot Stall Done" indication to PMC */
226 PERF_DATA_CSME_RBE_BOOT_STALL_DONE_TO_PMC = 6,
227
228 /* CSME start poll for PMC PPS register */
229 PERF_DATA_CSME_POLL_FOR_PMC_PPS_START = 7,
230
231 /* PMC set PPS */
232 PERF_DATA_PMC_SET_PPS = 8,
233
234 /* CSME BUP start running */
235 PERF_DATA_CSME_BUP_START = 9,
236
237 /* CSME set "Host Boot Prep Done" indication to PMC */
238 PERF_DATA_CSME_HOST_BOOT_PREP_DONE = 10,
239
240 /* CSME starts PHYs loading */
241 PERF_DATA_CSME_PHY_LOADING_START = 11,
242
243 /* CSME completed PHYs loading */
244 PERF_DATA_CSME_PHY_LOADING_COMPLETED = 12,
245
246 /* PMC indicated CSME that xxPWRGOOD was asserted */
247 PERF_DATA_PMC_PWRGOOD_ASSERTED = 13,
248
249 /* PMC indicated CSME that SYS_PWROK was asserted */
250 PERF_DATA_PMC_SYS_PWROK_ASSERTED = 14,
251
252 /* PMC sent "CPU_BOOT_CONFIG" start message to CSME */
253 PERF_DATA_PMC_CPU_BOOT_CONFIG_START = 15,
254
255 /* CSME sent "CPU_BOOT_CONFIG" done message to PMC */
256 PERF_DATA_CSME_CPU_BOOT_CONFIG_DONW = 16,
257
258 /* PMC indicated CSME that xxPLTRST was de-asserted */
259 PERF_DATA_PMC_PLTRST_DEASSERTED = 17,
260
261 /* PMC indicated CSME that TCO_S0 was asserted */
262 PERF_DATA_PMC_TC0_S0_ASSERTED = 18,
263
264 /* PMC sent "Core Reset Done Ack - Sent" message to CSME */
265 PERF_DATA_PMC_SENT_CRDA = 19,
266
267 /* ACM Active indication - ACM started its execution */
268 PERF_DATA_ACM_START = 20,
269
270 /* ACM Done indication - ACM completed execution */
271 PERF_DATA_ACM_DONE = 21,
272
273 /* BIOS sent DRAM Init Done message */
274 PERF_DATA_BIOS_DRAM_INIT_DONE = 22,
275
276 /* CSME sent DRAM Init Done message back to BIOS */
277 PERF_DATA_CSME_DRAM_INIT_DONE = 23,
278
279 /* CSME completed loading TCSS */
280 PERF_DATA_CSME_LOAD_TCSS_COMPLETED = 24,
281
282 /* CSME started loading ISH Bringup module */
283 PERF_DATA_PERF_DATA_CSME_LOAD_ISH_BRINGUP_START = 25,
284
285 /* CSME completed loading ISH Bringup module */
286 PERF_DATA_CSME_LOAD_ISH_BRINGUP_DONE = 26,
287
288 /* CSME started loading ISH Main module */
289 PERF_DATA_CSME_LOAD_ISH_MAIN_START = 27,
290
291 /* CSME completed loading Main module */
292 PERF_DATA_CSME_LOAD_ISH_MAIN_DONE = 28,
293
294 /* BIOS sent "End Of Post" message to CSME */
295 PERF_DATA_BIOS_END_OF_POST = 29,
296
297 /* CSME sent "End Of Post" ack message back to BIOS */
298 PERF_DATA_CSME_END_OF_POST = 30,
299
300 /* BIOS sent "Core BIOS Done" message to CSME */
301 PERF_DATA_BIOS_BIOS_CORE_DONE = 31,
302
303 /* CSME sent "Core BIOS Done" ack message back to BIOS */
304 PERF_DATA_CSME_BIOS_CORE_DONE = 32,
305
306 /* CSME reached Firmware Init Done */
307 PERF_DATA_CSME_GW_INIT_DONE = 33,
308
309 /* 34 - 62 Reserved */
310
311 /* Timestamp when CSME responded to BupGetBootData message itself */
312 PERF_DATA_CSME_GET_PERF_RESPONSE = 63,
313};
314
315/* CSE boot performance data */
316struct cse_boot_perf_rsp {
317 struct mkhi_hdr hdr;
318
319 /* Data version */
320 uint32_t version;
321
322 /* Data length in DWORDs, represents number of valid elements in timestamp array */
323 uint32_t num_valid_timestamps;
324
325 /* Boot performance data */
326 uint32_t timestamp[NUM_CSE_BOOT_PERF_DATA];
327} __packed;
328
Subrata Banik0b92aa62022-06-01 06:54:44 +0000329/*
330 * Initialize the CSE device.
331 *
332 * Set up CSE device for use in early boot environment with temp bar.
333 */
334void cse_init(uintptr_t bar);
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530335
Subrata Banik801dbf42022-06-01 07:56:40 +0000336/* Initialize the HECI devices. */
337void heci_init(void);
338
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530339/*
Rizwan Qureshi957857d2021-08-30 16:43:57 +0530340 * Send message from BIOS_HOST_ADDR to cse_addr.
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530341 * Sends snd_msg of size snd_sz, and reads message into buffer pointed by
342 * rcv_msg of size rcv_sz
Sridhar Siricilla6836da22022-02-23 23:36:45 +0530343 * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios.
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530344 */
Sridhar Siricilla6836da22022-02-23 23:36:45 +0530345enum cse_tx_rx_status heci_send_receive(const void *snd_msg, size_t snd_sz, void *rcv_msg,
346 size_t *rcv_sz, uint8_t cse_addr);
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530347
Andrey Petrov04a72c42017-03-01 15:51:57 -0800348/*
349 * Attempt device reset. This is useful and perhaps only thing left to do when
350 * CPU and CSE are out of sync or CSE fails to respond.
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +0530351 * Returns 0 on failure and 1 on success.
Andrey Petrov04a72c42017-03-01 15:51:57 -0800352 */
353int heci_reset(void);
Subrata Banik32e06732022-01-28 02:05:15 +0530354/* Disable HECI1 using Sideband interface communication */
355void heci1_disable(void);
Andrey Petrov04a72c42017-03-01 15:51:57 -0800356
Sridhar Siricilla2cc66912019-08-31 11:20:34 +0530357/* Reads config value from a specified offset in the CSE PCI Config space. */
358uint32_t me_read_config32(int offset);
359
360/*
Subrata Banik3710e992021-09-30 16:59:09 +0530361 * Check if the CSE device as per function argument `devfn` is enabled in device tree
362 * and also visible on the PCI bus.
363 */
364bool is_cse_devfn_visible(unsigned int devfn);
365
366/*
Sridhar Siricilla2cc66912019-08-31 11:20:34 +0530367 * Check if the CSE device is enabled in device tree. Also check if the device
368 * is visible on the PCI bus by reading config space.
369 * Return true if device present and config space enabled, else return false.
370 */
371bool is_cse_enabled(void);
372
Sridhar Siricillaff072e62019-11-27 14:55:16 +0530373/* Makes the host ready to communicate with CSE */
374void cse_set_host_ready(void);
Sridhar Siricillab9d075b2019-08-31 11:38:33 +0530375
376/*
377 * Polls for ME state 'HECI_OP_MODE_SEC_OVERRIDE' for 15 seconds.
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +0530378 * Returns 0 on failure and 1 on success.
Sridhar Siricillab9d075b2019-08-31 11:38:33 +0530379 */
Sridhar Siricillaff072e62019-11-27 14:55:16 +0530380uint8_t cse_wait_sec_override_mode(void);
Sridhar Siricillab9d075b2019-08-31 11:38:33 +0530381
Sridhar Siricillaf2eb6872019-12-05 19:54:16 +0530382enum rst_req_type {
383 GLOBAL_RESET = 1,
Sridhar Siricillaf2eb6872019-12-05 19:54:16 +0530384 CSE_RESET_ONLY = 3,
385};
386
Sridhar Siricillad415c202019-08-31 14:54:57 +0530387/*
Subrata Banikf463dc02020-09-14 19:04:03 +0530388 * Sends GLOBAL_RESET_REQ cmd to CSE with reset type GLOBAL_RESET.
Sridhar Siricillaf2eb6872019-12-05 19:54:16 +0530389 * Returns 0 on failure and 1 on success.
Sridhar Siricillad415c202019-08-31 14:54:57 +0530390 */
Subrata Banikf463dc02020-09-14 19:04:03 +0530391int cse_request_global_reset(void);
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530392/*
Sridhar Siricillad16187e2019-11-27 16:02:47 +0530393 * Sends HMRFPO_ENABLE command.
394 * HMRFPO - Host ME Region Flash Protection Override.
Sridhar Siricilla6ad70102020-05-12 21:28:53 +0530395 * For CSE Lite SKU, procedure to place CSE in HMRFPO (SECOVER_MEI_MSG) mode:
396 * 1. Ensure CSE boots from RO(BP1).
397 * - Set CSE's next boot partition to RO
398 * - Issue GLOBAL_RESET command to reset the system
Sridhar Siricillad16187e2019-11-27 16:02:47 +0530399 * 2. Send HMRFPO_ENABLE command to CSE. Further, no reset is required.
400 *
401 * The HMRFPO mode prevents CSE to execute SPI I/O cycles to CSE region, and unlocks
402 * the CSE region to perform updates to it.
403 * This command is only valid before EOP.
404 *
405 * Returns 0 on failure to send HECI command and to enable HMRFPO mode, and 1 on success.
406 *
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530407 */
Sridhar Siricillaad6d3122023-01-10 14:59:35 +0530408enum cb_err cse_hmrfpo_enable(void);
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530409
410/*
411 * Send HMRFPO_GET_STATUS command.
412 * returns -1 on failure and 0 (DISABLED)/ 1 (LOCKED)/ 2 (ENABLED)
413 * on success.
414 */
Sridhar Siricillaff072e62019-11-27 14:55:16 +0530415int cse_hmrfpo_get_status(void);
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530416
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530417/* Fixed Address MEI Header's Host Address field value */
418#define BIOS_HOST_ADDR 0x00
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530419
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530420/* Fixed Address MEI Header's ME Address field value */
421#define HECI_MKHI_ADDR 0x07
Andrey Petrov04a72c42017-03-01 15:51:57 -0800422
Tim Wawrzynczak9fdd2b22021-06-18 10:34:09 -0600423/* Fixed Address MEI Header's ME Address for MEI bus messages */
424#define HECI_MEI_ADDR 0x00
425
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530426/* HMRFPO Status types */
Sridhar Siricilla63be9182020-01-19 12:38:56 +0530427/* Host can't access ME region */
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530428#define MKHI_HMRFPO_DISABLED 0
Sridhar Siricilla63be9182020-01-19 12:38:56 +0530429
430/*
431 * ME Firmware locked down HMRFPO Feature.
432 * Host can't access ME region.
433 */
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530434#define MKHI_HMRFPO_LOCKED 1
Sridhar Siricilla63be9182020-01-19 12:38:56 +0530435
436/* Host can access ME region */
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530437#define MKHI_HMRFPO_ENABLED 2
438
Sridhar Siricilla8e465452019-09-23 20:59:38 +0530439/*
Sridhar Siricilla24a974a2020-02-19 14:41:36 +0530440 * Queries and logs ME firmware version
441 */
442void print_me_fw_version(void *unused);
443
444/*
Johnny Lin72e76672021-10-09 12:35:35 +0800445 * Queries and gets ME firmware version
446 */
447enum cb_err get_me_fw_version(struct me_fw_ver_resp *resp);
448
449/*
Sridhar Siricilla8e465452019-09-23 20:59:38 +0530450 * Checks current working operation state is normal or not.
451 * Returns true if CSE's current working state is normal, otherwise false.
452 */
453bool cse_is_hfs1_cws_normal(void);
454
455/*
456 * Checks CSE's current operation mode is normal or not.
457 * Returns true if CSE's current operation mode is normal, otherwise false.
458 */
459bool cse_is_hfs1_com_normal(void);
460
461/*
462 * Checks CSE's current operation mode is SECOVER_MEI_MSG or not.
463 * Returns true if CSE's current operation mode is SECOVER_MEI_MSG, otherwise false.
464 */
465bool cse_is_hfs1_com_secover_mei_msg(void);
466
467/*
468 * Checks CSE's current operation mode is Soft Disable Mode or not.
469 * Returns true if CSE's current operation mode is Soft Disable Mode, otherwise false.
470 */
471bool cse_is_hfs1_com_soft_temp_disable(void);
472
Sridhar Siricilla3465d272020-02-06 15:31:04 +0530473/*
Subrata Banike74ebcd2021-12-27 10:49:19 +0000474 * Checks CSE's spi protection mode is protected or unprotected.
475 * Returns true if CSE's spi protection mode is protected, otherwise false.
476 */
477bool cse_is_hfs1_spi_protected(void);
478
479/*
Sridhar Siricilla99dbca32020-05-12 21:05:04 +0530480 * Checks CSE's Firmware SKU is Lite or not.
481 * Returns true if CSE's Firmware SKU is Lite, otherwise false
Sridhar Siricilla3465d272020-02-06 15:31:04 +0530482 */
Sridhar Siricilla99dbca32020-05-12 21:05:04 +0530483bool cse_is_hfs3_fw_sku_lite(void);
Sridhar Siricilla3465d272020-02-06 15:31:04 +0530484
Sridhar Siricilla09ea3712019-11-12 23:35:50 +0530485/*
486 * Polls for CSE's current operation mode 'Soft Temp Disable'.
487 * Returns 0 on failure and 1 on success.
488 */
489uint8_t cse_wait_com_soft_temp_disable(void);
Sridhar Siricillaf87ff332019-09-12 17:18:20 +0530490
491/*
Sridhar Siricilla99dbca32020-05-12 21:05:04 +0530492 * The CSE Lite SKU supports notion of RO and RW boot partitions. The function will set
Jon Murphyc4e90452022-06-28 10:36:23 -0600493 * CSE's boot partition as per ChromeOS boot modes. In normal mode, the function allows CSE to
Sridhar Siricillaf87ff332019-09-12 17:18:20 +0530494 * boot from RW and triggers recovery mode if CSE fails to jump to RW.
495 * In software triggered recovery mode, the function allows CSE to boot from whatever is
496 * currently selected partition.
497 */
Sridhar Siricilla1a2b7022020-12-04 02:22:28 +0530498void cse_fw_sync(void);
Karthikeyan Ramasubramanianf9cc6372020-08-04 16:38:58 -0600499
500/* Perform a board-specific reset sequence for CSE RO<->RW jump */
501void cse_board_reset(void);
502
Jeremy Compostella08b5200d2023-01-19 11:32:25 -0700503/* Perform a misc operation before CSE firmware update. */
504void cse_fw_update_misc_oper(void);
505
Tim Wawrzynczak09635f42021-06-18 10:08:47 -0600506/* Trigger vboot recovery mode on a CSE error */
507void cse_trigger_vboot_recovery(enum csme_failure_reason reason);
508
Subrata Banika219edb2021-09-25 15:02:37 +0530509enum cse_device_state {
510 DEV_IDLE,
511 DEV_ACTIVE,
512};
513
514/* Function to get the current CSE device state as per `cse_device_state` */
Subrata Banikc6e25522021-09-30 18:14:09 +0530515enum cse_device_state get_cse_device_state(unsigned int devfn);
Subrata Banika219edb2021-09-25 15:02:37 +0530516
517/* Function that put the CSE into desired state based on `requested_state` */
Subrata Banikc6e25522021-09-30 18:14:09 +0530518bool set_cse_device_state(unsigned int devfn, enum cse_device_state requested_state);
Subrata Banika219edb2021-09-25 15:02:37 +0530519
Krishna Prasad Bhat333edcc2021-11-26 06:52:27 +0530520/*
521 * Check if cse sub-parition update is required or not.
522 * Returns true if cse sub-parition update is required otherwise false.
523 */
524bool skip_cse_sub_part_update(void);
Bora Guvendikf33c9bf2021-11-05 23:09:25 -0700525
526/*
527 * This command retrieves a set of boot performance timestamps CSME collected during
528 * the last platform boot flow.
529 */
Sridhar Siricilladd7d51d2023-01-10 15:05:07 +0530530enum cb_err cse_get_boot_performance_data(struct cse_boot_perf_rsp *boot_perf);
Bora Guvendikf33c9bf2021-11-05 23:09:25 -0700531
Subrata Banik736f9cc2022-01-27 20:52:46 +0530532/* Function to make cse disable using PMC IPC */
533bool cse_disable_mei_devices(void);
534
Subrata Banik526cc3e2022-01-31 21:55:51 +0530535/* Set CSE device state to D0I3 */
536void cse_set_to_d0i3(void);
537
538/* Function sets D0I3 for all HECI devices */
539void heci_set_to_d0i3(void);
540
Subrata Banik80c92892022-02-01 00:26:55 +0530541/* Function performs the global reset lock */
542void cse_control_global_reset_lock(void);
543
Subrata Banik7c31d172022-02-01 00:11:29 +0530544/* Send End of Post (EOP) command to CSE device */
545void cse_send_end_of_post(void);
546
Subrata Banik32e06732022-01-28 02:05:15 +0530547/*
Subrata Banik17a3da82022-11-24 21:51:42 +0530548 * This function to perform essential post EOP cse related operations
549 * upon SoC selecting `SOC_INTEL_CSE_SEND_EOP_LATE` config
550 */
551void cse_late_finalize(void);
552
553/*
Subrata Banik32e06732022-01-28 02:05:15 +0530554 * SoC override API to make heci1 disable using PCR.
555 *
556 * Allow SoC to implement heci1 disable override due to PSF registers being
557 * different across SoC generation.
558 */
559void soc_disable_heci1_using_pcr(void);
560
Bora Guvendik860672e2021-09-26 17:25:48 -0700561/*
562 * Get all the timestamps CSE collected using cse_get_boot_performance_data() and
563 * insert them into the CBMEM timestamp table.
564 */
565void cse_get_telemetry_data(void);
566
Subrata Banikda527ec2022-11-24 15:42:35 +0530567/* Function to log the cse WP information like range, if WP etc. */
568void cse_log_ro_write_protection_info(bool mfg_mode);
569
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530570#endif // SOC_INTEL_COMMON_CSE_H