From 0212e4c3a21d6413e77a256bc8b63b0ee5b4eb8c Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Mon, 27 Jan 2025 14:20:01 -0700 Subject: [PATCH] soc/intel/common/block/cse: Add API to match current PM event Introduce an API to read the Converged Security and Management Engine (CSME) host firmware status register to obtain the current Power Management event and compare it with a specified input event. BUG=b:391449110 TEST=Build Brox BIOS image and boot to OS. Change-Id: Ie9a49382ee2c1a8f59da6233e510cf2e38ac32ad Signed-off-by: Karthikeyan Ramasubramanian Reviewed-on: https://review.coreboot.org/c/coreboot/+/86169 Reviewed-by: Kapil Porwal Tested-by: build bot (Jenkins) Reviewed-by: Subrata Banik Reviewed-by: Dinesh Gehlot --- src/soc/intel/common/block/cse/cse.c | 22 +++++++++++++++++++ .../common/block/include/intelblocks/cse.h | 11 ++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/soc/intel/common/block/cse/cse.c b/src/soc/intel/common/block/cse/cse.c index 6389044428..53c5fe1471 100644 --- a/src/soc/intel/common/block/cse/cse.c +++ b/src/soc/intel/common/block/cse/cse.c @@ -298,6 +298,28 @@ bool cse_is_hfs1_spi_protected(void) return !hfs1.fields.mfg_mode; } +#define ME_HFSTS2_CUR_PM_EVENT_SHIFT 24 +#define ME_HFSTS2_CUR_PM_EVENT_MASK (0xf << ME_HFSTS2_CUR_PM_EVENT_SHIFT) + +static uint8_t cse_get_hfs2_current_pm_event(void) +{ + uint32_t data = me_read_config32(PCI_ME_HFSTS2); + return (uint8_t)((data & ME_HFSTS2_CUR_PM_EVENT_MASK) >> + ME_HFSTS2_CUR_PM_EVENT_SHIFT); +} + +bool cse_check_host_cold_reset(void) +{ + uint8_t event = cse_get_hfs2_current_pm_event(); + + switch (event) { + case PWR_CYCLE_RESET_CMOFF: + return true; + default: + return false; + } +} + bool cse_is_hfs3_fw_sku_lite(void) { union me_hfsts3 hfs3; diff --git a/src/soc/intel/common/block/include/intelblocks/cse.h b/src/soc/intel/common/block/include/intelblocks/cse.h index c97e4ec65c..99dd7d5e17 100644 --- a/src/soc/intel/common/block/include/intelblocks/cse.h +++ b/src/soc/intel/common/block/include/intelblocks/cse.h @@ -383,6 +383,10 @@ enum rst_req_type { CSE_RESET_ONLY = 3, }; +enum cse_fw_sts_current_pm_event { + PWR_CYCLE_RESET_CMOFF = 0xb, +}; + /* * Sends GLOBAL_RESET_REQ cmd to CSE with reset type GLOBAL_RESET. * Returns 0 on failure and 1 on success. @@ -618,4 +622,11 @@ bool is_cse_fw_update_required(void); */ bool is_cse_boot_to_rw(void); +/* + * Check if the CSE FW Status Current Power Management Event indicates that the + * host came out of cold reset. + * Returns true if the host came out of a cold reset, false otherwise. + */ +bool cse_check_host_cold_reset(void); + #endif // SOC_INTEL_COMMON_CSE_H