aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/mach-at32ap
diff options
context:
space:
mode:
authorHaavard Skinnemoen <haavard.skinnemoen@atmel.com>2008-10-23 05:23:08 -0400
committerHaavard Skinnemoen <haavard.skinnemoen@atmel.com>2008-10-23 09:18:33 -0400
commite3f91ca48162c3eb70450314a4d09384fccb92fa (patch)
tree07da27300068cb64fcc7e79bcdb502359b668ff7 /arch/avr32/mach-at32ap
parent6090065663ba5daab82d116d3040dc924e8cf79f (diff)
avr32: Scale loops_per_jiffy when cpu frequency changes
The loops_per_jiffy variable isn't updated when cpufreq changes the CPU frequency. This could cause udelay() and friends to produce wrong delays. Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Diffstat (limited to 'arch/avr32/mach-at32ap')
-rw-r--r--arch/avr32/mach-at32ap/cpufreq.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/avr32/mach-at32ap/cpufreq.c b/arch/avr32/mach-at32ap/cpufreq.c
index d84efe4984ab..024c586e936c 100644
--- a/arch/avr32/mach-at32ap/cpufreq.c
+++ b/arch/avr32/mach-at32ap/cpufreq.c
@@ -40,6 +40,9 @@ static unsigned int at32_get_speed(unsigned int cpu)
40 return (unsigned int)((clk_get_rate(cpuclk) + 500) / 1000); 40 return (unsigned int)((clk_get_rate(cpuclk) + 500) / 1000);
41} 41}
42 42
43static unsigned int ref_freq;
44static unsigned long loops_per_jiffy_ref;
45
43static int at32_set_target(struct cpufreq_policy *policy, 46static int at32_set_target(struct cpufreq_policy *policy,
44 unsigned int target_freq, 47 unsigned int target_freq,
45 unsigned int relation) 48 unsigned int relation)
@@ -61,8 +64,19 @@ static int at32_set_target(struct cpufreq_policy *policy,
61 freqs.cpu = 0; 64 freqs.cpu = 0;
62 freqs.flags = 0; 65 freqs.flags = 0;
63 66
67 if (!ref_freq) {
68 ref_freq = freqs.old;
69 loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy;
70 }
71
64 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 72 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
73 if (freqs.old < freqs.new)
74 boot_cpu_data.loops_per_jiffy = cpufreq_scale(
75 loops_per_jiffy_ref, ref_freq, freqs.new);
65 clk_set_rate(cpuclk, freq); 76 clk_set_rate(cpuclk, freq);
77 if (freqs.new < freqs.old)
78 boot_cpu_data.loops_per_jiffy = cpufreq_scale(
79 loops_per_jiffy_ref, ref_freq, freqs.new);
66 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 80 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
67 81
68 pr_debug("cpufreq: set frequency %lu Hz\n", freq); 82 pr_debug("cpufreq: set frequency %lu Hz\n", freq);