Krishna P Bhat D has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/75602?usp=email )
Change subject: common/block/cse: Add a field in CMOS to determine FW update required ......................................................................
common/block/cse: Add a field in CMOS to determine FW update required
This patch adds a field in CMOS to determine if CSE firmware update is required in cases where split CSE firmware option is chosen. CSE version check is performed in romstage to determine if firmware update is required. If an update is required, the field is set and update is deferred to ramstage.
BUG=None BRANCH=None TEST=Verified CSE firmware upgrade/downgrade on ADL-N craask.
Change-Id: I0d90f26747ea670cd0e5a74525ac585bad8ace9e Signed-off-by: Krishna Prasad Bhat krishna.p.bhat.d@intel.com --- M src/soc/intel/common/block/cse/Makefile.inc M src/soc/intel/common/block/cse/cse_cmos.c M src/soc/intel/common/block/cse/cse_lite.c M src/soc/intel/common/block/include/intelblocks/cse_cmos.h 4 files changed, 51 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/02/75602/1
diff --git a/src/soc/intel/common/block/cse/Makefile.inc b/src/soc/intel/common/block/cse/Makefile.inc index 679c4f7..3b73db2 100644 --- a/src/soc/intel/common/block/cse/Makefile.inc +++ b/src/soc/intel/common/block/cse/Makefile.inc @@ -7,7 +7,8 @@ ramstage-$(CONFIG_SOC_INTEL_CSE_HAVE_SPEC_SUPPORT) += cse_spec.c ramstage-$(CONFIG_SOC_INTEL_CSE_SET_EOP) += cse_eop.c romstage-$(CONFIG_SOC_INTEL_CSE_PRE_CPU_RESET_TELEMETRY) += telemetry.c -ramstage-$(CONFIG_SOC_INTEL_STORE_CSE_FPT_PARTITION_VERSION) += cse_cmos.c +romstage-$(SOC_INTEL_STORE_CSE_VERSION_IN_CMOS) += cse_cmos.c +ramstage-$(SOC_INTEL_STORE_CSE_VERSION_IN_CMOS) += cse_cmos.c smm-$(CONFIG_SOC_INTEL_COMMON_BLOCK_CSE) += disable_heci.c
ifeq ($(CONFIG_STITCH_ME_BIN),y) diff --git a/src/soc/intel/common/block/cse/cse_cmos.c b/src/soc/intel/common/block/cse/cse_cmos.c index f4582fe..8bdcab7 100644 --- a/src/soc/intel/common/block/cse/cse_cmos.c +++ b/src/soc/intel/common/block/cse/cse_cmos.c @@ -42,6 +42,7 @@ uint32_t signature; struct fw_version cse_version; struct fw_version ish_version; + uint8_t fw_update_req; uint16_t checksum; } __packed;
@@ -90,6 +91,7 @@ version->signature = PARTITION_FW_SIGNATURE; memset(&version->cse_version, 0, sizeof(struct fw_version)); memset(&version->ish_version, 0, sizeof(struct fw_version)); + memset(&version->fw_update_req, 0, sizeof(uint8_t)); version->checksum = compute_ip_checksum(version, offsetof(struct cse_fw_table, checksum));
for (p = (u8 *)version, i = 0; i < sizeof(*version); i++, p++) @@ -149,3 +151,30 @@ memcpy(&version.ish_version, ish_version, sizeof(struct fw_version)); write_cmos_partition_version(&version); } + +void set_cmos_fw_update_req(const uint8_t *fw_update_req) +{ + struct cse_fw_table version; + if (read_cmos_partition_version(&version)) { + /* + * CMOS failed to read the CSE version. This may be because the firmware version at + * cmos has not yet been initialized. + */ + init_cmos_partition_version(&version); + } + memcpy(&version.fw_update_req, fw_update_req, sizeof(fw_update_req)); + write_cmos_partition_version(&version); +} + +void get_cmos_fw_update_req(uint8_t *fw_update_req) +{ + struct cse_fw_table version; + if (read_cmos_partition_version(&version)) { + /* + * CMOS failed to read the CSE version. This may be because the firmware version at + * cmos has not yet been initialized. + */ + init_cmos_partition_version(&version); + } + memcpy(fw_update_req, &version.fw_update_req, sizeof(fw_update_req)); +} diff --git a/src/soc/intel/common/block/cse/cse_lite.c b/src/soc/intel/common/block/cse/cse_lite.c index 348449f..e98f60d 100644 --- a/src/soc/intel/common/block/cse/cse_lite.c +++ b/src/soc/intel/common/block/cse/cse_lite.c @@ -808,6 +808,10 @@ error_exit: cbfs_unmap(cbfs_rw_hash); cbfs_unmap(cse_cbfs_rw); + if(CONFIG(CSE_LITE_SPLIT_FW_SYNC) && ENV_RAMSTAGE) { + uint8_t fw_update_req = 0; + set_cmos_fw_update_req(&fw_update_req); + } return rv; }
@@ -1133,6 +1137,13 @@ return; }
+ if (CONFIG(CSE_LITE_SPLIT_FW_SYNC) && ENV_RAMSTAGE) { + uint8_t fw_update_req; + get_cmos_fw_update_req(&fw_update_req); + if(!fw_update_req) + return; + } + if (cse_get_bp_info(&cse_bp_info) != CB_SUCCESS) { printk(BIOS_ERR, "cse_lite: Failed to get CSE boot partition info\n");
@@ -1183,6 +1194,10 @@ cse_trigger_vboot_recovery(CSE_LITE_SKU_RW_METADATA_NOT_FOUND);
if (status != CSE_UPDATE_NOT_REQUIRED) { + if(CONFIG(CSE_LITE_SPLIT_FW_SYNC) && ENV_ROMSTAGE) { + uint8_t fw_update_req = 1; + set_cmos_fw_update_req(&fw_update_req); + } if(trigger_fw_update_prerequisite()) { printk(BIOS_DEBUG, "cse_lite: CSE RW update is initiated\n"); rv = cse_trigger_fw_update(&cse_bp_info.bp_info, status, &target_rdev); diff --git a/src/soc/intel/common/block/include/intelblocks/cse_cmos.h b/src/soc/intel/common/block/include/intelblocks/cse_cmos.h index 6ecc3e7..656ca76 100644 --- a/src/soc/intel/common/block/include/intelblocks/cse_cmos.h +++ b/src/soc/intel/common/block/include/intelblocks/cse_cmos.h @@ -17,4 +17,9 @@ /* Function to update the ish version stored in CMOS memory */ void set_cmos_ish_version(const struct fw_version *ish_version);
+/* Function to get the firmware update required field stored in CMOS memory */ +void get_cmos_fw_update_req(uint8_t *fw_update_req); + +/* Function to update the firmware update required field stored in CMOS memory */ +void set_cmos_fw_update_req(const uint8_t *fw_update_req); #endif /* SOC_INTEL_COMMON_BLOCK_CSE_CMOS_H */