RK3368 DDR: change get ddr freq method
authorTang Yun ping <typ@rock-chips.com>
Thu, 14 May 2015 01:59:10 +0000 (09:59 +0800)
committerTang Yun ping <typ@rock-chips.com>
Thu, 14 May 2015 01:59:10 +0000 (09:59 +0800)
The old method get ddr freq from MCU through mailbox,and new method get ddr
freq from ddrpctl register

Signed-off-by: Tang Yun ping <typ@rock-chips.com>
drivers/devfreq/ddr_rk3368.c

index 56d3b67..7cd74af 100644 (file)
@@ -64,6 +64,16 @@ struct rockchip_ddr {
 
 static struct rockchip_ddr *ddr_data = NULL;
 
+static int _ddr_recalc_rate(void)
+{
+       int ddr_freq;
+
+       regmap_read(ddr_data->ddrpctl_regs, DDR_PCTL_TOGCNT_1U,
+                   &ddr_freq);
+       ddr_freq = ddr_freq * 2 * 1000000;
+       return ddr_freq;
+}
+
 static int _ddr_change_freq(u32 n_mhz)
 {
        u32 ret;
@@ -71,7 +81,7 @@ static int _ddr_change_freq(u32 n_mhz)
        printk(KERN_DEBUG pr_fmt("In func %s,freq=%dMHz\n"), __func__, n_mhz);
        if (scpi_ddr_set_clk_rate(n_mhz))
                pr_info("set ddr freq timeout\n");
-       ret = scpi_ddr_get_clk_rate();
+       ret = _ddr_recalc_rate() / 1000000;
        printk(KERN_DEBUG pr_fmt("Func %s out,freq=%dMHz\n"), __func__, ret);
        return ret;
 }
@@ -81,11 +91,6 @@ static long _ddr_round_rate(u32 n_mhz)
        return (n_mhz / 12) * 12;
 }
 
-static int _ddr_recalc_rate(void)
-{
-       return (1000000 * scpi_ddr_get_clk_rate());
-}
-
 static void _ddr_set_auto_self_refresh(bool en)
 {
        if (scpi_ddr_set_auto_self_refresh(en))