diff options
Diffstat (limited to 'drivers/cpufreq/powernow-k6.c')
-rw-r--r-- | drivers/cpufreq/powernow-k6.c | 67 |
1 files changed, 8 insertions, 59 deletions
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c index 85f1c8c25ddc..643e7952cad3 100644 --- a/drivers/cpufreq/powernow-k6.c +++ b/drivers/cpufreq/powernow-k6.c | |||
@@ -63,12 +63,12 @@ static int powernow_k6_get_cpu_multiplier(void) | |||
63 | 63 | ||
64 | 64 | ||
65 | /** | 65 | /** |
66 | * powernow_k6_set_state - set the PowerNow! multiplier | 66 | * powernow_k6_target - set the PowerNow! multiplier |
67 | * @best_i: clock_ratio[best_i] is the target multiplier | 67 | * @best_i: clock_ratio[best_i] is the target multiplier |
68 | * | 68 | * |
69 | * Tries to change the PowerNow! multiplier | 69 | * Tries to change the PowerNow! multiplier |
70 | */ | 70 | */ |
71 | static void powernow_k6_set_state(struct cpufreq_policy *policy, | 71 | static int powernow_k6_target(struct cpufreq_policy *policy, |
72 | unsigned int best_i) | 72 | unsigned int best_i) |
73 | { | 73 | { |
74 | unsigned long outvalue = 0, invalue = 0; | 74 | unsigned long outvalue = 0, invalue = 0; |
@@ -77,7 +77,7 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy, | |||
77 | 77 | ||
78 | if (clock_ratio[best_i].driver_data > max_multiplier) { | 78 | if (clock_ratio[best_i].driver_data > max_multiplier) { |
79 | printk(KERN_ERR PFX "invalid target frequency\n"); | 79 | printk(KERN_ERR PFX "invalid target frequency\n"); |
80 | return; | 80 | return -EINVAL; |
81 | } | 81 | } |
82 | 82 | ||
83 | freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); | 83 | freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); |
@@ -100,44 +100,6 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy, | |||
100 | 100 | ||
101 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 101 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
102 | 102 | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | |||
107 | /** | ||
108 | * powernow_k6_verify - verifies a new CPUfreq policy | ||
109 | * @policy: new policy | ||
110 | * | ||
111 | * Policy must be within lowest and highest possible CPU Frequency, | ||
112 | * and at least one possible state must be within min and max. | ||
113 | */ | ||
114 | static int powernow_k6_verify(struct cpufreq_policy *policy) | ||
115 | { | ||
116 | return cpufreq_frequency_table_verify(policy, &clock_ratio[0]); | ||
117 | } | ||
118 | |||
119 | |||
120 | /** | ||
121 | * powernow_k6_setpolicy - sets a new CPUFreq policy | ||
122 | * @policy: new policy | ||
123 | * @target_freq: the target frequency | ||
124 | * @relation: how that frequency relates to achieved frequency | ||
125 | * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H) | ||
126 | * | ||
127 | * sets a new CPUFreq policy | ||
128 | */ | ||
129 | static int powernow_k6_target(struct cpufreq_policy *policy, | ||
130 | unsigned int target_freq, | ||
131 | unsigned int relation) | ||
132 | { | ||
133 | unsigned int newstate = 0; | ||
134 | |||
135 | if (cpufreq_frequency_table_target(policy, &clock_ratio[0], | ||
136 | target_freq, relation, &newstate)) | ||
137 | return -EINVAL; | ||
138 | |||
139 | powernow_k6_set_state(policy, newstate); | ||
140 | |||
141 | return 0; | 103 | return 0; |
142 | } | 104 | } |
143 | 105 | ||
@@ -145,7 +107,6 @@ static int powernow_k6_target(struct cpufreq_policy *policy, | |||
145 | static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | 107 | static int powernow_k6_cpu_init(struct cpufreq_policy *policy) |
146 | { | 108 | { |
147 | unsigned int i, f; | 109 | unsigned int i, f; |
148 | int result; | ||
149 | 110 | ||
150 | if (policy->cpu != 0) | 111 | if (policy->cpu != 0) |
151 | return -ENODEV; | 112 | return -ENODEV; |
@@ -165,15 +126,8 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | |||
165 | 126 | ||
166 | /* cpuinfo and default policy values */ | 127 | /* cpuinfo and default policy values */ |
167 | policy->cpuinfo.transition_latency = 200000; | 128 | policy->cpuinfo.transition_latency = 200000; |
168 | policy->cur = busfreq * max_multiplier; | ||
169 | |||
170 | result = cpufreq_frequency_table_cpuinfo(policy, clock_ratio); | ||
171 | if (result) | ||
172 | return result; | ||
173 | |||
174 | cpufreq_frequency_table_get_attr(clock_ratio, policy->cpu); | ||
175 | 129 | ||
176 | return 0; | 130 | return cpufreq_table_validate_and_show(policy, clock_ratio); |
177 | } | 131 | } |
178 | 132 | ||
179 | 133 | ||
@@ -182,7 +136,7 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy) | |||
182 | unsigned int i; | 136 | unsigned int i; |
183 | for (i = 0; i < 8; i++) { | 137 | for (i = 0; i < 8; i++) { |
184 | if (i == max_multiplier) | 138 | if (i == max_multiplier) |
185 | powernow_k6_set_state(policy, i); | 139 | powernow_k6_target(policy, i); |
186 | } | 140 | } |
187 | cpufreq_frequency_table_put_attr(policy->cpu); | 141 | cpufreq_frequency_table_put_attr(policy->cpu); |
188 | return 0; | 142 | return 0; |
@@ -195,19 +149,14 @@ static unsigned int powernow_k6_get(unsigned int cpu) | |||
195 | return ret; | 149 | return ret; |
196 | } | 150 | } |
197 | 151 | ||
198 | static struct freq_attr *powernow_k6_attr[] = { | ||
199 | &cpufreq_freq_attr_scaling_available_freqs, | ||
200 | NULL, | ||
201 | }; | ||
202 | |||
203 | static struct cpufreq_driver powernow_k6_driver = { | 152 | static struct cpufreq_driver powernow_k6_driver = { |
204 | .verify = powernow_k6_verify, | 153 | .verify = cpufreq_generic_frequency_table_verify, |
205 | .target = powernow_k6_target, | 154 | .target_index = powernow_k6_target, |
206 | .init = powernow_k6_cpu_init, | 155 | .init = powernow_k6_cpu_init, |
207 | .exit = powernow_k6_cpu_exit, | 156 | .exit = powernow_k6_cpu_exit, |
208 | .get = powernow_k6_get, | 157 | .get = powernow_k6_get, |
209 | .name = "powernow-k6", | 158 | .name = "powernow-k6", |
210 | .attr = powernow_k6_attr, | 159 | .attr = cpufreq_generic_attr, |
211 | }; | 160 | }; |
212 | 161 | ||
213 | static const struct x86_cpu_id powernow_k6_ids[] = { | 162 | static const struct x86_cpu_id powernow_k6_ids[] = { |