coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
romstage.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <soc/romstage.h>
4 #include <string.h>
5 #include <spd_bin.h>
6 
7 #include <fsp/soc_binding.h>
8 
9 void mainboard_memory_init_params(FSPM_UPD *mupd)
10 {
11  FSP_M_CONFIG *mem_cfg = &mupd->FspmConfig;
12  const FSPM_ARCH_UPD *arch_upd = &mupd->FspmArchUpd;
13  /* Rcomp resistor */
14  const u16 rcomp_resistor[] = { 121, 81, 100 };
15  /* Rcomp target */
16  const u16 rcomp_target[] = { 100, 40, 20, 20, 26 };
17 
18  /* SPD was saved in S0/S5 path, skips it when resumes from S3 */
19  if (arch_upd->BootMode == FSP_BOOT_ON_S3_RESUME)
20  return;
21 
22  memcpy(&mem_cfg->RcompResistor, rcomp_resistor, sizeof(rcomp_resistor));
23  memcpy(&mem_cfg->RcompTarget, rcomp_target, sizeof(rcomp_target));
24 
25  /* Read spd block to get memory config */
26  struct spd_block blk = {
27  .addr_map = { 0x50, 0x52, },
28  };
29  mem_cfg->DqPinsInterleaved = 1;
30  mem_cfg->CaVrefConfig = 2;
31  get_spd_smbus(&blk);
32  mem_cfg->MemorySpdDataLen = blk.len;
33  mem_cfg->MemorySpdPtr00 = (uintptr_t)blk.spd_array[0];
34  mem_cfg->MemorySpdPtr10 = (uintptr_t)blk.spd_array[1];
35 
36  dump_spd_info(&blk);
37 }
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
@ FSP_BOOT_ON_S3_RESUME
Definition: api.h:23
#define FSP_M_CONFIG
Definition: fsp_upd.h:8
void mainboard_memory_init_params(FSPM_UPD *mupd)
Definition: romstage.c:22
static const u16 rcomp_target[]
Definition: memory.c:26
static const u16 rcomp_resistor[]
Definition: memory.c:23
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
unsigned long uintptr_t
Definition: stdint.h:21
uint16_t u16
Definition: stdint.h:48
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