spd/lp5: Add Hynix memory part
[coreboot.git] / src / device / dram / spd.c
blobef7aead7f68352798a9501a23e42969b9ab27fed
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>
8 #include <smbios.h>
9 #include <spd.h>
10 #include <stddef.h>
12 const char *spd_manufacturer_name(const uint16_t mod_id)
14 switch (mod_id) {
15 case 0x9b85:
16 return "Crucial";
17 case 0x4304:
18 return "Ramaxel";
19 case 0x4f01:
20 return "Transcend";
21 case 0x9801:
22 return "Kingston";
23 case 0x987f:
24 case 0xad00:
25 return "Hynix";
26 case 0x9e02:
27 return "Corsair";
28 case 0xb004:
29 return "OCZ";
30 case 0xad80:
31 return "Hynix/Hyundai";
32 case 0x3486:
33 return "Super Talent";
34 case 0xcd04:
35 return "GSkill";
36 case 0xce80:
37 case 0xce00:
38 return "Samsung";
39 case 0xfe02:
40 return "Elpida";
41 case 0x2c80:
42 case 0x2c00:
43 return "Micron";
44 case 0x0b03:
45 return "Nanya";
46 default:
47 return NULL;
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;
65 break;
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;
70 break;
71 case SPD_DDR2_DIMM_TYPE_MICRO_DIMM:
72 info->form_factor = MEMORY_FORMFACTOR_DIMM;
73 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
74 break;
75 case SPD_DDR2_DIMM_TYPE_SO_DIMM:
76 info->form_factor = MEMORY_FORMFACTOR_SODIMM;
77 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
78 break;
79 default:
80 convert_default_module_type_to_spd_info(info);
81 break;
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;
93 break;
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;
98 break;
99 case SPD_DDR3_DIMM_TYPE_MICRO_DIMM:
100 info->form_factor = MEMORY_FORMFACTOR_DIMM;
101 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
102 break;
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;
107 break;
108 default:
109 convert_default_module_type_to_spd_info(info);
110 break;
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;
122 break;
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;
127 break;
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;
132 break;
133 default:
134 convert_default_module_type_to_spd_info(info);
135 break;
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;
147 break;
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;
152 break;
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;
157 break;
158 case SPD_DDR5_DIMM_TYPE_2DPC:
159 info->form_factor = MEMORY_FORMFACTOR_PROPRIETARY_CARD;
160 info->type_detail = MEMORY_TYPE_DETAIL_UNKNOWN;
161 break;
162 default:
163 convert_default_module_type_to_spd_info(info);
164 break;
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;
175 break;
176 default:
177 convert_default_module_type_to_spd_info(info);
178 break;
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);
187 break;
188 case MEMORY_TYPE_DDR3:
189 convert_ddr3_module_type_to_spd_info(module_type, info);
190 break;
191 case MEMORY_TYPE_DDR4:
192 convert_ddr4_module_type_to_spd_info(module_type, info);
193 break;
194 case MEMORY_TYPE_DDR5:
195 convert_ddr5_module_type_to_spd_info(module_type, info);
196 break;
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);
201 break;
202 default:
203 convert_default_module_type_to_spd_info(info);
204 break;
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)
216 uint8_t module_type;
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;
226 return module_type;
227 default:
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;
237 default:
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)
245 uint8_t module_type;
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);
253 break;
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);
258 break;
259 default:
260 module_type = convert_default_form_factor_to_module_type();
261 break;
264 return module_type;