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/ddr4.h>
6 #include <device/dram/ddr5.h>
7 #include <device/dram/spd.h>
12 const char *spd_manufacturer_name(const uint16_t mod_id
)
31 return "Hynix/Hyundai";
33 return "Super Talent";
51 static void convert_default_module_type_to_spd_info(struct spd_info
*info
)
53 info
->form_factor
= MEMORY_FORMFACTOR_UNKNOWN
;
54 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
57 static void convert_ddr2_module_type_to_spd_info(enum spd_dimm_type_ddr2 module_type
,
58 struct spd_info
*info
)
60 switch (module_type
) {
61 case SPD_DDR2_DIMM_TYPE_RDIMM
:
62 case SPD_DDR2_DIMM_TYPE_MINI_RDIMM
:
63 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
64 info
->type_detail
= MEMORY_TYPE_DETAIL_REGISTERED
;
66 case SPD_DDR2_DIMM_TYPE_UDIMM
:
67 case SPD_DDR2_DIMM_TYPE_MINI_UDIMM
:
68 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
69 info
->type_detail
= MEMORY_TYPE_DETAIL_UNBUFFERED
;
71 case SPD_DDR2_DIMM_TYPE_MICRO_DIMM
:
72 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
73 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
75 case SPD_DDR2_DIMM_TYPE_SO_DIMM
:
76 info
->form_factor
= MEMORY_FORMFACTOR_SODIMM
;
77 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
80 convert_default_module_type_to_spd_info(info
);
85 static void convert_ddr3_module_type_to_spd_info(enum spd_dimm_type_ddr3 module_type
,
86 struct spd_info
*info
)
88 switch (module_type
) {
89 case SPD_DDR3_DIMM_TYPE_RDIMM
:
90 case SPD_DDR3_DIMM_TYPE_MINI_RDIMM
:
91 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
92 info
->type_detail
= MEMORY_TYPE_DETAIL_REGISTERED
;
94 case SPD_DDR3_DIMM_TYPE_UDIMM
:
95 case SPD_DDR3_DIMM_TYPE_MINI_UDIMM
:
96 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
97 info
->type_detail
= MEMORY_TYPE_DETAIL_UNBUFFERED
;
99 case SPD_DDR3_DIMM_TYPE_MICRO_DIMM
:
100 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
101 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
103 case SPD_DDR3_DIMM_TYPE_SO_DIMM
:
104 case SPD_DDR3_DIMM_TYPE_72B_SO_UDIMM
:
105 info
->form_factor
= MEMORY_FORMFACTOR_SODIMM
;
106 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
109 convert_default_module_type_to_spd_info(info
);
114 static void convert_ddr4_module_type_to_spd_info(enum spd_dimm_type_ddr4 module_type
,
115 struct spd_info
*info
)
117 switch (module_type
) {
118 case SPD_DDR4_DIMM_TYPE_RDIMM
:
119 case SPD_DDR4_DIMM_TYPE_MINI_RDIMM
:
120 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
121 info
->type_detail
= MEMORY_TYPE_DETAIL_REGISTERED
;
123 case SPD_DDR4_DIMM_TYPE_UDIMM
:
124 case SPD_DDR4_DIMM_TYPE_MINI_UDIMM
:
125 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
126 info
->type_detail
= MEMORY_TYPE_DETAIL_UNBUFFERED
;
128 case SPD_DDR4_DIMM_TYPE_SO_DIMM
:
129 case SPD_DDR4_DIMM_TYPE_72B_SO_RDIMM
:
130 info
->form_factor
= MEMORY_FORMFACTOR_SODIMM
;
131 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
134 convert_default_module_type_to_spd_info(info
);
139 static void convert_ddr5_module_type_to_spd_info(enum spd_dimm_type_ddr5 module_type
,
140 struct spd_info
*info
)
142 switch (module_type
) {
143 case SPD_DDR5_DIMM_TYPE_RDIMM
:
144 case SPD_DDR5_DIMM_TYPE_MINI_RDIMM
:
145 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
146 info
->type_detail
= MEMORY_TYPE_DETAIL_REGISTERED
;
148 case SPD_DDR5_DIMM_TYPE_UDIMM
:
149 case SPD_DDR5_DIMM_TYPE_MINI_UDIMM
:
150 info
->form_factor
= MEMORY_FORMFACTOR_DIMM
;
151 info
->type_detail
= MEMORY_TYPE_DETAIL_UNBUFFERED
;
153 case SPD_DDR5_DIMM_TYPE_SODIMM
:
154 case SPD_DDR5_DIMM_TYPE_72B_SO_UDIMM
:
155 info
->form_factor
= MEMORY_FORMFACTOR_SODIMM
;
156 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
158 case SPD_DDR5_DIMM_TYPE_2DPC
:
159 info
->form_factor
= MEMORY_FORMFACTOR_PROPRIETARY_CARD
;
160 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
163 convert_default_module_type_to_spd_info(info
);
168 static void convert_lpx_module_type_to_spd_info(enum lpx_module_type module_type
,
169 struct spd_info
*info
)
171 switch (module_type
) {
172 case LPX_SPD_NONDIMM
:
173 info
->form_factor
= MEMORY_FORMFACTOR_ROC
;
174 info
->type_detail
= MEMORY_TYPE_DETAIL_UNKNOWN
;
177 convert_default_module_type_to_spd_info(info
);
182 void get_spd_info(smbios_memory_type memory_type
, uint8_t module_type
, struct spd_info
*info
)
184 switch (memory_type
) {
185 case MEMORY_TYPE_DDR2
:
186 convert_ddr2_module_type_to_spd_info(module_type
, info
);
188 case MEMORY_TYPE_DDR3
:
189 convert_ddr3_module_type_to_spd_info(module_type
, info
);
191 case MEMORY_TYPE_DDR4
:
192 convert_ddr4_module_type_to_spd_info(module_type
, info
);
194 case MEMORY_TYPE_DDR5
:
195 convert_ddr5_module_type_to_spd_info(module_type
, info
);
197 case MEMORY_TYPE_LPDDR3
:
198 case MEMORY_TYPE_LPDDR4
:
199 case MEMORY_TYPE_LPDDR5
:
200 convert_lpx_module_type_to_spd_info(module_type
, info
);
203 convert_default_module_type_to_spd_info(info
);
208 static uint8_t convert_default_form_factor_to_module_type(void)
210 return SPD_UNDEFINED
;
213 static uint8_t convert_ddrx_form_factor_to_module_type(smbios_memory_type memory_type
,
214 smbios_memory_form_factor form_factor
)
218 switch (form_factor
) {
219 case MEMORY_FORMFACTOR_DIMM
:
220 return SPD_DDR2_DIMM_TYPE_UDIMM
;
221 case MEMORY_FORMFACTOR_RIMM
:
222 return SPD_DDR2_DIMM_TYPE_RDIMM
;
223 case MEMORY_FORMFACTOR_SODIMM
:
224 module_type
= (memory_type
== MEMORY_TYPE_DDR2
) ? SPD_DDR2_DIMM_TYPE_SO_DIMM
:
225 SPD_DDR3_DIMM_TYPE_SO_DIMM
;
228 return convert_default_form_factor_to_module_type();
232 static uint8_t convert_lpx_form_factor_to_module_type(smbios_memory_form_factor form_factor
)
234 switch (form_factor
) {
235 case MEMORY_FORMFACTOR_ROC
:
236 return LPX_SPD_NONDIMM
;
238 return convert_default_form_factor_to_module_type();
242 uint8_t convert_form_factor_to_module_type(smbios_memory_type memory_type
,
243 smbios_memory_form_factor form_factor
)
247 switch (memory_type
) {
248 case MEMORY_TYPE_DDR2
:
249 case MEMORY_TYPE_DDR3
:
250 case MEMORY_TYPE_DDR4
:
251 case MEMORY_TYPE_DDR5
:
252 module_type
= convert_ddrx_form_factor_to_module_type(memory_type
, form_factor
);
254 case MEMORY_TYPE_LPDDR3
:
255 case MEMORY_TYPE_LPDDR4
:
256 case MEMORY_TYPE_LPDDR5
:
257 module_type
= convert_lpx_form_factor_to_module_type(form_factor
);
260 module_type
= convert_default_form_factor_to_module_type();