coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ddr3.c File Reference

Utilities for decoding DDR3 SPDs. More...

#include <console/console.h>
#include <device/device.h>
#include <device/dram/ddr3.h>
#include <device/dram/common.h>
#include <string.h>
#include <memory_info.h>
#include <cbmem.h>
#include <smbios.h>
#include <types.h>
Include dependency graph for ddr3.c:

Go to the source code of this file.

Functions

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. More...
 
u16 spd_ddr3_calc_crc (u8 *spd, int len)
 Calculate the CRC of a DDR3 SPD. More...
 
u16 spd_ddr3_calc_unique_crc (u8 *spd, int len)
 Calculate the CRC of a DDR3 SPD unique identifier. More...
 
int spd_decode_ddr3 (struct dimm_attr_ddr3_st *dimm, spd_raw_data spd)
 Decode the raw SPD data. More...
 
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. More...
 
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. More...
 
static void print_ns (const char *msg, u32 val)
 
void dram_print_spd_ddr3 (const struct dimm_attr_ddr3_st *dimm)
 Print the info in DIMM. More...
 

Detailed Description

Utilities for decoding DDR3 SPDs.

Definition in file ddr3.c.

Function Documentation

◆ dram_print_spd_ddr3()

void dram_print_spd_ddr3 ( const struct dimm_attr_ddr3_st dimm)

Print the info in DIMM.

Print info about the DIMM. Useful to use when CONFIG(DEBUG_RAM_SETUP) is selected, or for a purely informative output.

Parameters
dimmpointer to already decoded dimm_attr structure

Definition at line 600 of file ddr3.c.

References BIOS_INFO, dimm_attr_ddr3_st::cas_supported, dimm_attr_ddr3_st::col_bits, DIV_ROUND_UP, print_ns(), printk, dimm_attr_ddr3_st::ranks, dimm_attr_ddr3_st::row_bits, dimm_attr_ddr3_st::size_mb, dimm_attr_ddr3_st::tAA, dimm_attr_ddr3_st::tCK, dimm_attr_ddr3_st::tCMD, dimm_attr_ddr3_st::tCWL, dimm_attr_ddr3_st::tFAW, dimm_attr_ddr3_st::tRAS, dimm_attr_ddr3_st::tRC, dimm_attr_ddr3_st::tRCD, dimm_attr_ddr3_st::tRFC, dimm_attr_ddr3_st::tRP, dimm_attr_ddr3_st::tRRD, dimm_attr_ddr3_st::tRTP, dimm_attr_ddr3_st::tWR, and dimm_attr_ddr3_st::tWTR.

Referenced by ddr3_save_dimminfo(), and dram_find_spds_ddr3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_ns()

static void print_ns ( const char *  msg,
u32  val 
)
static

Definition at line 583 of file ddr3.c.

References BIOS_INFO, printk, and val.

Referenced by dram_print_spd_ddr3().

Here is the caller graph for this function:

◆ spd_add_smbios17()

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.

Parameters
channelCorresponding channel of provided @info
slotCorresponding slot of provided @info
selected_freqThe actual frequency the DRAM is running on
infoDIMM parameters read from SPD
Returns
CB_SUCCESS if DIMM info was written

Definition at line 397 of file ddr3.c.

References dimm_attr_ddr3_st::cas_supported, DDR3_XMP_PROFILE_1, dimm_attr_ddr3_st::dimms_per_channel, dimm_attr_ddr3_st::dram_type, printram, spd_decode_ddr3(), SPD_MEMORY_TYPE_UNDEFINED, SPD_STATUS_INVALID, SPD_STATUS_OK, dimm_attr_ddr3_st::tAA, dimm_attr_ddr3_st::tCK, dimm_attr_ddr3_st::tCMD, dimm_attr_ddr3_st::tCWL, dimm_attr_ddr3_st::tFAW, dimm_attr_ddr3_st::tRAS, dimm_attr_ddr3_st::tRC, dimm_attr_ddr3_st::tRCD, dimm_attr_ddr3_st::tRFC, dimm_attr_ddr3_st::tRP, dimm_attr_ddr3_st::tRRD, dimm_attr_ddr3_st::tRTP, dimm_attr_ddr3_st::tWR, dimm_attr_ddr3_st::tWTR, and dimm_attr_ddr3_st::voltage.

Referenced by populate_smbios_tables(), and setup_sdram_meminfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spd_ddr3_calc_crc()

u16 spd_ddr3_calc_crc ( u8 spd,
int  len 
)

Calculate the CRC of a DDR3 SPD.

Parameters
spdpointer to raw SPD data
lenlength of data in SPD
Returns
the CRC of the SPD data, or 0 when spd data is truncated.

Definition at line 48 of file ddr3.c.

References ddr_crc16().

Referenced by spd_decode_ddr3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spd_ddr3_calc_unique_crc()

u16 spd_ddr3_calc_unique_crc ( u8 spd,
int  len 
)

Calculate the CRC of a DDR3 SPD unique identifier.

Parameters
spdpointer to raw SPD data
lenlength of data in SPD
Returns
the CRC of SPD data bytes 117..127, or 0 when spd data is truncated.

Definition at line 74 of file ddr3.c.

References ddr_crc16().

Referenced by ddr3_get_crc(), ddr3_save_dimminfo(), dram_find_spds_ddr3(), and verify_crc16_spds_ddr3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spd_decode_ddr3()

int spd_decode_ddr3 ( struct dimm_attr_ddr3_st dimm,
spd_raw_data  spd 
)

Decode the raw SPD data.

Decodes a raw SPD data from a DDR3 DIMM, and organizes it into a dimm_attr structure. The SPD data must first be read in a contiguous array, and passed to this function.

Parameters
dimmpointer to dimm_attr structure where the decoded data is to be stored
spdarray of raw data previously read from the SPD.
Returns
spd_status enumerator SPD_STATUS_OK – decoding was successful SPD_STATUS_INVALID – invalid SPD or not a DDR3 SPD SPD_STATUS_CRC_ERROR – CRC did not verify SPD_STATUS_INVALID_FIELD – A field with an invalid value was detected.

Definition at line 101 of file ddr3.c.

References dimm_flags_ddr3_st::asr, dimm_attr_ddr3_st::cas_supported, dimm_attr_ddr3_st::col_bits, dimm_attr_ddr3_st::dimm_type, dimm_attr_ddr3_st::dimms_per_channel, dimm_flags_ddr3_st::dll_off_mode, dimm_attr_ddr3_st::dram_type, dimm_flags_ddr3_st::ext_temp_range, dimm_flags_ddr3_st::ext_temp_refresh, dimm_attr_ddr3_st::flags, dimm_flags_ddr3_st::is_ecc, dimm_attr_ddr3_st::manufacturer_id, memcpy(), dimm_flags_ddr3_st::odts, dimm_flags_ddr3_st::operable_1_25V, dimm_flags_ddr3_st::operable_1_35V, dimm_flags_ddr3_st::operable_1_50V, dimm_attr_ddr3_st::part_number, dimm_flags_ddr3_st::pasr, dimm_flags_ddr3_st::pins_mirrored, printram, dimm_attr_ddr3_st::ranks, dimm_flags_ddr3_st::raw, dimm_attr_ddr3_st::reference_card, dimm_attr_ddr3_st::row_bits, dimm_flags_ddr3_st::rzq6_supported, dimm_flags_ddr3_st::rzq7_supported, dimm_attr_ddr3_st::serial, dimm_attr_ddr3_st::size_mb, spd_ddr3_calc_crc(), SPD_DIMM_SERIAL_LEN, SPD_DIMM_SERIAL_NUM, SPD_MEMORY_TYPE_SDRAM_DDR3, SPD_MEMORY_TYPE_UNDEFINED, SPD_STATUS_CRC_ERROR, SPD_STATUS_INVALID, SPD_STATUS_INVALID_FIELD, SPD_STATUS_OK, dimm_attr_ddr3_st::tAA, dimm_attr_ddr3_st::tCK, dimm_attr_ddr3_st::tCMD, dimm_attr_ddr3_st::tCWL, dimm_attr_ddr3_st::tFAW, dimm_flags_ddr3_st::therm_sensor, dimm_attr_ddr3_st::tRAS, dimm_attr_ddr3_st::tRC, dimm_attr_ddr3_st::tRCD, dimm_attr_ddr3_st::tRFC, dimm_attr_ddr3_st::tRP, dimm_attr_ddr3_st::tRRD, dimm_attr_ddr3_st::tRTP, dimm_attr_ddr3_st::tWR, dimm_attr_ddr3_st::tWTR, val, dimm_attr_ddr3_st::voltage, and dimm_attr_ddr3_st::width.

Referenced by ddr3_save_dimminfo(), dram_find_spds_ddr3(), populate_smbios_tables(), and spd_add_smbios17().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spd_dimm_is_registered_ddr3()

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.

Tells if the DIMM type is registered or not.

Parameters
typeDIMM type. This is byte[3] of the SPD.

Definition at line 30 of file ddr3.c.

References SPD_DDR3_DIMM_TYPE_72B_SO_RDIMM, SPD_DDR3_DIMM_TYPE_MINI_RDIMM, SPD_DDR3_DIMM_TYPE_RDIMM, and type.

◆ spd_xmp_decode_ddr3()

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.

Decodes a raw SPD XMP data from a DDR3 DIMM, and organizes it into a dimm_attr structure. The SPD data must first be read in a contiguous array, and passed to this function.

Parameters
dimmpointer to dimm_attr structure where the decoded data is to be stored
spdarray of raw data previously read from the SPD.
profileselect one of the profiles to load
Returns
spd_status enumerator SPD_STATUS_OK – decoding was successful SPD_STATUS_INVALID – invalid SPD or not a DDR3 SPD SPD_STATUS_CRC_ERROR – CRC did not verify SPD_STATUS_INVALID_FIELD – A field with an invalid value was detected.

Definition at line 397 of file ddr3.c.

Referenced by dram_find_spds_ddr3().

Here is the caller graph for this function: