Commit 7998a878 authored by Graf Yang's avatar Graf Yang Committed by Mike Frysinger

Blackfin: scale calibration when cpu freq changes

Need to make sure we update the loops_per_jiffy values when we start
changing the core clock.
Signed-off-by: default avatarGraf Yang <graf.yang@analog.com>
Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
parent f2b0cd61
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/delay.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/time.h> #include <asm/time.h>
#include <asm/dpmc.h> #include <asm/dpmc.h>
...@@ -99,13 +100,15 @@ static unsigned int bfin_getfreq_khz(unsigned int cpu) ...@@ -99,13 +100,15 @@ static unsigned int bfin_getfreq_khz(unsigned int cpu)
return get_cclk() / 1000; return get_cclk() / 1000;
} }
static int bfin_target(struct cpufreq_policy *poli, static int bfin_target(struct cpufreq_policy *poli,
unsigned int target_freq, unsigned int relation) unsigned int target_freq, unsigned int relation)
{ {
unsigned int index, plldiv, cpu; unsigned int index, plldiv, cpu;
unsigned long flags, cclk_hz; unsigned long flags, cclk_hz;
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
static unsigned long lpj_ref;
static unsigned int lpj_ref_freq;
#if defined(CONFIG_CYCLES_CLOCKSOURCE) #if defined(CONFIG_CYCLES_CLOCKSOURCE)
cycles_t cycles; cycles_t cycles;
#endif #endif
...@@ -144,6 +147,14 @@ static int bfin_target(struct cpufreq_policy *poli, ...@@ -144,6 +147,14 @@ static int bfin_target(struct cpufreq_policy *poli,
(cycles << __bfin_cycles_mod) - (cycles << index); (cycles << __bfin_cycles_mod) - (cycles << index);
__bfin_cycles_mod = index; __bfin_cycles_mod = index;
#endif #endif
if (!lpj_ref_freq) {
lpj_ref = loops_per_jiffy;
lpj_ref_freq = freqs.old;
}
if (freqs.new != freqs.old) {
loops_per_jiffy = cpufreq_scale(lpj_ref,
lpj_ref_freq, freqs.new);
}
local_irq_restore_hw(flags); local_irq_restore_hw(flags);
} }
/* TODO: just test case for cycles clock source, remove later */ /* TODO: just test case for cycles clock source, remove later */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment