14 for (i = 0; i < CONFIG_DIMM_MAX; i++)
42 printk(
BIOS_ERR,
"Defaulting to using DDR4 params. Please add dram_type check for %d to %s\n",
72 static const int ddr3_banks[4] = { 8, 16, 32, 64 };
73 static const int ddr4_banks[10] = { 4, 8, -1, -1, 8, 16, -1, -1, 16, 32 };
79 return ddr4_banks[index];
83 return ddr3_banks[index];
89 static const int spd_capmb[13] = { 1, 2, 4, 8, 16, 32, 64,
90 128, 48, 96, 12, 24, 72 };
94 return spd_capmb[index] * 256;
99 static const int spd_rows[7] = { 12, 13, 14, 15, 16, 17, 18 };
103 return spd_rows[index];
108 static const int spd_cols[4] = { 9, 10, 11, 12 };
112 return spd_cols[index];
117 static const int spd_ranks[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
120 int index = (spd[organ_offset] >> 3) & 7;
123 return spd_ranks[index];
128 static const int spd_devw[4] = { 4, 8, 16, 32 };
131 int index = spd[organ_offset] & 7;
134 return spd_devw[index];
139 static const int spd_busw[4] = { 8, 16, 32, 64 };
142 int index = spd[busw_offset] & 7;
145 return spd_busw[index];
151 if (*spd_name !=
NULL) {
185 const char *nameptr =
NULL;
202 printk(
BIOS_INFO,
"SPD: module part number is %.*s\n", (
int) len, nameptr);
205 "SPD: banks %d, ranks %d, rows %d, columns %d, density %d Mb\n",
206 banks, ranks, rows, cols, capmb);
210 if (capmb > 0 && busw > 0 && devw > 0 && ranks > 0) {
213 capmb / 8 * busw / devw * ranks);
223 if (!map || size < (
spd_index + 1) * CONFIG_DIMM_SPD_SIZE)
229 #if CONFIG_DIMM_SPD_SIZE == 128
232 const int SPD_CRC_HI = 127;
233 const int SPD_CRC_LO = 126;
236 size_t spd_file_len = 0;
237 size_t min_len = (idx + 1) * CONFIG_DIMM_SPD_SIZE;
239 spd_file =
cbfs_map(
"spd.bin", &spd_file_len);
242 if (spd_file_len < min_len)
244 if (!spd_file || spd_file_len < min_len)
247 memcpy(
buf, spd_file + (idx * CONFIG_DIMM_SPD_SIZE),
248 CONFIG_DIMM_SPD_SIZE);
253 if (((
buf[SPD_CRC_LO] == 0) && (
buf[SPD_CRC_HI] == 0))
254 || (
buf[SPD_CRC_LO] != (crc & 0xff))
255 || (
buf[SPD_CRC_HI] != (crc >> 8))) {
257 "SPD CRC %02x%02x is invalid, should be %04x\n",
258 buf[SPD_CRC_HI],
buf[SPD_CRC_LO], crc);
259 buf[SPD_CRC_LO] = crc & 0xff;
260 buf[SPD_CRC_HI] = crc >> 8;
263 for (i = 0; i < CONFIG_DIMM_SPD_SIZE; i++) {
264 if ((i % 16) == 0x00)
void * memcpy(void *dest, const void *src, size_t n)
void cbfs_unmap(void *mapping)
static void * cbfs_type_map(const char *name, size_t *size_out, enum cbfs_type *type)
static void * cbfs_map(const char *name, size_t *size_out)
#define printk(level,...)
u16 spd_ddr3_calc_crc(u8 *spd, int len)
Calculate the CRC of a DDR3 SPD.
Utilities for decoding DDR3 SPDs.
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_EMERG
BIOS_EMERG - Emergency / Fatal.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
static const int spd_index[32]
const struct smm_save_state_ops *legacy_ops __weak
static int spd_get_devw(const uint8_t spd[], int dram_type)
static int spd_get_cols(const uint8_t spd[])
static int spd_get_busw(const uint8_t spd[], int dram_type)
static int spd_get_rows(const uint8_t spd[])
static int spd_get_ranks(const uint8_t spd[], int dram_type)
static int spd_get_banks(const uint8_t spd[], int dram_type)
uintptr_t spd_cbfs_map(u8 spd_index)
static int spd_get_capmb(const uint8_t spd[])
void print_spd_info(uint8_t spd[])
static const char * spd_get_module_type_string(int dram_type)
static void spd_get_name(const uint8_t spd[], int type, const char **spd_name, size_t *len)
const char *__weak mainboard_get_dram_part_num(void)
static bool use_ddr4_params(int dram_type)
void dump_spd_info(struct spd_block *blk)
#define DDR3_SPD_PART_LEN
int read_ddr3_spd_from_cbfs(u8 *buf, int idx)
#define LPDDR3_SPD_PART_OFF
#define SPD_DENSITY_BANKS
#define DDR4_ORGANIZATION
#define LPDDR3_SPD_PART_LEN
#define DDR3_SPD_PART_OFF
#define DDR4_SPD_PART_OFF
#define DDR3_BUS_DEV_WIDTH
#define SPD_DRAM_LPDDR3_INTEL
#define DDR3_ORGANIZATION
#define DDR4_BUS_DEV_WIDTH
#define DDR4_SPD_PART_LEN
#define SPD_DRAM_LPDDR3_JEDEC
size_t strlen(const char *src)
u8 addr_map[CONFIG_DIMM_MAX]
u8 * spd_array[CONFIG_DIMM_MAX]