};
static struct cpufreq_frequency_table dvfs_ddr_table[] = {
- {.frequency = 300 * 1000, .index = 1050 * 1000},
- {.frequency = 400 * 1000, .index = 1125 * 1000},
+ {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1050 * 1000},
+ {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
+ {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1125 * 1000},
{.frequency = CPUFREQ_TABLE_END},
};
return cpufreq_frequency_table_verify(policy, freq_table);
}
-static int ddr_scale_rate_for_dvfs(struct clk *clk, unsigned long rate, dvfs_set_rate_callback set_rate)
-{
- #if defined (CONFIG_DDR_FREQ)
- ddr_set_rate(rate/(1000*1000));
- #endif
- return 0;
-}
-
static int rk30_cpu_init(struct cpufreq_policy *policy)
{
if (policy->cpu == 0) {
ddr_clk = clk_get(NULL, "ddr");
if (!IS_ERR(ddr_clk))
- {
- dvfs_clk_register_set_rate_callback(ddr_clk, ddr_scale_rate_for_dvfs);
clk_enable_dvfs(ddr_clk);
- }
aclk_vepu_clk = clk_get(NULL, "aclk_vepu");
if (!IS_ERR(aclk_vepu_clk))
uint32_t cs,die=1;
uint32_t calStatusLeft, calStatusRight;
- ddr_print("version 1.00 20121009 \n");
+ ddr_print("version 1.00 20130124 \n");
cs = (1 << (((pGRF_Reg->GRF_OS_REG[1]) >> DDR_RANK_COUNT)&0x1)); //case 0:1rank ; case 1:2rank ;
mem_type = ((pGRF_Reg->GRF_OS_REG[1] >> 13) &0x7);
ddr_speed_bin = dram_speed_bin;
- ddr_freq = freq;
+ ddr_freq = 0;
ddr_sr_idle = 0;
ddr_dll_status = DDR3_DLL_DISABLE;
ddr_get_col(), \
(ddr_get_cap()>>20));
ddr_adjust_config(mem_type);
- value=ddr_change_freq(freq);
+
+ if(freq != 0)
+ value=ddr_change_freq(freq);
+ else
+ value=ddr_change_freq(clk_get_rate(clk_get(NULL, "ddr_pll"))/1000000);
+
clk_set_rate(clk_get(NULL, "ddr_pll"), 0);
- ddr_print("init success!!! freq=%dMHz\n", value);
+ ddr_print("init success!!! freq=%dMHz\n", clk_get_rate(clk_get(NULL, "ddr_pll"))/1000000);
calStatusLeft = pPHY_Reg->PHY_REG60;
calStatusRight = pPHY_Reg->PHY_REG61;
};
static struct cpufreq_frequency_table dvfs_ddr_table[] = {
- {.frequency = 300 * 1000, .index = 1050 * 1000},
- {.frequency = 400 * 1000, .index = 1125 * 1000},
+ {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND, .index = 1050 * 1000},
+ {.frequency = 300 * 1000 + DDR_FREQ_VIDEO, .index = 1050 * 1000},
+ {.frequency = 400 * 1000 + DDR_FREQ_NORMAL, .index = 1125 * 1000},
{.frequency = CPUFREQ_TABLE_END},
};
return -EINVAL;
return cpufreq_frequency_table_verify(policy, freq_table);
}
-
-static int ddr_scale_rate_for_dvfs(struct clk *clk, unsigned long rate, dvfs_set_rate_callback set_rate)
-{
- #if defined (CONFIG_DDR_FREQ)
- ddr_set_rate(rate/(1000*1000));
- #endif
- return 0;
-}
-
static int rk30_cpu_init(struct cpufreq_policy *policy)
{
if (policy->cpu == 0) {
ddr_clk = clk_get(NULL, "ddr");
if (!IS_ERR(ddr_clk))
- {
- dvfs_clk_register_set_rate_callback(ddr_clk, ddr_scale_rate_for_dvfs);
clk_enable_dvfs(ddr_clk);
- //clk_set_rate(ddr_clk,clk_get_rate(ddr_clk)-1);
- }
cpu_clk = clk_get(NULL, "cpu");
uint32_t cs,die=1;
uint32_t gsr,dqstr;
- ddr_print("version 1.00 20130124 \n");
+ ddr_print("version 1.00 20130124-2 \n");
mem_type = pPHY_Reg->DCR.b.DDRMD;
ddr_speed_bin = dram_speed_bin;
- ddr_freq = freq;
+
+ if(freq != 0)
+ ddr_freq = freq;
+ else
+ ddr_freq = clk_get_rate(clk_get(NULL, "ddr_pll"))/1000000;
+
ddr_sr_idle = 0;
switch(mem_type)
{
(ddr_get_cap()>>20));
ddr_adjust_config(mem_type);
- value=ddr_change_freq(freq);
+ if(freq != 0)
+ value=ddr_change_freq(freq);
+ else
+ value=ddr_change_freq(clk_get_rate(clk_get(NULL, "ddr_pll"))/1000000);
+
clk_set_rate(clk_get(NULL, "ddr_pll"), 0);
- ddr_print("init success!!! freq=%dMHz\n", value);
+ ddr_print("init success!!! freq=%dMHz\n", clk_get_rate(clk_get(NULL, "ddr_pll"))/1000000);
for(value=0;value<4;value++)
{
endchoice
+config DDR_INIT_CHANGE_FREQ
+ bool "Enable change DDR frequence when ddr_init"
+ default y
+
config DDR_SDRAM_FREQ
int "DDR SDRAM frequence (in MHz)"
+ depends on DDR_INIT_CHANGE_FREQ
default 400
config DDR_FREQ
bool "Enable DDR frequency scaling"
- select RK_SRAM_DMA if ARCH_RK30
+ select RK_SRAM_DMA if ARCH_RK30XX
config DDR_TEST
bool "DDR Test"
cpu = clk_get(NULL, "cpu");
if (!gpu)
gpu = clk_get(NULL, "gpu");
-
dprintk(DEBUG_VERBOSE, "sys_status %02lx\n", sys_status);
if (ddr.suspend_rate && (s & (1 << SYS_STATUS_SUSPEND))) {
ddrfreq_mode(true, &ddr.suspend_rate, "suspend");
CLK_NOTIFIER(pd_cif0, CIF0);
CLK_NOTIFIER(pd_cif1, CIF1);
+static int ddr_scale_rate_for_dvfs(struct clk *clk, unsigned long rate, dvfs_set_rate_callback set_rate)
+{
+ ddr_set_rate(rate/(1000*1000));
+ return 0;
+}
+
static int ddrfreq_init(void)
{
int i, ret;
pr_err("failed to get ddr clk, error %d\n", ret);
return ret;
}
+ dvfs_clk_register_set_rate_callback(ddr.clk, ddr_scale_rate_for_dvfs);
ddr.normal_rate = clk_get_rate(ddr.clk);
#ifdef CONFIG_DDR_SDRAM_FREQ
#define DDR_FREQ (CONFIG_DDR_SDRAM_FREQ)
#else
-#define DDR_FREQ 360
+#define DDR_FREQ 0
#endif
#define DDR3_800D (0) // 5-5-5