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>
9 const char *spd_manufacturer_name(const uint16_t mod_id
)
28 return "Hynix/Hyundai";
30 return "Super Talent";
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
;
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
;
68 case SPD_DDR2_DIMM_TYPE_MICRO_DIMM
:
69 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
70 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
72 case SPD_DDR2_DIMM_TYPE_SO_DIMM
:
73 info
->form_factor
= MEMORY_FORMFACTOR_SODIMM
;
74 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
77 convert_default_module_type_to_spd_info(info
);
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
;
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
;
96 case SPD_DDR3_DIMM_TYPE_MICRO_DIMM
:
97 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
98 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
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
;
106 convert_default_module_type_to_spd_info(info
);
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
) {
116 case DDR4_SPD_MINI_RDIMM
:
117 info
->form_factor
= MEMORY_FORMFACTOR_RIMM
;
118 info
->type_detail
= MEMORY_TYPE_DETAIL_REGISTERED
;
121 case DDR4_SPD_MINI_UDIMM
:
122 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
123 info
->type_detail
= MEMORY_TYPE_DETAIL_UNBUFFERED
;
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
;
131 convert_default_module_type_to_spd_info(info
);
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
) {
141 case DDR5_SPD_MINI_RDIMM
:
142 info
->form_factor
= MEMORY_FORMFACTOR_RIMM
;
143 info
->type_detail
= MEMORY_TYPE_DETAIL_REGISTERED
;
146 case DDR5_SPD_MINI_UDIMM
:
147 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
148 info
->type_detail
= MEMORY_TYPE_DETAIL_UNBUFFERED
;
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
;
156 info
->form_factor
= MEMORY_FORMFACTOR_PROPRIETARY_CARD
;
157 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
160 convert_default_module_type_to_spd_info(info
);
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
;
174 convert_default_module_type_to_spd_info(info
);
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
);
185 case MEMORY_TYPE_DDR3
:
186 convert_ddr3_module_type_to_spd_info(module_type
, info
);
188 case MEMORY_TYPE_DDR4
:
189 convert_ddr4_module_type_to_spd_info(module_type
, info
);
191 case MEMORY_TYPE_DDR5
:
192 convert_ddr5_module_type_to_spd_info(module_type
, info
);
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
);
200 convert_default_module_type_to_spd_info(info
);
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
)
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
;
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
;
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
)
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
);
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
);
257 module_type
= convert_default_form_factor_to_module_type();