coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
raminit.c File Reference
#include <commonlib/helpers.h>
#include <stdint.h>
#include <arch/cpu.h>
#include <device/mmio.h>
#include <device/pci_ops.h>
#include <device/pci_def.h>
#include <device/device.h>
#include <device/smbus_host.h>
#include <spd.h>
#include <console/console.h>
#include <lib.h>
#include <delay.h>
#include <timestamp.h>
#include "gm45.h"
#include "chip.h"
Include dependency graph for raminit.c:

Go to the source code of this file.

Data Structures

struct  spdinfo_t
 

Macros

#define DEFAULT_PCI_MMIO_SIZE   2048
 
#define HOST_BRIDGE   PCI_DEVFN(0, 0)
 

Functions

void get_gmch_info (sysinfo_t *sysinfo)
 
void enter_raminit_or_reset (void)
 
static int test_dimm (sysinfo_t *const sysinfo, int dimm, int addr, int bitmask, int expected)
 
static void verify_ddr3_dimm (sysinfo_t *const sysinfo, int dimm)
 
static void verify_ddr3 (sysinfo_t *const sysinfo, int mask)
 
static void collect_ddr3 (sysinfo_t *const sysinfo, spdinfo_t *const config)
 
static fsb_clock_t read_fsb_clock (void)
 
static mem_clock_t clock_index (const unsigned int clock)
 
static void normalize_clock (unsigned int *const clock)
 
static void lower_clock (unsigned int *const clock)
 
static unsigned int find_common_clock_cas (sysinfo_t *const sysinfo, const spdinfo_t *const spdinfo)
 
static void calculate_derived_timings (sysinfo_t *const sysinfo, const unsigned int tCLK, const spdinfo_t *const spdinfo)
 
static void collect_dimm_config (sysinfo_t *const sysinfo)
 
static void reset_on_bad_warmboot (void)
 
static void set_system_memory_frequency (const timings_t *const timings)
 
int raminit_read_vco_index (void)
 
static void set_igd_memory_frequencies (const sysinfo_t *const sysinfo)
 
static void configure_dram_control_mode (const timings_t *const timings, const dimminfo_t *const dimms)
 
static void rcomp_initialization (const stepping_t stepping, const int sff)
 
static void dram_powerup (const int resume)
 
static void dram_program_timings (const timings_t *const timings)
 
static void dram_program_banks (const dimminfo_t *const dimms)
 
static void odt_setup (const timings_t *const timings, const int sff)
 
static void misc_settings (const timings_t *const timings, const stepping_t stepping)
 
static void clock_crossing_setup (const fsb_clock_t fsb, const mem_clock_t ddr3clock, const dimminfo_t *const dimms)
 
static void vc1_program_timings (const fsb_clock_t fsb)
 
static unsigned int get_mmio_size (void)
 
static void program_memory_map (const dimminfo_t *const dimms, const channel_mode_t mode, const int prejedec, u16 ggc)
 
static void prejedec_memory_map (const dimminfo_t *const dimms, channel_mode_t mode)
 
static void ddr3_select_clock_mux (const mem_clock_t ddr3clock, const dimminfo_t *const dimms, const stepping_t stepping)
 
static void ddr3_write_io_init (const mem_clock_t ddr3clock, const dimminfo_t *const dimms, const stepping_t stepping, const int sff)
 
static void ddr3_read_io_init (const mem_clock_t ddr3clock, const dimminfo_t *const dimms, const int sff)
 
static void memory_io_init (const mem_clock_t ddr3clock, const dimminfo_t *const dimms, const stepping_t stepping, const int sff)
 
static void jedec_init (const timings_t *const timings, const dimminfo_t *const dimms)
 
static void ddr3_calibrate_zq (void)
 
static void post_jedec_sequence (const int cores)
 
static void dram_optimizations (const timings_t *const timings, const dimminfo_t *const dimms)
 
u32 raminit_get_rank_addr (unsigned int channel, unsigned int rank)
 
void raminit_reset_readwrite_pointers (void)
 
void raminit (sysinfo_t *const sysinfo, const int s3resume)
 

Variables

static const gmch_gfx_t gmch_gfx_types [][5]
 

Macro Definition Documentation

◆ DEFAULT_PCI_MMIO_SIZE

#define DEFAULT_PCI_MMIO_SIZE   2048

Definition at line 1143 of file raminit.c.

◆ HOST_BRIDGE

#define HOST_BRIDGE   PCI_DEVFN(0, 0)

Definition at line 1144 of file raminit.c.

Function Documentation

◆ calculate_derived_timings()

◆ clock_crossing_setup()

static void clock_crossing_setup ( const fsb_clock_t  fsb,
const mem_clock_t  ddr3clock,
const dimminfo_t *const  dimms 
)
static

Definition at line 1084 of file raminit.c.

References ch, CHANNEL_IS_CARDF, FOR_EACH_CHANNEL, FSB_CLOCK_1067MHz, FSB_CLOCK_800MHz, mchbar_write32(), MEM_CLOCK_667MT, and MEM_CLOCK_800MT.

Referenced by raminit().

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

◆ clock_index()

static mem_clock_t clock_index ( const unsigned int  clock)
static

Definition at line 361 of file raminit.c.

References die(), MEM_CLOCK_333MHz, MEM_CLOCK_400MHz, and MEM_CLOCK_533MHz.

Referenced by find_common_clock_cas().

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

◆ collect_ddr3()

static void collect_ddr3 ( sysinfo_t *const  sysinfo,
spdinfo_t *const  config 
)
static

Definition at line 306 of file raminit.c.

References config, mask, smbus_read_byte(), and sysinfo::spd_map.

Referenced by collect_dimm_config().

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

◆ collect_dimm_config()

◆ configure_dram_control_mode()

static void configure_dram_control_mode ( const timings_t *const  timings,
const dimminfo_t *const  dimms 
)
static

◆ ddr3_calibrate_zq()

static void ddr3_calibrate_zq ( void  )
static

Definition at line 1592 of file raminit.c.

References CxDRT6_MCHBAR, DCC_MCHBAR, mchbar_clrbits32, mchbar_read32(), mchbar_setbits32, mchbar_write32(), and udelay().

Referenced by raminit().

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

◆ ddr3_read_io_init()

static void ddr3_read_io_init ( const mem_clock_t  ddr3clock,
const dimminfo_t *const  dimms,
const int  sff 
)
static

Definition at line 1405 of file raminit.c.

References addr, base, ch, die(), FOR_EACH_POPULATED_CHANNEL, mchbar_read32(), mchbar_write32(), MEM_CLOCK_1067MT, MEM_CLOCK_667MT, and MEM_CLOCK_800MT.

Referenced by memory_io_init().

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

◆ ddr3_select_clock_mux()

static void ddr3_select_clock_mux ( const mem_clock_t  ddr3clock,
const dimminfo_t *const  dimms,
const stepping_t  stepping 
)
static

Definition at line 1305 of file raminit.c.

References ch, CHANNEL_IS_CARDF, CHANNEL_IS_POPULATED, die(), FOR_EACH_POPULATED_CHANNEL, mchbar_read32(), mchbar_write32(), MEM_CLOCK_1067MT, stepping, and STEPPING_B1.

Referenced by memory_io_init().

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

◆ ddr3_write_io_init()

static void ddr3_write_io_init ( const mem_clock_t  ddr3clock,
const dimminfo_t *const  dimms,
const stepping_t  stepping,
const int  sff 
)
static

Definition at line 1339 of file raminit.c.

References ch, CHANNEL_IS_CARDF, CHANNEL_IS_POPULATED, CxWRTy_MCHBAR, die(), FOR_EACH_POPULATED_CHANNEL, mchbar_write32(), MEM_CLOCK_1067MT, stepping, STEPPING_B1, and STEPPING_CONVERSION_A1.

Referenced by memory_io_init().

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

◆ dram_optimizations()

static void dram_optimizations ( const timings_t *const  timings,
const dimminfo_t *const  dimms 
)
static

Definition at line 1643 of file raminit.c.

References ch, CxDRC1_DS, CxDRC1_MCHBAR, CxDRC1_SS, CxDRC1_SSDS_MASK, FOR_EACH_POPULATED_CHANNEL, mchbar_read32(), and mchbar_write32().

Referenced by raminit().

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

◆ dram_powerup()

static void dram_powerup ( const int  resume)
static

Definition at line 899 of file raminit.c.

References CLKCFG_MCHBAR, mchbar_clrbits32, mchbar_clrsetbits32(), mchbar_setbits32, and udelay().

Referenced by raminit().

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

◆ dram_program_banks()

static void dram_program_banks ( const dimminfo_t *const  dimms)
static

Definition at line 1001 of file raminit.c.

References dimminfo_t::banks, ch, CxDRA_BANKS, CxDRA_BANKS_MASK, CxDRA_MCHBAR, CxDRT1_MCHBAR, FOR_EACH_CHANNEL, FOR_EACH_POPULATED_RANK_IN_CHANNEL, IF_CHANNEL_POPULATED, mchbar_read32(), and mchbar_write32().

Referenced by raminit().

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

◆ dram_program_timings()

static void dram_program_timings ( const timings_t *const  timings)
static

◆ enter_raminit_or_reset()

void enter_raminit_or_reset ( void  )

Definition at line 191 of file raminit.c.

References BIOS_INFO, BIOS_WARNING, gm45_early_reset(), PCI_DEV, pci_read_config8(), pci_write_config8(), and printk.

Referenced by mainboard_romstage_entry().

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

◆ find_common_clock_cas()

static unsigned int find_common_clock_cas ( sysinfo_t *const  sysinfo,
const spdinfo_t *const  spdinfo 
)
static

◆ get_gmch_info()

◆ get_mmio_size()

static unsigned int get_mmio_size ( void  )
static

Definition at line 1146 of file raminit.c.

References device::chip_info, DEFAULT_PCI_MMIO_SIZE, HOST_BRIDGE, NULL, northbridge_intel_gm45_config::pci_mmio_size, and pcidev_path_on_root().

Referenced by program_memory_map().

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

◆ jedec_init()

static void jedec_init ( const timings_t *const  timings,
const dimminfo_t *const  dimms 
)
static

Definition at line 1538 of file raminit.c.

References BIOS_DEBUG, timings::CAS, CAS, ch, DCC_CMD_MASK, DCC_CMD_NOP, DCC_MCHBAR, DCC_SET_EREG_MASK, DCC_SET_EREGx, DCC_SET_MREG, die(), FOR_EACH_POPULATED_RANK, mchbar_clrsetbits32(), mchbar_setbits32, pci_and_config8(), PCI_DEV, pci_or_config8(), printk, raminit_get_rank_addr(), read32(), timings::tWR, and udelay().

Referenced by raminit().

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

◆ lower_clock()

static void lower_clock ( unsigned int *const  clock)
static

Definition at line 382 of file raminit.c.

References normalize_clock().

Referenced by find_common_clock_cas().

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

◆ memory_io_init()

static void memory_io_init ( const mem_clock_t  ddr3clock,
const dimminfo_t *const  dimms,
const stepping_t  stepping,
const int  sff 
)
static

Definition at line 1439 of file raminit.c.

References ddr3_read_io_init(), ddr3_select_clock_mux(), ddr3_write_io_init(), die(), mchbar_clrbits32, mchbar_read32(), mchbar_setbits32, mchbar_write32(), MEM_CLOCK_1067MT, MEM_CLOCK_667MT, MEM_CLOCK_800MT, stepping, and STEPPING_B1.

Referenced by raminit().

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

◆ misc_settings()

static void misc_settings ( const timings_t *const  timings,
const stepping_t  stepping 
)
static

Definition at line 1065 of file raminit.c.

References mchbar_clrsetbits32(), mchbar_clrsetbits8(), mchbar_setbits8, stepping, and STEPPING_B1.

Referenced by raminit().

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

◆ normalize_clock()

static void normalize_clock ( unsigned int *const  clock)
static

Definition at line 371 of file raminit.c.

Referenced by find_common_clock_cas(), and lower_clock().

Here is the caller graph for this function:

◆ odt_setup()

static void odt_setup ( const timings_t *const  timings,
const int  sff 
)
static

Definition at line 1021 of file raminit.c.

References timings::CAS, ch, CxODT_HIGH, CxODT_LOW, FOR_EACH_CHANNEL, mchbar_read32(), mchbar_write32(), timings::mem_clock, MEM_CLOCK_1067MT, MEM_CLOCK_667MT, and MEM_CLOCK_800MT.

Referenced by raminit().

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

◆ post_jedec_sequence()

static void post_jedec_sequence ( const int  cores)
static

Definition at line 1611 of file raminit.c.

References mchbar_clrbits32, mchbar_clrsetbits32(), mchbar_setbits32, and mchbar_write32().

Referenced by raminit().

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

◆ prejedec_memory_map()

static void prejedec_memory_map ( const dimminfo_t *const  dimms,
channel_mode_t  mode 
)
static

Definition at line 1295 of file raminit.c.

References CHANNEL_MODE_DUAL_ASYNC, CHANNEL_MODE_DUAL_INTERLEAVED, DCC_MCHBAR, DCC_NO_CHANXOR, mchbar_setbits32, and program_memory_map().

Referenced by raminit().

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

◆ program_memory_map()

◆ raminit()

◆ raminit_get_rank_addr()

u32 raminit_get_rank_addr ( unsigned int  channel,
unsigned int  rank 
)

Definition at line 1660 of file raminit.c.

References CxDRBy_BOUND_MASK, CxDRBy_BOUND_SHIFT, CxDRBy_MCHBAR, and mchbar_read32().

Referenced by jedec_init(), perform_read_training(), perform_write_training(), and read_dqs_level().

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

◆ raminit_read_vco_index()

int raminit_read_vco_index ( void  )

Definition at line 733 of file raminit.c.

References die(), HPLLVCO_MCHBAR, mchbar_read8(), VCO_2666, VCO_3200, VCO_4000, and VCO_5333.

Referenced by enable_igd(), and init_freq_scaling().

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

◆ raminit_reset_readwrite_pointers()

void raminit_reset_readwrite_pointers ( void  )

Definition at line 1677 of file raminit.c.

References mchbar_clrbits32, and mchbar_setbits32.

Referenced by raminit_read_training(), raminit_receive_enable_calibration(), and raminit_write_training().

Here is the caller graph for this function:

◆ rcomp_initialization()

static void rcomp_initialization ( const stepping_t  stepping,
const int  sff 
)
static

Definition at line 851 of file raminit.c.

References die(), mchbar_clrbits32, mchbar_clrbits8, mchbar_clrsetbits32(), mchbar_read32(), mchbar_setbits32, mchbar_write8(), raminit_rcomp_calibration(), and stepping.

Referenced by raminit().

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

◆ read_fsb_clock()

static fsb_clock_t read_fsb_clock ( void  )
static

Definition at line 348 of file raminit.c.

References CLKCFG_FSBCLK_MASK, CLKCFG_MCHBAR, die(), FSB_CLOCK_1067MHz, FSB_CLOCK_667MHz, FSB_CLOCK_800MHz, and mchbar_read32().

Referenced by find_common_clock_cas().

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

◆ reset_on_bad_warmboot()

static void reset_on_bad_warmboot ( void  )
static

Definition at line 665 of file raminit.c.

References BIOS_INFO, gm45_early_reset(), mchbar_read32(), mchbar_write32(), PMSTS_BOTH_SELFREFRESH, PMSTS_MCHBAR, PMSTS_WARM_RESET, and printk.

Referenced by raminit().

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

◆ set_igd_memory_frequencies()

static void set_igd_memory_frequencies ( const sysinfo_t *const  sysinfo)
static

Definition at line 749 of file raminit.c.

References GMCH_GS45.

Referenced by raminit().

Here is the caller graph for this function:

◆ set_system_memory_frequency()

static void set_system_memory_frequency ( const timings_t *const  timings)
static

◆ test_dimm()

static int test_dimm ( sysinfo_t *const  sysinfo,
int  dimm,
int  addr,
int  bitmask,
int  expected 
)
static

Definition at line 220 of file raminit.c.

References addr, smbus_read_byte(), and sysinfo::spd_map.

Referenced by verify_ddr3_dimm().

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

◆ vc1_program_timings()

static void vc1_program_timings ( const fsb_clock_t  fsb)
static

Definition at line 1131 of file raminit.c.

References epbar_write32(), epbar_write8(), EPVC1IST, and EPVC1ITC.

Referenced by raminit().

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

◆ verify_ddr3()

static void verify_ddr3 ( sysinfo_t *const  sysinfo,
int  mask 
)
static

Definition at line 270 of file raminit.c.

References mask, and verify_ddr3_dimm().

Referenced by collect_dimm_config().

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

◆ verify_ddr3_dimm()

static void verify_ddr3_dimm ( sysinfo_t *const  sysinfo,
int  dimm 
)
static

Definition at line 227 of file raminit.c.

References die(), and test_dimm().

Referenced by verify_ddr3().

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

Variable Documentation

◆ gmch_gfx_types

const gmch_gfx_t gmch_gfx_types[][5]
static