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

Go to the source code of this file.

Data Structures

struct  optimize_ac_time
 
struct  shuffle_reg_addr
 

Macros

#define AO_SHU_ADDR(s, e)
 
#define PHY_SHU_ADDR(s, e)
 

Functions

void dramc_set_broadcast (u32 onoff)
 
u32 dramc_get_broadcast (void)
 
u32 get_shu_freq (u8 shu)
 
static u64 get_ch_rank_size (u8 chn, u8 rank)
 
void dramc_get_rank_size (u64 *dram_rank_size)
 
size_t sdram_size (void)
 
static void set_rank_info_to_conf (const struct sdram_params *params)
 
void cbt_mrr_pinmux_mapping (void)
 
void set_mrr_pinmux_mapping (void)
 
static void global_option_init (const struct sdram_params *params)
 
static void set_vcore_voltage (u8 freq_group)
 
static void set_vdram1_vddq_voltage (void)
 
static void emi_esl_setting1 (void)
 
static void emi_esl_setting2 (void)
 
static void emi_init (const struct sdram_params *params)
 
static void emi_init2 (const struct sdram_params *params)
 
static void dramc_init_pre_settings (void)
 
static void dramc_ac_timing_optimize (u8 freq_group, u8 density)
 
static void spm_pinmux_setting (void)
 
static void dfs_init_for_calibration (const struct sdram_params *params, u8 freq_group, struct dram_shared_data *shared)
 
static void init_dram (const struct sdram_params *params, u8 freq_group, struct dram_shared_data *shared)
 
void enable_emi_dcm (void)
 
static void dramc_save_result_to_shuffle (u32 src_shuffle, u32 dst_shuffle)
 
static int run_calib (const struct dramc_param *dparam, struct dram_shared_data *shared, const int shuffle, bool *first_run)
 
static void after_calib (const struct mr_value *mr, u32 rk_num)
 
int mt_set_emi (const struct dramc_param *dparam)
 

Variables

static const u8 freq_shuffle [DRAM_DFS_SHUFFLE_MAX]
 
static const u8 freq_shuffle_emcp [DRAM_DFS_SHUFFLE_MAX]
 
static const u32 frequency_table [LP4X_DDRFREQ_MAX]
 
static const u32 vcore_lp4x [LP4X_DDRFREQ_MAX]
 
struct emi_regsemi_regs = (void *)EMI_BASE
 
const u8 phy_mapping [CHANNEL_MAX][16]
 
static const struct shuffle_reg_addr dramc_regs []
 
static const struct shuffle_reg_addr phy_regs []
 

Macro Definition Documentation

◆ AO_SHU_ADDR

#define AO_SHU_ADDR (   s,
 
)
Value:
{ \
.start = offsetof(struct dramc_ao_regs_shu, s), \
.end = offsetof(struct dramc_ao_regs_shu, e), \
}
#define offsetof(TYPE, MEMBER)
Definition: helpers.h:84
#define s(param, src_bits, pmcreg, dst_bits)

Definition at line 483 of file emi.c.

◆ PHY_SHU_ADDR

#define PHY_SHU_ADDR (   s,
 
)
Value:
{ \
.start = offsetof(struct ddrphy_ao_shu, s), \
.end = offsetof(struct ddrphy_ao_shu, e), \
}

Definition at line 497 of file emi.c.

Function Documentation

◆ after_calib()

static void after_calib ( const struct mr_value mr,
u32  rk_num 
)
static

Definition at line 616 of file emi.c.

References dramc_apply_config_after_calibration(), and dramc_runtime_config().

Referenced by mt_set_emi().

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

◆ cbt_mrr_pinmux_mapping()

void cbt_mrr_pinmux_mapping ( void  )

Definition at line 160 of file emi.c.

References ch, CHANNEL_MAX, phy_mapping, and write32().

Referenced by dramc_cmd_bus_training().

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

◆ dfs_init_for_calibration()

static void dfs_init_for_calibration ( const struct sdram_params params,
u8  freq_group,
struct dram_shared_data shared 
)
static

Definition at line 443 of file emi.c.

References dramc_apply_config_before_calibration(), dramc_init(), and params.

Referenced by run_calib().

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

◆ dramc_ac_timing_optimize()

static void dramc_ac_timing_optimize ( u8  freq_group,
u8  density 
)
static

◆ dramc_get_broadcast()

u32 dramc_get_broadcast ( void  )

Definition at line 64 of file emi.c.

References mt8183_infracfg_regs::dramc_wbr, mt8183_infracfg, and read32().

Referenced by auto_refresh_cke_off(), dramc_mode_reg_init(), and dramc_sw_impedance_cal().

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

◆ dramc_get_rank_size()

void dramc_get_rank_size ( u64 dram_rank_size)

Definition at line 93 of file emi.c.

References CHANNEL_A, CHANNEL_B, emi_regs::cona, emi_regs::conh, get_ch_rank_size(), RANK_0, RANK_1, and read32().

Referenced by mt_mem_test(), and sdram_size().

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

◆ dramc_init_pre_settings()

static void dramc_init_pre_settings ( void  )
static

Definition at line 323 of file emi.c.

References ch, clrbits32, clrsetbits32, and setbits32.

Referenced by init_dram().

Here is the caller graph for this function:

◆ dramc_save_result_to_shuffle()

static void dramc_save_result_to_shuffle ( u32  src_shuffle,
u32  dst_shuffle 
)
static

Definition at line 520 of file emi.c.

References ARRAY_SIZE, ch, CHANNEL_MAX, clrsetbits32, DRAM_DFS_SHUFFLE_2, DRAM_DFS_SHUFFLE_3, dramc_dbg, dramc_regs, shuffle_reg_addr::end, offset, phy_regs, read32(), shuffle_reg_addr::start, value, and write32().

Referenced by run_calib().

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

◆ dramc_set_broadcast()

void dramc_set_broadcast ( u32  onoff)

Definition at line 59 of file emi.c.

References mt8183_infracfg_regs::dramc_wbr, mt8183_infracfg, and write32().

Referenced by auto_refresh_cke_off(), dramc_mode_reg_init(), dramc_sw_impedance_cal(), dramc_sw_impedance_save_reg(), emi_esl_setting1(), emi_esl_setting2(), init_dram(), and update_initial_settings().

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

◆ emi_esl_setting1()

◆ emi_esl_setting2()

static void emi_esl_setting2 ( void  )
static

Definition at line 281 of file emi.c.

References ch, emi_regs::conm, DRAMC_BROADCAST_OFF, DRAMC_BROADCAST_ON, dramc_set_broadcast(), and write32().

Referenced by emi_init2().

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

◆ emi_init()

static void emi_init ( const struct sdram_params params)
static

Definition at line 291 of file emi.c.

References ch, CHANNEL_A, CHANNEL_MAX, emi_regs::cona, emi_regs::conf, emi_regs::conh, emi_esl_setting1(), params, and write32().

Referenced by init_dram().

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

◆ emi_init2()

static void emi_init2 ( const struct sdram_params params)
static

Definition at line 305 of file emi.c.

References emi_regs::bwct0, emi_regs::bwct0_2nd, emi_regs::bwct0_3rd, emi_regs::bwct0_4th, emi_regs::bwct0_5th, CONFIG, emi_esl_setting2(), emi_mpu, emi_mpu_regs::mpu_ctrl_d, setbits32, and write32().

Referenced by init_dram().

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

◆ enable_emi_dcm()

void enable_emi_dcm ( void  )

Definition at line 469 of file emi.c.

Referenced by dramc_runtime_config().

Here is the caller graph for this function:

◆ get_ch_rank_size()

static u64 get_ch_rank_size ( u8  chn,
u8  rank 
)
static

Definition at line 76 of file emi.c.

References emi_regs::cona, and read32().

Referenced by dramc_get_rank_size().

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

◆ get_shu_freq()

u32 get_shu_freq ( u8  shu)

Definition at line 69 of file emi.c.

References CONFIG, freq_shuffle, freq_shuffle_emcp, and frequency_table.

Referenced by dramc_dqs_precalculation_preset(), and dramc_hw_dqsosc().

Here is the caller graph for this function:

◆ global_option_init()

static void global_option_init ( const struct sdram_params params)
static

Definition at line 195 of file emi.c.

References params, set_mrr_pinmux_mapping(), and set_rank_info_to_conf().

Referenced by init_dram().

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

◆ init_dram()

static void init_dram ( const struct sdram_params params,
u8  freq_group,
struct dram_shared_data shared 
)
static

◆ mt_set_emi()

◆ run_calib()

static int run_calib ( const struct dramc_param dparam,
struct dram_shared_data shared,
const int  shuffle,
bool first_run 
)
static

◆ sdram_size()

size_t sdram_size ( void  )

Definition at line 140 of file emi.c.

References dramc_get_rank_size(), and RANK_MAX.

Here is the call graph for this function:

◆ set_mrr_pinmux_mapping()

void set_mrr_pinmux_mapping ( void  )

Definition at line 173 of file emi.c.

References ch, CHANNEL_MAX, phy_mapping, and write32().

Referenced by dramc_cmd_bus_training(), and global_option_init().

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

◆ set_rank_info_to_conf()

static void set_rank_info_to_conf ( const struct sdram_params params)
static

Definition at line 153 of file emi.c.

References ch, clrsetbits32, is_dual_rank(), and params.

Referenced by global_option_init().

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

◆ set_vcore_voltage()

static void set_vcore_voltage ( u8  freq_group)
static

Definition at line 201 of file emi.c.

References dramc_dbg, frequency_table, pmic_set_vcore_vol(), and vcore_lp4x.

Referenced by run_calib().

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

◆ set_vdram1_vddq_voltage()

static void set_vdram1_vddq_voltage ( void  )
static

Definition at line 209 of file emi.c.

References dramc_dbg, pmic_set_vddq_vol(), and pmic_set_vdram1_vol().

Referenced by mt_set_emi().

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

◆ spm_pinmux_setting()

static void spm_pinmux_setting ( void  )
static

Definition at line 434 of file emi.c.

References clrbits32, clrsetbits32, mtk_spm_regs::dramc_dpy_clk_sw_con_sel, mtk_spm_regs::dramc_dpy_clk_sw_con_sel2, mtk_spm, mtk_spm_regs::pcm_pwr_io_en, mtk_spm_regs::poweron_config_set, and write32().

Referenced by init_dram().

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

Variable Documentation

◆ dramc_regs

const struct shuffle_reg_addr dramc_regs[]
static
Initial value:
= {
AO_SHU_ADDR(actim, hwset_vrcg),
AO_SHU_ADDR(rk[0], rk[0].dqs2dq_cal5),
AO_SHU_ADDR(rk[1], rk[1].dqs2dq_cal5),
AO_SHU_ADDR(rk[2], rk[2].dqs2dq_cal5),
AO_SHU_ADDR(dqsg_retry, dqsg_retry),
}
#define AO_SHU_ADDR(s, e)
Definition: emi.c:483

Definition at line 469 of file emi.c.

Referenced by dramc_save_result_to_shuffle().

◆ emi_regs

Definition at line 38 of file emi.c.

◆ freq_shuffle

const u8 freq_shuffle[DRAM_DFS_SHUFFLE_MAX]
static
Initial value:
= {
}
@ DRAM_DFS_SHUFFLE_1
@ DRAM_DFS_SHUFFLE_3
@ DRAM_DFS_SHUFFLE_2
@ LP4X_DDR2400
Definition: emi.h:68
@ LP4X_DDR3200
Definition: emi.h:69
@ LP4X_DDR1600
Definition: emi.h:67

Definition at line 12 of file emi.c.

Referenced by get_shu_freq(), and run_calib().

◆ freq_shuffle_emcp

const u8 freq_shuffle_emcp[DRAM_DFS_SHUFFLE_MAX]
static
Initial value:

Definition at line 18 of file emi.c.

Referenced by get_shu_freq(), and run_calib().

◆ frequency_table

const u32 frequency_table[LP4X_DDRFREQ_MAX]
static
Initial value:
= {
[LP4X_DDR1600] = 1600,
[LP4X_DDR2400] = 2400,
[LP4X_DDR3200] = 3200,
[LP4X_DDR3600] = 3600,
}

Definition at line 24 of file emi.c.

Referenced by get_shu_freq(), run_calib(), and set_vcore_voltage().

◆ phy_mapping

const u8 phy_mapping[CHANNEL_MAX][16]
Initial value:
= {
[CHANNEL_A] = {
1, 0, 2, 4, 3, 7, 5, 6,
9, 8, 12, 11, 10, 15, 13, 14
},
[CHANNEL_B] = {
0, 1, 5, 6, 3, 7, 4, 2,
9, 8, 12, 15, 11, 14, 13, 10
}
}
@ CHANNEL_A
Definition: dramc_soc.h:7
@ CHANNEL_B
Definition: dramc_soc.h:8

Definition at line 39 of file emi.c.

Referenced by cbt_mrr_pinmux_mapping(), dramc_rx_rd_dqc_init(), get_cbt_vref_pinmux_value(), and set_mrr_pinmux_mapping().

◆ phy_regs

const struct shuffle_reg_addr phy_regs[]
static
Initial value:
= {
PHY_SHU_ADDR(b[0], b[0].dll[1]),
PHY_SHU_ADDR(b[1], b[1].dll[1]),
PHY_SHU_ADDR(ca_cmd, ca_dll[1]),
PHY_SHU_ADDR(pll[0], pll[15]),
PHY_SHU_ADDR(pll20, misc0),
PHY_SHU_ADDR(rk[0].b[0], rk[0].b[0].rsvd_20[3]),
PHY_SHU_ADDR(rk[0].b[1], rk[0].b[1].rsvd_20[3]),
PHY_SHU_ADDR(rk[0].ca_cmd, rk[0].rsvd_22[1]),
PHY_SHU_ADDR(rk[1].b[0], rk[1].b[0].rsvd_20[3]),
PHY_SHU_ADDR(rk[1].b[1], rk[1].b[1].rsvd_20[3]),
PHY_SHU_ADDR(rk[1].ca_cmd, rk[1].rsvd_22[1]),
PHY_SHU_ADDR(rk[2].b[0], rk[2].b[0].rsvd_20[3]),
PHY_SHU_ADDR(rk[2].b[1], rk[2].b[1].rsvd_20[3]),
PHY_SHU_ADDR(rk[2].ca_cmd, rk[2].rsvd_22[1]),
}
#define PHY_SHU_ADDR(s, e)
Definition: emi.c:497
Definition: pll_common.h:32

Definition at line 469 of file emi.c.

Referenced by dramc_save_result_to_shuffle().

◆ vcore_lp4x

const u32 vcore_lp4x[LP4X_DDRFREQ_MAX]
static
Initial value:
= {
[LP4X_DDR1600] = 725000,
[LP4X_DDR2400] = 725000,
[LP4X_DDR3200] = 762500,
[LP4X_DDR3600] = 800000,
}

Definition at line 31 of file emi.c.

Referenced by set_vcore_voltage().