From 1c69877328187b44c0327f15e84873ef6352c90c Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Mon, 4 Nov 2024 15:35:45 +0000 Subject: soc/intel/cmn/block/cse: Add API to check the current boot partition This patch introduces an API to check whether CSE is booting from the RW slot. This information can be used to determine if a CSE firmware update is pending, which would help to optimize the boot flow by knowing if any reset is expected due to CSE sync. TEST=Able to build google/brox. Change-Id: I1a63ae9992d83b439a0f995d599ee475f7abd75b Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/84995 Tested-by: build bot (Jenkins) Reviewed-by: Karthik Ramasubramanian --- src/soc/intel/common/block/cse/cse_lite.c | 13 +++++++++++++ src/soc/intel/common/block/include/intelblocks/cse.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/soc/intel/common/block/cse/cse_lite.c b/src/soc/intel/common/block/cse/cse_lite.c index c5f0560d2a..09281ab150 100644 --- a/src/soc/intel/common/block/cse/cse_lite.c +++ b/src/soc/intel/common/block/cse/cse_lite.c @@ -1071,6 +1071,19 @@ bool is_cse_fw_update_required(void) return !!cse_compare_sub_part_version(&cbfs_rw_version, cse_get_rw_version()); } +bool is_cse_boot_to_rw(void) +{ + if (cse_get_bp_info() != CB_SUCCESS) { + printk(BIOS_ERR, "cse_lite: Failed to get CSE boot partition info\n"); + return false; + } + + if (cse_get_current_bp() == RW) + return true; + + return false; +} + static uint8_t cse_fw_update(void) { struct region_device target_rdev; diff --git a/src/soc/intel/common/block/include/intelblocks/cse.h b/src/soc/intel/common/block/include/intelblocks/cse.h index 552eb7b2d4..c97e4ec65c 100644 --- a/src/soc/intel/common/block/include/intelblocks/cse.h +++ b/src/soc/intel/common/block/include/intelblocks/cse.h @@ -611,4 +611,11 @@ void cse_fill_bp_info(void); * Returns true if an update is required, false otherwise */ bool is_cse_fw_update_required(void); + +/* + * Check if the CSE firmware is booting from RW slot. + * Returns true if CSE is booting from RW slot, false otherwise + */ +bool is_cse_boot_to_rw(void); + #endif // SOC_INTEL_COMMON_CSE_H -- cgit v1.2.3