blob: ebf20ed85732b3bcd1db5b11a02b3c400c6388f2 [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
Subrata Banik65a6d172023-08-13 13:03:50 +0000163/* CSE Specific Information */
164struct cse_specific_info {
165 struct cse_fw_partition_info cse_fwp_version;
166 bool cse_downgrade_requested;
167 uint32_t crc;
168};
169
Krishna Prasad Bhat98fb5ff2023-07-18 21:49:17 +0530170/* PSR backup status */
171enum psr_backup_state {
172 PSR_BACKUP_DONE = 0,
173 PSR_BACKUP_PENDING = 1,
174};
175
176struct psr_backup_status {
177 uint32_t signature;
178 int8_t value;
179 uint16_t checksum;
180};
181
Sridhar Siricilla6836da22022-02-23 23:36:45 +0530182/* CSE RX and TX error status */
183enum cse_tx_rx_status {
184 /*
185 * Transmission of HECI message is success or
186 * Reception of HECI message is success.
187 */
188 CSE_TX_RX_SUCCESS = 0,
189
190 /* Timeout to send a message to CSE */
191 CSE_TX_ERR_TIMEOUT = 1,
192
193 /* Timeout to receive the response message from CSE */
194 CSE_RX_ERR_TIMEOUT = 2,
195
196 /*
197 * Response length doesn't match with expected
198 * response message length
199 */
200 CSE_RX_ERR_RESP_LEN_MISMATCH = 3,
201
202 /* CSE is not ready during TX flow */
203 CSE_TX_ERR_CSE_NOT_READY = 4,
204
205 /* CSE is not ready during RX flow */
206 CSE_RX_ERR_CSE_NOT_READY = 5,
207
208 /* Invalid input arguments provided for TX API */
209 CSE_TX_ERR_INPUT = 6,
210
211 /* Invalid input arguments provided for RX API */
212 CSE_RX_ERR_INPUT = 7,
213};
214
Tim Wawrzynczake380a432021-06-18 09:54:55 -0600215/* CSE recovery sub-error codes */
216enum csme_failure_reason {
217 /* No error */
218 CSE_NO_ERROR = 0,
219
220 /* Unspecified error */
221 CSE_ERROR_UNSPECIFIED = 1,
222
223 /* CSE fails to boot from RW */
224 CSE_LITE_SKU_RW_JUMP_ERROR = 2,
225
226 /* CSE RW boot partition access error */
227 CSE_LITE_SKU_RW_ACCESS_ERROR = 3,
228
229 /* Fails to set next boot partition as RW */
230 CSE_LITE_SKU_RW_SWITCH_ERROR = 4,
231
232 /* CSE firmware update failure */
233 CSE_LITE_SKU_FW_UPDATE_ERROR = 5,
234
235 /* Fails to communicate with CSE */
236 CSE_COMMUNICATION_ERROR = 6,
237
238 /* Fails to wipe CSE runtime data */
239 CSE_LITE_SKU_DATA_WIPE_ERROR = 7,
240
241 /* CSE RW is not found */
242 CSE_LITE_SKU_RW_BLOB_NOT_FOUND = 8,
243
244 /* CSE CBFS RW SHA-256 mismatch with the provided SHA */
245 CSE_LITE_SKU_RW_BLOB_SHA256_MISMATCH = 9,
246
247 /* CSE CBFS RW metadata is not found */
248 CSE_LITE_SKU_RW_METADATA_NOT_FOUND = 10,
249
250 /* CSE CBFS RW blob layout is not correct */
251 CSE_LITE_SKU_LAYOUT_MISMATCH_ERROR = 11,
Tim Wawrzynczak064ca182021-06-17 12:40:13 -0600252
253 /* Error sending EOP to CSE */
254 CSE_EOP_FAIL = 12,
Krishna Prasad Bhat333edcc2021-11-26 06:52:27 +0530255
256 /* CSE Sub-partition update fail */
257 CSE_LITE_SKU_SUB_PART_UPDATE_FAIL = 13,
258
259 /* CSE sub-partition access failure */
260 CSE_LITE_SKU_SUB_PART_ACCESS_ERR = 14,
261
262 /* CSE CBFS sub-partition access error */
263 CSE_LITE_SKU_SUB_PART_BLOB_ACCESS_ERR = 15,
264
265 /* CSE Lite sub-partition update is not required */
266 CSE_LITE_SKU_SUB_PART_UPDATE_NOT_REQ = 16,
267
268 /* CSE Lite sub-partition layout mismatch error */
269 CSE_LITE_SKU_SUB_PART_LAYOUT_MISMATCH_ERROR = 17,
270
271 /* CSE Lite sub-partition update success */
272 CSE_LITE_SKU_PART_UPDATE_SUCCESS = 18,
Tim Wawrzynczake380a432021-06-18 09:54:55 -0600273};
274
Bora Guvendikf33c9bf2021-11-05 23:09:25 -0700275/* CSE boot performance data */
276struct cse_boot_perf_rsp {
277 struct mkhi_hdr hdr;
278
279 /* Data version */
280 uint32_t version;
281
282 /* Data length in DWORDs, represents number of valid elements in timestamp array */
283 uint32_t num_valid_timestamps;
284
285 /* Boot performance data */
286 uint32_t timestamp[NUM_CSE_BOOT_PERF_DATA];
287} __packed;
288
Subrata Banik0b92aa62022-06-01 06:54:44 +0000289/*
290 * Initialize the CSE device.
291 *
292 * Set up CSE device for use in early boot environment with temp bar.
293 */
294void cse_init(uintptr_t bar);
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530295
Subrata Banik801dbf42022-06-01 07:56:40 +0000296/* Initialize the HECI devices. */
297void heci_init(void);
298
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530299/*
Jeremy Compostella0e1be042023-03-13 13:41:43 -0700300 * Send message msg of size len to host from host_addr to cse_addr.
301 * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios.
302 * Also, in case of errors, heci_reset() is triggered.
303 */
304enum cse_tx_rx_status heci_send(const void *msg, size_t len, uint8_t host_addr,
305 uint8_t client_addr);
306
307/*
308 * Receive message into buff not exceeding maxlen. Message is considered
309 * successfully received if a 'complete' indication is read from ME side
310 * and there was enough space in the buffer to fit that message. maxlen
311 * is updated with size of message that was received.
312 * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios.
313 * Also, in case of errors, heci_reset() is triggered.
314 */
315enum cse_tx_rx_status heci_receive(void *buff, size_t *maxlen);
316
317/*
Rizwan Qureshi957857d2021-08-30 16:43:57 +0530318 * Send message from BIOS_HOST_ADDR to cse_addr.
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530319 * Sends snd_msg of size snd_sz, and reads message into buffer pointed by
320 * rcv_msg of size rcv_sz
Sridhar Siricilla6836da22022-02-23 23:36:45 +0530321 * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios.
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530322 */
Sridhar Siricilla6836da22022-02-23 23:36:45 +0530323enum cse_tx_rx_status heci_send_receive(const void *snd_msg, size_t snd_sz, void *rcv_msg,
324 size_t *rcv_sz, uint8_t cse_addr);
Sridhar Siricillaa5208f52019-08-30 17:10:24 +0530325
Andrey Petrov04a72c42017-03-01 15:51:57 -0800326/*
327 * Attempt device reset. This is useful and perhaps only thing left to do when
328 * CPU and CSE are out of sync or CSE fails to respond.
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +0530329 * Returns 0 on failure and 1 on success.
Andrey Petrov04a72c42017-03-01 15:51:57 -0800330 */
331int heci_reset(void);
Subrata Banik32e06732022-01-28 02:05:15 +0530332/* Disable HECI1 using Sideband interface communication */
333void heci1_disable(void);
Andrey Petrov04a72c42017-03-01 15:51:57 -0800334
Sridhar Siricilla2cc66912019-08-31 11:20:34 +0530335/* Reads config value from a specified offset in the CSE PCI Config space. */
336uint32_t me_read_config32(int offset);
337
338/*
Subrata Banik3710e992021-09-30 16:59:09 +0530339 * Check if the CSE device as per function argument `devfn` is enabled in device tree
340 * and also visible on the PCI bus.
341 */
342bool is_cse_devfn_visible(unsigned int devfn);
343
344/*
Sridhar Siricilla2cc66912019-08-31 11:20:34 +0530345 * Check if the CSE device is enabled in device tree. Also check if the device
346 * is visible on the PCI bus by reading config space.
347 * Return true if device present and config space enabled, else return false.
348 */
349bool is_cse_enabled(void);
350
Sridhar Siricillaff072e62019-11-27 14:55:16 +0530351/* Makes the host ready to communicate with CSE */
352void cse_set_host_ready(void);
Sridhar Siricillab9d075b2019-08-31 11:38:33 +0530353
354/*
355 * Polls for ME state 'HECI_OP_MODE_SEC_OVERRIDE' for 15 seconds.
Sridhar Siricilla1d20cfa2020-01-12 12:29:15 +0530356 * Returns 0 on failure and 1 on success.
Sridhar Siricillab9d075b2019-08-31 11:38:33 +0530357 */
Sridhar Siricillaff072e62019-11-27 14:55:16 +0530358uint8_t cse_wait_sec_override_mode(void);
Sridhar Siricillab9d075b2019-08-31 11:38:33 +0530359
Sridhar Siricillaf2eb6872019-12-05 19:54:16 +0530360enum rst_req_type {
361 GLOBAL_RESET = 1,
Sridhar Siricillaf2eb6872019-12-05 19:54:16 +0530362 CSE_RESET_ONLY = 3,
363};
364
Sridhar Siricillad415c202019-08-31 14:54:57 +0530365/*
Subrata Banikf463dc02020-09-14 19:04:03 +0530366 * Sends GLOBAL_RESET_REQ cmd to CSE with reset type GLOBAL_RESET.
Sridhar Siricillaf2eb6872019-12-05 19:54:16 +0530367 * Returns 0 on failure and 1 on success.
Sridhar Siricillad415c202019-08-31 14:54:57 +0530368 */
Subrata Banikf463dc02020-09-14 19:04:03 +0530369int cse_request_global_reset(void);
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530370/*
Sridhar Siricillad16187e2019-11-27 16:02:47 +0530371 * Sends HMRFPO_ENABLE command.
372 * HMRFPO - Host ME Region Flash Protection Override.
Sridhar Siricilla6ad70102020-05-12 21:28:53 +0530373 * For CSE Lite SKU, procedure to place CSE in HMRFPO (SECOVER_MEI_MSG) mode:
374 * 1. Ensure CSE boots from RO(BP1).
375 * - Set CSE's next boot partition to RO
376 * - Issue GLOBAL_RESET command to reset the system
Sridhar Siricillad16187e2019-11-27 16:02:47 +0530377 * 2. Send HMRFPO_ENABLE command to CSE. Further, no reset is required.
378 *
379 * The HMRFPO mode prevents CSE to execute SPI I/O cycles to CSE region, and unlocks
380 * the CSE region to perform updates to it.
381 * This command is only valid before EOP.
382 *
383 * Returns 0 on failure to send HECI command and to enable HMRFPO mode, and 1 on success.
384 *
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530385 */
Sridhar Siricillaad6d3122023-01-10 14:59:35 +0530386enum cb_err cse_hmrfpo_enable(void);
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530387
388/*
389 * Send HMRFPO_GET_STATUS command.
390 * returns -1 on failure and 0 (DISABLED)/ 1 (LOCKED)/ 2 (ENABLED)
391 * on success.
392 */
Sridhar Siricillaff072e62019-11-27 14:55:16 +0530393int cse_hmrfpo_get_status(void);
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530394
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530395/* Fixed Address MEI Header's Host Address field value */
396#define BIOS_HOST_ADDR 0x00
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530397
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530398/* Fixed Address MEI Header's ME Address field value */
399#define HECI_MKHI_ADDR 0x07
Andrey Petrov04a72c42017-03-01 15:51:57 -0800400
Tim Wawrzynczak9fdd2b22021-06-18 10:34:09 -0600401/* Fixed Address MEI Header's ME Address for MEI bus messages */
402#define HECI_MEI_ADDR 0x00
403
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530404/* HMRFPO Status types */
Sridhar Siricilla63be9182020-01-19 12:38:56 +0530405/* Host can't access ME region */
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530406#define MKHI_HMRFPO_DISABLED 0
Sridhar Siricilla63be9182020-01-19 12:38:56 +0530407
408/*
409 * ME Firmware locked down HMRFPO Feature.
410 * Host can't access ME region.
411 */
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530412#define MKHI_HMRFPO_LOCKED 1
Sridhar Siricilla63be9182020-01-19 12:38:56 +0530413
414/* Host can access ME region */
Sridhar Siricillae30a0e62019-08-31 16:12:21 +0530415#define MKHI_HMRFPO_ENABLED 2
416
Sridhar Siricilla8e465452019-09-23 20:59:38 +0530417/*
Sridhar Siricilla24a974a2020-02-19 14:41:36 +0530418 * Queries and logs ME firmware version
419 */
420void print_me_fw_version(void *unused);
421
422/*
Johnny Lin72e76672021-10-09 12:35:35 +0800423 * Queries and gets ME firmware version
424 */
425enum cb_err get_me_fw_version(struct me_fw_ver_resp *resp);
426
427/*
Sridhar Siricilla8e465452019-09-23 20:59:38 +0530428 * Checks current working operation state is normal or not.
429 * Returns true if CSE's current working state is normal, otherwise false.
430 */
431bool cse_is_hfs1_cws_normal(void);
432
433/*
434 * Checks CSE's current operation mode is normal or not.
435 * Returns true if CSE's current operation mode is normal, otherwise false.
436 */
437bool cse_is_hfs1_com_normal(void);
438
439/*
440 * Checks CSE's current operation mode is SECOVER_MEI_MSG or not.
441 * Returns true if CSE's current operation mode is SECOVER_MEI_MSG, otherwise false.
442 */
443bool cse_is_hfs1_com_secover_mei_msg(void);
444
445/*
446 * Checks CSE's current operation mode is Soft Disable Mode or not.
447 * Returns true if CSE's current operation mode is Soft Disable Mode, otherwise false.
448 */
449bool cse_is_hfs1_com_soft_temp_disable(void);
450
Sridhar Siricilla3465d272020-02-06 15:31:04 +0530451/*
Subrata Banike74ebcd2021-12-27 10:49:19 +0000452 * Checks CSE's spi protection mode is protected or unprotected.
453 * Returns true if CSE's spi protection mode is protected, otherwise false.
454 */
455bool cse_is_hfs1_spi_protected(void);
456
457/*
Sridhar Siricilla99dbca32020-05-12 21:05:04 +0530458 * Checks CSE's Firmware SKU is Lite or not.
459 * Returns true if CSE's Firmware SKU is Lite, otherwise false
Sridhar Siricilla3465d272020-02-06 15:31:04 +0530460 */
Sridhar Siricilla99dbca32020-05-12 21:05:04 +0530461bool cse_is_hfs3_fw_sku_lite(void);
Sridhar Siricilla3465d272020-02-06 15:31:04 +0530462
Sridhar Siricilla09ea3712019-11-12 23:35:50 +0530463/*
464 * Polls for CSE's current operation mode 'Soft Temp Disable'.
465 * Returns 0 on failure and 1 on success.
466 */
467uint8_t cse_wait_com_soft_temp_disable(void);
Sridhar Siricillaf87ff332019-09-12 17:18:20 +0530468
469/*
Sridhar Siricilla99dbca32020-05-12 21:05:04 +0530470 * The CSE Lite SKU supports notion of RO and RW boot partitions. The function will set
Jon Murphyc4e90452022-06-28 10:36:23 -0600471 * CSE's boot partition as per ChromeOS boot modes. In normal mode, the function allows CSE to
Sridhar Siricillaf87ff332019-09-12 17:18:20 +0530472 * boot from RW and triggers recovery mode if CSE fails to jump to RW.
473 * In software triggered recovery mode, the function allows CSE to boot from whatever is
474 * currently selected partition.
475 */
Sridhar Siricilla1a2b7022020-12-04 02:22:28 +0530476void cse_fw_sync(void);
Karthikeyan Ramasubramanianf9cc6372020-08-04 16:38:58 -0600477
478/* Perform a board-specific reset sequence for CSE RO<->RW jump */
479void cse_board_reset(void);
480
Jeremy Compostella08b5200d2023-01-19 11:32:25 -0700481/* Perform a misc operation before CSE firmware update. */
482void cse_fw_update_misc_oper(void);
483
Tim Wawrzynczak09635f42021-06-18 10:08:47 -0600484/* Trigger vboot recovery mode on a CSE error */
485void cse_trigger_vboot_recovery(enum csme_failure_reason reason);
486
Subrata Banika219edb2021-09-25 15:02:37 +0530487enum cse_device_state {
488 DEV_IDLE,
489 DEV_ACTIVE,
490};
491
492/* Function to get the current CSE device state as per `cse_device_state` */
Subrata Banikc6e25522021-09-30 18:14:09 +0530493enum cse_device_state get_cse_device_state(unsigned int devfn);
Subrata Banika219edb2021-09-25 15:02:37 +0530494
495/* Function that put the CSE into desired state based on `requested_state` */
Subrata Banikc6e25522021-09-30 18:14:09 +0530496bool set_cse_device_state(unsigned int devfn, enum cse_device_state requested_state);
Subrata Banika219edb2021-09-25 15:02:37 +0530497
Krishna Prasad Bhat333edcc2021-11-26 06:52:27 +0530498/*
499 * Check if cse sub-parition update is required or not.
500 * Returns true if cse sub-parition update is required otherwise false.
501 */
502bool skip_cse_sub_part_update(void);
Bora Guvendikf33c9bf2021-11-05 23:09:25 -0700503
504/*
505 * This command retrieves a set of boot performance timestamps CSME collected during
506 * the last platform boot flow.
507 */
Sridhar Siricilladd7d51d2023-01-10 15:05:07 +0530508enum cb_err cse_get_boot_performance_data(struct cse_boot_perf_rsp *boot_perf);
Bora Guvendikf33c9bf2021-11-05 23:09:25 -0700509
Subrata Banik736f9cc2022-01-27 20:52:46 +0530510/* Function to make cse disable using PMC IPC */
511bool cse_disable_mei_devices(void);
512
Subrata Banik526cc3e2022-01-31 21:55:51 +0530513/* Set CSE device state to D0I3 */
514void cse_set_to_d0i3(void);
515
516/* Function sets D0I3 for all HECI devices */
517void heci_set_to_d0i3(void);
518
Subrata Banik80c92892022-02-01 00:26:55 +0530519/* Function performs the global reset lock */
520void cse_control_global_reset_lock(void);
521
Subrata Banik7c31d172022-02-01 00:11:29 +0530522/* Send End of Post (EOP) command to CSE device */
523void cse_send_end_of_post(void);
524
Subrata Banik32e06732022-01-28 02:05:15 +0530525/*
Subrata Banik17a3da82022-11-24 21:51:42 +0530526 * This function to perform essential post EOP cse related operations
527 * upon SoC selecting `SOC_INTEL_CSE_SEND_EOP_LATE` config
528 */
529void cse_late_finalize(void);
530
531/*
Subrata Banik32e06732022-01-28 02:05:15 +0530532 * SoC override API to make heci1 disable using PCR.
533 *
534 * Allow SoC to implement heci1 disable override due to PSF registers being
535 * different across SoC generation.
536 */
537void soc_disable_heci1_using_pcr(void);
538
Bora Guvendik860672e2021-09-26 17:25:48 -0700539/*
Subrata Banikfc313d62023-04-14 01:31:29 +0530540 * SoC override API to identify if ISH Firmware existed inside CSE FPT.
541 *
542 * This override is required to avoid making default call into non-ISH
543 * supported SKU to attempt to retrieve ISH version which would results into
544 * increased boot time by 100ms+.
545 *
546 * Ideally SoC with UFS enabled would like to keep ISH enabled as well, hence
547 * identifying the UFS enabled device is enough to conclude if ISH partition is
548 * available.
549 */
Subrata Banik272ce9a2023-06-13 00:44:44 +0530550#if CONFIG(SOC_INTEL_STORE_ISH_FW_VERSION)
Subrata Banikfc313d62023-04-14 01:31:29 +0530551bool soc_is_ish_partition_enabled(void);
552#else
553static inline bool soc_is_ish_partition_enabled(void)
554{
555 /* Default implementation, ISH not enabled. */
556 return false;
557}
558#endif
559
560/*
Bora Guvendik94050492023-03-12 12:24:58 -0700561 * Injects CSE timestamps into cbmem timestamp table. SoC code needs to
562 * implement it since timestamp definitions differ from SoC to SoC.
563 */
564void soc_cbmem_inject_telemetry_data(s64 *ts, s64 current_time);
565
566/*
Bora Guvendik860672e2021-09-26 17:25:48 -0700567 * Get all the timestamps CSE collected using cse_get_boot_performance_data() and
568 * insert them into the CBMEM timestamp table.
569 */
570void cse_get_telemetry_data(void);
571
Subrata Banikda527ec2022-11-24 15:42:35 +0530572/* Function to log the cse WP information like range, if WP etc. */
573void cse_log_ro_write_protection_info(bool mfg_mode);
574
Michał Żygowskidaa17102022-10-04 10:55:38 +0200575/*
576 * Changes Intel PTT feature state at runtime. Global reset is required after
577 * successful HECI command completion.
578 */
579void cse_enable_ptt(bool state);
580
581/*
582 * Queries CSE for runtime status of firmware features.
583 * Returns 0 on success and < 0 on failure.
584 */
585enum cb_err cse_get_fw_feature_state(uint32_t *feature_state);
586
Krishna Prasad Bhat4f062ec2023-09-21 23:33:34 +0530587/* Fills the CSE Boot Partition Info response */
588void cse_fill_bp_info(void);
589
Sridhar Siricilla83af7332020-01-08 00:13:21 +0530590#endif // SOC_INTEL_COMMON_CSE_H