cpufreq: set core volt to 1.0V when reboot, and make sure core rate will not change...
author陈亮 <cl@rock-chips.com>
Sun, 4 May 2014 07:34:10 +0000 (00:34 -0700)
committer陈亮 <cl@rock-chips.com>
Sun, 4 May 2014 07:34:48 +0000 (00:34 -0700)
arch/arm/mach-rockchip/ddr_freq.c
drivers/cpufreq/rockchip-cpufreq.c

index c371a042fcaaa227d4450f2990b27a37ccc4f335..41d2d04eeb9efa95d0d8a01b3009087ce8b2f10a 100755 (executable)
@@ -78,6 +78,9 @@ static noinline void ddrfreq_clear_sys_status(int status)
 
 static void ddrfreq_mode(bool auto_self_refresh, unsigned long *target_rate, char *name)
 {
+       unsigned int min_rate, max_rate;
+       int freq_limit_en;
+
        ddr.mode = name;
        if (auto_self_refresh != ddr.auto_self_refresh) {
                ddr_set_auto_self_refresh(auto_self_refresh);
@@ -85,12 +88,17 @@ static void ddrfreq_mode(bool auto_self_refresh, unsigned long *target_rate, cha
                dprintk(DEBUG_DDR, "change auto self refresh to %d when %s\n", auto_self_refresh, name);
        }
        if (*target_rate != dvfs_clk_get_rate(ddr.clk_dvfs_node)) {
+               freq_limit_en = dvfs_clk_get_limit(clk_cpu_dvfs_node, &min_rate, &max_rate);
                dvfs_clk_enable_limit(clk_cpu_dvfs_node, 600000000, -1);
                if (dvfs_clk_set_rate(ddr.clk_dvfs_node, *target_rate) == 0) {
                        *target_rate = dvfs_clk_get_rate(ddr.clk_dvfs_node);
                        dprintk(DEBUG_DDR, "change freq to %lu MHz when %s\n", *target_rate / MHZ, name);
                }
-               dvfs_clk_enable_limit(clk_cpu_dvfs_node, 0, -1);
+               if (freq_limit_en) {
+                       dvfs_clk_enable_limit(clk_cpu_dvfs_node, min_rate, max_rate);
+               } else {
+                       dvfs_clk_disable_limit(clk_cpu_dvfs_node);
+               }
        }
 }
 
index 22a7baedd8a515fe0a10eb8a0381a2020827517c..c8496eabba666138ba4f35c313f4262b2511c93d 100644 (file)
@@ -109,6 +109,7 @@ static unsigned int get_freq_from_table(unsigned int max_freq)
 
 static int cpufreq_notifier_policy(struct notifier_block *nb, unsigned long val, void *data)
 {
+       static unsigned int min_rate=0, max_rate=-1;
        struct cpufreq_policy *policy = data;
 
        if (val != CPUFREQ_ADJUST)
@@ -116,9 +117,10 @@ static int cpufreq_notifier_policy(struct notifier_block *nb, unsigned long val,
 
        if (cpufreq_is_ondemand(policy)) {
                FREQ_DBG("queue work\n");
-               dvfs_clk_enable_limit(clk_cpu_dvfs_node, 0, ~0);
+               dvfs_clk_enable_limit(clk_cpu_dvfs_node, min_rate, max_rate);
        } else {
                FREQ_DBG("cancel work\n");
+               dvfs_clk_get_limit(clk_cpu_dvfs_node, &min_rate, &max_rate);
                dvfs_clk_disable_limit(clk_cpu_dvfs_node);
        }
 
@@ -385,14 +387,10 @@ static struct notifier_block cpufreq_pm_notifier = {
 
 static int cpufreq_reboot_notifier_event(struct notifier_block *this, unsigned long event, void *ptr)
 {
-       struct cpufreq_policy *policy = cpufreq_cpu_get(0);
 
-       if (policy) {
-               is_booting = false;
-               policy->cur++;
-               cpufreq_driver_target(policy, suspend_freq, DISABLE_FURTHER_CPUFREQ | CPUFREQ_RELATION_H);
-               cpufreq_cpu_put(policy);
-       }
+       dvfs_clk_enable_limit(clk_cpu_dvfs_node, 1000*suspend_freq, 1000*suspend_freq);
+       printk("cpufreq: reboot set core rate=%lu, volt=%d\n", dvfs_clk_get_rate(clk_cpu_dvfs_node), 
+               regulator_get_voltage(clk_cpu_dvfs_node->vd->regulator));
 
        return NOTIFY_OK;
 }