coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
romstage_fsp_params.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/mmio.h>
4 #include <baseboard/variants.h>
5 #include <console/console.h>
6 #include <device/dram/common.h>
7 #include <hwilib.h>
8 #include <soc/meminit.h>
9 #include <soc/romstage.h>
10 #include <string.h>
11 #include <types.h>
12 
13 void mainboard_memory_init_params(FSPM_UPD *memupd)
14 {
15  static struct spd_info spd_info;
16  const struct mb_cfg *board_cfg = variant_memcfg_config();
17  static uint8_t spd_data[CONFIG_DIMM_SPD_SIZE];
18  const char *cbfs_hwi_name = "hwinfo.hex";
19 
20  /* Initialize SPD information for LPDDR4x from HW-Info primarily with a fallback to
21  spd.bin in the case where the SPD data in HW-Info is not available or invalid. */
22  memset(spd_data, 0, sizeof(spd_data));
23  if ((hwilib_find_blocks(cbfs_hwi_name) == CB_SUCCESS) &&
24  (hwilib_get_field(SPD, spd_data, 0x80) == 0x80) &&
25  (ddr_crc16(spd_data, 126) == read16((void *)&spd_data[126]))) {
27  spd_info.spd_spec.spd_data_ptr_info.spd_data_len = CONFIG_DIMM_SPD_SIZE;
29  } else {
30  printk(BIOS_WARNING, "SPD in HW-Info not valid, fall back to spd.bin!\n");
33  }
34  /* Initialize variant specific configurations */
35  memcfg_init(&memupd->FspmConfig, board_cfg, &spd_info, false);
36 
37  /* Enable Row-Hammer prevention */
38  memupd->FspmConfig.RhPrevention = 1;
39 }
void memcfg_init(FSPM_UPD *memupd, const struct mb_cfg *mb_cfg, const struct mem_spd *spd_info, bool half_populated)
Definition: meminit.c:238
static uint16_t read16(const void *addr)
Definition: mmio.h:17
void * memset(void *dstpp, int c, size_t len)
Definition: memset.c:12
@ CB_SUCCESS
Call completed successfully.
Definition: cb_err.h:16
@ READ_SPD_MEMPTR
@ READ_SPD_CBFS
#define printk(level,...)
Definition: stdlib.h:16
u16 ddr_crc16(const u8 *ptr, int n_crc)
Calculate the CRC of a DDR SPD data.
Definition: ddr_common.c:14
const struct mb_cfg * variant_memcfg_config(void)
Definition: memory.c:46
void mainboard_memory_init_params(FSPM_UPD *memupd)
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
Definition: loglevel.h:86
static const struct mb_cfg board_cfg
Definition: romstage.c:8
static u8 spd_data[CONFIG_DIMM_MAX *CONFIG_DIMM_SPD_SIZE]
Definition: smbuslib.c:70
unsigned long uintptr_t
Definition: stdint.h:21
unsigned char uint8_t
Definition: stdint.h:8
Definition: meminit.h:71
uintptr_t spd_data_ptr
Definition: spd.h:11
union spd_info::spd_data_by spd_spec
enum mem_info_read_type read_type
struct spd_by_pointer spd_data_ptr_info