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 <assert.h>
4 #include <console/console.h>
5 #include <fsp/api.h>
6 #include <soc/romstage.h>
7 #include <spd_bin.h>
8 #include <soc/meminit.h>
9 #include <baseboard/variants.h>
10 #include "board_id.h"
11 
12 #define SPD_ID_MASK 0x7
13 
14 static size_t get_spd_index(void)
15 {
17  size_t spd_index;
18 
19  printk(BIOS_INFO, "board id is 0x%x\n", board_id);
20 
22 
23  printk(BIOS_INFO, "SPD index is 0x%x\n", (unsigned int)spd_index);
24  return spd_index;
25 }
26 
27 /*
28  * ADL-P silicon can support 7 SRC CLK's and 10 CLKREQ signals. Out of 7 SRCCLK's
29  * 3 will be used for CPU, the rest are for PCH. If more than 4 PCH devices are
30  * connected on the platform, an external differential buffer chip needs to be placed at
31  * the platform level.
32  *
33  * GEN3_EXTERNAL_CLOCK_BUFFER Kconfig is selected for ADL-P RVP (not applicable for
34  * ADL-M/N RVP)
35  *
36  * CONFIG_CLKSRC_FOR_EXTERNAL_BUFFER provides the CLKSRC that feed clock to discrete
37  * buffer for further distribution to platform.
38  */
40 {
41  for (unsigned int i = CONFIG_MAX_PCIE_CLOCK_SRC; i < CONFIG_MAX_PCIE_CLOCK_REQ; i++)
42  m_cfg->PcieClkSrcUsage[i] = CONFIG_CLKSRC_FOR_EXTERNAL_BUFFER;
43 }
44 
45 void mainboard_memory_init_params(FSPM_UPD *memupd)
46 {
47  FSP_M_CONFIG *m_cfg = &memupd->FspmConfig;
48  const struct mb_cfg *mem_config = variant_memory_params();
49  int board_id = get_board_id();
50 
51  /*
52  * Alder Lake common meminit block driver considers bus width to be 128-bit and
53  * populates the meminit data accordingly. Alder Lake-N has single memory controller
54  * with 64-bit bus width. By setting half_populated to true, only the bottom half is
55  * populated.
56  * TODO: Implement __weak variant_is_half_populated(void) function.
57  */
58  const bool half_populated = (CONFIG(BOARD_INTEL_ADLRVP_N_EXT_EC)
59  || CONFIG(BOARD_INTEL_ADLRVP_N));
60 
61  const struct mem_spd memory_down_spd_info = {
63  .cbfs_index = get_spd_index(),
64  };
65 
66  const struct mem_spd dimm_module_spd_info = {
68  .smbus = {
69  [0] = {
70  .addr_dimm[0] = 0x50,
71  .addr_dimm[1] = 0x51,
72  },
73  [1] = {
74  .addr_dimm[0] = 0x52,
75  .addr_dimm[1] = 0x53,
76  },
77  },
78  };
79 
80  switch (board_id) {
81  case ADL_P_DDR4_1:
82  case ADL_P_DDR4_2:
83  case ADL_P_DDR5_1:
84  memcfg_init(memupd, mem_config, &dimm_module_spd_info, half_populated);
85  break;
86  case ADL_P_DDR5_2:
87  case ADL_P_LP4_1:
88  case ADL_P_LP4_2:
89  case ADL_P_LP5_1:
90  case ADL_P_LP5_2:
91  case ADL_M_LP4:
92  case ADL_M_LP5:
93  case ADL_N_LP5:
94  memcfg_init(memupd, mem_config, &memory_down_spd_info, half_populated);
95  break;
96  default:
97  die("Unknown board id = 0x%x\n", board_id);
98  break;
99  }
100 
101  if (CONFIG(GEN3_EXTERNAL_CLOCK_BUFFER))
103 }
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
@ MEM_TOPO_DIMM_MODULE
Definition: meminit.h:26
@ MEM_TOPO_MEMORY_DOWN
Definition: meminit.h:25
#define printk(level,...)
Definition: stdlib.h:16
void __noreturn die(const char *fmt,...)
Definition: die.c:17
@ CONFIG
Definition: dsi_common.h:201
uint32_t board_id(void)
board_id() - Get the board version
Definition: ec_boardid.c:6
#define FSP_M_CONFIG
Definition: fsp_upd.h:8
@ ADL_M_LP4
Definition: variants.h:24
@ ADL_P_DDR5_2
Definition: variants.h:16
@ ADL_P_LP4_1
Definition: variants.h:12
@ ADL_P_LP4_2
Definition: variants.h:13
@ ADL_N_LP5
Definition: variants.h:27
@ ADL_P_LP5_1
Definition: variants.h:18
@ ADL_P_DDR4_2
Definition: variants.h:22
@ ADL_M_LP5
Definition: variants.h:25
@ ADL_P_DDR5_1
Definition: variants.h:15
@ ADL_P_DDR4_1
Definition: variants.h:21
@ ADL_P_LP5_2
Definition: variants.h:19
static void configure_external_clksrc(FSP_M_CONFIG *m_cfg)
void mainboard_memory_init_params(FSPM_UPD *memupd)
static size_t get_spd_index(void)
#define SPD_ID_MASK
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
const struct mb_cfg *__weak variant_memory_params(void)
Definition: memory.c:67
static const int spd_index[32]
Definition: memory.c:10
static uint8_t get_board_id(void)
Definition: boardid.c:14
static const struct mb_cfg mem_config
Definition: memory.c:11
unsigned char uint8_t
Definition: stdint.h:8
Definition: meminit.h:71
enum mem_topology topo
Definition: meminit.h:38