summaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/p4-clockmod.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/p4-clockmod.c')
-rw-r--r--drivers/cpufreq/p4-clockmod.c53
1 files changed, 7 insertions, 46 deletions
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
index 2f0a2a65c37f..3d1cba9fd5f9 100644
--- a/drivers/cpufreq/p4-clockmod.c
+++ b/drivers/cpufreq/p4-clockmod.c
@@ -105,47 +105,21 @@ static struct cpufreq_frequency_table p4clockmod_table[] = {
105}; 105};
106 106
107 107
108static int cpufreq_p4_target(struct cpufreq_policy *policy, 108static int cpufreq_p4_target(struct cpufreq_policy *policy, unsigned int index)
109 unsigned int target_freq,
110 unsigned int relation)
111{ 109{
112 unsigned int newstate = DC_RESV;
113 struct cpufreq_freqs freqs;
114 int i; 110 int i;
115 111
116 if (cpufreq_frequency_table_target(policy, &p4clockmod_table[0],
117 target_freq, relation, &newstate))
118 return -EINVAL;
119
120 freqs.old = cpufreq_p4_get(policy->cpu);
121 freqs.new = stock_freq * p4clockmod_table[newstate].driver_data / 8;
122
123 if (freqs.new == freqs.old)
124 return 0;
125
126 /* notifiers */
127 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
128
129 /* run on each logical CPU, 112 /* run on each logical CPU,
130 * see section 13.15.3 of IA32 Intel Architecture Software 113 * see section 13.15.3 of IA32 Intel Architecture Software
131 * Developer's Manual, Volume 3 114 * Developer's Manual, Volume 3
132 */ 115 */
133 for_each_cpu(i, policy->cpus) 116 for_each_cpu(i, policy->cpus)
134 cpufreq_p4_setdc(i, p4clockmod_table[newstate].driver_data); 117 cpufreq_p4_setdc(i, p4clockmod_table[index].driver_data);
135
136 /* notifiers */
137 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
138 118
139 return 0; 119 return 0;
140} 120}
141 121
142 122
143static int cpufreq_p4_verify(struct cpufreq_policy *policy)
144{
145 return cpufreq_frequency_table_verify(policy, &p4clockmod_table[0]);
146}
147
148
149static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c) 123static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
150{ 124{
151 if (c->x86 == 0x06) { 125 if (c->x86 == 0x06) {
@@ -230,25 +204,17 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
230 else 204 else
231 p4clockmod_table[i].frequency = (stock_freq * i)/8; 205 p4clockmod_table[i].frequency = (stock_freq * i)/8;
232 } 206 }
233 cpufreq_frequency_table_get_attr(p4clockmod_table, policy->cpu);
234 207
235 /* cpuinfo and default policy values */ 208 /* cpuinfo and default policy values */
236 209
237 /* the transition latency is set to be 1 higher than the maximum 210 /* the transition latency is set to be 1 higher than the maximum
238 * transition latency of the ondemand governor */ 211 * transition latency of the ondemand governor */
239 policy->cpuinfo.transition_latency = 10000001; 212 policy->cpuinfo.transition_latency = 10000001;
240 policy->cur = stock_freq;
241 213
242 return cpufreq_frequency_table_cpuinfo(policy, &p4clockmod_table[0]); 214 return cpufreq_table_validate_and_show(policy, &p4clockmod_table[0]);
243} 215}
244 216
245 217
246static int cpufreq_p4_cpu_exit(struct cpufreq_policy *policy)
247{
248 cpufreq_frequency_table_put_attr(policy->cpu);
249 return 0;
250}
251
252static unsigned int cpufreq_p4_get(unsigned int cpu) 218static unsigned int cpufreq_p4_get(unsigned int cpu)
253{ 219{
254 u32 l, h; 220 u32 l, h;
@@ -267,19 +233,14 @@ static unsigned int cpufreq_p4_get(unsigned int cpu)
267 return stock_freq; 233 return stock_freq;
268} 234}
269 235
270static struct freq_attr *p4clockmod_attr[] = {
271 &cpufreq_freq_attr_scaling_available_freqs,
272 NULL,
273};
274
275static struct cpufreq_driver p4clockmod_driver = { 236static struct cpufreq_driver p4clockmod_driver = {
276 .verify = cpufreq_p4_verify, 237 .verify = cpufreq_generic_frequency_table_verify,
277 .target = cpufreq_p4_target, 238 .target_index = cpufreq_p4_target,
278 .init = cpufreq_p4_cpu_init, 239 .init = cpufreq_p4_cpu_init,
279 .exit = cpufreq_p4_cpu_exit, 240 .exit = cpufreq_generic_exit,
280 .get = cpufreq_p4_get, 241 .get = cpufreq_p4_get,
281 .name = "p4-clockmod", 242 .name = "p4-clockmod",
282 .attr = p4clockmod_attr, 243 .attr = cpufreq_generic_attr,
283}; 244};
284 245
285static const struct x86_cpu_id cpufreq_p4_id[] = { 246static const struct x86_cpu_id cpufreq_p4_id[] = {