blob: 636b1f4064297945f05750e8828c8ee95974aa29 [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
Bora Guvendik94050492023-03-12 12:24:58 -07006#include <intelblocks/cse_telemetry.h>
Rizwan Qureshib8b8ec82020-03-30 16:52:19 +05307#include <types.h>
V Sowmya338b83c2020-11-11 07:04:13 +05308#include <vb2_api.h>
Andrey Petrov04a72c42017-03-01 15:51:57 -08009
Sridhar Siricillae202e672020-01-07 23:36:40 +053010/* MKHI Command groups */
Sridhar Siricillae9f4e562023-05-05 10:50:43 +053011enum mkhi_group_id {
12 MKHI_GROUP_ID_CBM = 0x0,
13 MKHI_GROUP_ID_HMRFPO = 0x5,
14 MKHI_GROUP_ID_GEN = 0xff,
15 MKHI_GROUP_ID_BUP_COMMON = 0xf0,
16 MKHI_GROUP_ID_FWCAPS = 0x3,
17};
Sridhar Siricillae202e672020-01-07 23:36:40 +053018
19/* Global Reset Command ID */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053020#define MKHI_CBM_GLOBAL_RESET_REQ 0xb
Sridhar Siricillae202e672020-01-07 23:36:40 +053021
Sean Rhodes69ed3ed2021-04-30 16:38:17 +010022/* Set State Command ID */
23#define MKHI_SET_ME_DISABLE 0x3
24#define MKHI_SET_ME_ENABLE 0x3
25
Sridhar Siricilla83af7332020-01-08 00:13:21 +053026/* Origin of Global Reset command */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053027#define GR_ORIGIN_BIOS_POST 0x2
Sridhar Siricillae202e672020-01-07 23:36:40 +053028
29/* HMRFPO Command Ids */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053030#define MKHI_HMRFPO_ENABLE 0x1
31#define MKHI_HMRFPO_GET_STATUS 0x3
Sridhar Siricillae202e672020-01-07 23:36:40 +053032
Sridhar Siricilla24a974a2020-02-19 14:41:36 +053033/* Get Firmware Version Command Id */
34#define MKHI_GEN_GET_FW_VERSION 0x2
35
Michał Żygowskidaa17102022-10-04 10:55:38 +020036/* Firmware Feature Shipment Time State Override Command Id */
37#define MKHI_GEN_FW_FEATURE_SHIPMENT_OVER 0x14
38#define ME_FW_FEATURE_PTT BIT(29)
39
40/* Get Firmware Feature State Command Id */
41#define MKHI_FWCAPS_GET_FW_FEATURE_STATE 0x02
42#define ME_FEATURE_STATE_RULE_ID 0x20
43
Tim Wawrzynczak9fdd2b22021-06-18 10:34:09 -060044/* MEI bus disable command. Must be sent to MEI client endpoint, not MKHI */
45#define MEI_BUS_DISABLE_COMMAND 0xc
46
Tim Wawrzynczak064ca182021-06-17 12:40:13 -060047/* Set End-of-POST in CSE */
48#define MKHI_END_OF_POST 0xc
49
Sridhar Siricillaf87ff332019-09-12 17:18:20 +053050/* Boot partition info and set boot partition info command ids */
51#define MKHI_BUP_COMMON_GET_BOOT_PARTITION_INFO 0x1c
52#define MKHI_BUP_COMMON_SET_BOOT_PARTITION_INFO 0x1d
Sridhar Siricilla2f6d5552020-04-19 23:39:02 +053053#define MKHI_BUP_COMMON_DATA_CLEAR 0x20
Dinesh Gehlotf963feb2023-03-24 06:39:33 +000054#define GEN_GET_IMAGE_FW_VERSION 0x1c
Sridhar Siricillaf87ff332019-09-12 17:18:20 +053055
Bora Guvendikf33c9bf2021-11-05 23:09:25 -070056/* Get boot performance command id */
57#define MKHI_BUP_COMMON_GET_BOOT_PERF_DATA 0x8
58
Sridhar Siricillae202e672020-01-07 23:36:40 +053059/* ME Current Working States */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053060#define ME_HFS1_CWS_NORMAL 0x5
Sridhar Siricillae202e672020-01-07 23:36:40 +053061
62/* ME Current Operation Modes */
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +053063#define ME_HFS1_COM_NORMAL 0x0
64#define ME_HFS1_COM_SOFT_TEMP_DISABLE 0x3
65#define ME_HFS1_COM_SECOVER_MEI_MSG 0x5
Sridhar Siricillae202e672020-01-07 23:36:40 +053066
Sean Rhodes69ed3ed2021-04-30 16:38:17 +010067/* ME Disable Rule */
68#define ME_DISABLE_RULE_ID 6
69#define ME_DISABLE_RULE_LENGTH 4
70#define ME_DISABLE_COMMAND 0
71#define ME_DISABLE_ATTEMPTS 3
72
Sridhar Siricilla3d277052020-02-06 14:21:49 +053073/* ME Firmware SKU Types */
Sridhar Siricillae9f4e562023-05-05 10:50:43 +053074enum me_fw_sku {
75 ME_HFS3_FW_SKU_CONSUMER = 0x2,
76 ME_HFS3_FW_SKU_CORPORATE = 0x3,
77 ME_HFS3_FW_SKU_LITE = 0x5,
78};
Sridhar Siricilla3d277052020-02-06 14:21:49 +053079
Bora Guvendikf33c9bf2021-11-05 23:09:25 -070080/* Number of cse boot performance data */
81#define NUM_CSE_BOOT_PERF_DATA 64
82
Sridhar Siricilla2cc66912019-08-31 11:20:34 +053083/* HFSTS register offsets in PCI config space */
84enum {
85 PCI_ME_HFSTS1 = 0x40,
86 PCI_ME_HFSTS2 = 0x48,
87 PCI_ME_HFSTS3 = 0x60,
88 PCI_ME_HFSTS4 = 0x64,
89 PCI_ME_HFSTS5 = 0x68,
90 PCI_ME_HFSTS6 = 0x6C,
91};
92
Dinesh Gehlotf963feb2023-03-24 06:39:33 +000093/* CSE partition list */
94enum fpt_partition_id {
95 FPT_PARTITION_NAME_UNDEFINED = 0x0,
96 FPT_PARTITION_NAME_ISHC = 0x43485349,
97};
98
Sridhar Siricillaff072e62019-11-27 14:55:16 +053099/* MKHI Message Header */
Sridhar Siricillaf35eee92019-09-23 19:38:21 +0530100struct mkhi_hdr {
101 uint8_t group_id;
102 uint8_t command:7;
103 uint8_t is_resp:1;
104 uint8_t rsvd;
105 uint8_t result;
106} __packed;
107
V Sowmya338b83c2020-11-11 07:04:13 +0530108/* CSE FW Version */
109struct fw_version {
110 uint16_t major;
111 uint16_t minor;
112 uint16_t hotfix;
113 uint16_t build;
114} __packed;
115
Johnny Lin72e76672021-10-09 12:35:35 +0800116/* ME FW Version */
117struct me_version {
118 uint16_t minor;
119 uint16_t major;
120 uint16_t build;
121 uint16_t hotfix;
122} __packed;
123
124/* ME FW Version response */
125struct me_fw_ver_resp {
126 struct mkhi_hdr hdr;
127 struct me_version code;
128 struct me_version rec;
129 struct me_version fitc;
130} __packed;
131
Dinesh Gehlotf963feb2023-03-24 06:39:33 +0000132/* Module data from manifest */
133struct flash_partition_data {
134 enum fpt_partition_id partition_id;
135 uint8_t reserved1[8];
136 struct fw_version version;
137 uint32_t vendor_id;
138 uint32_t tcb_svn;
139 uint32_t arb_svn;
140 uint32_t vcn;
141 uint32_t reserved2[13];
142};
143
144/* Response header for partition information request */
145struct fw_version_resp {
146 struct mkhi_hdr hdr;
147 uint32_t module_count;
148 struct flash_partition_data manifest_data;
149};
150
Subrata Banikfc313d62023-04-14 01:31:29 +0530151/* ISHC version */
152struct cse_fw_ish_version_info {
153 struct fw_version prev_cse_fw_version;
154 struct fw_version cur_ish_fw_version;
155};
156
157/* CSE and ISHC version */
158struct cse_fw_partition_info {
159 struct fw_version cur_cse_fw_version;
160 struct cse_fw_ish_version_info ish_partition_info;
161};
162
Sridhar Siricilla6836da22022-02-23 23:36:45 +0530163/* CSE RX and TX error status */
164enum cse_tx_rx_status {
165 /*
166 * Transmission of HECI message is success or
167 * Reception of HECI message is success.
168 */
169 CSE_TX_RX_SUCCESS = 0,
170
171 /* Timeout to send a message to CSE */
172 CSE_TX_ERR_TIMEOUT = 1,
173
174 /* Timeout to receive the response message from CSE */
175 CSE_RX_ERR_TIMEOUT = 2,
176
177 /*
178 * Response length doesn't match with expected
179 * response message length
180 */
181 CSE_RX_ERR_RESP_LEN_MISMATCH = 3,
182
183 /* CSE is not ready during TX flow */
184 CSE_TX_ERR_CSE_NOT_READY = 4,
185
186 /* CSE is not ready during RX flow */
187 CSE_RX_ERR_CSE_NOT_READY = 5,
188
189 /* Invalid input arguments provided for TX API */
190 CSE_TX_ERR_INPUT = 6,
191
192 /* Invalid input arguments provided for RX API */
193 CSE_RX_ERR_INPUT = 7,
194};
195
Tim Wawrzynczake380a432021-06-18 09:54:55 -0600196/* CSE recovery sub-error codes */
197enum csme_failure_reason {
198 /* No error */
199 CSE_NO_ERROR = 0,
200
201 /* Unspecified error */
202 CSE_ERROR_UNSPECIFIED = 1,
203
204 /* CSE fails to boot from RW */
205 CSE_LITE_SKU_RW_JUMP_ERROR = 2,
206
207 /* CSE RW boot partition access error */
208 CSE_LITE_SKU_RW_ACCESS_ERROR = 3,
209
210 /* Fails to set next boot partition as RW */
211 CSE_LITE_SKU_RW_SWITCH_ERROR = 4,
212
213 /* CSE firmware update failure */
214 CSE_LITE_SKU_FW_UPDATE_ERROR = 5,
215
216 /* Fails to communicate with CSE */
217 CSE_COMMUNICATION_ERROR = 6,
218
219 /* Fails to wipe CSE runtime data */
220 CSE_LITE_SKU_DATA_WIPE_ERROR = 7,
221
222 /* CSE RW is not found */
223 CSE_LITE_SKU_RW_BLOB_NOT_FOUND = 8,
224
225 /* CSE CBFS RW SHA-256 mismatch with the provided SHA */
226 CSE_LITE_SKU_RW_BLOB_SHA256_MISMATCH = 9,
227
228 /* CSE CBFS RW metadata is not found */
229 CSE_LITE_SKU_RW_METADATA_NOT_FOUND = 10,
230
231 /* CSE CBFS RW blob layout is not correct */
232 CSE_LITE_SKU_LAYOUT_MISMATCH_ERROR = 11,
Tim Wawrzynczak064ca182021-06-17 12:40:13 -0600233
234 /* Error sending EOP to CSE */
235 CSE_EOP_FAIL = 12,
Krishna Prasad Bhat333edcc2021-11-26 06:52:27 +0530236
237 /* CSE Sub-partition update fail */
238 CSE_LITE_SKU_SUB_PART_UPDATE_FAIL = 13,
239
240 /* CSE sub-partition access failure */
241 CSE_LITE_SKU_SUB_PART_ACCESS_ERR = 14,
242
243 /* CSE CBFS sub-partition access error */
244 CSE_LITE_SKU_SUB_PART_BLOB_ACCESS_ERR = 15,
245
246 /* CSE Lite sub-partition update is not required */
247 CSE_LITE_SKU_SUB_PART_UPDATE_NOT_REQ = 16,
248
249 /* CSE Lite sub-partition layout mismatch error */
250 CSE_LITE_SKU_SUB_PART_LAYOUT_MISMATCH_ERROR = 17,
251
252 /* CSE Lite sub-partition update success */
253 CSE_LITE_SKU_PART_UPDATE_SUCCESS = 18,
Tim Wawrzynczake380a432021-06-18 09:54:55 -0600254};
255
Bora Guvendikf33c9bf2021-11-05 23:09:25 -0700256/* CSE boot performance data */
257struct cse_boot_perf_rsp {
258 struct mkhi_hdr hdr;
259
260 /* Data version */
261 uint32_t version;
262
263 /* Data length in DWORDs, represents number of valid elements in timestamp array */
264 uint32_t num_valid_timestamps;
265
266 /* Boot performance data */
267 uint32_t timestamp[NUM_CSE_BOOT_PERF_DATA];
268} __packed;
269
Subrata Banik0b92aa62022-06-01 06:54:44 +0000270/*
271 * Initialize the CSE device.
272 *
273 * Set up CSE device for use in early boot environment with temp bar.
274 */
275void cse_init(uintptr_t bar);
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530276
Subrata Banik801dbf42022-06-01 07:56:40 +0000277/* Initialize the HECI devices. */
278void heci_init(void);
279
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530280/*
Jeremy Compostella0e1be042023-03-13 13:41:43 -0700281 * Send message msg of size len to host from host_addr to cse_addr.
282 * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios.
283 * Also, in case of errors, heci_reset() is triggered.
284 */
285enum cse_tx_rx_status heci_send(const void *msg, size_t len, uint8_t host_addr,
286 uint8_t client_addr);
287
288/*
289 * Receive message into buff not exceeding maxlen. Message is considered
290 * successfully received if a 'complete' indication is read from ME side
291 * and there was enough space in the buffer to fit that message. maxlen
292 * is updated with size of message that was received.
293 * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios.
294 * Also, in case of errors, heci_reset() is triggered.
295 */
296enum cse_tx_rx_status heci_receive(void *buff, size_t *maxlen);
297
298/*
Rizwan Qureshi957857d2021-08-30 16:43:57 +0530299 * Send message from BIOS_HOST_ADDR to cse_addr.
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530300 * Sends snd_msg of size snd_sz, and reads message into buffer pointed by
301 * rcv_msg of size rcv_sz
Sridhar Siricilla6836da22022-02-23 23:36:45 +0530302 * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios.
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530303 */
Sridhar Siricilla6836da22022-02-23 23:36:45 +0530304enum cse_tx_rx_status heci_send_receive(const void *snd_msg, size_t snd_sz, void *rcv_msg,
305 size_t *rcv_sz, uint8_t cse_addr);
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530306
Andrey Petrov04a72c42017-03-01 15:51:57 -0800307/*
308 * Attempt device reset. This is useful and perhaps only thing left to do when
309 * CPU and CSE are out of sync or CSE fails to respond.
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +0530310 * Returns 0 on failure and 1 on success.
Andrey Petrov04a72c42017-03-01 15:51:57 -0800311 */
312int heci_reset(void);
Subrata Banik32e06732022-01-28 02:05:15 +0530313/* Disable HECI1 using Sideband interface communication */
314void heci1_disable(void);
Andrey Petrov04a72c42017-03-01 15:51:57 -0800315
Sridhar Siricilla2cc66912019-08-31 11:20:34 +0530316/* Reads config value from a specified offset in the CSE PCI Config space. */
317uint32_t me_read_config32(int offset);
318
319/*
Subrata Banik3710e992021-09-30 16:59:09 +0530320 * Check if the CSE device as per function argument `devfn` is enabled in device tree
321 * and also visible on the PCI bus.
322 */
323bool is_cse_devfn_visible(unsigned int devfn);
324
325/*
Sridhar Siricilla2cc66912019-08-31 11:20:34 +0530326 * Check if the CSE device is enabled in device tree. Also check if the device
327 * is visible on the PCI bus by reading config space.
328 * Return true if device present and config space enabled, else return false.
329 */
330bool is_cse_enabled(void);
331
Sridhar Siricillaff072e62019-11-27 14:55:16 +0530332/* Makes the host ready to communicate with CSE */
333void cse_set_host_ready(void);
Sridhar Siricillab9d075b2019-08-31 11:38:33 +0530334
335/*
336 * Polls for ME state 'HECI_OP_MODE_SEC_OVERRIDE' for 15 seconds.
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +0530337 * Returns 0 on failure and 1 on success.
Sridhar Siricillab9d075b2019-08-31 11:38:33 +0530338 */
Sridhar Siricillaff072e62019-11-27 14:55:16 +0530339uint8_t cse_wait_sec_override_mode(void);
Sridhar Siricillab9d075b2019-08-31 11:38:33 +0530340
Sridhar Siricillaf2eb6872019-12-05 19:54:16 +0530341enum rst_req_type {
342 GLOBAL_RESET = 1,
Sridhar Siricillaf2eb6872019-12-05 19:54:16 +0530343 CSE_RESET_ONLY = 3,
344};
345
Sridhar Siricillad415c202019-08-31 14:54:57 +0530346/*
Subrata Banikf463dc02020-09-14 19:04:03 +0530347 * Sends GLOBAL_RESET_REQ cmd to CSE with reset type GLOBAL_RESET.
Sridhar Siricillaf2eb6872019-12-05 19:54:16 +0530348 * Returns 0 on failure and 1 on success.
Sridhar Siricillad415c202019-08-31 14:54:57 +0530349 */
Subrata Banikf463dc02020-09-14 19:04:03 +0530350int cse_request_global_reset(void);
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530351/*
Sridhar Siricillad16187e2019-11-27 16:02:47 +0530352 * Sends HMRFPO_ENABLE command.
353 * HMRFPO - Host ME Region Flash Protection Override.
Sridhar Siricilla6ad70102020-05-12 21:28:53 +0530354 * For CSE Lite SKU, procedure to place CSE in HMRFPO (SECOVER_MEI_MSG) mode:
355 * 1. Ensure CSE boots from RO(BP1).
356 * - Set CSE's next boot partition to RO
357 * - Issue GLOBAL_RESET command to reset the system
Sridhar Siricillad16187e2019-11-27 16:02:47 +0530358 * 2. Send HMRFPO_ENABLE command to CSE. Further, no reset is required.
359 *
360 * The HMRFPO mode prevents CSE to execute SPI I/O cycles to CSE region, and unlocks
361 * the CSE region to perform updates to it.
362 * This command is only valid before EOP.
363 *
364 * Returns 0 on failure to send HECI command and to enable HMRFPO mode, and 1 on success.
365 *
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530366 */
Sridhar Siricillaad6d3122023-01-10 14:59:35 +0530367enum cb_err cse_hmrfpo_enable(void);
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530368
369/*
370 * Send HMRFPO_GET_STATUS command.
371 * returns -1 on failure and 0 (DISABLED)/ 1 (LOCKED)/ 2 (ENABLED)
372 * on success.
373 */
Sridhar Siricillaff072e62019-11-27 14:55:16 +0530374int cse_hmrfpo_get_status(void);
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530375
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530376/* Fixed Address MEI Header's Host Address field value */
377#define BIOS_HOST_ADDR 0x00
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530378
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530379/* Fixed Address MEI Header's ME Address field value */
380#define HECI_MKHI_ADDR 0x07
Andrey Petrov04a72c42017-03-01 15:51:57 -0800381
Tim Wawrzynczak9fdd2b22021-06-18 10:34:09 -0600382/* Fixed Address MEI Header's ME Address for MEI bus messages */
383#define HECI_MEI_ADDR 0x00
384
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530385/* HMRFPO Status types */
Sridhar Siricilla63be9182020-01-19 12:38:56 +0530386/* Host can't access ME region */
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530387#define MKHI_HMRFPO_DISABLED 0
Sridhar Siricilla63be9182020-01-19 12:38:56 +0530388
389/*
390 * ME Firmware locked down HMRFPO Feature.
391 * Host can't access ME region.
392 */
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530393#define MKHI_HMRFPO_LOCKED 1
Sridhar Siricilla63be9182020-01-19 12:38:56 +0530394
395/* Host can access ME region */
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530396#define MKHI_HMRFPO_ENABLED 2
397
Sridhar Siricilla8e465452019-09-23 20:59:38 +0530398/*
Sridhar Siricilla24a974a2020-02-19 14:41:36 +0530399 * Queries and logs ME firmware version
400 */
401void print_me_fw_version(void *unused);
402
403/*
Johnny Lin72e76672021-10-09 12:35:35 +0800404 * Queries and gets ME firmware version
405 */
406enum cb_err get_me_fw_version(struct me_fw_ver_resp *resp);
407
408/*
Sridhar Siricilla8e465452019-09-23 20:59:38 +0530409 * Checks current working operation state is normal or not.
410 * Returns true if CSE's current working state is normal, otherwise false.
411 */
412bool cse_is_hfs1_cws_normal(void);
413
414/*
415 * Checks CSE's current operation mode is normal or not.
416 * Returns true if CSE's current operation mode is normal, otherwise false.
417 */
418bool cse_is_hfs1_com_normal(void);
419
420/*
421 * Checks CSE's current operation mode is SECOVER_MEI_MSG or not.
422 * Returns true if CSE's current operation mode is SECOVER_MEI_MSG, otherwise false.
423 */
424bool cse_is_hfs1_com_secover_mei_msg(void);
425
426/*
427 * Checks CSE's current operation mode is Soft Disable Mode or not.
428 * Returns true if CSE's current operation mode is Soft Disable Mode, otherwise false.
429 */
430bool cse_is_hfs1_com_soft_temp_disable(void);
431
Sridhar Siricilla3465d272020-02-06 15:31:04 +0530432/*
Subrata Banike74ebcd2021-12-27 10:49:19 +0000433 * Checks CSE's spi protection mode is protected or unprotected.
434 * Returns true if CSE's spi protection mode is protected, otherwise false.
435 */
436bool cse_is_hfs1_spi_protected(void);
437
438/*
Sridhar Siricilla99dbca32020-05-12 21:05:04 +0530439 * Checks CSE's Firmware SKU is Lite or not.
440 * Returns true if CSE's Firmware SKU is Lite, otherwise false
Sridhar Siricilla3465d272020-02-06 15:31:04 +0530441 */
Sridhar Siricilla99dbca32020-05-12 21:05:04 +0530442bool cse_is_hfs3_fw_sku_lite(void);
Sridhar Siricilla3465d272020-02-06 15:31:04 +0530443
Sridhar Siricilla09ea3712019-11-12 23:35:50 +0530444/*
445 * Polls for CSE's current operation mode 'Soft Temp Disable'.
446 * Returns 0 on failure and 1 on success.
447 */
448uint8_t cse_wait_com_soft_temp_disable(void);
Sridhar Siricillaf87ff332019-09-12 17:18:20 +0530449
450/*
Sridhar Siricilla99dbca32020-05-12 21:05:04 +0530451 * The CSE Lite SKU supports notion of RO and RW boot partitions. The function will set
Jon Murphyc4e90452022-06-28 10:36:23 -0600452 * CSE's boot partition as per ChromeOS boot modes. In normal mode, the function allows CSE to
Sridhar Siricillaf87ff332019-09-12 17:18:20 +0530453 * boot from RW and triggers recovery mode if CSE fails to jump to RW.
454 * In software triggered recovery mode, the function allows CSE to boot from whatever is
455 * currently selected partition.
456 */
Sridhar Siricilla1a2b7022020-12-04 02:22:28 +0530457void cse_fw_sync(void);
Karthikeyan Ramasubramanianf9cc6372020-08-04 16:38:58 -0600458
459/* Perform a board-specific reset sequence for CSE RO<->RW jump */
460void cse_board_reset(void);
461
Jeremy Compostella08b5200d2023-01-19 11:32:25 -0700462/* Perform a misc operation before CSE firmware update. */
463void cse_fw_update_misc_oper(void);
464
Tim Wawrzynczak09635f42021-06-18 10:08:47 -0600465/* Trigger vboot recovery mode on a CSE error */
466void cse_trigger_vboot_recovery(enum csme_failure_reason reason);
467
Subrata Banika219edb2021-09-25 15:02:37 +0530468enum cse_device_state {
469 DEV_IDLE,
470 DEV_ACTIVE,
471};
472
473/* Function to get the current CSE device state as per `cse_device_state` */
Subrata Banikc6e25522021-09-30 18:14:09 +0530474enum cse_device_state get_cse_device_state(unsigned int devfn);
Subrata Banika219edb2021-09-25 15:02:37 +0530475
476/* Function that put the CSE into desired state based on `requested_state` */
Subrata Banikc6e25522021-09-30 18:14:09 +0530477bool set_cse_device_state(unsigned int devfn, enum cse_device_state requested_state);
Subrata Banika219edb2021-09-25 15:02:37 +0530478
Krishna Prasad Bhat333edcc2021-11-26 06:52:27 +0530479/*
480 * Check if cse sub-parition update is required or not.
481 * Returns true if cse sub-parition update is required otherwise false.
482 */
483bool skip_cse_sub_part_update(void);
Bora Guvendikf33c9bf2021-11-05 23:09:25 -0700484
485/*
486 * This command retrieves a set of boot performance timestamps CSME collected during
487 * the last platform boot flow.
488 */
Sridhar Siricilladd7d51d2023-01-10 15:05:07 +0530489enum cb_err cse_get_boot_performance_data(struct cse_boot_perf_rsp *boot_perf);
Bora Guvendikf33c9bf2021-11-05 23:09:25 -0700490
Subrata Banik736f9cc2022-01-27 20:52:46 +0530491/* Function to make cse disable using PMC IPC */
492bool cse_disable_mei_devices(void);
493
Subrata Banik526cc3e2022-01-31 21:55:51 +0530494/* Set CSE device state to D0I3 */
495void cse_set_to_d0i3(void);
496
497/* Function sets D0I3 for all HECI devices */
498void heci_set_to_d0i3(void);
499
Subrata Banik80c92892022-02-01 00:26:55 +0530500/* Function performs the global reset lock */
501void cse_control_global_reset_lock(void);
502
Subrata Banik7c31d172022-02-01 00:11:29 +0530503/* Send End of Post (EOP) command to CSE device */
504void cse_send_end_of_post(void);
505
Subrata Banik32e06732022-01-28 02:05:15 +0530506/*
Subrata Banik17a3da82022-11-24 21:51:42 +0530507 * This function to perform essential post EOP cse related operations
508 * upon SoC selecting `SOC_INTEL_CSE_SEND_EOP_LATE` config
509 */
510void cse_late_finalize(void);
511
512/*
Subrata Banik32e06732022-01-28 02:05:15 +0530513 * SoC override API to make heci1 disable using PCR.
514 *
515 * Allow SoC to implement heci1 disable override due to PSF registers being
516 * different across SoC generation.
517 */
518void soc_disable_heci1_using_pcr(void);
519
Bora Guvendik860672e2021-09-26 17:25:48 -0700520/*
Subrata Banikfc313d62023-04-14 01:31:29 +0530521 * SoC override API to identify if ISH Firmware existed inside CSE FPT.
522 *
523 * This override is required to avoid making default call into non-ISH
524 * supported SKU to attempt to retrieve ISH version which would results into
525 * increased boot time by 100ms+.
526 *
527 * Ideally SoC with UFS enabled would like to keep ISH enabled as well, hence
528 * identifying the UFS enabled device is enough to conclude if ISH partition is
529 * available.
530 */
Subrata Banik272ce9a2023-06-13 00:44:44 +0530531#if CONFIG(SOC_INTEL_STORE_ISH_FW_VERSION)
Subrata Banikfc313d62023-04-14 01:31:29 +0530532bool soc_is_ish_partition_enabled(void);
533#else
534static inline bool soc_is_ish_partition_enabled(void)
535{
536 /* Default implementation, ISH not enabled. */
537 return false;
538}
539#endif
540
541/*
Bora Guvendik94050492023-03-12 12:24:58 -0700542 * Injects CSE timestamps into cbmem timestamp table. SoC code needs to
543 * implement it since timestamp definitions differ from SoC to SoC.
544 */
545void soc_cbmem_inject_telemetry_data(s64 *ts, s64 current_time);
546
547/*
Bora Guvendik860672e2021-09-26 17:25:48 -0700548 * Get all the timestamps CSE collected using cse_get_boot_performance_data() and
549 * insert them into the CBMEM timestamp table.
550 */
551void cse_get_telemetry_data(void);
552
Subrata Banikda527ec2022-11-24 15:42:35 +0530553/* Function to log the cse WP information like range, if WP etc. */
554void cse_log_ro_write_protection_info(bool mfg_mode);
555
Michał Żygowskidaa17102022-10-04 10:55:38 +0200556/*
557 * Changes Intel PTT feature state at runtime. Global reset is required after
558 * successful HECI command completion.
559 */
560void cse_enable_ptt(bool state);
561
562/*
563 * Queries CSE for runtime status of firmware features.
564 * Returns 0 on success and < 0 on failure.
565 */
566enum cb_err cse_get_fw_feature_state(uint32_t *feature_state);
567
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530568#endif // SOC_INTEL_COMMON_CSE_H