aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaro Koskinen <aaro.koskinen@iki.fi>2014-04-03 15:24:01 -0400
committerRalf Baechle <ralf@linux-mips.org>2014-05-12 18:29:41 -0400
commit8e8acb32960f42c81b1d50deac56a2c07bb6a18a (patch)
tree73c8180a1885397ec3c9232b82c1ac0dd3bf1ce9
parent3deff253315effd23fdde86e4d818d8cf3dcc5dc (diff)
MIPS/loongson2_cpufreq: Fix CPU clock rate setting
Loongson2 has been using (incorrectly) kHz for cpu_clk rate. This has been unnoticed, as loongson2_cpufreq was the only place where the rate was set/get. After commit 652ed95d5fa6074b3c4ea245deb0691f1acb6656 (cpufreq: introduce cpufreq_generic_get() routine) things however broke, and now loops_per_jiffy adjustments are incorrect (1000 times too long). The patch fixes this by changing cpu_clk rate to Hz. Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Cc: stable@vger.kernel.org Cc: Rafael J. Wysocki <rjw@rjwysocki.net> Cc: Viresh Kumar <viresh.kumar@linaro.org> Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Cc: cpufreq@vger.kernel.org Cc: Aaro Koskinen <aaro.koskinen@iki.fi> Patchwork: https://patchwork.linux-mips.org/patch/6678/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/loongson/lemote-2f/clock.c5
-rw-r--r--drivers/cpufreq/loongson2_cpufreq.c4
2 files changed, 5 insertions, 4 deletions
diff --git a/arch/mips/loongson/lemote-2f/clock.c b/arch/mips/loongson/lemote-2f/clock.c
index e1f427f4f5f3..67dd94ef28e6 100644
--- a/arch/mips/loongson/lemote-2f/clock.c
+++ b/arch/mips/loongson/lemote-2f/clock.c
@@ -91,6 +91,7 @@ EXPORT_SYMBOL(clk_put);
91 91
92int clk_set_rate(struct clk *clk, unsigned long rate) 92int clk_set_rate(struct clk *clk, unsigned long rate)
93{ 93{
94 unsigned int rate_khz = rate / 1000;
94 int ret = 0; 95 int ret = 0;
95 int regval; 96 int regval;
96 int i; 97 int i;
@@ -111,10 +112,10 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
111 if (loongson2_clockmod_table[i].frequency == 112 if (loongson2_clockmod_table[i].frequency ==
112 CPUFREQ_ENTRY_INVALID) 113 CPUFREQ_ENTRY_INVALID)
113 continue; 114 continue;
114 if (rate == loongson2_clockmod_table[i].frequency) 115 if (rate_khz == loongson2_clockmod_table[i].frequency)
115 break; 116 break;
116 } 117 }
117 if (rate != loongson2_clockmod_table[i].frequency) 118 if (rate_khz != loongson2_clockmod_table[i].frequency)
118 return -ENOTSUPP; 119 return -ENOTSUPP;
119 120
120 clk->rate = rate; 121 clk->rate = rate;
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index f0bc31f5db27..d4add8621944 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -62,7 +62,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
62 set_cpus_allowed_ptr(current, &cpus_allowed); 62 set_cpus_allowed_ptr(current, &cpus_allowed);
63 63
64 /* setting the cpu frequency */ 64 /* setting the cpu frequency */
65 clk_set_rate(policy->clk, freq); 65 clk_set_rate(policy->clk, freq * 1000);
66 66
67 return 0; 67 return 0;
68} 68}
@@ -92,7 +92,7 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
92 i++) 92 i++)
93 loongson2_clockmod_table[i].frequency = (rate * i) / 8; 93 loongson2_clockmod_table[i].frequency = (rate * i) / 8;
94 94
95 ret = clk_set_rate(cpuclk, rate); 95 ret = clk_set_rate(cpuclk, rate * 1000);
96 if (ret) { 96 if (ret) {
97 clk_put(cpuclk); 97 clk_put(cpuclk);
98 return ret; 98 return ret;