diff --git a/src/soc/intel/xeon_sp/cpx/include/soc/soc_util.h b/src/soc/intel/xeon_sp/cpx/include/soc/soc_util.h index 5e9ab5a13c..91919b8a68 100644 --- a/src/soc/intel/xeon_sp/cpx/include/soc/soc_util.h +++ b/src/soc/intel/xeon_sp/cpx/include/soc/soc_util.h @@ -6,6 +6,22 @@ #include #include +/* + * Address of the MRC status byte in CMOS. Should be reserved + * in mainboards' cmos.layout and not covered by checksum. + */ +#define CMOS_OFFSET_MRC_STATUS 0x47 + +#if CONFIG(USE_OPTION_TABLE) +#include "option_table.h" +#if CMOS_VSTART_mrc_status != CMOS_OFFSET_MRC_STATUS * 8 +#error "CMOS start for CPX-SP MRC status byte is not correct, check your cmos.layout" +#endif +#if CMOS_VLEN_mrc_status != 8 +#error "CMOS length for CPX-SP MRC status byte is not correct, check your cmos.layout" +#endif +#endif + const struct SystemMemoryMapHob *get_system_memory_map(void); uint8_t get_stack_busno(const uint8_t stack); @@ -14,5 +30,6 @@ uint32_t get_socket_ubox_busno(uint32_t socket); uint8_t get_cxl_node_count(void); int soc_get_stack_for_port(int port); +void soc_set_mrc_cold_boot_flag(bool cold_boot_required); #endif /* _SOC_UTIL_H_ */ diff --git a/src/soc/intel/xeon_sp/cpx/romstage.c b/src/soc/intel/xeon_sp/cpx/romstage.c index 43a74e20a9..265ab70d6d 100644 --- a/src/soc/intel/xeon_sp/cpx/romstage.c +++ b/src/soc/intel/xeon_sp/cpx/romstage.c @@ -8,53 +8,20 @@ #include #include #include -#include #include #include #include #include -#include +#include #include #include "chip.h" -/* - * Address of the MRC status byte in CMOS. Should be reserved - * in mainboards' cmos.layout and not covered by checksum. - */ -#define CMOS_OFFSET_MRC_STATUS 0x47 - -#if CONFIG(USE_OPTION_TABLE) -#include "option_table.h" -#if CMOS_VSTART_mrc_status != CMOS_OFFSET_MRC_STATUS * 8 -#error "CMOS start for CPX-SP MRC status byte is not correct, check your cmos.layout" -#endif -#if CMOS_VLEN_mrc_status != 8 -#error "CMOS length for CPX-SP MRC status byte is not correct, check your cmos.layout" -#endif -#endif - void __weak mainboard_memory_init_params(FSPM_UPD *mupd) { /* Default weak implementation */ } -static const struct SystemMemoryMapHob *get_system_memory_map(void) -{ - size_t hob_size; - const uint8_t mem_hob_guid[16] = FSP_SYSTEM_MEMORYMAP_HOB_GUID; - const struct SystemMemoryMapHob **memmap_addr; - - memmap_addr = (const struct SystemMemoryMapHob **) - fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size); - /* hob_size is the size of the 8-byte address not the hob data */ - assert(memmap_addr && hob_size != 0); - /* assert the pointer to the hob is not NULL */ - assert(*memmap_addr); - - return *memmap_addr; -} - static uint8_t get_error_correction_type(const uint8_t RasModesEnabled) { switch (RasModesEnabled) { @@ -155,16 +122,6 @@ void save_dimm_info(void) printk(BIOS_DEBUG, "%d out of %d DIMMs found\n", num_dimms, mem_info->dimm_cnt); } -static void set_cmos_mrc_cold_boot_flag(bool cold_boot_required) -{ - uint8_t mrc_status = cmos_read(CMOS_OFFSET_MRC_STATUS); - uint8_t new_mrc_status = (mrc_status & 0xfe) | cold_boot_required; - printk(BIOS_SPEW, "MRC status: 0x%02x want 0x%02x\n", mrc_status, new_mrc_status); - if (new_mrc_status != mrc_status) { - cmos_write(new_mrc_status, CMOS_OFFSET_MRC_STATUS); - } -} - void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) { FSP_M_CONFIG *m_cfg = &mupd->FspmConfig; @@ -233,5 +190,5 @@ void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) mainboard_memory_init_params(mupd); /* Adjust the "cold boot required" flag in CMOS. */ - set_cmos_mrc_cold_boot_flag(!mupd->FspmArchUpd.NvsBufferPtr); + soc_set_mrc_cold_boot_flag(!mupd->FspmArchUpd.NvsBufferPtr); } diff --git a/src/soc/intel/xeon_sp/cpx/soc_util.c b/src/soc/intel/xeon_sp/cpx/soc_util.c index 01057fa17c..031b2bb745 100644 --- a/src/soc/intel/xeon_sp/cpx/soc_util.c +++ b/src/soc/intel/xeon_sp/cpx/soc_util.c @@ -7,6 +7,7 @@ #include #include #include +#include const struct SystemMemoryMapHob *get_system_memory_map(void) { @@ -100,3 +101,13 @@ uint8_t soc_get_iio_ioapicid(int socket, int stack) } return ioapic_id; } + +void soc_set_mrc_cold_boot_flag(bool cold_boot_required) +{ + uint8_t mrc_status = cmos_read(CMOS_OFFSET_MRC_STATUS); + uint8_t new_mrc_status = (mrc_status & 0xfe) | cold_boot_required; + printk(BIOS_SPEW, "MRC status: 0x%02x want 0x%02x\n", mrc_status, new_mrc_status); + if (new_mrc_status != mrc_status) { + cmos_write(new_mrc_status, CMOS_OFFSET_MRC_STATUS); + } +} diff --git a/src/soc/intel/xeon_sp/spr/include/soc/soc_util.h b/src/soc/intel/xeon_sp/spr/include/soc/soc_util.h index 2028dfafe2..97938ead91 100644 --- a/src/soc/intel/xeon_sp/spr/include/soc/soc_util.h +++ b/src/soc/intel/xeon_sp/spr/include/soc/soc_util.h @@ -44,6 +44,6 @@ const EWL_PRIVATE_DATA *get_ewl_hob(void); uint32_t get_ubox_busno(uint32_t socket, uint8_t offset); uint32_t get_socket_ubox_busno(uint32_t socket); -void set_cmos_mrc_cold_boot_flag(bool cold_boot_required); +void soc_set_mrc_cold_boot_flag(bool cold_boot_required); #endif /* _SOC_UTIL_H_ */ diff --git a/src/soc/intel/xeon_sp/spr/soc_util.c b/src/soc/intel/xeon_sp/spr/soc_util.c index 94d172c37a..67cb0638b0 100644 --- a/src/soc/intel/xeon_sp/spr/soc_util.c +++ b/src/soc/intel/xeon_sp/spr/soc_util.c @@ -162,7 +162,7 @@ void bios_done_msr(void *unused) } } -void set_cmos_mrc_cold_boot_flag(bool cold_boot_required) +void soc_set_mrc_cold_boot_flag(bool cold_boot_required) { uint8_t mrc_status = cmos_read(CMOS_OFFSET_MRC_STATUS); uint8_t new_mrc_status = (mrc_status & 0xfe) | cold_boot_required;