| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #ifndef SOC_INTEL_COMMON_CSE_H |
| 4 | #define SOC_INTEL_COMMON_CSE_H |
| 5 | |
| 6 | #include <intelblocks/cse_telemetry.h> |
| 7 | #include <types.h> |
| 8 | #include <vb2_api.h> |
| 9 | |
| 10 | /* MKHI Command groups */ |
| 11 | enum 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 | }; |
| 18 | |
| 19 | /* Global Reset Command ID */ |
| 20 | #define MKHI_CBM_GLOBAL_RESET_REQ 0xb |
| 21 | |
| 22 | /* Set State Command ID */ |
| 23 | #define MKHI_SET_ME_DISABLE 0x3 |
| 24 | #define MKHI_SET_ME_ENABLE 0x3 |
| 25 | |
| 26 | /* Origin of Global Reset command */ |
| 27 | #define GR_ORIGIN_BIOS_POST 0x2 |
| 28 | |
| 29 | /* HMRFPO Command Ids */ |
| 30 | #define MKHI_HMRFPO_ENABLE 0x1 |
| 31 | #define MKHI_HMRFPO_GET_STATUS 0x3 |
| 32 | |
| 33 | /* Get Firmware Version Command Id */ |
| 34 | #define MKHI_GEN_GET_FW_VERSION 0x2 |
| 35 | |
| 36 | /* 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 | #define ME_FW_FEATURE_PSR BIT(5) |
| 44 | /* MEI bus disable command. Must be sent to MEI client endpoint, not MKHI */ |
| 45 | #define MEI_BUS_DISABLE_COMMAND 0xc |
| 46 | |
| 47 | /* Set End-of-POST in CSE */ |
| 48 | #define MKHI_END_OF_POST 0xc |
| 49 | |
| 50 | /* 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 |
| 53 | #define MKHI_BUP_COMMON_DATA_CLEAR 0x20 |
| 54 | #define GEN_GET_IMAGE_FW_VERSION 0x1c |
| 55 | |
| 56 | /* Get boot performance command id */ |
| 57 | #define MKHI_BUP_COMMON_GET_BOOT_PERF_DATA 0x8 |
| 58 | |
| 59 | /* ME Current Working States */ |
| 60 | #define ME_HFS1_CWS_M3_NO_UMA 0x4 |
| 61 | #define ME_HFS1_CWS_NORMAL 0x5 |
| 62 | |
| 63 | /* ME Current Operation Modes */ |
| 64 | #define ME_HFS1_COM_NORMAL 0x0 |
| 65 | #define ME_HFS1_COM_SOFT_TEMP_DISABLE 0x3 |
| 66 | #define ME_HFS1_COM_SECOVER_MEI_MSG 0x5 |
| 67 | |
| 68 | /* ME Disable Rule */ |
| 69 | #define ME_DISABLE_RULE_ID 6 |
| 70 | #define ME_DISABLE_RULE_LENGTH 4 |
| 71 | #define ME_DISABLE_COMMAND 0 |
| 72 | #define ME_DISABLE_ATTEMPTS 3 |
| 73 | |
| 74 | /* ME Firmware SKU Types */ |
| 75 | enum me_fw_sku { |
| 76 | ME_HFS3_FW_SKU_CONSUMER = 0x2, |
| 77 | ME_HFS3_FW_SKU_CORPORATE = 0x3, |
| 78 | ME_HFS3_FW_SKU_LITE = 0x5, |
| 79 | }; |
| 80 | |
| 81 | /* Number of cse boot performance data */ |
| 82 | #define NUM_CSE_BOOT_PERF_DATA 64 |
| 83 | |
| 84 | /* PSR_HECI_FW_DOWNGRADE_BACKUP Command */ |
| 85 | #define PSR_HECI_FW_DOWNGRADE_BACKUP 0x3 |
| 86 | |
| 87 | /* HFSTS register offsets in PCI config space */ |
| 88 | enum { |
| 89 | PCI_ME_HFSTS1 = 0x40, |
| 90 | PCI_ME_HFSTS2 = 0x48, |
| 91 | PCI_ME_HFSTS3 = 0x60, |
| 92 | PCI_ME_HFSTS4 = 0x64, |
| 93 | PCI_ME_HFSTS5 = 0x68, |
| 94 | PCI_ME_HFSTS6 = 0x6C, |
| 95 | }; |
| 96 | |
| 97 | /* CSE partition list */ |
| 98 | enum fpt_partition_id { |
| 99 | FPT_PARTITION_NAME_UNDEFINED = 0x0, |
| 100 | FPT_PARTITION_NAME_ISHC = 0x43485349, |
| 101 | }; |
| 102 | |
| 103 | /* MKHI Message Header */ |
| 104 | struct mkhi_hdr { |
| 105 | uint8_t group_id; |
| 106 | uint8_t command:7; |
| 107 | uint8_t is_resp:1; |
| 108 | uint8_t rsvd; |
| 109 | uint8_t result; |
| 110 | } __packed; |
| 111 | |
| 112 | /* PSR HECI message status */ |
| 113 | enum psr_status { |
| 114 | PSR_STATUS_SUCCESS, |
| 115 | PSR_STATUS_FEATURE_NOT_SUPPORTED, |
| 116 | PSR_STATUS_UPID_DISABLED, |
| 117 | PSR_STATUS_ACTION_NOT_ALLOWED, |
| 118 | PSR_STATUS_INVALID_INPUT_PARAMETER, |
| 119 | PSR_STATUS_INTERNAL_ERROR, |
| 120 | PSR_STATUS_NOT_ALLOWED_AFTER_EOP, |
| 121 | }; |
| 122 | |
| 123 | /* PSR HECI message header */ |
| 124 | struct psr_heci_header { |
| 125 | uint8_t command; |
| 126 | uint8_t reserved; |
| 127 | uint16_t length; |
| 128 | } __packed; |
| 129 | |
| 130 | /* CSE FW Version */ |
| 131 | struct fw_version { |
| 132 | uint16_t major; |
| 133 | uint16_t minor; |
| 134 | uint16_t hotfix; |
| 135 | uint16_t build; |
| 136 | } __packed; |
| 137 | |
| 138 | /* ME FW Version */ |
| 139 | struct me_version { |
| 140 | uint16_t minor; |
| 141 | uint16_t major; |
| 142 | uint16_t build; |
| 143 | uint16_t hotfix; |
| 144 | } __packed; |
| 145 | |
| 146 | /* ME FW Version response */ |
| 147 | struct me_fw_ver_resp { |
| 148 | struct mkhi_hdr hdr; |
| 149 | struct me_version code; |
| 150 | struct me_version rec; |
| 151 | struct me_version fitc; |
| 152 | } __packed; |
| 153 | |
| 154 | /* Module data from manifest */ |
| 155 | struct flash_partition_data { |
| 156 | enum fpt_partition_id partition_id; |
| 157 | uint8_t reserved1[8]; |
| 158 | struct fw_version version; |
| 159 | uint32_t vendor_id; |
| 160 | uint32_t tcb_svn; |
| 161 | uint32_t arb_svn; |
| 162 | uint32_t vcn; |
| 163 | uint32_t reserved2[13]; |
| 164 | }; |
| 165 | |
| 166 | /* Response header for partition information request */ |
| 167 | struct fw_version_resp { |
| 168 | struct mkhi_hdr hdr; |
| 169 | uint32_t module_count; |
| 170 | struct flash_partition_data manifest_data; |
| 171 | }; |
| 172 | |
| 173 | /* ISHC version */ |
| 174 | struct cse_fw_ish_version_info { |
| 175 | struct fw_version prev_cse_fw_version; |
| 176 | struct fw_version cur_ish_fw_version; |
| 177 | }; |
| 178 | |
| 179 | /* CSE and ISHC version */ |
| 180 | struct cse_fw_partition_info { |
| 181 | struct fw_version cur_cse_fw_version; |
| 182 | struct cse_fw_ish_version_info ish_partition_info; |
| 183 | }; |
| 184 | |
| 185 | /* CSE sync flags */ |
| 186 | enum cse_sync_flags { |
| 187 | CSE_DOWNGRADE_REQUEST = 1 << 0, |
| 188 | CSE_ENFORCED_SYNC_REQUEST = 1 << 1, |
| 189 | CSE_ENFORCED_SYNC_PERFORMED = 1 << 2, |
| 190 | }; |
| 191 | |
| 192 | /* CSE Specific Information */ |
| 193 | struct cse_specific_info { |
| 194 | struct cse_fw_partition_info cse_fwp_version; |
| 195 | int8_t cse_sync_status; |
| 196 | uint32_t crc; |
| 197 | }; |
| 198 | |
| 199 | /* PSR backup status */ |
| 200 | enum psr_backup_state { |
| 201 | PSR_BACKUP_DONE = 0, |
| 202 | PSR_BACKUP_PENDING = 1, |
| 203 | }; |
| 204 | |
| 205 | struct psr_backup_status { |
| 206 | uint32_t signature; |
| 207 | int8_t value; |
| 208 | uint16_t checksum; |
| 209 | }; |
| 210 | |
| 211 | /* CSE RX and TX error status */ |
| 212 | enum cse_tx_rx_status { |
| 213 | /* |
| 214 | * Transmission of HECI message is success or |
| 215 | * Reception of HECI message is success. |
| 216 | */ |
| 217 | CSE_TX_RX_SUCCESS = 0, |
| 218 | |
| 219 | /* Timeout to send a message to CSE */ |
| 220 | CSE_TX_ERR_TIMEOUT = 1, |
| 221 | |
| 222 | /* Timeout to receive the response message from CSE */ |
| 223 | CSE_RX_ERR_TIMEOUT = 2, |
| 224 | |
| 225 | /* |
| 226 | * Response length doesn't match with expected |
| 227 | * response message length |
| 228 | */ |
| 229 | CSE_RX_ERR_RESP_LEN_MISMATCH = 3, |
| 230 | |
| 231 | /* CSE is not ready during TX flow */ |
| 232 | CSE_TX_ERR_CSE_NOT_READY = 4, |
| 233 | |
| 234 | /* CSE is not ready during RX flow */ |
| 235 | CSE_RX_ERR_CSE_NOT_READY = 5, |
| 236 | |
| 237 | /* Invalid input arguments provided for TX API */ |
| 238 | CSE_TX_ERR_INPUT = 6, |
| 239 | |
| 240 | /* Invalid input arguments provided for RX API */ |
| 241 | CSE_RX_ERR_INPUT = 7, |
| 242 | }; |
| 243 | |
| 244 | /* CSE recovery sub-error codes */ |
| 245 | enum csme_failure_reason { |
| 246 | /* No error */ |
| 247 | CSE_NO_ERROR = 0, |
| 248 | |
| 249 | /* Unspecified error */ |
| 250 | CSE_ERROR_UNSPECIFIED = 1, |
| 251 | |
| 252 | /* CSE fails to boot from RW */ |
| 253 | CSE_LITE_SKU_RW_JUMP_ERROR = 2, |
| 254 | |
| 255 | /* CSE RW boot partition access error */ |
| 256 | CSE_LITE_SKU_RW_ACCESS_ERROR = 3, |
| 257 | |
| 258 | /* Fails to set next boot partition as RW */ |
| 259 | CSE_LITE_SKU_RW_SWITCH_ERROR = 4, |
| 260 | |
| 261 | /* CSE firmware update failure */ |
| 262 | CSE_LITE_SKU_FW_UPDATE_ERROR = 5, |
| 263 | |
| 264 | /* Fails to communicate with CSE */ |
| 265 | CSE_COMMUNICATION_ERROR = 6, |
| 266 | |
| 267 | /* Fails to wipe CSE runtime data */ |
| 268 | CSE_LITE_SKU_DATA_WIPE_ERROR = 7, |
| 269 | |
| 270 | /* CSE RW is not found */ |
| 271 | CSE_LITE_SKU_RW_BLOB_NOT_FOUND = 8, |
| 272 | |
| 273 | /* CSE CBFS RW SHA-256 mismatch with the provided SHA */ |
| 274 | CSE_LITE_SKU_RW_BLOB_SHA256_MISMATCH = 9, |
| 275 | |
| 276 | /* CSE CBFS RW metadata is not found */ |
| 277 | CSE_LITE_SKU_RW_METADATA_NOT_FOUND = 10, |
| 278 | |
| 279 | /* CSE CBFS RW blob layout is not correct */ |
| 280 | CSE_LITE_SKU_LAYOUT_MISMATCH_ERROR = 11, |
| 281 | |
| 282 | /* Error sending EOP to CSE */ |
| 283 | CSE_EOP_FAIL = 12, |
| 284 | |
| 285 | /* CSE Sub-partition update fail */ |
| 286 | CSE_LITE_SKU_SUB_PART_UPDATE_FAIL = 13, |
| 287 | |
| 288 | /* CSE sub-partition access failure */ |
| 289 | CSE_LITE_SKU_SUB_PART_ACCESS_ERR = 14, |
| 290 | |
| 291 | /* CSE CBFS sub-partition access error */ |
| 292 | CSE_LITE_SKU_SUB_PART_BLOB_ACCESS_ERR = 15, |
| 293 | |
| 294 | /* CSE Lite sub-partition update is not required */ |
| 295 | CSE_LITE_SKU_SUB_PART_UPDATE_NOT_REQ = 16, |
| 296 | |
| 297 | /* CSE Lite sub-partition layout mismatch error */ |
| 298 | CSE_LITE_SKU_SUB_PART_LAYOUT_MISMATCH_ERROR = 17, |
| 299 | |
| 300 | /* CSE Lite sub-partition update success */ |
| 301 | CSE_LITE_SKU_PART_UPDATE_SUCCESS = 18, |
| 302 | }; |
| 303 | |
| 304 | /* CSE boot performance data */ |
| 305 | struct cse_boot_perf_rsp { |
| 306 | struct mkhi_hdr hdr; |
| 307 | |
| 308 | /* Data version */ |
| 309 | uint32_t version; |
| 310 | |
| 311 | /* Data length in DWORDs, represents number of valid elements in timestamp array */ |
| 312 | uint32_t num_valid_timestamps; |
| 313 | |
| 314 | /* Boot performance data */ |
| 315 | uint32_t timestamp[NUM_CSE_BOOT_PERF_DATA]; |
| 316 | } __packed; |
| 317 | |
| 318 | /* |
| 319 | * Initialize the CSE device. |
| 320 | * |
| 321 | * Set up CSE device for use in early boot environment with temp bar. |
| 322 | */ |
| 323 | void cse_init(uintptr_t bar); |
| 324 | |
| 325 | /* Initialize the HECI devices. */ |
| 326 | void heci_init(void); |
| 327 | |
| 328 | /* |
| 329 | * Send message msg of size len to host from host_addr to cse_addr. |
| 330 | * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios. |
| 331 | * Also, in case of errors, heci_reset() is triggered. |
| 332 | */ |
| 333 | enum cse_tx_rx_status heci_send(const void *msg, size_t len, uint8_t host_addr, |
| 334 | uint8_t client_addr); |
| 335 | |
| 336 | /* |
| 337 | * Receive message into buff not exceeding maxlen. Message is considered |
| 338 | * successfully received if a 'complete' indication is read from ME side |
| 339 | * and there was enough space in the buffer to fit that message. maxlen |
| 340 | * is updated with size of message that was received. |
| 341 | * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios. |
| 342 | * Also, in case of errors, heci_reset() is triggered. |
| 343 | */ |
| 344 | enum cse_tx_rx_status heci_receive(void *buff, size_t *maxlen); |
| 345 | |
| 346 | /* |
| 347 | * Send message from BIOS_HOST_ADDR to cse_addr. |
| 348 | * Sends snd_msg of size snd_sz, and reads message into buffer pointed by |
| 349 | * rcv_msg of size rcv_sz |
| 350 | * Returns CSE_TX_RX_SUCCESS on success and other enum values on failure scenarios. |
| 351 | */ |
| 352 | enum cse_tx_rx_status heci_send_receive(const void *snd_msg, size_t snd_sz, void *rcv_msg, |
| 353 | size_t *rcv_sz, uint8_t cse_addr); |
| 354 | |
| 355 | /* |
| 356 | * Attempt device reset. This is useful and perhaps only thing left to do when |
| 357 | * CPU and CSE are out of sync or CSE fails to respond. |
| 358 | * Returns 0 on failure and 1 on success. |
| 359 | */ |
| 360 | int heci_reset(void); |
| 361 | /* Disable HECI1 using Sideband interface communication */ |
| 362 | void heci1_disable(void); |
| 363 | |
| 364 | /* Reads config value from a specified offset in the CSE PCI Config space. */ |
| 365 | uint32_t me_read_config32(int offset); |
| 366 | |
| 367 | /* |
| 368 | * Check if the CSE device as per function argument `devfn` is enabled in device tree |
| 369 | * and also visible on the PCI bus. |
| 370 | */ |
| 371 | bool is_cse_devfn_visible(unsigned int devfn); |
| 372 | |
| 373 | /* |
| 374 | * Check if the CSE device is enabled in device tree. Also check if the device |
| 375 | * is visible on the PCI bus by reading config space. |
| 376 | * Return true if device present and config space enabled, else return false. |
| 377 | */ |
| 378 | bool is_cse_enabled(void); |
| 379 | |
| 380 | /* Makes the host ready to communicate with CSE */ |
| 381 | void cse_set_host_ready(void); |
| 382 | |
| 383 | /* |
| 384 | * Polls for ME state 'HECI_OP_MODE_SEC_OVERRIDE' for 15 seconds. |
| 385 | * Returns 0 on failure and 1 on success. |
| 386 | */ |
| 387 | uint8_t cse_wait_sec_override_mode(void); |
| 388 | |
| 389 | enum rst_req_type { |
| 390 | GLOBAL_RESET = 1, |
| 391 | CSE_RESET_ONLY = 3, |
| 392 | }; |
| 393 | |
| 394 | enum cse_fw_sts_current_pm_event { |
| 395 | PWR_CYCLE_RESET_CMOFF = 0xb, |
| 396 | }; |
| 397 | |
| 398 | /* |
| 399 | * Sends GLOBAL_RESET_REQ cmd to CSE with reset type GLOBAL_RESET. |
| 400 | * Returns 0 on failure and 1 on success. |
| 401 | */ |
| 402 | int cse_request_global_reset(void); |
| 403 | /* |
| 404 | * Sends HMRFPO_ENABLE command. |
| 405 | * HMRFPO - Host ME Region Flash Protection Override. |
| 406 | * For CSE Lite SKU, procedure to place CSE in HMRFPO (SECOVER_MEI_MSG) mode: |
| 407 | * 1. Ensure CSE boots from RO(BP1). |
| 408 | * - Set CSE's next boot partition to RO |
| 409 | * - Issue GLOBAL_RESET command to reset the system |
| 410 | * 2. Send HMRFPO_ENABLE command to CSE. Further, no reset is required. |
| 411 | * |
| 412 | * The HMRFPO mode prevents CSE to execute SPI I/O cycles to CSE region, and unlocks |
| 413 | * the CSE region to perform updates to it. |
| 414 | * This command is only valid before EOP. |
| 415 | * |
| 416 | * Returns 0 on failure to send HECI command and to enable HMRFPO mode, and 1 on success. |
| 417 | * |
| 418 | */ |
| 419 | enum cb_err cse_hmrfpo_enable(void); |
| 420 | |
| 421 | /* |
| 422 | * Send HMRFPO_GET_STATUS command. |
| 423 | * returns -1 on failure and 0 (DISABLED)/ 1 (LOCKED)/ 2 (ENABLED) |
| 424 | * on success. |
| 425 | */ |
| 426 | int cse_hmrfpo_get_status(void); |
| 427 | |
| 428 | /* Fixed Address MEI Header's Host Address field value */ |
| 429 | #define BIOS_HOST_ADDR 0x00 |
| 430 | |
| 431 | /* Fixed Address MEI Header's ME Address field value */ |
| 432 | #define HECI_MKHI_ADDR 0x07 |
| 433 | |
| 434 | /* Fixed Address MEI Header's ME Address field value for PSR messages */ |
| 435 | #define HECI_PSR_ADDR 0x04 |
| 436 | |
| 437 | /* Fixed Address MEI Header's ME Address for MEI bus messages */ |
| 438 | #define HECI_MEI_ADDR 0x00 |
| 439 | |
| 440 | /* HMRFPO Status types */ |
| 441 | /* Host can't access ME region */ |
| 442 | #define MKHI_HMRFPO_DISABLED 0 |
| 443 | |
| 444 | /* |
| 445 | * ME Firmware locked down HMRFPO Feature. |
| 446 | * Host can't access ME region. |
| 447 | */ |
| 448 | #define MKHI_HMRFPO_LOCKED 1 |
| 449 | |
| 450 | /* Host can access ME region */ |
| 451 | #define MKHI_HMRFPO_ENABLED 2 |
| 452 | |
| 453 | /* |
| 454 | * Queries and logs ME firmware version |
| 455 | */ |
| 456 | void print_me_fw_version(void *unused); |
| 457 | |
| 458 | /* |
| 459 | * Checks current working operation state is normal or not. |
| 460 | * Returns true if CSE's current working state is normal, otherwise false. |
| 461 | */ |
| 462 | bool cse_is_hfs1_cws_normal(void); |
| 463 | |
| 464 | /* |
| 465 | * Checks current working operation state is M3_NO_UMA or not. |
| 466 | * Returns true if CSE's current working state is M3_NO_UMA, otherwise false. |
| 467 | */ |
| 468 | bool cse_is_hfs1_cws_m3_no_uma(void); |
| 469 | |
| 470 | /* |
| 471 | * Checks CSE's current operation mode is normal or not. |
| 472 | * Returns true if CSE's current operation mode is normal, otherwise false. |
| 473 | */ |
| 474 | bool cse_is_hfs1_com_normal(void); |
| 475 | |
| 476 | /* |
| 477 | * Checks CSE's current operation mode is SECOVER_MEI_MSG or not. |
| 478 | * Returns true if CSE's current operation mode is SECOVER_MEI_MSG, otherwise false. |
| 479 | */ |
| 480 | bool cse_is_hfs1_com_secover_mei_msg(void); |
| 481 | |
| 482 | /* |
| 483 | * Checks CSE's current operation mode is Soft Disable Mode or not. |
| 484 | * Returns true if CSE's current operation mode is Soft Disable Mode, otherwise false. |
| 485 | */ |
| 486 | bool cse_is_hfs1_com_soft_temp_disable(void); |
| 487 | |
| 488 | /* |
| 489 | * Checks CSE's spi protection mode is protected or unprotected. |
| 490 | * Returns true if CSE's spi protection mode is protected, otherwise false. |
| 491 | */ |
| 492 | bool cse_is_hfs1_spi_protected(void); |
| 493 | |
| 494 | /* |
| 495 | * Checks CSE's Firmware SKU is Lite or not. |
| 496 | * Returns true if CSE's Firmware SKU is Lite, otherwise false |
| 497 | */ |
| 498 | bool cse_is_hfs3_fw_sku_lite(void); |
| 499 | |
| 500 | /* |
| 501 | * Polls for CSE's current operation mode 'Soft Temp Disable'. |
| 502 | * Returns 0 on failure and 1 on success. |
| 503 | */ |
| 504 | uint8_t cse_wait_com_soft_temp_disable(void); |
| 505 | |
| 506 | /* |
| 507 | * The CSE Lite SKU supports notion of RO and RW boot partitions. The function will set |
| 508 | * CSE's boot partition as per ChromeOS boot modes. In normal mode, the function allows CSE to |
| 509 | * boot from RW and triggers recovery mode if CSE fails to jump to RW. |
| 510 | * In software triggered recovery mode, the function allows CSE to boot from whatever is |
| 511 | * currently selected partition. |
| 512 | */ |
| 513 | void cse_fw_sync(void); |
| 514 | |
| 515 | /* Perform a board-specific reset sequence for CSE RO<->RW jump */ |
| 516 | void cse_board_reset(void); |
| 517 | |
| 518 | /* Perform a misc operation before CSE firmware update. */ |
| 519 | void cse_fw_update_misc_oper(void); |
| 520 | |
| 521 | /* Trigger vboot recovery mode on a CSE error */ |
| 522 | void cse_trigger_vboot_recovery(enum csme_failure_reason reason); |
| 523 | |
| 524 | enum cse_device_state { |
| 525 | DEV_IDLE, |
| 526 | DEV_ACTIVE, |
| 527 | }; |
| 528 | |
| 529 | /* Function to get the current CSE device state as per `cse_device_state` */ |
| 530 | enum cse_device_state get_cse_device_state(unsigned int devfn); |
| 531 | |
| 532 | /* Function that put the CSE into desired state based on `requested_state` */ |
| 533 | bool set_cse_device_state(unsigned int devfn, enum cse_device_state requested_state); |
| 534 | |
| 535 | /* |
| 536 | * Check if cse sub-parition update is required or not. |
| 537 | * Returns true if cse sub-parition update is required otherwise false. |
| 538 | */ |
| 539 | bool skip_cse_sub_part_update(void); |
| 540 | |
| 541 | /* |
| 542 | * This command retrieves a set of boot performance timestamps CSME collected during |
| 543 | * the last platform boot flow. |
| 544 | */ |
| 545 | enum cb_err cse_get_boot_performance_data(struct cse_boot_perf_rsp *boot_perf); |
| 546 | |
| 547 | /* Function to make cse disable using PMC IPC */ |
| 548 | bool cse_disable_mei_devices(void); |
| 549 | |
| 550 | /* Set CSE device state to D0I3 */ |
| 551 | void cse_set_to_d0i3(void); |
| 552 | |
| 553 | /* Function sets D0I3 for all HECI devices */ |
| 554 | void heci_set_to_d0i3(void); |
| 555 | |
| 556 | /* Function performs the global reset lock */ |
| 557 | void cse_control_global_reset_lock(void); |
| 558 | |
| 559 | /* Send End of Post (EOP) command to CSE device */ |
| 560 | void cse_send_end_of_post(void); |
| 561 | |
| 562 | /* |
| 563 | * This function to perform essential post EOP cse related operations |
| 564 | * upon SoC selecting `SOC_INTEL_CSE_SEND_EOP_LATE` config |
| 565 | */ |
| 566 | void cse_late_finalize(void); |
| 567 | |
| 568 | /* |
| 569 | * SoC override API to make heci1 disable using PCR. |
| 570 | * |
| 571 | * Allow SoC to implement heci1 disable override due to PSF registers being |
| 572 | * different across SoC generation. |
| 573 | */ |
| 574 | void soc_disable_heci1_using_pcr(void); |
| 575 | |
| 576 | /* |
| 577 | * SoC override API to identify if ISH Firmware existed inside CSE FPT. |
| 578 | * |
| 579 | * This override is required to avoid making default call into non-ISH |
| 580 | * supported SKU to attempt to retrieve ISH version which would results into |
| 581 | * increased boot time by 100ms+. |
| 582 | * |
| 583 | * Ideally SoC with UFS enabled would like to keep ISH enabled as well, hence |
| 584 | * identifying the UFS enabled device is enough to conclude if ISH partition is |
| 585 | * available. |
| 586 | */ |
| 587 | #if CONFIG(SOC_INTEL_STORE_ISH_FW_VERSION) |
| 588 | bool soc_is_ish_partition_enabled(void); |
| 589 | #else |
| 590 | static inline bool soc_is_ish_partition_enabled(void) |
| 591 | { |
| 592 | /* Default implementation, ISH not enabled. */ |
| 593 | return false; |
| 594 | } |
| 595 | #endif |
| 596 | |
| 597 | /* |
| 598 | * Injects CSE timestamps into cbmem timestamp table. SoC code needs to |
| 599 | * implement it since timestamp definitions differ from SoC to SoC. |
| 600 | */ |
| 601 | void soc_cbmem_inject_telemetry_data(s64 *ts, s64 current_time); |
| 602 | |
| 603 | /* |
| 604 | * Get all the timestamps CSE collected using cse_get_boot_performance_data() and |
| 605 | * insert them into the CBMEM timestamp table. |
| 606 | */ |
| 607 | void cse_get_telemetry_data(void); |
| 608 | |
| 609 | /* Function to log the cse WP information like range, if WP etc. */ |
| 610 | void cse_log_ro_write_protection_info(bool mfg_mode); |
| 611 | |
| 612 | /* |
| 613 | * Changes Intel PTT feature state at runtime. Global reset is required after |
| 614 | * successful HECI command completion. |
| 615 | */ |
| 616 | void cse_enable_ptt(bool state); |
| 617 | |
| 618 | /* |
| 619 | * Queries CSE for runtime status of firmware features. |
| 620 | * Returns 0 on success and < 0 on failure. |
| 621 | */ |
| 622 | enum cb_err cse_get_fw_feature_state(uint32_t *feature_state); |
| 623 | |
| 624 | /* Fills the CSE Boot Partition Info response */ |
| 625 | void cse_fill_bp_info(void); |
| 626 | |
| 627 | /* |
| 628 | * Check if a CSE Firmware update is required |
| 629 | * Returns true if an update is required, false otherwise |
| 630 | */ |
| 631 | bool is_cse_fw_update_required(void); |
| 632 | |
| 633 | /* |
| 634 | * Check if the CSE firmware is booting from RW slot. |
| 635 | * Returns true if CSE is booting from RW slot, false otherwise |
| 636 | */ |
| 637 | bool is_cse_boot_to_rw(void); |
| 638 | |
| 639 | /* |
| 640 | * Check if the CSE FW Status Current Power Management Event indicates that the |
| 641 | * host came out of cold reset. |
| 642 | * Returns true if the host came out of a cold reset, false otherwise. |
| 643 | */ |
| 644 | bool cse_check_host_cold_reset(void); |
| 645 | |
| 646 | #endif // SOC_INTEL_COMMON_CSE_H |