rk29: cpufreq: do not set vcore every time
author黄涛 <huangtao@rock-chips.com>
Wed, 26 Jan 2011 12:52:44 +0000 (20:52 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 26 Jan 2011 12:52:44 +0000 (20:52 +0800)
arch/arm/mach-rk29/cpufreq.c

index a1a737d92b9d914daf54a67c996dca03124d66ff..9c62d1c8d26b2e1164338931c163dc3d541aba99 100755 (executable)
@@ -46,6 +46,7 @@ static struct cpufreq_frequency_table freq_table[] = {
 };
 static struct clk *arm_clk;
 static struct regulator *vcore;
+static int vcore_uV;
 
 static int rk29_cpufreq_verify(struct cpufreq_policy *policy)
 {
@@ -96,13 +97,14 @@ static int rk29_cpufreq_target(struct cpufreq_policy *policy, unsigned int targe
        pr_debug("%d r %d (%d-%d) selected %d (%duV)\n", target_freq, relation, policy->min, policy->max, freq->frequency, freq->index);
 
 #ifdef CONFIG_REGULATOR
-       if (vcore && freqs.new > freqs.old) {
+       if (vcore && freqs.new > freqs.old && vcore_uV != freq->index) {
                err = regulator_set_voltage(vcore, freq->index, freq->index);
                if (err) {
                        pr_err("fail to set vcore (%duV) for %dkHz: %d\n",
                                freq->index, freqs.new, err);
                        goto err_vol;
                }
+               vcore_uV = freq->index;
        }
 #endif
 
@@ -112,12 +114,13 @@ static int rk29_cpufreq_target(struct cpufreq_policy *policy, unsigned int targe
        cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
 
 #ifdef CONFIG_REGULATOR
-       if (vcore && freqs.new < freqs.old) {
+       if (vcore && freqs.new < freqs.old && vcore_uV != freq->index) {
                err = regulator_set_voltage(vcore, freq->index, freq->index);
                if (err) {
                        pr_err("fail to set vcore (%duV) for %dkHz: %d\n",
                                freq->index, freqs.new, err);
                }
+               vcore_uV = freq->index;
        }
 #endif