From: 陈亮 Date: Sun, 4 May 2014 07:34:10 +0000 (-0700) Subject: cpufreq: set core volt to 1.0V when reboot, and make sure core rate will not change... X-Git-Tag: firefly_0821_release~5384 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4cc5af311c35403c6fe6bce846c890dc04902418;p=firefly-linux-kernel-4.4.55.git cpufreq: set core volt to 1.0V when reboot, and make sure core rate will not change any more --- diff --git a/arch/arm/mach-rockchip/ddr_freq.c b/arch/arm/mach-rockchip/ddr_freq.c index c371a042fcaa..41d2d04eeb9e 100755 --- a/arch/arm/mach-rockchip/ddr_freq.c +++ b/arch/arm/mach-rockchip/ddr_freq.c @@ -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); + } } } diff --git a/drivers/cpufreq/rockchip-cpufreq.c b/drivers/cpufreq/rockchip-cpufreq.c index 22a7baedd8a5..c8496eabba66 100644 --- a/drivers/cpufreq/rockchip-cpufreq.c +++ b/drivers/cpufreq/rockchip-cpufreq.c @@ -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; }