coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
dramc_pi_calibration_api.c File Reference
#include <device/mmio.h>
#include <console/console.h>
#include <soc/addressmap.h>
#include <soc/dramc_common.h>
#include <soc/dramc_register.h>
#include <soc/dramc_pi_api.h>
#include <soc/dramc_soc.h>
#include <soc/emi.h>
Include dependency graph for dramc_pi_calibration_api.c:

Go to the source code of this file.

Functions

void sw_impedance_cal (u32 channel, const struct mt8173_sdram_params *sdram_params)
 
void ca_training (u32 channel, const struct mt8173_sdram_params *sdram_params)
 
void write_leveling (u32 channel, const struct mt8173_sdram_params *sdram_params)
 
static void set_gw_coarse_factor (u32 channel, u8 curr_val)
 
static void set_gw_fine_factor (u32 channel, u8 curr_val, u8 rank)
 
static void set_gw_coarse_factor_rank1 (u32 channel, u8 curr_val, u8 dqsinctl)
 
static void dqs_gw_counter_reset (u32 channel)
 
static int dqs_gw_test (u32 channel)
 
static u8 dqs_gw_fine_tune_calib (u32 channel, u8 fine_val)
 
static u8 dqs_gw_coarse_tune_calib (u32 channel, u8 coarse_val)
 
void rx_dqs_gating_cal (u32 channel, u8 rank, const struct mt8173_sdram_params *sdram_params)
 
void dual_rank_rx_dqs_gating_cal (u32 channel, const struct mt8173_sdram_params *sdram_params)
 
void dramc_rankinctl_config (u32 channel, const struct mt8173_sdram_params *sdram_params)
 
u32 dram_k_perbit (u32 channel)
 
void dramk_check_dqs_win (struct dqs_perbit_dly *p, u8 dly_step, u8 last_step, u32 fail_bit)
 
void dramk_check_dq_win (struct dqs_perbit_dly *p, u8 dly_step, u8 last_step, u32 fail_bit)
 
u8 dramk_calcu_best_dly (u8 bit, struct dqs_perbit_dly *p, u8 *p_max_byte)
 
void clk_duty_cal (u32 channel)
 
static void set_dle_factor (u32 channel, u8 curr_val)
 
void dual_rank_rx_datlat_cal (u32 channel, const struct mt8173_sdram_params *sdram_params)
 
u8 rx_datlat_cal (u32 channel, u8 rank, const struct mt8173_sdram_params *sdram_params)
 
void tx_delay_for_wrleveling (u32 channel, struct dqs_perbit_dly *dqdqs_perbit_dly, u8 *max_dqsdly_byte, u8 *ave_dqdly_byte)
 
static void set_rx_dly_factor (u32 channel, u32 curr_val, u8 type)
 
static void set_tx_dly_factor (u32 channel, u32 curr_val, u8 type)
 
static void set_dly_factor (u32 channel, u8 stage, u8 type, u8 dly)
 
static void set_rx_best_dly_factor (u32 channel, struct dqs_perbit_dly *dqdqs_perbit_dly, u8 *max_dqsdly_byte)
 
static void set_tx_best_dly_factor (u32 channel, struct dqs_perbit_dly *dqdqs_perbit_dly, u8 *max_dqsdly_byte, u8 *ave_dqdly_byte)
 
void perbit_window_cal (u32 channel, u8 type)
 

Variables

static u8 opt_gw_coarse_value [CHANNEL_NUM][DUAL_RANKS]
 
static u8 opt_gw_fine_value [CHANNEL_NUM][DUAL_RANKS]
 
static s8 wrlevel_dqs_dly [CHANNEL_NUM][DQS_NUMBER]
 

Function Documentation

◆ ca_training()

◆ clk_duty_cal()

void clk_duty_cal ( u32  channel)

Definition at line 607 of file dramc_pi_calibration_api.c.

References ch, clrsetbits32, ddrphy_regs, dramc_dbg, dramc_ddrphy_regs::phyclkduty, PHYCLKDUTY_CMDCLKP0DUTYN_SHIFT, PHYCLKDUTY_CMDCLKP0DUTYP_SHIFT, PHYCLKDUTY_CMDCLKP0DUTYSEL_SHIFT, and read32().

Referenced by do_calib().

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

◆ dqs_gw_coarse_tune_calib()

static u8 dqs_gw_coarse_tune_calib ( u32  channel,
u8  coarse_val 
)
static

Definition at line 319 of file dramc_pi_calibration_api.c.

References BIOS_ERR, dqs_gw_test(), printk, and set_gw_coarse_factor().

Referenced by rx_dqs_gating_cal().

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

◆ dqs_gw_counter_reset()

static void dqs_gw_counter_reset ( u32  channel)
static

Definition at line 261 of file dramc_pi_calibration_api.c.

References ao_regs, ch, clrbits32, dramc_phy_reset(), setbits32, dramc_ao_regs::spcmd, and SPCMD_DQSGCNTRST_SHIFT.

Referenced by dqs_gw_test(), and rx_dqs_gating_cal().

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

◆ dqs_gw_fine_tune_calib()

static u8 dqs_gw_fine_tune_calib ( u32  channel,
u8  fine_val 
)
static

Definition at line 291 of file dramc_pi_calibration_api.c.

References ARRAY_SIZE, die(), dqs_gw_test(), MAX, MIN, and set_gw_fine_factor().

Referenced by rx_dqs_gating_cal().

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

◆ dqs_gw_test()

static int dqs_gw_test ( u32  channel)
static

Definition at line 269 of file dramc_pi_calibration_api.c.

References ch, dqs_gw_counter_reset(), DQS_GW_GOLD_COUNTER_32BIT, DQS_GW_PATTERN1, DQS_GW_PATTERN2, DQS_GW_TE_OFFSET, dramc_nao_regs::dqsgnwcnt, dramc_engine2(), nao_regs, read32(), and TE_OP_READ_CHECK.

Referenced by dqs_gw_coarse_tune_calib(), and dqs_gw_fine_tune_calib().

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

◆ dram_k_perbit()

u32 dram_k_perbit ( u32  channel)

Definition at line 447 of file dramc_pi_calibration_api.c.

References DEFAULT_TEST2_1_CAL, DEFAULT_TEST2_2_CAL, dramc_engine2(), and TE_OP_WRITE_READ_CHECK.

Referenced by dramc_window_perbit_cal_partial(), and perbit_window_cal().

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

◆ dramc_rankinctl_config()

void dramc_rankinctl_config ( u32  channel,
const struct mt8173_sdram_params sdram_params 
)

Definition at line 426 of file dramc_pi_calibration_api.c.

References ao_regs, ch, clrsetbits32, dramc_ao_regs::dqscal1, dramc_ao_regs::dummy, is_dual_rank(), MIN, opt_gw_coarse_value, dramc_ao_regs::rkcfg, RKCFG_PBREF_DISBYRATE_SHIFT, setbits32, and value.

Referenced by do_calib().

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

◆ dramk_calcu_best_dly()

◆ dramk_check_dq_win()

void dramk_check_dq_win ( struct dqs_perbit_dly p,
u8  dly_step,
u8  last_step,
u32  fail_bit 
)

◆ dramk_check_dqs_win()

void dramk_check_dqs_win ( struct dqs_perbit_dly p,
u8  dly_step,
u8  last_step,
u32  fail_bit 
)

◆ dual_rank_rx_datlat_cal()

void dual_rank_rx_datlat_cal ( u32  channel,
const struct mt8173_sdram_params sdram_params 
)

Definition at line 651 of file dramc_pi_calibration_api.c.

References ao_regs, ch, clrbits32, dramc_dbg, MASK_RKCFG_RKSWAP_EN, opt_gw_coarse_value, opt_gw_fine_value, dramc_ao_regs::rkcfg, rx_datlat_cal(), set_dle_factor(), set_gw_coarse_factor(), set_gw_fine_factor(), and setbits32.

Referenced by do_calib().

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

◆ dual_rank_rx_dqs_gating_cal()

void dual_rank_rx_dqs_gating_cal ( u32  channel,
const struct mt8173_sdram_params sdram_params 
)

◆ perbit_window_cal()

◆ rx_datlat_cal()

u8 rx_datlat_cal ( u32  channel,
u8  rank,
const struct mt8173_sdram_params sdram_params 
)

Definition at line 694 of file dramc_pi_calibration_api.c.

References ao_regs, BIOS_ERR, ch, clrbits32, DEFAULT_TEST2_1_CAL, DEFAULT_TEST2_2_CAL, DLE_TEST_NUM, dramc_dbg, dramc_engine2(), dramc_ao_regs::mckdly, MCKDLY_DQIENLAT_SHIFT, MCKDLY_DQIENQKEND_SHIFT, printk, set_dle_factor(), and TE_OP_WRITE_READ_CHECK.

Referenced by do_calib(), and dual_rank_rx_datlat_cal().

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

◆ rx_dqs_gating_cal()

◆ set_dle_factor()

static void set_dle_factor ( u32  channel,
u8  curr_val 
)
static

◆ set_dly_factor()

static void set_dly_factor ( u32  channel,
u8  stage,
u8  type,
u8  dly 
)
static

Definition at line 840 of file dramc_pi_calibration_api.c.

References RX_DQ, RX_DQS, set_rx_dly_factor(), set_tx_dly_factor(), STAGE_HOLD_RX_WIN, STAGE_HOLD_TX_WIN, STAGE_SETUP_RX_WIN, STAGE_SETUP_TX_WIN, TX_DQ, TX_DQM, TX_DQS, and type.

Referenced by perbit_window_cal().

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

◆ set_gw_coarse_factor()

◆ set_gw_coarse_factor_rank1()

static void set_gw_coarse_factor_rank1 ( u32  channel,
u8  curr_val,
u8  dqsinctl 
)
static

◆ set_gw_fine_factor()

static void set_gw_fine_factor ( u32  channel,
u8  curr_val,
u8  rank 
)
static

◆ set_rx_best_dly_factor()

static void set_rx_best_dly_factor ( u32  channel,
struct dqs_perbit_dly dqdqs_perbit_dly,
u8 max_dqsdly_byte 
)
static

Definition at line 864 of file dramc_pi_calibration_api.c.

References ao_regs, dqs_perbit_dly::best_dqdly, ch, DATA_WIDTH_32BIT, dramc_ao_regs::dqidly, DQS_NUMBER, dramc_dbg, dramc_ao_regs::r0deldly, dramc_ao_regs::r1deldly, read32(), value, and write32().

Referenced by perbit_window_cal().

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

◆ set_rx_dly_factor()

static void set_rx_dly_factor ( u32  channel,
u32  curr_val,
u8  type 
)
static

Definition at line 798 of file dramc_pi_calibration_api.c.

References ao_regs, ch, DATA_WIDTH_32BIT, dramc_ao_regs::dqidly, DQS_NUMBER, dramc_ao_regs::r0deldly, RX_DQ, RX_DQS, type, value, and write32().

Referenced by set_dly_factor().

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

◆ set_tx_best_dly_factor()

static void set_tx_best_dly_factor ( u32  channel,
struct dqs_perbit_dly dqdqs_perbit_dly,
u8 max_dqsdly_byte,
u8 ave_dqdly_byte 
)
static

Definition at line 893 of file dramc_pi_calibration_api.c.

References ch, DATA_WIDTH_32BIT, ddrphy_regs, dramc_ddrphy_regs::dqodly, DQS_BIT_NUMBER, DQS_NUMBER, dramc_dbg, MASK_PADCTL2, dramc_ddrphy_regs::padctl2, dramc_ddrphy_regs::padctl3, read32(), value, and write32().

Referenced by perbit_window_cal().

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

◆ set_tx_dly_factor()

static void set_tx_dly_factor ( u32  channel,
u32  curr_val,
u8  type 
)
static

Definition at line 816 of file dramc_pi_calibration_api.c.

References ch, ddrphy_regs, dramc_ddrphy_regs::dqodly, DQS_BIT_NUMBER, DQS_NUMBER, dramc_ddrphy_regs::padctl2, dramc_ddrphy_regs::padctl3, TX_DQ, TX_DQM, TX_DQS, type, value, and write32().

Referenced by set_dly_factor().

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

◆ sw_impedance_cal()

◆ tx_delay_for_wrleveling()

void tx_delay_for_wrleveling ( u32  channel,
struct dqs_perbit_dly dqdqs_perbit_dly,
u8 max_dqsdly_byte,
u8 ave_dqdly_byte 
)

Definition at line 745 of file dramc_pi_calibration_api.c.

References dqs_perbit_dly::best_dqdly, BIOS_ERR, DATA_WIDTH_32BIT, DQS_BIT_NUMBER, dramc_dbg, MAX_DQDLY_TAPS, printk, and wrlevel_dqs_dly.

Referenced by perbit_window_cal().

Here is the caller graph for this function:

◆ write_leveling()

void write_leveling ( u32  channel,
const struct mt8173_sdram_params sdram_params 
)

Definition at line 129 of file dramc_pi_calibration_api.c.

References ch, clrsetbits32, ddrphy_regs, dramc_ddrphy_regs::dqodly, DQS_BIT_NUMBER, DQS_NUMBER, dramc_dbg, MASK_PADCTL2_32BIT, dramc_ddrphy_regs::padctl2, PADCTL2_SHIFT, dramc_ddrphy_regs::padctl3, read32(), val, value, sdram_params::wr_level, write32(), and wrlevel_dqs_dly.

Referenced by do_calib().

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

Variable Documentation

◆ opt_gw_coarse_value

◆ opt_gw_fine_value

u8 opt_gw_fine_value[CHANNEL_NUM][DUAL_RANKS]
static

◆ wrlevel_dqs_dly

s8 wrlevel_dqs_dly[CHANNEL_NUM][DQS_NUMBER]
static

Definition at line 14 of file dramc_pi_calibration_api.c.

Referenced by tx_delay_for_wrleveling(), and write_leveling().