20 #define MRC_CACHE_VERSION 0
25 i2c_eeprom_read(
device, 64, 9, &raw_spd[64]);
26 i2c_eeprom_read(
device, 93, 6, &raw_spd[93]);
33 i2c_eeprom_read(
device, 117, 11, &raw_spd[117]);
77 #define CTRL_MIN_TCLK_DDR2 TCK_400MHZ
88 while (cas_mask & (1 << try_cas) && try_cas > 0) {
89 s->selected_timings.CAS = try_cas;
90 s->selected_timings.tclk = saved_timings->
min_tCLK_cas[try_cas];
98 if ((
s->selected_timings.CAS < 3) || (
s->selected_timings.tclk == 0))
99 die(
"Could not find common memory frequency and CAS\n");
101 switch (
s->selected_timings.tclk) {
105 die(
"Selected dram frequency not supported\n");
121 if (!(capid & (1<<(79-64))))
125 if (!(capid & (1<<(57-32))))
128 if (!(capid & (1<<(56-32))))
131 if (!(capid & (1<<(48-32))))
146 if (
CONFIG(DEBUG_RAM_SETUP))
149 if (!(decoded_dimm.
width & (0x08 | 0x10))) {
151 printk(
BIOS_ERR,
"DIMM%d Unsupported width: x%d. Disabling dimm\n",
152 dimm_idx,
s->dimms[dimm_idx].width);
155 s->dimms[dimm_idx].width = (decoded_dimm.
width >> 3) - 1;
164 s->dimms[dimm_idx].page_size = decoded_dimm.
width * (1 << decoded_dimm.
col_bits) / 8;
166 switch (decoded_dimm.
banks) {
174 printk(
BIOS_ERR,
"DIMM%d Unsupported #banks: x%d. Disabling dimm\n",
175 dimm_idx, decoded_dimm.
banks);
179 s->dimms[dimm_idx].ranks = decoded_dimm.
ranks;
180 s->dimms[dimm_idx].rows = decoded_dimm.
row_bits;
181 s->dimms[dimm_idx].cols = decoded_dimm.
col_bits;
193 for (i = 0; i < 8; i++) {
234 switch (
s->max_fsb) {
247 switch (capid >> 3) {
266 "DRAM frequency is under lowest supported frequency (400 MHz).\n"
267 "Increasing to 400 MHz as last resort.\n");
274 die(
"Couldn't find compatible clock / CAS settings.\n");
285 if ((try_CAS <=
DDR3_MAX_CAS) && (try_CAS * min_tCLK < 20 * 256)) {
299 s->selected_timings.tclk = min_tCLK;
300 s->selected_timings.CAS = try_CAS;
302 switch (
s->selected_timings.tclk) {
321 if (
s->spd_type ==
DDR2)
342 if (
CONFIG(DEBUG_RAM_SETUP))
346 if (!(decoded_dimm.
width & (0x8 | 0x10))) {
347 printk(
BIOS_ERR,
"DIMM%d Unsupported width: x%d. Disabling dimm\n",
348 dimm_idx,
s->dimms[dimm_idx].width);
351 s->dimms[dimm_idx].width = (decoded_dimm.
width >> 3) - 1;
359 s->dimms[dimm_idx].page_size = decoded_dimm.
width * (1 << decoded_dimm.
col_bits) / 8;
363 s->dimms[dimm_idx].ranks = decoded_dimm.
ranks;
364 s->dimms[dimm_idx].rows = decoded_dimm.
row_bits;
365 s->dimms[dimm_idx].cols = decoded_dimm.
col_bits;
430 s->selected_timings.fsb_clk =
s->max_fsb;
436 u8 dram_type_mask = (1 <<
DDR2) | (1 <<
DDR3);
441 memset(&saved_timings, 0,
sizeof(saved_timings));
453 dram_type_mask &= 1 <<
DDR2;
457 dram_type_mask &= 1 <<
DDR3;
465 die(
"Mixing up dimm types is not supported!\n");
468 if (i2c_eeprom_read(
device, 0, 128, raw_spd) != 128) {
470 "i2c block operation failed, trying smbus byte operation.\n");
471 for (j = 0; j < 128; j++)
475 if (
s->spd_type ==
DDR2){
478 "Encountered problems with SPD, skipping this DIMM.\n");
485 "Encountered problems with SPD, skipping this DIMM.\n");
491 dimm_mask |= (1 << i);
494 die(
"No memory installed.\n");
496 if (
s->spd_type ==
DDR2)
511 if (
s->dimms[i].ranks == 1) {
512 if (
s->dimms[i].width == 0)
517 if (
s->dimms[i].width == 0)
520 die(
"Dual-rank x16 not supported\n");
534 if (boot_path >= 1) {
566 int fast_boot, cbmem_was_inited;
580 if (!ctrl_cached || mrc_size <
sizeof(
s)) {
597 "SPD checksums don't match, dimm's have been replaced\n");
600 fast_boot =
s.max_fsb == ctrl_cached->
max_fsb;
603 "CPU FSB does not match and has been replaced\n");
651 if (
s3resume && !cbmem_was_inited) {
#define DIMMS_PER_CHANNEL
static struct cpuid_result cpuid_ext(int op, unsigned int ecx)
void * memcpy(void *dest, const void *src, size_t n)
void * memset(void *dstpp, int c, size_t len)
#define DIV_ROUND_UP(x, y)
cb_err
coreboot error codes
@ CB_ERR
Generic error code.
@ CB_SUCCESS
Call completed successfully.
int cbmem_recovery(int s3resume)
enum fch_io_device device
#define printk(level,...)
void __noreturn die(const char *fmt,...)
u8 spd_get_msbs(u8 c)
Return index of MSB set.
void dram_print_spd_ddr2(const struct dimm_attr_ddr2_st *dimm)
Print the info in DIMM.
u16 spd_ddr2_calc_unique_crc(const u8 *spd, int len)
Calculate the CRC of a DDR2 SPD unique identifier.
int spd_decode_ddr2(struct dimm_attr_ddr2_st *dimm, u8 spd[SPD_SIZE_MAX_DDR2])
Decode the raw SPD data.
u32 spd_decode_spd_size_ddr2(u8 byte0)
Return size of SPD.
Utilities for decoding DDR2 SPDs.
void dram_print_spd_ddr3(const struct dimm_attr_ddr3_st *dimm)
Print the info in DIMM.
int spd_decode_ddr3(struct dimm_attr_ddr3_st *dimm, spd_raw_data spd)
Decode the raw SPD data.
u16 spd_ddr3_calc_unique_crc(u8 *spd, int len)
Calculate the CRC of a DDR3 SPD unique identifier.
static __always_inline uint32_t mchbar_read32(const uintptr_t offset)
#define CLKCFG_FSBCLK_MASK
#define CLKCFG_FSBCLK_SHIFT
Utilities for decoding DDR3 SPDs.
static __always_inline void pci_and_config8(const struct device *dev, u16 reg, u8 andmask)
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
static __always_inline void pci_or_config8(const struct device *dev, u16 reg, u8 ormask)
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
static int smbus_read_byte(struct device *const dev, u8 addr)
#define SPD_CAS_LATENCY_DDR2_5
#define SPD_CAS_LATENCY_DDR2_6
void timestamp_add_now(enum timestamp_id id)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define BIOS_SPEW
BIOS_SPEW - Excessively verbose output.
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
int mrc_cache_stash_data(int type, uint32_t version, const void *data, size_t size)
Returns < 0 on error, 0 on success.
void * mrc_cache_current_mmap_leak(int type, uint32_t version, size_t *data_size)
mrc_cache_mmap_leak
void sdram_initialize(void)
#define FOR_EACH_POPULATED_CHANNEL(dimms, idx)
#define FOR_EACH_DIMM(idx)
#define CHANNEL_IS_POPULATED(dimms, idx)
static void workaround_stacked_mode(struct sysinfo *s)
static u16 ddr3_get_crc(u8 device, u8 len)
static void mchinfo_ddr2(struct sysinfo *s)
static int ddr3_save_dimminfo(u8 dimm_idx, u8 *raw_spd, struct abs_timings *saved_timings, struct sysinfo *s)
static void select_cas_dramfreq_ddr2(struct sysinfo *s, const struct abs_timings *saved_timings)
static void normalize_tCLK(u32 *tCLK)
static enum cb_err verify_spds(const u8 *spd_map, const struct sysinfo *ctrl_cached)
static void select_discrete_timings(struct sysinfo *s, const struct abs_timings *timings)
static void select_cas_dramfreq_ddr3(struct sysinfo *s, struct abs_timings *saved_timings)
static void find_dimm_config(struct sysinfo *s)
#define MRC_CACHE_VERSION
static void print_selected_timings(struct sysinfo *s)
#define CTRL_MIN_TCLK_DDR2
static u16 ddr2_get_crc(u8 device, u8 len)
static void decode_spd_select_timings(struct sysinfo *s)
static int ddr2_save_dimminfo(u8 dimm_idx, u8 *raw_spd, struct abs_timings *saved_timings, struct sysinfo *s)
static void find_fsb_speed(struct sysinfo *s)
static void checkreset_ddr2(int boot_path)
#define PCI_DEV(SEGBUS, DEV, FN)
union dimm_flags_ddr3_st flags
#define s(param, src_bits, pmcreg, dst_bits)
unsigned int pins_mirrored
u32 fsb_to_mhz(u32 speed)
#define RAW_CARD_POPULATED
u32 ddr_to_mhz(u32 speed)
#define RAW_CARD_UNPOPULATED
#define FOR_EACH_POPULATED_DIMM_IN_CHANNEL(dimms, ch, idx)
void do_raminit(struct sysinfo *, int fast_boot)
#define BOOT_PATH_WARM_RESET