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

Utilities for decoding DDR2 SPDs. More...

#include <stdint.h>
#include <spd.h>
#include <device/dram/common.h>
Include dependency graph for ddr2.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_ddr2_st
 DIMM flags. More...
 
struct  dimm_attr_ddr2_st
 DIMM characteristics. More...
 

Macros

#define SPD_SIZE_MAX_DDR2   128
 Maximum SPD size supported. More...
 

Enumerations

enum  spd_dimm_type_ddr2 {
  SPD_DDR2_DIMM_TYPE_UNDEFINED = 0x00 , SPD_DDR2_DIMM_TYPE_RDIMM = 0x01 , SPD_DDR2_DIMM_TYPE_UDIMM = 0x02 , SPD_DDR2_DIMM_TYPE_SO_DIMM = 0x04 ,
  SPD_DDR2_DIMM_TYPE_72B_SO_CDIMM = 0x06 , SPD_DDR2_DIMM_TYPE_72B_SO_RDIMM = 0x07 , SPD_DDR2_DIMM_TYPE_MICRO_DIMM = 0x08 , SPD_DDR2_DIMM_TYPE_MINI_RDIMM = 0x10 ,
  SPD_DDR2_DIMM_TYPE_MINI_UDIMM = 0x20 , SPD_DDR2_DIMM_TYPE_MASK = 0x3f
}
 

Functions

int spd_dimm_is_registered_ddr2 (enum spd_dimm_type_ddr2 type)
 Checks if the DIMM is Registered based on byte[20] of the SPD. More...
 
u8 spd_ddr2_calc_checksum (u8 *spd, int len)
 Calculate the checksum of a DDR2 SPD unique identifier. More...
 
u32 spd_decode_spd_size_ddr2 (u8 byte0)
 Return size of SPD. More...
 
u32 spd_decode_eeprom_size_ddr2 (u8 byte1)
 Return size of eeprom. More...
 
int spd_decode_ddr2 (struct dimm_attr_ddr2_st *dimm, u8 spd[SPD_SIZE_MAX_DDR2])
 Decode the raw SPD data. More...
 
void dram_print_spd_ddr2 (const struct dimm_attr_ddr2_st *dimm)
 Print the info in DIMM. More...
 
void normalize_tck (u32 *tclk)
 
u8 spd_get_msbs (u8 c)
 Return index of MSB set. More...
 
u16 spd_ddr2_calc_unique_crc (const u8 *spd, int len)
 Calculate the CRC of a DDR2 SPD unique identifier. More...
 

Detailed Description

Utilities for decoding DDR2 SPDs.

Definition in file ddr2.h.

Macro Definition Documentation

◆ SPD_SIZE_MAX_DDR2

#define SPD_SIZE_MAX_DDR2   128

Maximum SPD size supported.

Definition at line 158 of file ddr2.h.

Enumeration Type Documentation

◆ spd_dimm_type_ddr2

Enumerator
SPD_DDR2_DIMM_TYPE_UNDEFINED 
SPD_DDR2_DIMM_TYPE_RDIMM 
SPD_DDR2_DIMM_TYPE_UDIMM 
SPD_DDR2_DIMM_TYPE_SO_DIMM 
SPD_DDR2_DIMM_TYPE_72B_SO_CDIMM 
SPD_DDR2_DIMM_TYPE_72B_SO_RDIMM 
SPD_DDR2_DIMM_TYPE_MICRO_DIMM 
SPD_DDR2_DIMM_TYPE_MINI_RDIMM 
SPD_DDR2_DIMM_TYPE_MINI_UDIMM 
SPD_DDR2_DIMM_TYPE_MASK 

Definition at line 25 of file ddr2.h.

Function Documentation

◆ dram_print_spd_ddr2()

◆ normalize_tck()

void normalize_tck ( u32 tclk)

Definition at line 712 of file ddr2.c.

References BIOS_ERR, printk, TCK_200MHZ, TCK_266MHZ, TCK_333MHZ, TCK_400MHZ, TCK_533MHZ, TCK_666MHZ, and TCK_800MHZ.

Referenced by choose_tclk().

Here is the caller graph for this function:

◆ spd_ddr2_calc_checksum()

u8 spd_ddr2_calc_checksum ( u8 spd,
int  len 
)

Calculate the checksum of a DDR2 SPD unique identifier.

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

Definition at line 45 of file ddr2.c.

References c.

Referenced by spd_decode_ddr2().

Here is the caller graph for this function:

◆ spd_ddr2_calc_unique_crc()

u16 spd_ddr2_calc_unique_crc ( const u8 spd,
int  len 
)

Calculate the CRC of a DDR2 SPD unique identifier.

Parameters
spdpointer to raw SPD data
lenlength of data in SPD
Returns
the CRC of SPD data bytes 64..72 and 93..98, or 0 when spd data is truncated.

Definition at line 69 of file ddr2.c.

References ddr_crc16().

Referenced by ddr2_get_crc(), and ddr2_save_dimminfo().

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

◆ spd_decode_ddr2()

int spd_decode_ddr2 ( struct dimm_attr_ddr2_st dimm,
u8  spd[SPD_SIZE_MAX_DDR2] 
)

Decode the raw SPD data.

Decodes a raw SPD data from a DDR2 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 DDR2 SPD SPD_STATUS_CRC_ERROR – CRC did not verify SPD_STATUS_INVALID_FIELD – A field with an invalid value was detected.

Definition at line 310 of file ddr2.c.

References dimm_attr_ddr2_st::access_time, dimm_attr_ddr2_st::banks, BIOS_ERR, BIOS_WARNING, dimm_flags_ddr2_st::bl4, dimm_flags_ddr2_st::bl8, dimm_attr_ddr2_st::cas_supported, CB_SUCCESS, dimm_attr_ddr2_st::checksum, dimm_attr_ddr2_st::col_bits, dimm_attr_ddr2_st::cycle_time, dimm_attr_ddr2_st::dimm_type, dimm_attr_ddr2_st::dram_type, dimm_attr_ddr2_st::flags, dimm_flags_ddr2_st::is_ecc, dimm_attr_ddr2_st::manufacturer_id, memcpy(), memset(), dimm_attr_ddr2_st::mod_width, dimm_flags_ddr2_st::operable_1_50V, dimm_flags_ddr2_st::operable_1_80V, dimm_flags_ddr2_st::operable_2_50V, dimm_flags_ddr2_st::operable_3_33V, dimm_flags_ddr2_st::operable_5_00V, dimm_attr_ddr2_st::part_number, dimm_flags_ddr2_st::pasr, dimm_attr_ddr2_st::plls, printk, printram, dimm_attr_ddr2_st::ranks, dimm_attr_ddr2_st::ranksize_mb, dimm_attr_ddr2_st::rev, dimm_attr_ddr2_st::row_bits, dimm_flags_ddr2_st::self_refresh, dimm_attr_ddr2_st::serial, dimm_attr_ddr2_st::size_mb, spd_ddr2_calc_checksum(), SPD_DDR2_DIMM_TYPE_MASK, spd_decode_bcd_time(), spd_decode_eeprom_size_ddr2(), spd_decode_quarter_time(), spd_decode_spd_size_ddr2(), spd_decode_tck_time(), spd_decode_tRCtRFC_time(), spd_decode_tRR_time(), spd_get_msbs(), SPD_MEMORY_TYPE_SDRAM_DDR2, SPD_MEMORY_TYPE_UNDEFINED, SPD_STATUS_CRC_ERROR, SPD_STATUS_INVALID, SPD_STATUS_INVALID_FIELD, SPD_STATUS_OK, dimm_flags_ddr2_st::stacked, dimm_attr_ddr2_st::tCK, dimm_attr_ddr2_st::tDH, dimm_attr_ddr2_st::tDQSQ, dimm_attr_ddr2_st::tDS, dimm_flags_ddr2_st::terminate_50ohms, dimm_attr_ddr2_st::tPLL, dimm_attr_ddr2_st::tQHS, dimm_attr_ddr2_st::tRAS, dimm_attr_ddr2_st::tRC, dimm_attr_ddr2_st::tRCD, dimm_attr_ddr2_st::tRFC, dimm_attr_ddr2_st::tRP, dimm_attr_ddr2_st::tRR, dimm_attr_ddr2_st::tRRD, dimm_attr_ddr2_st::tRTP, dimm_attr_ddr2_st::tWR, dimm_attr_ddr2_st::tWTR, dimm_flags_ddr2_st::weak_driver, dimm_attr_ddr2_st::weeks, dimm_attr_ddr2_st::width, and dimm_attr_ddr2_st::year.

Referenced by ddr2_save_dimminfo(), and gather_common_timing().

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

◆ spd_decode_eeprom_size_ddr2()

u32 spd_decode_eeprom_size_ddr2 ( u8  byte1)

Return size of eeprom.

Returns size of eeprom. Usually 256 Byte.

Definition at line 99 of file ddr2.c.

Referenced by spd_decode_ddr2().

Here is the caller graph for this function:

◆ spd_decode_spd_size_ddr2()

u32 spd_decode_spd_size_ddr2 ( u8  byte0)

Return size of SPD.

Returns size of SPD. Usually 128 Byte.

Definition at line 89 of file ddr2.c.

References MIN, and SPD_SIZE_MAX_DDR2.

Referenced by ddr2_save_dimminfo(), and spd_decode_ddr2().

Here is the caller graph for this function:

◆ spd_dimm_is_registered_ddr2()

int spd_dimm_is_registered_ddr2 ( enum spd_dimm_type_ddr2  type)

Checks if the DIMM is Registered based on byte[20] of the SPD.

Tells if the DIMM type is registered or not.

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

Definition at line 27 of file ddr2.c.

References SPD_DDR2_DIMM_TYPE_72B_SO_RDIMM, SPD_DDR2_DIMM_TYPE_MINI_RDIMM, SPD_DDR2_DIMM_TYPE_RDIMM, and type.

Referenced by gather_common_timing().

Here is the caller graph for this function:

◆ spd_get_msbs()

u8 spd_get_msbs ( u8  c)

Return index of MSB set.

Returns the index of MSB set.

Definition at line 115 of file ddr2.c.

References c, and log2().

Referenced by choose_tclk(), select_cas_dramfreq_ddr2(), and spd_decode_ddr2().

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