7 #include <soc/addressmap.h>
9 #include <soc/dramc_register.h>
10 #include <soc/dramc_pi_api.h>
11 #include <soc/dramc_soc.h>
28 return (
sdram_params->emi_set.cona & (1 << (17 - channel))) ? 1 : 0;
41 0x1 << 12 | 0xf << 4);
51 0xff << 8 | 0x11 << 0);
53 0x11 << 8 | 0x11 << 0);
79 0x1b << 8 | 0x3 << 0);
82 0x6 << 8 | 0x1e << 0);
96 u32 pattern1, pattern2, pattern3;
97 u32 mempll_ic_3_0, mempll_bp_3_0;
98 u32 mempll_fbdiv_6_0, mempll_m4pdiv_1_0;
99 u32 mempll_br_1_0, mempll_bc_1_0, mempll_ir_3_0;
101 mempll_fbdiv_6_0 = 0x7 << 16;
102 mempll_br_1_0 = 0x1 << 10;
103 mempll_bc_1_0 = 0x0 << 8;
104 mempll_ir_3_0 = 0xc << 28;
105 mempll_ic_3_0 = 0x6 << 8;
106 mempll_bp_3_0 = 0x1 << 12;
107 mempll_m4pdiv_1_0 = 0x0 << 28;
114 pattern1 = mempll_ir_3_0 | mempll_fbdiv_6_0 | mempll_ic_3_0;
115 pattern2 = mempll_m4pdiv_1_0;
116 pattern3 = mempll_bp_3_0 | mempll_br_1_0 | mempll_bc_1_0;
120 0x1 << 23 | pattern1);
122 0x3 << 14 | pattern2);
127 0x1 << 23 | pattern1);
129 0x3 << 14 | pattern2);
134 0x1 << 23 | pattern1);
136 0x3 << 14 | pattern2);
156 switch (mempll->
phase) {
188 dramc_dbg(
"PLL %d, phase %d, one_count %d, zero_count %d\n",
189 (idx + 2), mempll->
phase, one_count, zero_count);
191 switch (mempll->
phase) {
236 dramc_dbg(
"[PLL_Phase_Calib] ===== PLL Phase Calibration: ");
237 dramc_dbg(
"CHANNEL %d (0: CHA, 1: CHB) =====\n", channel);
240 for (i = 0; i < 3; i++)
247 for (i = 0; i < 3; i++) {
248 if (!mempll[i].
done) {
256 for (i = 0; i < 3; i++)
264 for (i = 0; i < 3; i++) {
265 if (!mempll[i].
done) {
271 for (i = 0; i < 3; i++)
280 for (i = 0; i < 3; i++) {
281 if (mempll[i].
delay >= 32) {
282 die(
"MEMPLL calibration fail\n");
303 for (channel = 0; channel <
CHANNEL_NUM; channel++)
309 for (channel = 0; channel <
CHANNEL_NUM; channel++)
319 for (channel = 0; channel <
CHANNEL_NUM; channel++) {
382 for (channel = 0; channel <
CHANNEL_NUM; channel++)
388 for (channel = 0; channel <
CHANNEL_NUM; channel++)
415 0x1 << 20 | 0x5 << 16 |
425 static void mrs_write(
int channel,
int rank,
u32 mrs_value,
unsigned int dly)
453 u32 bit, dual_rank_set;
634 if (!dual_rank_set) {
694 die(
"set tCKE error in runtime config");
759 u8 testaudpat,
u8 log2loopcount)
763 if (log2loopcount > 15)
764 die(
"Invalid loopcount of engine2!");
782 switch (testaudpat) {
831 if ((testaudpat == 1) || (testaudpat == 2)) {
static void write32(void *addr, uint32_t val)
static uint32_t read32(const void *addr)
#define assert(statement)
#define printk(level,...)
void __noreturn die(const char *fmt,...)
void delay(unsigned int secs)
#define dramc_dbg(_x_...)
#define setbits32(addr, set)
#define clrsetbits32(addr, clear, set)
#define clrbits32(addr, clear)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
void transfer_to_reg_control(void)
static void mem_pll_pre_init(u32 channel)
void mem_pll_init(const struct mt8173_sdram_params *sdram_params)
static void mem_pll_init_set_params(u32 channel)
void dramc_init(u32 channel, const struct mt8173_sdram_params *sdram_params)
static void mrs_write(int channel, int rank, u32 mrs_value, unsigned int dly)
void dramc_pre_init(u32 channel, const struct mt8173_sdram_params *sdram_params)
u8 is_dual_rank(u32 channel, const struct mt8173_sdram_params *sdram_params)
void div2_phase_sync(void)
static void mem_pll_phase_cali(u32 channel)
void transfer_to_spm_control(void)
void dramc_phy_reset(u32 channel)
u32 dramc_engine2(u32 channel, enum dram_tw_op wr, u32 test2_1, u32 test2_2, u8 testaudpat, u8 log2loopcount)
static void pll_phase_adjust(u32 channel, struct mem_pll *mempll, int reg_offs)
static void dramc_set_mrs_value(int channel, int rank, const struct mt8173_sdram_params *sdram_params)
void dramc_runtime_config(u32 channel, const struct mt8173_sdram_params *sdram_params)
static void pll_phase_check(u32 channel, struct mem_pll *mempll, int idx)
static void mem_pll_init_phase_sync(u32 channel)
struct dramc_ddrphy_regs * ddrphy_regs
struct dramc_nao_regs * nao_regs
struct dramc_ao_regs * ao_regs
static struct dramc_channel const ch[2]
@ GDDR3CTL1_RDATRST_SHIFT
@ TEST2_4_TESTAUDBITINV_EN
@ TEST2_4_TESTAUDINC_SHIFT
@ TEST2_4_TESTAUDINIT_SHIFT
@ TEST2_4_TESTAUDINC_MASK
@ TESTRPT_DM_CMP_CPT_SHIFT
@ TEST2_4_TESTAUDINIT_MASK
@ TEST2_4_TESTXTALKPAT_EN
void mt_mem_pll_config_pre(const struct mt8173_sdram_params *sdram_params)
void mt_mem_pll_mux(void)
void mt_mem_pll_config_post(void)
static struct mtk_spm_regs *const mtk_spm
uint32_t jmeter_pll_st[3]
uint32_t mempll05_divider
u32 rx_dq_dly[CHANNEL_NUM][DQS_BIT_NUMBER]
u32 rx_dqs_dly[CHANNEL_NUM]
Defines the SDRAM parameter structure.