coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
romstage_spd_smbus.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <baseboard/variants.h>
4 #include <console/console.h>
5 #include <soc/cnl_memcfg_init.h>
6 #include <soc/romstage.h>
7 #include <spd_bin.h>
8 #include <spd_cache.h>
9 
10 void mainboard_memory_init_params(FSPM_UPD *memupd)
11 {
12  struct cnl_mb_cfg memcfg;
14 
15  /* Read spd block to get memory config */
16  struct spd_block blk = {
17  .addr_map = { 0x50, 0x52, },
18  };
19 
20  uint8_t *spd_cache;
21  size_t spd_cache_sz;
22  bool need_update_cache = false;
23  bool dimm_changed = true;
24 
25  /* load spd cache from RW_SPD_CACHE */
26  if (load_spd_cache(&spd_cache, &spd_cache_sz) == CB_SUCCESS) {
27  if (!spd_cache_is_valid(spd_cache, spd_cache_sz)) {
28  printk(BIOS_WARNING, "Invalid SPD cache\n");
29  } else {
30  dimm_changed = check_if_dimm_changed(spd_cache, &blk);
31  if (dimm_changed && memupd->FspmArchUpd.NvsBufferPtr != 0) {
32  /* Set mrc_cache as invalid */
33  printk(BIOS_INFO, "Set mrc_cache as invalid\n");
34  memupd->FspmArchUpd.NvsBufferPtr = 0;
35  }
36  }
37  need_update_cache = true;
38  }
39 
40  if (!dimm_changed) {
41  spd_fill_from_cache(spd_cache, &blk);
42  } else {
43  /* Access memory info through SMBUS. */
44  get_spd_smbus(&blk);
45 
46  if (need_update_cache && update_spd_cache(&blk) == CB_ERR)
47  printk(BIOS_WARNING, "update SPD cache failed\n");
48  }
49 
50  if (blk.spd_array[0] == NULL) {
52  } else {
56  }
57 
59 
60  if (blk.spd_array[1] == NULL) {
62  } else {
66  }
67 
69  dump_spd_info(&blk);
70 
71  /* set to 2 VREF_CA goes to CH_A and VREF_DQ_B goes to CH_B. */
74 
75  cannonlake_memcfg_init(&memupd->FspmConfig, &memcfg);
76 }
@ CB_ERR
Generic error code.
Definition: cb_err.h:17
@ CB_SUCCESS
Call completed successfully.
Definition: cb_err.h:16
void cannonlake_memcfg_init(FSP_M_CONFIG *mem_cfg, const struct cnl_mb_cfg *cnl_cfg)
@ NOT_EXISTING
@ READ_SPD_MEMPTR
#define printk(level,...)
Definition: stdlib.h:16
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
Definition: loglevel.h:86
static const struct cnl_mb_cfg memcfg
Definition: romstage.c:6
const struct mb_cfg *__weak variant_memory_params(void)
Definition: memory.c:67
void mainboard_memory_init_params(FSPM_UPD *memupd)
void get_spd_smbus(struct spd_block *blk)
Definition: smbuslib.c:72
void dump_spd_info(struct spd_block *blk)
Definition: spd_bin.c:10
bool check_if_dimm_changed(u8 *spd_cache, struct spd_block *blk)
Definition: spd_cache.c:150
enum cb_err load_spd_cache(uint8_t **spd_cache, size_t *spd_cache_sz)
Definition: spd_cache.c:92
enum cb_err spd_fill_from_cache(uint8_t *spd_cache, struct spd_block *blk)
Definition: spd_cache.c:195
enum cb_err update_spd_cache(struct spd_block *blk)
Definition: spd_cache.c:35
bool spd_cache_is_valid(uint8_t *spd_cache, size_t spd_cache_sz)
Definition: spd_cache.c:117
#define NULL
Definition: stddef.h:19
unsigned long uintptr_t
Definition: stdint.h:21
unsigned char uint8_t
Definition: stdint.h:8
uint8_t dq_pins_interleaved
struct spd_info spd[NUM_DIMM_SLOT]
uint8_t vref_ca_config
Definition: ddr4.c:86
u8 addr_map[CONFIG_DIMM_MAX]
Definition: spd_bin.h:39
u8 * spd_array[CONFIG_DIMM_MAX]
Definition: spd_bin.h:40
uint16_t len
Definition: ddr4.c:89
uintptr_t spd_data_ptr
union spd_info::spd_data_by spd_spec
enum mem_info_read_type read_type
struct spd_by_pointer spd_data_ptr_info