soc/intel/alderlake: Add ADL-P 4+4 with 28W TDP
[coreboot.git] / src / device / dram / spd.c
blob564a4ead921bcaa7cd2a793c20c78b2fb7418430
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <device/dram/ddr2.h>
4 #include <device/dram/ddr3.h>
5 #include <device/dram/spd.h>
6 #include <spd.h>
7 #include <stddef.h>
9 const char *spd_manufacturer_name(const uint16_t mod_id)
11 switch (mod_id) {
12 case 0x9b85:
13 return "Crucial";
14 case 0x4304:
15 return "Ramaxel";
16 case 0x4f01:
17 return "Transcend";
18 case 0x9801:
19 return "Kingston";
20 case 0x987f:
21 case 0xad00:
22 return "Hynix";
23 case 0x9e02:
24 return "Corsair";
25 case 0xb004:
26 return "OCZ";
27 case 0xad80:
28 return "Hynix/Hyundai";
29 case 0x3486:
30 return "Super Talent";
31 case 0xcd04:
32 return "GSkill";
33 case 0xce80:
34 case 0xce00:
35 return "Samsung";
36 case 0xfe02:
37 return "Elpida";
38 case 0x2c80:
39 case 0x2c00:
40 return "Micron";
41 case 0x0b03:
42 return "Nanya";
43 default:
44 return NULL;
48 static void convert_default_module_type_to_spd_info(struct spd_info *info)
50 info->form_factor = MEMORY_FORMFACTOR_UNKNOWN;
51 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
54 static void convert_ddr2_module_type_to_spd_info(enum spd_dimm_type_ddr2 module_type,
55 struct spd_info *info)
57 switch (module_type) {
58 case SPD_DDR2_DIMM_TYPE_RDIMM:
59 case SPD_DDR2_DIMM_TYPE_MINI_RDIMM:
60 info->form_factor = MEMORY_FORMFACTOR_RIMM;
61 info->type_detail = MEMORY_TYPE_DETAIL_REGISTERED;
62 break;
63 case SPD_DDR2_DIMM_TYPE_UDIMM:
64 case SPD_DDR2_DIMM_TYPE_MINI_UDIMM:
65 info->form_factor = MEMORY_FORMFACTOR_DIMM;
66 info->type_detail = MEMORY_TYPE_DETAIL_UNBUFFERED;
67 break;
68 case SPD_DDR2_DIMM_TYPE_MICRO_DIMM:
69 info->form_factor = MEMORY_FORMFACTOR_DIMM;
70 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
71 break;
72 case SPD_DDR2_DIMM_TYPE_SO_DIMM:
73 info->form_factor = MEMORY_FORMFACTOR_SODIMM;
74 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
75 break;
76 default:
77 convert_default_module_type_to_spd_info(info);
78 break;
82 static void convert_ddr3_module_type_to_spd_info(enum spd_dimm_type_ddr3 module_type,
83 struct spd_info *info)
85 switch (module_type) {
86 case SPD_DDR3_DIMM_TYPE_RDIMM:
87 case SPD_DDR3_DIMM_TYPE_MINI_RDIMM:
88 info->form_factor = MEMORY_FORMFACTOR_RIMM;
89 info->type_detail = MEMORY_TYPE_DETAIL_REGISTERED;
90 break;
91 case SPD_DDR3_DIMM_TYPE_UDIMM:
92 case SPD_DDR3_DIMM_TYPE_MINI_UDIMM:
93 info->form_factor = MEMORY_FORMFACTOR_DIMM;
94 info->type_detail = MEMORY_TYPE_DETAIL_UNBUFFERED;
95 break;
96 case SPD_DDR3_DIMM_TYPE_MICRO_DIMM:
97 info->form_factor = MEMORY_FORMFACTOR_DIMM;
98 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
99 break;
100 case SPD_DDR3_DIMM_TYPE_SO_DIMM:
101 case SPD_DDR3_DIMM_TYPE_72B_SO_UDIMM:
102 info->form_factor = MEMORY_FORMFACTOR_SODIMM;
103 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
104 break;
105 default:
106 convert_default_module_type_to_spd_info(info);
107 break;
111 static void convert_ddr4_module_type_to_spd_info(enum ddr4_module_type module_type,
112 struct spd_info *info)
114 switch (module_type) {
115 case DDR4_SPD_RDIMM:
116 case DDR4_SPD_MINI_RDIMM:
117 info->form_factor = MEMORY_FORMFACTOR_RIMM;
118 info->type_detail = MEMORY_TYPE_DETAIL_REGISTERED;
119 break;
120 case DDR4_SPD_UDIMM:
121 case DDR4_SPD_MINI_UDIMM:
122 info->form_factor = MEMORY_FORMFACTOR_DIMM;
123 info->type_detail = MEMORY_TYPE_DETAIL_UNBUFFERED;
124 break;
125 case DDR4_SPD_SODIMM:
126 case DDR4_SPD_72B_SO_UDIMM:
127 info->form_factor = MEMORY_FORMFACTOR_SODIMM;
128 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
129 break;
130 default:
131 convert_default_module_type_to_spd_info(info);
132 break;
136 static void convert_ddr5_module_type_to_spd_info(enum ddr5_module_type module_type,
137 struct spd_info *info)
139 switch (module_type) {
140 case DDR5_SPD_RDIMM:
141 case DDR5_SPD_MINI_RDIMM:
142 info->form_factor = MEMORY_FORMFACTOR_RIMM;
143 info->type_detail = MEMORY_TYPE_DETAIL_REGISTERED;
144 break;
145 case DDR5_SPD_UDIMM:
146 case DDR5_SPD_MINI_UDIMM:
147 info->form_factor = MEMORY_FORMFACTOR_DIMM;
148 info->type_detail = MEMORY_TYPE_DETAIL_UNBUFFERED;
149 break;
150 case DDR5_SPD_SODIMM:
151 case DDR5_SPD_72B_SO_UDIMM:
152 info->form_factor = MEMORY_FORMFACTOR_SODIMM;
153 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
154 break;
155 case DDR5_SPD_2DPC:
156 info->form_factor = MEMORY_FORMFACTOR_PROPRIETARY_CARD;
157 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
158 break;
159 default:
160 convert_default_module_type_to_spd_info(info);
161 break;
165 static void convert_lpx_module_type_to_spd_info(enum lpx_module_type module_type,
166 struct spd_info *info)
168 switch (module_type) {
169 case LPX_SPD_NONDIMM:
170 info->form_factor = MEMORY_FORMFACTOR_ROC;
171 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
172 break;
173 default:
174 convert_default_module_type_to_spd_info(info);
175 break;
179 void get_spd_info(smbios_memory_type memory_type, uint8_t module_type, struct spd_info *info)
181 switch (memory_type) {
182 case MEMORY_TYPE_DDR2:
183 convert_ddr2_module_type_to_spd_info(module_type, info);
184 break;
185 case MEMORY_TYPE_DDR3:
186 convert_ddr3_module_type_to_spd_info(module_type, info);
187 break;
188 case MEMORY_TYPE_DDR4:
189 convert_ddr4_module_type_to_spd_info(module_type, info);
190 break;
191 case MEMORY_TYPE_DDR5:
192 convert_ddr5_module_type_to_spd_info(module_type, info);
193 break;
194 case MEMORY_TYPE_LPDDR3:
195 case MEMORY_TYPE_LPDDR4:
196 case MEMORY_TYPE_LPDDR5:
197 convert_lpx_module_type_to_spd_info(module_type, info);
198 break;
199 default:
200 convert_default_module_type_to_spd_info(info);
201 break;
205 static uint8_t convert_default_form_factor_to_module_type(void)
207 return SPD_UNDEFINED;
210 static uint8_t convert_ddrx_form_factor_to_module_type(smbios_memory_type memory_type,
211 smbios_memory_form_factor form_factor)
213 uint8_t module_type;
215 switch (form_factor) {
216 case MEMORY_FORMFACTOR_DIMM:
217 return SPD_DDR2_DIMM_TYPE_UDIMM;
218 case MEMORY_FORMFACTOR_RIMM:
219 return SPD_DDR2_DIMM_TYPE_RDIMM;
220 case MEMORY_FORMFACTOR_SODIMM:
221 module_type = (memory_type == MEMORY_TYPE_DDR2) ? SPD_DDR2_DIMM_TYPE_SO_DIMM :
222 SPD_DDR3_DIMM_TYPE_SO_DIMM;
223 return module_type;
224 default:
225 return convert_default_form_factor_to_module_type();
229 static uint8_t convert_lpx_form_factor_to_module_type(smbios_memory_form_factor form_factor)
231 switch (form_factor) {
232 case MEMORY_FORMFACTOR_ROC:
233 return LPX_SPD_NONDIMM;
234 default:
235 return convert_default_form_factor_to_module_type();
239 uint8_t convert_form_factor_to_module_type(smbios_memory_type memory_type,
240 smbios_memory_form_factor form_factor)
242 uint8_t module_type;
244 switch (memory_type) {
245 case MEMORY_TYPE_DDR2:
246 case MEMORY_TYPE_DDR3:
247 case MEMORY_TYPE_DDR4:
248 case MEMORY_TYPE_DDR5:
249 module_type = convert_ddrx_form_factor_to_module_type(memory_type, form_factor);
250 break;
251 case MEMORY_TYPE_LPDDR3:
252 case MEMORY_TYPE_LPDDR4:
253 case MEMORY_TYPE_LPDDR5:
254 module_type = convert_lpx_form_factor_to_module_type(form_factor);
255 break;
256 default:
257 module_type = convert_default_form_factor_to_module_type();
258 break;
261 return module_type;