coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ddr4.c File Reference
#include <console/console.h>
#include <cbmem.h>
#include <device/device.h>
#include <device/dram/ddr4.h>
#include <string.h>
#include <memory_info.h>
#include <smbios.h>
#include <types.h>
Include dependency graph for ddr4.c:

Go to the source code of this file.

Data Structures

struct  ddr4_speed_attr
 
struct  spd_block
 

Enumerations

enum  ddr4_speed_grade {
  DDR4_1600 , DDR4_1866 , DDR4_2133 , DDR4_2400 ,
  DDR4_2666 , DDR4_2933 , DDR4_3200
}
 
enum  spd_block_type {
  BLOCK_0 , BLOCK_1 , BLOCK_1_L , BLOCK_1_H ,
  BLOCK_2 , BLOCK_2_L , BLOCK_2_H , BLOCK_3
}
 

Functions

static bool verify_block (const spd_block *block, spd_raw_data spd)
 
static bool block_exists (spd_block_type type, u8 dimm_type)
 
uint16_t ddr4_speed_mhz_to_reported_mts (uint16_t speed_mhz)
 Converts DDR4 clock speed in MHz to the standard reported speed in MT/s. More...
 
int spd_decode_ddr4 (struct dimm_attr_ddr4_st *dimm, spd_raw_data spd)
 Decode the raw SPD data. More...
 
enum cb_err spd_add_smbios17_ddr4 (const u8 channel, const u8 slot, const u16 selected_freq, const struct dimm_attr_ddr4_st *info)
 

Variables

static const struct ddr4_speed_attr ddr4_speeds []
 DDR4 speed attributes derived from JEDEC 79-4C tables 169 & 170. More...
 
const spd_block spd_blocks []
 

Enumeration Type Documentation

◆ ddr4_speed_grade

Enumerator
DDR4_1600 
DDR4_1866 
DDR4_2133 
DDR4_2400 
DDR4_2666 
DDR4_2933 
DDR4_3200 

Definition at line 12 of file ddr4.c.

◆ spd_block_type

Enumerator
BLOCK_0 
BLOCK_1 
BLOCK_1_L 
BLOCK_1_H 
BLOCK_2 
BLOCK_2_L 
BLOCK_2_H 
BLOCK_3 

Definition at line 75 of file ddr4.c.

Function Documentation

◆ block_exists()

static bool block_exists ( spd_block_type  type,
u8  dimm_type 
)
static

Definition at line 112 of file ddr4.c.

References BLOCK_0, BLOCK_1, BLOCK_1_H, BLOCK_1_L, BLOCK_2_H, BLOCK_2_L, BLOCK_3, and type.

Referenced by spd_add_smbios17_ddr4().

Here is the caller graph for this function:

◆ ddr4_speed_mhz_to_reported_mts()

uint16_t ddr4_speed_mhz_to_reported_mts ( uint16_t  speed_mhz)

Converts DDR4 clock speed in MHz to the standard reported speed in MT/s.

Definition at line 137 of file ddr4.c.

References ARRAY_SIZE, BIOS_ERR, ddr4_speeds, ddr4_speed_attr::max_clock_mhz, ddr4_speed_attr::min_clock_mhz, printk, and ddr4_speed_attr::reported_mts.

Referenced by ddr_speed_mhz_to_reported_mts().

Here is the caller graph for this function:

◆ spd_add_smbios17_ddr4()

◆ spd_decode_ddr4()

int spd_decode_ddr4 ( struct dimm_attr_ddr4_st dimm,
spd_raw_data  spd 
)

Decode the raw SPD data.

Decodes a raw SPD data from a DDR4 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 DDR4 SPD SPD_STATUS_CRC_ERROR – checksum mismatch

Definition at line 166 of file ddr4.c.

◆ verify_block()

static bool verify_block ( const spd_block block,
spd_raw_data  spd 
)
static

Definition at line 100 of file ddr4.c.

References spd_block::crc_start, ddr_crc16(), spd_block::len, and spd_block::start.

Referenced by spd_add_smbios17_ddr4().

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

Variable Documentation

◆ ddr4_speeds

const struct ddr4_speed_attr ddr4_speeds[]
static

DDR4 speed attributes derived from JEDEC 79-4C tables 169 & 170.

min_clock_mhz = 1000/max_tCk_avg(ns) + 1 Adding 1 to make minimum inclusive max_clock_mhz = 1000/min_tCk_avg(ns) reported_mts = Standard reported DDR4 speed in MT/s May be 1 less than the actual max MT/s

Definition at line 1 of file ddr4.c.

Referenced by ddr4_speed_mhz_to_reported_mts().

◆ spd_blocks

const spd_block spd_blocks[]
Initial value:
= {
{.type = BLOCK_0, 0, 128, 126}, {.type = BLOCK_1, 128, 128, 126},
{.type = BLOCK_1_L, 128, 64, 0}, {.type = BLOCK_1_H, 192, 64, 0},
{.type = BLOCK_2_L, 256, 64, 62}, {.type = BLOCK_2_H, 320, 64, 0},
{.type = BLOCK_3, 384, 128, 0} }
@ BLOCK_2_L
Definition: ddr4.c:81
@ BLOCK_1
Definition: ddr4.c:77
@ BLOCK_1_L
Definition: ddr4.c:78
@ BLOCK_1_H
Definition: ddr4.c:79
@ BLOCK_0
Definition: ddr4.c:76
@ BLOCK_3
Definition: ddr4.c:83
@ BLOCK_2_H
Definition: ddr4.c:82

Definition at line 94 of file ddr4.c.

Referenced by spd_add_smbios17_ddr4().