aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/ppc_cbe_cpufreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/ppc_cbe_cpufreq.c')
-rw-r--r--drivers/cpufreq/ppc_cbe_cpufreq.c50
1 files changed, 6 insertions, 44 deletions
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
index 2e448f0bbdc5..e42ca9c31cea 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
@@ -30,9 +30,6 @@
30 30
31#include "ppc_cbe_cpufreq.h" 31#include "ppc_cbe_cpufreq.h"
32 32
33static DEFINE_MUTEX(cbe_switch_mutex);
34
35
36/* the CBE supports an 8 step frequency scaling */ 33/* the CBE supports an 8 step frequency scaling */
37static struct cpufreq_frequency_table cbe_freqs[] = { 34static struct cpufreq_frequency_table cbe_freqs[] = {
38 {1, 0}, 35 {1, 0},
@@ -123,63 +120,28 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
123 cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu)); 120 cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu));
124#endif 121#endif
125 122
126 cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);
127
128 /* this ensures that policy->cpuinfo_min 123 /* this ensures that policy->cpuinfo_min
129 * and policy->cpuinfo_max are set correctly */ 124 * and policy->cpuinfo_max are set correctly */
130 return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs); 125 return cpufreq_table_validate_and_show(policy, cbe_freqs);
131}
132
133static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy)
134{
135 cpufreq_frequency_table_put_attr(policy->cpu);
136 return 0;
137}
138
139static int cbe_cpufreq_verify(struct cpufreq_policy *policy)
140{
141 return cpufreq_frequency_table_verify(policy, cbe_freqs);
142} 126}
143 127
144static int cbe_cpufreq_target(struct cpufreq_policy *policy, 128static int cbe_cpufreq_target(struct cpufreq_policy *policy,
145 unsigned int target_freq, 129 unsigned int cbe_pmode_new)
146 unsigned int relation)
147{ 130{
148 int rc;
149 struct cpufreq_freqs freqs;
150 unsigned int cbe_pmode_new;
151
152 cpufreq_frequency_table_target(policy,
153 cbe_freqs,
154 target_freq,
155 relation,
156 &cbe_pmode_new);
157
158 freqs.old = policy->cur;
159 freqs.new = cbe_freqs[cbe_pmode_new].frequency;
160
161 mutex_lock(&cbe_switch_mutex);
162 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
163
164 pr_debug("setting frequency for cpu %d to %d kHz, " \ 131 pr_debug("setting frequency for cpu %d to %d kHz, " \
165 "1/%d of max frequency\n", 132 "1/%d of max frequency\n",
166 policy->cpu, 133 policy->cpu,
167 cbe_freqs[cbe_pmode_new].frequency, 134 cbe_freqs[cbe_pmode_new].frequency,
168 cbe_freqs[cbe_pmode_new].driver_data); 135 cbe_freqs[cbe_pmode_new].driver_data);
169 136
170 rc = set_pmode(policy->cpu, cbe_pmode_new); 137 return set_pmode(policy->cpu, cbe_pmode_new);
171
172 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
173 mutex_unlock(&cbe_switch_mutex);
174
175 return rc;
176} 138}
177 139
178static struct cpufreq_driver cbe_cpufreq_driver = { 140static struct cpufreq_driver cbe_cpufreq_driver = {
179 .verify = cbe_cpufreq_verify, 141 .verify = cpufreq_generic_frequency_table_verify,
180 .target = cbe_cpufreq_target, 142 .target_index = cbe_cpufreq_target,
181 .init = cbe_cpufreq_cpu_init, 143 .init = cbe_cpufreq_cpu_init,
182 .exit = cbe_cpufreq_cpu_exit, 144 .exit = cpufreq_generic_exit,
183 .name = "cbe-cpufreq", 145 .name = "cbe-cpufreq",
184 .flags = CPUFREQ_CONST_LOOPS, 146 .flags = CPUFREQ_CONST_LOOPS,
185}; 147};