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

Utilities for decoding DDR3 SPDs. More...

#include <spd.h>
#include <device/dram/common.h>
#include <types.h>
Include dependency graph for ddr3.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  dimm_flags_ddr3_st
 DIMM flags. More...
 
struct  dimm_attr_ddr3_st
 DIMM characteristics. More...
 

Macros

#define SPD_DIMM_MOD_ID1   117
 Convenience definitions for SPD offsets. More...
 
#define SPD_DIMM_MOD_ID2   118
 
#define SPD_DIMM_SERIAL_NUM   122
 
#define SPD_DIMM_SERIAL_LEN   4
 
#define SPD_DIMM_PART_NUM   128
 
#define SPD_DIMM_PART_LEN   18
 

Typedefs

typedef u8 spd_raw_data[256]
 

Enumerations

enum  spd_dimm_type_ddr3 {
  SPD_DDR3_DIMM_TYPE_UNDEFINED = 0x00 , SPD_DDR3_DIMM_TYPE_RDIMM = 0x01 , SPD_DDR3_DIMM_TYPE_UDIMM = 0x02 , SPD_DDR3_DIMM_TYPE_SO_DIMM = 0x03 ,
  SPD_DDR3_DIMM_TYPE_MICRO_DIMM = 0x04 , SPD_DDR3_DIMM_TYPE_MINI_RDIMM = 0x05 , SPD_DDR3_DIMM_TYPE_MINI_UDIMM = 0x06 , SPD_DDR3_DIMM_TYPE_MINI_CDIMM = 0x07 ,
  SPD_DDR3_DIMM_TYPE_72B_SO_UDIMM = 0x08 , SPD_DDR3_DIMM_TYPE_72B_SO_RDIMM = 0x09 , SPD_DDR3_DIMM_TYPE_72B_SO_CDIMM = 0x0a , SPD_DDR3_DIMM_TYPE_LRDIMM = 0x0b ,
  SPD_DDR3_DIMM_TYPE_16B_SO_DIMM = 0x0c , SPD_DDR3_DIMM_TYPE_32B_SO_DIMM = 0x0d , SPD_DDR3_DIMM_TYPE_MASK = 0x0f
}
 
enum  ddr3_xmp_profile { DDR3_XMP_PROFILE_1 = 0 , DDR3_XMP_PROFILE_2 = 1 }
 

Functions

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_data)
 Decode the raw SPD data. More...
 
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...
 
void dram_print_spd_ddr3 (const struct dimm_attr_ddr3_st *dimm)
 Print the info in DIMM. 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...
 

Detailed Description

Utilities for decoding DDR3 SPDs.

Definition in file ddr3.h.

Macro Definition Documentation

◆ SPD_DIMM_MOD_ID1

#define SPD_DIMM_MOD_ID1   117

Convenience definitions for SPD offsets.

Definition at line 27 of file ddr3.h.

◆ SPD_DIMM_MOD_ID2

#define SPD_DIMM_MOD_ID2   118

Definition at line 28 of file ddr3.h.

◆ SPD_DIMM_PART_LEN

#define SPD_DIMM_PART_LEN   18

Definition at line 32 of file ddr3.h.

◆ SPD_DIMM_PART_NUM

#define SPD_DIMM_PART_NUM   128

Definition at line 31 of file ddr3.h.

◆ SPD_DIMM_SERIAL_LEN

#define SPD_DIMM_SERIAL_LEN   4

Definition at line 30 of file ddr3.h.

◆ SPD_DIMM_SERIAL_NUM

#define SPD_DIMM_SERIAL_NUM   122

Definition at line 29 of file ddr3.h.

Typedef Documentation

◆ spd_raw_data

typedef u8 spd_raw_data[256]

Definition at line 156 of file ddr3.h.

Enumeration Type Documentation

◆ ddr3_xmp_profile

Enumerator
DDR3_XMP_PROFILE_1 
DDR3_XMP_PROFILE_2 

Definition at line 151 of file ddr3.h.

◆ spd_dimm_type_ddr3

Enumerator
SPD_DDR3_DIMM_TYPE_UNDEFINED 
SPD_DDR3_DIMM_TYPE_RDIMM 
SPD_DDR3_DIMM_TYPE_UDIMM 
SPD_DDR3_DIMM_TYPE_SO_DIMM 
SPD_DDR3_DIMM_TYPE_MICRO_DIMM 
SPD_DDR3_DIMM_TYPE_MINI_RDIMM 
SPD_DDR3_DIMM_TYPE_MINI_UDIMM 
SPD_DDR3_DIMM_TYPE_MINI_CDIMM 
SPD_DDR3_DIMM_TYPE_72B_SO_UDIMM 
SPD_DDR3_DIMM_TYPE_72B_SO_RDIMM 
SPD_DDR3_DIMM_TYPE_72B_SO_CDIMM 
SPD_DDR3_DIMM_TYPE_LRDIMM 
SPD_DDR3_DIMM_TYPE_16B_SO_DIMM 
SPD_DDR3_DIMM_TYPE_32B_SO_DIMM 
SPD_DDR3_DIMM_TYPE_MASK 

Definition at line 39 of file ddr3.h.

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:

◆ 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: