30 if (!(cp.
ecx & (1 << 6)))
34 if (!(
read32((
void *)0xfed30010) & 1))
38 while (!(
read8((
void *)0xfed40000) & (1 << 7)))
53 memset(&ctrl->
info.dimm[channel][0], 0,
sizeof(ctrl->
info.dimm[0]));
99 const u16 ddr_freq = (1000 << 8) / ctrl->
tCK;
103 &ctrl->
info.dimm[channel][slot]);
125 int channel, slot, spd_slot;
129 for (slot = 0; slot <
NUM_SLOTS; slot++) {
130 spd_slot = 2 * channel + slot;
131 match &= ctrl->
spd_crc[channel][slot] ==
142 for (j = 117; j < 128; j++)
145 for (j = 0; j < 256; j++)
152 int dimms = 0, ch_dimms;
153 int channel, slot, spd_slot;
166 for (slot = 0; slot <
NUM_SLOTS; slot++) {
167 spd_slot = 2 * channel + slot;
173 for (slot = 0; slot <
NUM_SLOTS; slot++) {
174 spd_slot = 2 * channel + slot;
184 printram(
"No valid XMP profile found.\n");
189 "XMP profile supports %u DIMMs, but %u DIMMs are installed.\n",
192 if (
CONFIG(NATIVE_RAMINIT_IGNORE_XMP_MAX_DIMMS))
194 "XMP maximum DIMMs will be ignored.\n");
198 }
else if (dimm->
voltage != 1500) {
200 printram(
"XMP profile's requested %u mV is unsupported.\n",
203 if (
CONFIG(NATIVE_RAMINIT_IGNORE_XMP_REQUESTED_VOLTAGE))
205 "XMP requested voltage will be ignored.\n");
235 ctrl->
rankmap[channel] |= ((1 << dimm->
ranks) - 1) << (2 * slot);
241 const u8 rc_0 = ctrl->
info.dimm[channel][0].reference_card;
242 const u8 rc_1 = ctrl->
info.dimm[channel][1].reference_card;
244 if (ch_dimms ==
NUM_SLOTS && rc_0 < 6 && rc_1 < 6) {
245 const int ref_card_offset_table[6][6] = {
246 { 0, 0, 0, 0, 2, 2 },
247 { 0, 0, 0, 0, 2, 2 },
248 { 0, 0, 0, 0, 2, 2 },
249 { 0, 0, 0, 0, 1, 1 },
250 { 2, 2, 2, 1, 0, 0 },
251 { 2, 2, 2, 1, 0, 0 },
262 die(
"ECC mode forced but non-ECC DIMM installed!");
268 die(
"No DIMMs were found");
280 memset(ctrl, 0,
sizeof(*ctrl));
295 int me_uma_size, cbmem_was_inited, fast_boot, err;
330 if (mrc_size <
sizeof(ctrl))
334 if (ctrl_cached &&
cpuid != ctrl_cached->
cpu) {
338 "CPUID %x differs from stored CPUID %x, CPU was replaced!\n",
345 if (s3resume && !ctrl_cached) {
351 if (!s3resume && ctrl_cached) {
353 memset(spds, 0,
sizeof(spds));
361 fast_boot = s3resume;
366 memcpy(&ctrl, ctrl_cached,
sizeof(ctrl));
388 memset(spds, 0,
sizeof(spds));
398 printram(
"Disable failing channel.\n");
413 die(
"raminit failed");
431 printk(
BIOS_INFO,
"RAMINIT: ECC scrub test on first channel up to 0x%x\n",
441 for (i = 1; i < tseg >> 20; i++) {
442 for (
int j = 0; j < 1 *
MiB; j += 4096) {
448 " addr 0x%lx\n",
addr);
468 if (s3resume && !cbmem_was_inited) {
static uint32_t read32(const void *addr)
static uint8_t read8(const void *addr)
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)
int intel_early_me_init(void)
void intel_early_me_status(void)
int intel_early_me_uma_size(void)
int intel_early_me_init_done(u8 status)
void early_thermal_init(void)
cb_err
coreboot error codes
@ CB_SUCCESS
Call completed successfully.
int cbmem_recovery(int s3resume)
void * cbmem_find(u32 id)
#define printk(level,...)
void __noreturn die(const char *fmt,...)
uint32_t cpu_get_cpuid(void)
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.
void dram_print_spd_ddr3(const struct dimm_attr_ddr3_st *dimm)
Print the info in DIMM.
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.
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.
void early_init_dmi(void)
#define mchbar_setbits32(addr, set)
static __always_inline void mchbar_write32(const uintptr_t offset, const uint32_t value)
static __always_inline uint32_t mchbar_read32(const uintptr_t offset)
static __always_inline void wrmsr(unsigned int index, msr_t msr)
#define printram(x,...)
Convenience macro for enabling printk with CONFIG(DEBUG_RAM_SETUP)
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
static int smbus_read_byte(struct device *const dev, u8 addr)
@ MEMORY_ARRAY_ECC_SINGLE_BIT
@ SPD_MEMORY_TYPE_SDRAM_DDR3
void timestamp_add_now(enum timestamp_id id)
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_NOTICE
BIOS_NOTICE - Unexpected but relatively insignificant.
#define BIOS_ALERT
BIOS_ALERT - Dying / Unrecoverable.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
void mainboard_get_spd(spd_raw_data *spd, bool id_only)
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
#define MRC_CACHE_VERSION
void perform_raminit(const int s3resume)
static uint16_t nb_slots_per_channel(const uint32_t capid0_a)
static int verify_crc16_spds_ddr3(spd_raw_data *spd, ramctr_timing *ctrl)
void read_spd(spd_raw_data *spd, u8 addr, bool id_only)
static void init_dram_ddr3(int s3resume, const u32 cpuid)
static void setup_sdram_meminfo(ramctr_timing *ctrl)
static void disable_channel(ramctr_timing *ctrl, int channel)
static uint8_t nb_get_ecc_type(const uint32_t capid0_a)
static void dram_find_spds_ddr3(spd_raw_data *spd, ramctr_timing *ctrl)
static uint32_t nb_max_chan_capacity_mib(const uint32_t capid0_a)
static void wait_txt_clear(void)
static uint16_t nb_number_of_channels(const uint32_t capid0_a)
static void reinit_ctrl(ramctr_timing *ctrl, const u32 cpuid)
static void save_timings(ramctr_timing *ctrl)
bool get_host_ecc_cap(void)
void set_normal_operation(ramctr_timing *ctrl)
void final_registers(ramctr_timing *ctrl)
void channel_scrub(ramctr_timing *ctrl)
bool get_host_ecc_forced(void)
void dram_zones(ramctr_timing *ctrl, int training)
void set_scrambling_seed(ramctr_timing *ctrl)
int try_init_dram_ddr3(ramctr_timing *ctrl, int fast_boot, int s3resume, int me_uma_size)
#define GET_ERR_CHANNEL(x)
#define ME_INIT_STATUS_SUCCESS
static void report_memory_config(void)
void early_pch_init_native(void)
union dimm_flags_ddr3_st flags
enum spd_memory_type dram_type
int extended_temperature_range
int rank_mirror[NUM_CHANNELS][NUM_SLOTRANKS]
u32 cmd_stretch[NUM_CHANNELS]
u16 spd_crc[NUM_CHANNELS][NUM_SLOTS]
int ref_card_offset[NUM_CHANNELS]
int channel_size_mb[NUM_CHANNELS]
u32 mad_dimm[NUM_CHANNELS]
struct ram_rank_timings timings[NUM_CHANNELS][NUM_SLOTRANKS]
#define m(clkreg, src_bits, pmcreg, dst_bits)
unsigned int pins_mirrored
unsigned int ext_temp_refresh