coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ddr3.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /**
4  * @file ddr3.c
5  *
6  * \brief Utilities for decoding DDR3 SPDs
7  */
8 
9 #include <console/console.h>
10 #include <device/device.h>
11 #include <device/dram/ddr3.h>
12 #include <device/dram/common.h>
13 #include <string.h>
14 #include <memory_info.h>
15 #include <cbmem.h>
16 #include <smbios.h>
17 #include <types.h>
18 
19 /*==============================================================================
20  * = DDR3 SPD decoding helpers
21  *----------------------------------------------------------------------------*/
22 
23 /**
24  * \brief Checks if the DIMM is Registered based on byte[3] of the SPD
25  *
26  * Tells if the DIMM type is registered or not.
27  *
28  * @param type DIMM type. This is byte[3] of the SPD.
29  */
31 {
35  return 1;
36 
37  return 0;
38 }
39 
40 /**
41  * \brief Calculate the CRC of a DDR3 SPD
42  *
43  * @param spd pointer to raw SPD data
44  * @param len length of data in SPD
45  *
46  * @return the CRC of the SPD data, or 0 when spd data is truncated.
47  */
48 u16 spd_ddr3_calc_crc(u8 *spd, int len)
49 {
50  int n_crc;
51 
52  /* Find the number of bytes covered by CRC */
53  if (spd[0] & 0x80) {
54  n_crc = 117;
55  } else {
56  n_crc = 126;
57  }
58 
59  if (len < n_crc)
60  /* Not enough bytes available to get the CRC */
61  return 0;
62 
63  return ddr_crc16(spd, n_crc);
64 }
65 
66 /**
67  * \brief Calculate the CRC of a DDR3 SPD unique identifier
68  *
69  * @param spd pointer to raw SPD data
70  * @param len length of data in SPD
71  *
72  * @return the CRC of SPD data bytes 117..127, or 0 when spd data is truncated.
73  */
75 {
76  if (len < (117 + 11))
77  /* Not enough bytes available to get the CRC */
78  return 0;
79 
80  return ddr_crc16(&spd[117], 11);
81 }
82 
83 /**
84  * \brief Decode the raw SPD data
85  *
86  * Decodes a raw SPD data from a DDR3 DIMM, and organizes it into a
87  * @ref dimm_attr structure. The SPD data must first be read in a contiguous
88  * array, and passed to this function.
89  *
90  * @param dimm pointer to @ref dimm_attr structure where the decoded data is to
91  * be stored
92  * @param spd array of raw data previously read from the SPD.
93  *
94  * @return @ref spd_status enumerator
95  * SPD_STATUS_OK -- decoding was successful
96  * SPD_STATUS_INVALID -- invalid SPD or not a DDR3 SPD
97  * SPD_STATUS_CRC_ERROR -- CRC did not verify
98  * SPD_STATUS_INVALID_FIELD -- A field with an invalid value was
99  * detected.
100  */
102 {
103  int ret;
104  u16 crc, spd_crc;
105  u8 capacity_shift, bus_width;
106  u8 reg8;
107  u32 mtb; /* medium time base */
108  u32 ftb; /* fine time base */
109  unsigned int val;
110 
111  ret = SPD_STATUS_OK;
112 
113  /* Don't assume we memset 0 dimm struct. Clear all our flags */
114  dimm->flags.raw = 0;
115  dimm->dimms_per_channel = 3;
116 
117  /* Make sure that the SPD dump is indeed from a DDR3 module */
118  if (spd[2] != SPD_MEMORY_TYPE_SDRAM_DDR3) {
119  printram("Not a DDR3 SPD!\n");
121  return SPD_STATUS_INVALID;
122  }
124  dimm->dimm_type = spd[3] & 0xf;
125 
126  crc = spd_ddr3_calc_crc(spd, sizeof(spd_raw_data));
127  /* Compare with the CRC in the SPD */
128  spd_crc = (spd[127] << 8) + spd[126];
129  /* Verify the CRC is correct */
130  if (crc != spd_crc) {
131  printram("ERROR: SPD CRC failed!!!\n");
132  ret = SPD_STATUS_CRC_ERROR;
133  };
134 
135  printram(" Revision : %x\n", spd[1]);
136  printram(" Type : %x\n", spd[2]);
137  printram(" Key : %x\n", spd[3]);
138 
139  reg8 = spd[4];
140  /* Number of memory banks */
141  val = (reg8 >> 4) & 0x07;
142  if (val > 0x03) {
143  printram(" Invalid number of memory banks\n");
145  }
146  printram(" Banks : %u\n", 1 << (val + 3));
147  /* SDRAM capacity */
148  capacity_shift = reg8 & 0x0f;
149  if (capacity_shift > 0x06) {
150  printram(" Invalid module capacity\n");
152  }
153  if (capacity_shift < 0x02) {
154  printram(" Capacity : %u Mb\n", 256 << capacity_shift);
155  } else {
156  printram(" Capacity : %u Gb\n", 1 << (capacity_shift - 2));
157  }
158 
159  reg8 = spd[5];
160  /* Row address bits */
161  val = (reg8 >> 3) & 0x07;
162  if (val > 0x04) {
163  printram(" Invalid row address bits\n");
165  }
166  dimm->row_bits = val + 12;
167  /* Column address bits */
168  val = reg8 & 0x07;
169  if (val > 0x03) {
170  printram(" Invalid column address bits\n");
172  }
173  dimm->col_bits = val + 9;
174 
175  /* Module nominal voltage */
176  reg8 = spd[6];
177  printram(" Supported voltages :");
178  if (reg8 & (1 << 2)) {
179  dimm->flags.operable_1_25V = 1;
180  dimm->voltage = 1250;
181  printram(" 1.25V");
182  }
183  if (reg8 & (1 << 1)) {
184  dimm->flags.operable_1_35V = 1;
185  dimm->voltage = 1300;
186  printram(" 1.35V");
187  }
188  if (!(reg8 & (1 << 0))) {
189  dimm->flags.operable_1_50V = 1;
190  dimm->voltage = 1500;
191  printram(" 1.5V");
192  }
193  printram("\n");
194 
195  /* Module organization */
196  reg8 = spd[7];
197  /* Number of ranks */
198  val = (reg8 >> 3) & 0x07;
199  if (val > 3) {
200  printram(" Invalid number of ranks\n");
202  }
203  dimm->ranks = val + 1;
204  /* SDRAM device width */
205  val = (reg8 & 0x07);
206  if (val > 3) {
207  printram(" Invalid SDRAM width\n");
209  }
210  dimm->width = (4 << val);
211  printram(" SDRAM width : %u\n", dimm->width);
212 
213  /* Memory bus width */
214  reg8 = spd[8];
215  /* Bus extension */
216  val = (reg8 >> 3) & 0x03;
217  if (val > 1) {
218  printram(" Invalid bus extension\n");
220  }
221  dimm->flags.is_ecc = val ? 1 : 0;
222  printram(" Bus extension : %u bits\n", val ? 8 : 0);
223  /* Bus width */
224  val = reg8 & 0x07;
225  if (val > 3) {
226  printram(" Invalid bus width\n");
228  }
229  bus_width = 8 << val;
230  printram(" Bus width : %u\n", bus_width);
231 
232  /* We have all the info we need to compute the dimm size */
233  /* Capacity is 256Mbit multiplied by the power of 2 specified in
234  * capacity_shift
235  * The rest is the JEDEC formula */
236  dimm->size_mb = ((1 << (capacity_shift + (25 - 20))) * bus_width
237  * dimm->ranks) / dimm->width;
238 
239  /* Medium Timebase =
240  * Medium Timebase (MTB) Dividend /
241  * Medium Timebase (MTB) Divisor */
242  mtb = (((u32) spd[10]) << 8) / spd[11];
243 
244  /* SDRAM Minimum Cycle Time (tCKmin) */
245  dimm->tCK = spd[12] * mtb;
246  /* CAS Latencies Supported */
247  dimm->cas_supported = (spd[15] << 8) + spd[14];
248  /* Minimum CAS Latency Time (tAAmin) */
249  dimm->tAA = spd[16] * mtb;
250  /* Minimum Write Recovery Time (tWRmin) */
251  dimm->tWR = spd[17] * mtb;
252  /* Minimum RAS# to CAS# Delay Time (tRCDmin) */
253  dimm->tRCD = spd[18] * mtb;
254  /* Minimum Row Active to Row Active Delay Time (tRRDmin) */
255  dimm->tRRD = spd[19] * mtb;
256  /* Minimum Row Precharge Delay Time (tRPmin) */
257  dimm->tRP = spd[20] * mtb;
258  /* Minimum Active to Precharge Delay Time (tRASmin) */
259  dimm->tRAS = (((spd[21] & 0x0f) << 8) + spd[22]) * mtb;
260  /* Minimum Active to Active/Refresh Delay Time (tRCmin) */
261  dimm->tRC = (((spd[21] & 0xf0) << 4) + spd[23]) * mtb;
262  /* Minimum Refresh Recovery Delay Time (tRFCmin) */
263  dimm->tRFC = ((spd[25] << 8) + spd[24]) * mtb;
264  /* Minimum Internal Write to Read Command Delay Time (tWTRmin) */
265  dimm->tWTR = spd[26] * mtb;
266  /* Minimum Internal Read to Precharge Command Delay Time (tRTPmin) */
267  dimm->tRTP = spd[27] * mtb;
268  /* Minimum Four Activate Window Delay Time (tFAWmin) */
269  dimm->tFAW = (((spd[28] & 0x0f) << 8) + spd[29]) * mtb;
270  /* Minimum CAS Write Latency Time (tCWLmin)
271  * - not present in standard SPD */
272  dimm->tCWL = 0;
273  /* System CMD Rate Mode - not present in standard SPD */
274  dimm->tCMD = 0;
275 
276  printram(" FTB timings :");
277  /* FTB is introduced in SPD revision 1.1 */
278  if (spd[1] >= 0x11 && spd[9] & 0x0f) {
279  printram(" yes\n");
280 
281  /* Fine timebase (1/256 ps) =
282  * Fine Timebase (FTB) Dividend /
283  * Fine Timebase (FTB) Divisor */
284  ftb = (((u16) spd[9] & 0xf0) << 4) / (spd[9] & 0x0f);
285 
286  /* SPD recommends to round up the MTB part and use a negative
287  * FTB, so a negative rounding should be always safe */
288 
289  /* SDRAM Minimum Cycle Time (tCKmin) correction */
290  dimm->tCK += (s32)((s8) spd[34] * ftb - 500) / 1000;
291  /* Minimum CAS Latency Time (tAAmin) correction */
292  dimm->tAA += (s32)((s8) spd[35] * ftb - 500) / 1000;
293  /* Minimum RAS# to CAS# Delay Time (tRCDmin) correction */
294  dimm->tRCD += (s32)((s8) spd[36] * ftb - 500) / 1000;
295  /* Minimum Row Precharge Delay Time (tRPmin) correction */
296  dimm->tRP += (s32)((s8) spd[37] * ftb - 500) / 1000;
297  /* Minimum Active to Active/Refresh Delay Time (tRCmin) corr. */
298  dimm->tRC += (s32)((s8) spd[38] * ftb - 500) / 1000;
299  }
300  else {
301  printram(" no\n");
302  }
303 
304  /* SDRAM Optional Features */
305  reg8 = spd[30];
306  printram(" Optional features :");
307  if (reg8 & 0x80) {
308  dimm->flags.dll_off_mode = 1;
309  printram(" DLL-Off_mode");
310  }
311  if (reg8 & 0x02) {
312  dimm->flags.rzq7_supported = 1;
313  printram(" RZQ/7");
314  }
315  if (reg8 & 0x01) {
316  dimm->flags.rzq6_supported = 1;
317  printram(" RZQ/6");
318  }
319  printram("\n");
320 
321  /* SDRAM Thermal and Refresh Options */
322  reg8 = spd[31];
323  printram(" Thermal features :");
324  if (reg8 & 0x80) {
325  dimm->flags.pasr = 1;
326  printram(" PASR");
327  }
328  if (reg8 & 0x08) {
329  dimm->flags.odts = 1;
330  printram(" ODTS");
331  }
332  if (reg8 & 0x04) {
333  dimm->flags.asr = 1;
334  printram(" ASR");
335  }
336  if (reg8 & 0x02) {
337  dimm->flags.ext_temp_range = 1;
338  printram(" ext_temp_refresh");
339  }
340  if (reg8 & 0x01) {
341  dimm->flags.ext_temp_refresh = 1;
342  printram(" ext_temp_range");
343  }
344  printram("\n");
345 
346  /* Module Thermal Sensor */
347  reg8 = spd[32];
348  if (reg8 & 0x80)
349  dimm->flags.therm_sensor = 1;
350  printram(" Thermal sensor : %s\n",
351  dimm->flags.therm_sensor ? "yes" : "no");
352 
353  /* SDRAM Device Type */
354  printram(" Standard SDRAM : %s\n", (spd[33] & 0x80) ? "no" : "yes");
355 
356  if (spd[63] & 0x01) {
357  dimm->flags.pins_mirrored = 1;
358  }
359  printram(" Rank1 Address bits : %s\n",
360  (spd[63] & 0x01) ? "mirrored" : "normal");
361 
362  dimm->reference_card = spd[62] & 0x1f;
363  printram(" DIMM Reference card: %c\n", 'A' + dimm->reference_card);
364 
365  dimm->manufacturer_id = (spd[118] << 8) | spd[117];
366  printram(" Manufacturer ID : %x\n", dimm->manufacturer_id);
367 
368  dimm->part_number[16] = 0;
369  memcpy(dimm->part_number, &spd[128], 16);
370  printram(" Part number : %s\n", dimm->part_number);
371 
373 
374  return ret;
375 }
376 
377 /**
378  * \brief Decode the raw SPD XMP data
379  *
380  * Decodes a raw SPD XMP data from a DDR3 DIMM, and organizes it into a
381  * @ref dimm_attr structure. The SPD data must first be read in a contiguous
382  * array, and passed to this function.
383  *
384  * @param dimm pointer to @ref dimm_attr structure where the decoded data is to
385  * be stored
386  * @param spd array of raw data previously read from the SPD.
387  *
388  * @param profile select one of the profiles to load
389  *
390  * @return @ref spd_status enumerator
391  * SPD_STATUS_OK -- decoding was successful
392  * SPD_STATUS_INVALID -- invalid SPD or not a DDR3 SPD
393  * SPD_STATUS_CRC_ERROR -- CRC did not verify
394  * SPD_STATUS_INVALID_FIELD -- A field with an invalid value was
395  * detected.
396  */
398  spd_raw_data spd,
399  enum ddr3_xmp_profile profile)
400 {
401  int ret;
402  u32 mtb; /* medium time base */
403  u8 *xmp; /* pointer to XMP profile data */
404 
405  /* need a valid SPD */
406  ret = spd_decode_ddr3(dimm, spd);
407  if (ret != SPD_STATUS_OK)
408  return ret;
409 
410  /* search for magic header */
411  if (spd[176] != 0x0C || spd[177] != 0x4A) {
412  printram("Not a DDR3 XMP profile!\n");
414  return SPD_STATUS_INVALID;
415  }
416 
417  if (profile == DDR3_XMP_PROFILE_1) {
418  if (!(spd[178] & 1)) {
419  printram("Selected XMP profile disabled!\n");
421  return SPD_STATUS_INVALID;
422  }
423 
424  printram(" XMP Profile : 1\n");
425  xmp = &spd[185];
426 
427  /* Medium Timebase =
428  * Medium Timebase (MTB) Dividend /
429  * Medium Timebase (MTB) Divisor */
430  mtb = (((u32) spd[180]) << 8) / spd[181];
431 
432  dimm->dimms_per_channel = ((spd[178] >> 2) & 0x3) + 1;
433  } else {
434  if (!(spd[178] & 2)) {
435  printram("Selected XMP profile disabled!\n");
437  return SPD_STATUS_INVALID;
438  }
439  printram(" XMP Profile : 2\n");
440  xmp = &spd[220];
441 
442  /* Medium Timebase =
443  * Medium Timebase (MTB) Dividend /
444  * Medium Timebase (MTB) Divisor */
445  mtb = (((u32) spd[182]) << 8) / spd[183];
446 
447  dimm->dimms_per_channel = ((spd[178] >> 4) & 0x3) + 1;
448  }
449 
450  printram(" Max DIMMs/channel : %u\n",
451  dimm->dimms_per_channel);
452 
453  printram(" XMP Revision : %u.%u\n", spd[179] >> 4, spd[179] & 0xf);
454 
455  /* calculate voltage in mV */
456  dimm->voltage = (xmp[0] & 1) * 50;
457  dimm->voltage += ((xmp[0] >> 1) & 0xf) * 100;
458  dimm->voltage += ((xmp[0] >> 5) & 0x3) * 1000;
459 
460  printram(" Requested voltage : %u mV\n", dimm->voltage);
461 
462  /* SDRAM Minimum Cycle Time (tCKmin) */
463  dimm->tCK = xmp[1] * mtb;
464  /* CAS Latencies Supported */
465  dimm->cas_supported = ((xmp[4] << 8) + xmp[3]) & 0x7fff;
466  /* Minimum CAS Latency Time (tAAmin) */
467  dimm->tAA = xmp[2] * mtb;
468  /* Minimum Write Recovery Time (tWRmin) */
469  dimm->tWR = xmp[8] * mtb;
470  /* Minimum RAS# to CAS# Delay Time (tRCDmin) */
471  dimm->tRCD = xmp[7] * mtb;
472  /* Minimum Row Active to Row Active Delay Time (tRRDmin) */
473  dimm->tRRD = xmp[17] * mtb;
474  /* Minimum Row Precharge Delay Time (tRPmin) */
475  dimm->tRP = xmp[6] * mtb;
476  /* Minimum Active to Precharge Delay Time (tRASmin) */
477  dimm->tRAS = (((xmp[9] & 0x0f) << 8) + xmp[10]) * mtb;
478  /* Minimum Active to Active/Refresh Delay Time (tRCmin) */
479  dimm->tRC = (((xmp[9] & 0xf0) << 4) + xmp[11]) * mtb;
480  /* Minimum Refresh Recovery Delay Time (tRFCmin) */
481  dimm->tRFC = ((xmp[15] << 8) + xmp[14]) * mtb;
482  /* Minimum Internal Write to Read Command Delay Time (tWTRmin) */
483  dimm->tWTR = xmp[20] * mtb;
484  /* Minimum Internal Read to Precharge Command Delay Time (tRTPmin) */
485  dimm->tRTP = xmp[16] * mtb;
486  /* Minimum Four Activate Window Delay Time (tFAWmin) */
487  dimm->tFAW = (((xmp[18] & 0x0f) << 8) + xmp[19]) * mtb;
488  /* Minimum CAS Write Latency Time (tCWLmin) */
489  dimm->tCWL = xmp[5] * mtb;
490  /* System CMD Rate Mode */
491  dimm->tCMD = xmp[23] * mtb;
492 
493  return ret;
494 }
495 
496 /**
497  * Fill cbmem with information for SMBIOS type 17.
498  *
499  * @param channel Corresponding channel of provided @info
500  * @param slot Corresponding slot of provided @info
501  * @param selected_freq The actual frequency the DRAM is running on
502  * @param info DIMM parameters read from SPD
503  *
504  * @return CB_SUCCESS if DIMM info was written
505  */
506 enum cb_err spd_add_smbios17(const u8 channel, const u8 slot,
507  const u16 selected_freq,
508  const struct dimm_attr_ddr3_st *info)
509 {
510  struct memory_info *mem_info;
511  struct dimm_info *dimm;
512 
513  /*
514  * Allocate CBMEM area for DIMM information used to populate SMBIOS
515  * table 17
516  */
517  mem_info = cbmem_find(CBMEM_ID_MEMINFO);
518  if (!mem_info) {
519  mem_info = cbmem_add(CBMEM_ID_MEMINFO, sizeof(*mem_info));
520 
521  printk(BIOS_DEBUG, "CBMEM entry for DIMM info: %p\n",
522  mem_info);
523  if (!mem_info)
524  return CB_ERR;
525 
526  memset(mem_info, 0, sizeof(*mem_info));
527  }
528 
529  if (mem_info->dimm_cnt >= ARRAY_SIZE(mem_info->dimm)) {
530  printk(BIOS_WARNING, "BUG: Too many DIMM infos for %s.\n",
531  __func__);
532  return CB_ERR;
533  }
534 
535  dimm = &mem_info->dimm[mem_info->dimm_cnt];
536  if (info->size_mb) {
537  dimm->ddr_type = MEMORY_TYPE_DDR3;
538  dimm->ddr_frequency = selected_freq;
539  dimm->dimm_size = info->size_mb;
540  dimm->channel_num = channel;
541  dimm->rank_per_dimm = info->ranks;
542  dimm->dimm_num = slot;
543  memcpy(dimm->module_part_number, info->part_number, 16);
544  dimm->mod_id = info->manufacturer_id;
545 
546  switch (info->dimm_type) {
548  dimm->mod_type = DDR3_SPD_SODIMM;
549  break;
552  break;
555  break;
557  dimm->mod_type = DDR3_SPD_UDIMM;
558  break;
560  dimm->mod_type = DDR3_SPD_RDIMM;
561  break;
563  default:
564  dimm->mod_type = SPD_UNDEFINED;
565  break;
566  }
567 
568  dimm->bus_width = MEMORY_BUS_WIDTH_64; // non-ECC only
569  memcpy(dimm->serial, info->serial,
570  MIN(sizeof(dimm->serial), sizeof(info->serial)));
571  mem_info->dimm_cnt++;
572  }
573 
574  return CB_SUCCESS;
575 }
576 
577 /*
578  * The information printed below has a more informational character, and is not
579  * necessarily tied in to RAM init debugging. Hence, we stop using printram(),
580  * and use the standard printk()'s below.
581  */
582 
583 static void print_ns(const char *msg, u32 val)
584 {
585  u32 mant, fp;
586  mant = val / 256;
587  fp = (val % 256) * 1000 / 256;
588 
589  printk(BIOS_INFO, "%s%3u.%.3u ns\n", msg, mant, fp);
590 }
591 
592 /**
593 * \brief Print the info in DIMM
594 *
595 * Print info about the DIMM. Useful to use when CONFIG(DEBUG_RAM_SETUP) is
596 * selected, or for a purely informative output.
597 *
598 * @param dimm pointer to already decoded @ref dimm_attr structure
599 */
600 void dram_print_spd_ddr3(const struct dimm_attr_ddr3_st *dimm)
601 {
602  u16 val16;
603  int i;
604 
605  printk(BIOS_INFO, " Row addr bits : %u\n", dimm->row_bits);
606  printk(BIOS_INFO, " Column addr bits : %u\n", dimm->col_bits);
607  printk(BIOS_INFO, " Number of ranks : %u\n", dimm->ranks);
608  printk(BIOS_INFO, " DIMM Capacity : %u MB\n", dimm->size_mb);
609 
610  /* CAS Latencies Supported */
611  val16 = dimm->cas_supported;
612  printk(BIOS_INFO, " CAS latencies :");
613  i = 0;
614  do {
615  if (val16 & 1)
616  printk(BIOS_INFO, " %u", i + 4);
617  i++;
618  val16 >>= 1;
619  } while (val16);
620  printk(BIOS_INFO, "\n");
621 
622  print_ns(" tCKmin : ", dimm->tCK);
623  print_ns(" tAAmin : ", dimm->tAA);
624  print_ns(" tWRmin : ", dimm->tWR);
625  print_ns(" tRCDmin : ", dimm->tRCD);
626  print_ns(" tRRDmin : ", dimm->tRRD);
627  print_ns(" tRPmin : ", dimm->tRP);
628  print_ns(" tRASmin : ", dimm->tRAS);
629  print_ns(" tRCmin : ", dimm->tRC);
630  print_ns(" tRFCmin : ", dimm->tRFC);
631  print_ns(" tWTRmin : ", dimm->tWTR);
632  print_ns(" tRTPmin : ", dimm->tRTP);
633  print_ns(" tFAWmin : ", dimm->tFAW);
634  /* Those values are only relevant if an XMP profile sets them */
635  if (dimm->tCWL)
636  print_ns(" tCWLmin : ", dimm->tCWL);
637  if (dimm->tCMD)
638  printk(BIOS_INFO, " tCMDmin : %3u\n",
639  DIV_ROUND_UP(dimm->tCMD, 256));
640 }
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
void * memset(void *dstpp, int c, size_t len)
Definition: memset.c:12
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define MIN(a, b)
Definition: helpers.h:37
#define DIV_ROUND_UP(x, y)
Definition: helpers.h:60
cb_err
coreboot error codes
Definition: cb_err.h:15
@ CB_ERR
Generic error code.
Definition: cb_err.h:17
@ CB_SUCCESS
Call completed successfully.
Definition: cb_err.h:16
void * cbmem_add(u32 id, u64 size)
Definition: imd_cbmem.c:144
void * cbmem_find(u32 id)
Definition: imd_cbmem.c:166
#define CBMEM_ID_MEMINFO
Definition: cbmem_id.h:33
#define printk(level,...)
Definition: stdlib.h:16
static void print_ns(const char *msg, u32 val)
Definition: ddr3.c:583
int spd_dimm_is_registered_ddr3(enum spd_dimm_type_ddr3 type)
Checks if the DIMM is Registered based on byte[3] of the SPD.
Definition: ddr3.c:30
enum cb_err spd_add_smbios17(const u8 channel, const u8 slot, const u16 selected_freq, const struct dimm_attr_ddr3_st *info)
Fill cbmem with information for SMBIOS type 17.
Definition: ddr3.c:506
void dram_print_spd_ddr3(const struct dimm_attr_ddr3_st *dimm)
Print the info in DIMM.
Definition: ddr3.c:600
int spd_xmp_decode_ddr3(struct dimm_attr_ddr3_st *dimm, spd_raw_data spd, enum ddr3_xmp_profile profile)
Decode the raw SPD XMP data.
Definition: ddr3.c:397
int spd_decode_ddr3(struct dimm_attr_ddr3_st *dimm, spd_raw_data spd)
Decode the raw SPD data.
Definition: ddr3.c:101
u16 spd_ddr3_calc_crc(u8 *spd, int len)
Calculate the CRC of a DDR3 SPD.
Definition: ddr3.c:48
u16 spd_ddr3_calc_unique_crc(u8 *spd, int len)
Calculate the CRC of a DDR3 SPD unique identifier.
Definition: ddr3.c:74
u16 ddr_crc16(const u8 *ptr, int n_crc)
Calculate the CRC of a DDR SPD data.
Definition: ddr_common.c:14
static struct smmstore_params_info info
Definition: ramstage.c:12
#define printram(x,...)
Convenience macro for enabling printk with CONFIG(DEBUG_RAM_SETUP)
Definition: common.h:46
@ SPD_STATUS_CRC_ERROR
Definition: common.h:54
@ SPD_STATUS_INVALID_FIELD
Definition: common.h:55
@ SPD_STATUS_INVALID
Definition: common.h:53
@ SPD_STATUS_OK
Definition: common.h:52
Utilities for decoding DDR3 SPDs.
spd_dimm_type_ddr3
Definition: ddr3.h:39
@ SPD_DDR3_DIMM_TYPE_SO_DIMM
Definition: ddr3.h:43
@ SPD_DDR3_DIMM_TYPE_72B_SO_CDIMM
Definition: ddr3.h:50
@ SPD_DDR3_DIMM_TYPE_72B_SO_RDIMM
Definition: ddr3.h:49
@ SPD_DDR3_DIMM_TYPE_MINI_RDIMM
Definition: ddr3.h:45
@ SPD_DDR3_DIMM_TYPE_UNDEFINED
Definition: ddr3.h:40
@ SPD_DDR3_DIMM_TYPE_RDIMM
Definition: ddr3.h:41
@ SPD_DDR3_DIMM_TYPE_UDIMM
Definition: ddr3.h:42
#define SPD_DIMM_SERIAL_NUM
Definition: ddr3.h:29
ddr3_xmp_profile
Definition: ddr3.h:151
@ DDR3_XMP_PROFILE_1
Definition: ddr3.h:152
#define SPD_DIMM_SERIAL_LEN
Definition: ddr3.h:30
u8 spd_raw_data[256]
Definition: ddr3.h:156
@ MEMORY_BUS_WIDTH_64
Definition: smbios.h:137
@ MEMORY_TYPE_DDR3
Definition: smbios.h:185
#define SPD_UNDEFINED
Definition: spd.h:200
@ SPD_MEMORY_TYPE_SDRAM_DDR3
Definition: spd.h:152
@ SPD_MEMORY_TYPE_UNDEFINED
Definition: spd.h:141
@ DDR3_SPD_72B_SO_CDIMM
Definition: spd.h:226
@ DDR3_SPD_UDIMM
Definition: spd.h:218
@ DDR3_SPD_72B_SO_RDIMM
Definition: spd.h:225
@ DDR3_SPD_RDIMM
Definition: spd.h:217
@ DDR3_SPD_SODIMM
Definition: spd.h:219
unsigned int type
Definition: edid.c:57
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
Definition: loglevel.h:86
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
int8_t s8
Definition: stdint.h:44
uint8_t u8
Definition: stdint.h:45
int32_t s32
Definition: stdint.h:50
DIMM characteristics.
Definition: ddr3.h:106
union dimm_flags_ddr3_st flags
Definition: ddr3.h:111
u16 cas_supported
Definition: ddr3.h:109
enum spd_memory_type dram_type
Definition: ddr3.h:107
u16 manufacturer_id
Definition: ddr3.h:144
u8 serial[SPD_DIMM_SERIAL_LEN]
Definition: ddr3.h:148
u8 dimms_per_channel
Definition: ddr3.h:142
u8 reference_card
Definition: ddr3.h:138
u8 part_number[17]
Definition: ddr3.h:146
enum spd_dimm_type_ddr3 dimm_type
Definition: ddr3.h:108
If this table is filled and put in CBMEM, then these info in CBMEM will be used to generate smbios ty...
Definition: memory_info.h:19
uint8_t mod_type
Definition: memory_info.h:60
uint8_t rank_per_dimm
Definition: memory_info.h:35
uint8_t channel_num
Definition: memory_info.h:36
uint8_t dimm_num
Definition: memory_info.h:37
uint8_t bus_width
Definition: memory_info.h:80
uint8_t module_part_number[DIMM_INFO_PART_NUMBER_SIZE]
Definition: memory_info.h:48
uint16_t ddr_type
Definition: memory_info.h:29
uint8_t serial[DIMM_INFO_SERIAL_SIZE]
Definition: memory_info.h:42
uint16_t ddr_frequency
Definition: memory_info.h:34
uint16_t mod_id
Definition: memory_info.h:52
uint32_t dimm_size
Definition: memory_info.h:23
struct dimm_info dimm[DIMM_INFO_TOTAL]
Definition: memory_info.h:110
uint8_t dimm_cnt
Definition: memory_info.h:109
u8 val
Definition: sys.c:300
unsigned int raw
Definition: ddr3.h:98
unsigned int rzq7_supported
Definition: ddr3.h:84
unsigned int is_ecc
Definition: ddr3.h:78
unsigned int asr
Definition: ddr3.h:90
unsigned int operable_1_25V
Definition: ddr3.h:76
unsigned int rzq6_supported
Definition: ddr3.h:82
unsigned int operable_1_50V
Definition: ddr3.h:72
unsigned int pins_mirrored
Definition: ddr3.h:70
unsigned int odts
Definition: ddr3.h:88
unsigned int dll_off_mode
Definition: ddr3.h:80
unsigned int operable_1_35V
Definition: ddr3.h:74
unsigned int ext_temp_range
Definition: ddr3.h:92
unsigned int pasr
Definition: ddr3.h:86
unsigned int therm_sensor
Definition: ddr3.h:96
unsigned int ext_temp_refresh
Definition: ddr3.h:94