diff options
Diffstat (limited to 'drivers/cpufreq/at32ap-cpufreq.c')
-rw-r--r-- | drivers/cpufreq/at32ap-cpufreq.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c index 7c03dd84f66a..a1c79f549edb 100644 --- a/drivers/cpufreq/at32ap-cpufreq.c +++ b/drivers/cpufreq/at32ap-cpufreq.c | |||
@@ -21,17 +21,8 @@ | |||
21 | #include <linux/export.h> | 21 | #include <linux/export.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | 23 | ||
24 | static struct clk *cpuclk; | ||
25 | static struct cpufreq_frequency_table *freq_table; | 24 | static struct cpufreq_frequency_table *freq_table; |
26 | 25 | ||
27 | static unsigned int at32_get_speed(unsigned int cpu) | ||
28 | { | ||
29 | /* No SMP support */ | ||
30 | if (cpu) | ||
31 | return 0; | ||
32 | return (unsigned int)((clk_get_rate(cpuclk) + 500) / 1000); | ||
33 | } | ||
34 | |||
35 | static unsigned int ref_freq; | 26 | static unsigned int ref_freq; |
36 | static unsigned long loops_per_jiffy_ref; | 27 | static unsigned long loops_per_jiffy_ref; |
37 | 28 | ||
@@ -39,7 +30,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) | |||
39 | { | 30 | { |
40 | unsigned int old_freq, new_freq; | 31 | unsigned int old_freq, new_freq; |
41 | 32 | ||
42 | old_freq = at32_get_speed(0); | 33 | old_freq = policy->cur; |
43 | new_freq = freq_table[index].frequency; | 34 | new_freq = freq_table[index].frequency; |
44 | 35 | ||
45 | if (!ref_freq) { | 36 | if (!ref_freq) { |
@@ -50,7 +41,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) | |||
50 | if (old_freq < new_freq) | 41 | if (old_freq < new_freq) |
51 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( | 42 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( |
52 | loops_per_jiffy_ref, ref_freq, new_freq); | 43 | loops_per_jiffy_ref, ref_freq, new_freq); |
53 | clk_set_rate(cpuclk, new_freq * 1000); | 44 | clk_set_rate(policy->clk, new_freq * 1000); |
54 | if (new_freq < old_freq) | 45 | if (new_freq < old_freq) |
55 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( | 46 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( |
56 | loops_per_jiffy_ref, ref_freq, new_freq); | 47 | loops_per_jiffy_ref, ref_freq, new_freq); |
@@ -61,6 +52,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) | |||
61 | static int at32_cpufreq_driver_init(struct cpufreq_policy *policy) | 52 | static int at32_cpufreq_driver_init(struct cpufreq_policy *policy) |
62 | { | 53 | { |
63 | unsigned int frequency, rate, min_freq; | 54 | unsigned int frequency, rate, min_freq; |
55 | static struct clk *cpuclk; | ||
64 | int retval, steps, i; | 56 | int retval, steps, i; |
65 | 57 | ||
66 | if (policy->cpu != 0) | 58 | if (policy->cpu != 0) |
@@ -103,6 +95,7 @@ static int at32_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
103 | frequency /= 2; | 95 | frequency /= 2; |
104 | } | 96 | } |
105 | 97 | ||
98 | policy->clk = cpuclk; | ||
106 | freq_table[steps - 1].frequency = CPUFREQ_TABLE_END; | 99 | freq_table[steps - 1].frequency = CPUFREQ_TABLE_END; |
107 | 100 | ||
108 | retval = cpufreq_table_validate_and_show(policy, freq_table); | 101 | retval = cpufreq_table_validate_and_show(policy, freq_table); |
@@ -123,7 +116,7 @@ static struct cpufreq_driver at32_driver = { | |||
123 | .init = at32_cpufreq_driver_init, | 116 | .init = at32_cpufreq_driver_init, |
124 | .verify = cpufreq_generic_frequency_table_verify, | 117 | .verify = cpufreq_generic_frequency_table_verify, |
125 | .target_index = at32_set_target, | 118 | .target_index = at32_set_target, |
126 | .get = at32_get_speed, | 119 | .get = cpufreq_generic_get, |
127 | .flags = CPUFREQ_STICKY, | 120 | .flags = CPUFREQ_STICKY, |
128 | }; | 121 | }; |
129 | 122 | ||