aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/mach-at32ap/cpufreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/avr32/mach-at32ap/cpufreq.c')
-rw-r--r--arch/avr32/mach-at32ap/cpufreq.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/arch/avr32/mach-at32ap/cpufreq.c b/arch/avr32/mach-at32ap/cpufreq.c
index 5dd8d25428bf..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);
@@ -87,7 +101,6 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
87 policy->cur = at32_get_speed(0); 101 policy->cur = at32_get_speed(0);
88 policy->min = policy->cpuinfo.min_freq; 102 policy->min = policy->cpuinfo.min_freq;
89 policy->max = policy->cpuinfo.max_freq; 103 policy->max = policy->cpuinfo.max_freq;
90 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
91 104
92 printk("cpufreq: AT32AP CPU frequency driver\n"); 105 printk("cpufreq: AT32AP CPU frequency driver\n");
93 106