coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
meminit.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __SOC_INTEL_COMMON_BLOCK_MEMINIT_H__
4 #define __SOC_INTEL_COMMON_BLOCK_MEMINIT_H__
5 
6 #include <fsp/api.h>
7 #include <types.h>
8 
9 /*
10  * Calculates the number of channels depending upon the data bus width of the
11  * platform and the channel width.
12  */
13 #define CHANNEL_COUNT(ch_width) (CONFIG_DATA_BUS_WIDTH / (ch_width))
14 
15 /*
16  * UPDs for FSP-M are organized depending upon the MRC's view of channel. Thus,
17  * the number of channels as seen by the MRC are dependent on the channel width
18  * assumption in the UPDs. These channels might not necessarily be the same as
19  * the physical channels supported by the platform.
20  */
21 #define MRC_CHANNELS CHANNEL_COUNT(CONFIG_MRC_CHANNEL_WIDTH)
22 
23 /* Different memory topologies supported by the platform. */
28 };
29 
30 /*
31  * SPD provides information about the memory module. Depending upon the memory
32  * topology, the SPD data can be obtained from different sources. Example: for
33  * memory down topology, SPD is read from CBFS using cbfs_index. For DIMM
34  * modules, SPD is read from EEPROM using the DIMM addresses provided by the
35  * mainboard.
36  */
37 struct mem_spd {
38  enum mem_topology topo;
39  /*
40  * SPD data is read from CBFS spd.bin file using cbfs_index to locate
41  * the entry. This is used in case of MEM_TOPO_MEMORY_DOWN and
42  * MEM_TOPO_MIXED topologies.
43  */
44  size_t cbfs_index;
45 
46  /*
47  * SPD data is read from on-module EEPROM using the DIMM addresses
48  * provided by the mainboard. This is used in case of
49  * MEM_TOPO_DIMM_MODULE and MEM_TOPO_MIXED topologies.
50  *
51  * Up to a maximum of MRC_CHANNELS * CONFIG_DIMMS_PER_CHANNEL addresses
52  * can be provided by mainboard. However, depending upon the memory
53  * technology being used and the number of physical channels supported
54  * by that technology, the actual channels might be less than
55  * MRC_CHANNELS.
56  */
57  struct {
58  uint8_t addr_dimm[CONFIG_DIMMS_PER_CHANNEL];
60 };
61 
62 /* Information about memory technology supported by SoC */
63 struct soc_mem_cfg {
64  /*
65  * Number of physical channels that are supported by the memory
66  * technology.
67  */
69 
70  /*
71  * Map of physical channel numbers to MRC channel numbers. This is
72  * helpful in identifying what SPD entries need to be filled for a
73  * physical channel.
74  *
75  * Example: MRC supports 8 channels 0 - 7, but a memory technology
76  * supports only 2 physical channels 0 - 1. In this case, the map could
77  * be:
78  * [0] = 0,
79  * [1] = 4,
80  * indicating that physical channel 0 is mapped to MRC channel 0 and
81  * physical channel 1 is mapped to MRC channel 4.
82  */
84 
85  /*
86  * Masks to be applied in case of memory down topology. For memory down
87  * topology, there is no separate EEPROM. Thus, the masks need to be
88  * hard-coded by the SoC to indicate what combinations are supported.
89  * This is a mask of physical channels for the memory technology.
90  *
91  * Example: For the memory technology supporting 2 physical channels,
92  * where the population rules restrict use of channel 0 for
93  * half-channel, half_channel mask would be set to 0x1 indicating
94  * channel 0 is always populated.
95  */
96  struct {
97  /*
98  * Mask of physical channels that are populated in case of
99  * half-channel configuration.
100  */
102  /*
103  * Mask of physical channels that are populated with memory
104  * down parts in case of mixed topology.
105  */
108 };
109 
110 /* Flags indicating how the channels are populated. */
116 };
117 
118 /*
119  * Data for the memory channels that can be used by SoC code to populate FSP
120  * UPDs.
121  */
123  /* Pointer to SPD data for each DIMM of each channel */
124  uintptr_t spd[MRC_CHANNELS][CONFIG_DIMMS_PER_CHANNEL];
125  /* Length of SPD data */
126  size_t spd_len;
127  /* Flags indicating how channels are populated */
129 };
130 
131 /*
132  * This change populates data regarding memory channels in `struct
133  * mem_channel_data` using the following inputs from SoC code:
134  * memupd : FSP-M UPD configuration.
135  * soc_mem_cfg : SoC-specific information about the memory technology used by
136  * the mainboard.
137  * spd_info : Information about the memory topology.
138  * half_populated: Hint from mainboard if channels are half populated.
139  */
140 void mem_populate_channel_data(FSPM_UPD *memupd, const struct soc_mem_cfg *soc_mem_cfg,
141  const struct mem_spd *spd_info,
142  bool half_populated,
143  struct mem_channel_data *data);
144 
145 /*
146  * Given a channel number and the maximum number of supported channels, this
147  * function returns if a channel is populated. This is useful for populating
148  * DQ/DQS UPDs by the SoC code.
149  */
150 static inline bool channel_is_populated(size_t curr_ch, size_t max_ch,
151  enum channel_population flags)
152 {
153  if ((curr_ch * 2) < max_ch)
154  return !!(flags & BOTTOM_HALF_POPULATED);
155 
156  return !!(flags & TOP_HALF_POPULATED);
157 }
158 
159 #endif /* __SOC_INTEL_COMMON_BLOCK_MEMINIT_H__ */
static bool channel_is_populated(size_t curr_ch, size_t max_ch, enum channel_population flags)
Definition: meminit.h:150
void mem_populate_channel_data(FSPM_UPD *memupd, const struct soc_mem_cfg *soc_mem_cfg, const struct mem_spd *spd_info, bool half_populated, struct mem_channel_data *data)
Definition: meminit.c:187
channel_population
Definition: meminit.h:111
@ NO_CHANNEL_POPULATED
Definition: meminit.h:112
@ TOP_HALF_POPULATED
Definition: meminit.h:113
@ FULLY_POPULATED
Definition: meminit.h:115
@ BOTTOM_HALF_POPULATED
Definition: meminit.h:114
#define MRC_CHANNELS
Definition: meminit.h:21
mem_topology
Definition: meminit.h:24
@ MEM_TOPO_MIXED
Definition: meminit.h:27
@ MEM_TOPO_DIMM_MODULE
Definition: meminit.h:26
@ MEM_TOPO_MEMORY_DOWN
Definition: meminit.h:25
#define BIT(nr)
Definition: ec_commands.h:45
unsigned int uint32_t
Definition: stdint.h:14
unsigned long uintptr_t
Definition: stdint.h:21
unsigned char uint8_t
Definition: stdint.h:8
uintptr_t spd[MRC_CHANNELS][CONFIG_DIMMS_PER_CHANNEL]
Definition: meminit.h:124
enum channel_population ch_population_flags
Definition: meminit.h:128
size_t spd_len
Definition: meminit.h:126
enum mem_topology topo
Definition: meminit.h:38
size_t cbfs_index
Definition: meminit.h:44
struct mem_spd::@542 smbus[MRC_CHANNELS]
uint8_t addr_dimm[CONFIG_DIMMS_PER_CHANNEL]
Definition: meminit.h:58
size_t num_phys_channels
Definition: meminit.h:68
uint32_t mixed_topo
Definition: meminit.h:106
size_t phys_to_mrc_map[MRC_CHANNELS]
Definition: meminit.h:83
uint32_t half_channel
Definition: meminit.h:101
struct soc_mem_cfg::@543 md_phy_masks
Definition: spd.h:11