Skip to content

Commit 3435f81

Browse files
johnnylinwiwynnfelixheld
authored andcommitted
soc/intel/xeon_sp: move and rename set_cmos_mrc_cold_boot_flag
1. Rename set_cmos_mrc_cold_boot_flag() to soc_set_mrc_cold_boot_flag in case a certain platform may not support this via CMOS data, and the function could in turn calls mainboard defined method in the future. Move the code into soc_util.c. 2. Remove redundant static get_system_memory_map() from cpx/romstage.c and call the soc_util.c one. Change-Id: Ib7d9bed9092814658f4a0b1d6dcf3c7d79178048 Signed-off-by: Johnny Lin <johnny_lin@wiwynn.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/72029 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
1 parent 14d69d0 commit 3435f81

5 files changed

Lines changed: 32 additions & 47 deletions

File tree

src/soc/intel/xeon_sp/cpx/include/soc/soc_util.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66
#include <hob_iiouds.h>
77
#include <hob_memmap.h>
88

9+
/*
10+
* Address of the MRC status byte in CMOS. Should be reserved
11+
* in mainboards' cmos.layout and not covered by checksum.
12+
*/
13+
#define CMOS_OFFSET_MRC_STATUS 0x47
14+
15+
#if CONFIG(USE_OPTION_TABLE)
16+
#include "option_table.h"
17+
#if CMOS_VSTART_mrc_status != CMOS_OFFSET_MRC_STATUS * 8
18+
#error "CMOS start for CPX-SP MRC status byte is not correct, check your cmos.layout"
19+
#endif
20+
#if CMOS_VLEN_mrc_status != 8
21+
#error "CMOS length for CPX-SP MRC status byte is not correct, check your cmos.layout"
22+
#endif
23+
#endif
24+
925
const struct SystemMemoryMapHob *get_system_memory_map(void);
1026

1127
uint8_t get_stack_busno(const uint8_t stack);
@@ -14,5 +30,6 @@ uint32_t get_socket_ubox_busno(uint32_t socket);
1430
uint8_t get_cxl_node_count(void);
1531

1632
int soc_get_stack_for_port(int port);
33+
void soc_set_mrc_cold_boot_flag(bool cold_boot_required);
1734

1835
#endif /* _SOC_UTIL_H_ */

src/soc/intel/xeon_sp/cpx/romstage.c

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,20 @@
88
#include <fsp/util.h>
99
#include <hob_iiouds.h>
1010
#include <hob_memmap.h>
11-
#include <pc80/mc146818rtc.h>
1211
#include <soc/ddr.h>
1312
#include <soc/romstage.h>
1413
#include <soc/pci_devs.h>
1514
#include <soc/intel/common/smbios.h>
16-
#include <stdbool.h>
15+
#include <soc/soc_util.h>
1716
#include <string.h>
1817

1918
#include "chip.h"
2019

21-
/*
22-
* Address of the MRC status byte in CMOS. Should be reserved
23-
* in mainboards' cmos.layout and not covered by checksum.
24-
*/
25-
#define CMOS_OFFSET_MRC_STATUS 0x47
26-
27-
#if CONFIG(USE_OPTION_TABLE)
28-
#include "option_table.h"
29-
#if CMOS_VSTART_mrc_status != CMOS_OFFSET_MRC_STATUS * 8
30-
#error "CMOS start for CPX-SP MRC status byte is not correct, check your cmos.layout"
31-
#endif
32-
#if CMOS_VLEN_mrc_status != 8
33-
#error "CMOS length for CPX-SP MRC status byte is not correct, check your cmos.layout"
34-
#endif
35-
#endif
36-
3720
void __weak mainboard_memory_init_params(FSPM_UPD *mupd)
3821
{
3922
/* Default weak implementation */
4023
}
4124

42-
static const struct SystemMemoryMapHob *get_system_memory_map(void)
43-
{
44-
size_t hob_size;
45-
const uint8_t mem_hob_guid[16] = FSP_SYSTEM_MEMORYMAP_HOB_GUID;
46-
const struct SystemMemoryMapHob **memmap_addr;
47-
48-
memmap_addr = (const struct SystemMemoryMapHob **)
49-
fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size);
50-
/* hob_size is the size of the 8-byte address not the hob data */
51-
assert(memmap_addr && hob_size != 0);
52-
/* assert the pointer to the hob is not NULL */
53-
assert(*memmap_addr);
54-
55-
return *memmap_addr;
56-
}
57-
5825
static uint8_t get_error_correction_type(const uint8_t RasModesEnabled)
5926
{
6027
switch (RasModesEnabled) {
@@ -155,16 +122,6 @@ void save_dimm_info(void)
155122
printk(BIOS_DEBUG, "%d out of %d DIMMs found\n", num_dimms, mem_info->dimm_cnt);
156123
}
157124

158-
static void set_cmos_mrc_cold_boot_flag(bool cold_boot_required)
159-
{
160-
uint8_t mrc_status = cmos_read(CMOS_OFFSET_MRC_STATUS);
161-
uint8_t new_mrc_status = (mrc_status & 0xfe) | cold_boot_required;
162-
printk(BIOS_SPEW, "MRC status: 0x%02x want 0x%02x\n", mrc_status, new_mrc_status);
163-
if (new_mrc_status != mrc_status) {
164-
cmos_write(new_mrc_status, CMOS_OFFSET_MRC_STATUS);
165-
}
166-
}
167-
168125
void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
169126
{
170127
FSP_M_CONFIG *m_cfg = &mupd->FspmConfig;
@@ -233,5 +190,5 @@ void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
233190
mainboard_memory_init_params(mupd);
234191

235192
/* Adjust the "cold boot required" flag in CMOS. */
236-
set_cmos_mrc_cold_boot_flag(!mupd->FspmArchUpd.NvsBufferPtr);
193+
soc_set_mrc_cold_boot_flag(!mupd->FspmArchUpd.NvsBufferPtr);
237194
}

src/soc/intel/xeon_sp/cpx/soc_util.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <soc/pci_devs.h>
88
#include <soc/soc_util.h>
99
#include <soc/util.h>
10+
#include <pc80/mc146818rtc.h>
1011

1112
const struct SystemMemoryMapHob *get_system_memory_map(void)
1213
{
@@ -100,3 +101,13 @@ uint8_t soc_get_iio_ioapicid(int socket, int stack)
100101
}
101102
return ioapic_id;
102103
}
104+
105+
void soc_set_mrc_cold_boot_flag(bool cold_boot_required)
106+
{
107+
uint8_t mrc_status = cmos_read(CMOS_OFFSET_MRC_STATUS);
108+
uint8_t new_mrc_status = (mrc_status & 0xfe) | cold_boot_required;
109+
printk(BIOS_SPEW, "MRC status: 0x%02x want 0x%02x\n", mrc_status, new_mrc_status);
110+
if (new_mrc_status != mrc_status) {
111+
cmos_write(new_mrc_status, CMOS_OFFSET_MRC_STATUS);
112+
}
113+
}

src/soc/intel/xeon_sp/spr/include/soc/soc_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ const EWL_PRIVATE_DATA *get_ewl_hob(void);
4444

4545
uint32_t get_ubox_busno(uint32_t socket, uint8_t offset);
4646
uint32_t get_socket_ubox_busno(uint32_t socket);
47-
void set_cmos_mrc_cold_boot_flag(bool cold_boot_required);
47+
void soc_set_mrc_cold_boot_flag(bool cold_boot_required);
4848

4949
#endif /* _SOC_UTIL_H_ */

src/soc/intel/xeon_sp/spr/soc_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void bios_done_msr(void *unused)
162162
}
163163
}
164164

165-
void set_cmos_mrc_cold_boot_flag(bool cold_boot_required)
165+
void soc_set_mrc_cold_boot_flag(bool cold_boot_required)
166166
{
167167
uint8_t mrc_status = cmos_read(CMOS_OFFSET_MRC_STATUS);
168168
uint8_t new_mrc_status = (mrc_status & 0xfe) | cold_boot_required;

0 commit comments

Comments
 (0)