diff options
Diffstat (limited to 'arch/x86/kernel/cpu/cpufreq/powernow-k6.c')
-rw-r--r-- | arch/x86/kernel/cpu/cpufreq/powernow-k6.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k6.c b/arch/x86/kernel/cpu/cpufreq/powernow-k6.c index c1ac5790c63e..f10dea409f40 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k6.c +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k6.c | |||
@@ -1,6 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * This file was based upon code in Powertweak Linux (http://powertweak.sf.net) | 2 | * This file was based upon code in Powertweak Linux (http://powertweak.sf.net) |
3 | * (C) 2000-2003 Dave Jones, Arjan van de Ven, Janne Pänkälä, Dominik Brodowski. | 3 | * (C) 2000-2003 Dave Jones, Arjan van de Ven, Janne Pänkälä, |
4 | * Dominik Brodowski. | ||
4 | * | 5 | * |
5 | * Licensed under the terms of the GNU GPL License version 2. | 6 | * Licensed under the terms of the GNU GPL License version 2. |
6 | * | 7 | * |
@@ -13,14 +14,15 @@ | |||
13 | #include <linux/cpufreq.h> | 14 | #include <linux/cpufreq.h> |
14 | #include <linux/ioport.h> | 15 | #include <linux/ioport.h> |
15 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
16 | |||
17 | #include <asm/msr.h> | ||
18 | #include <linux/timex.h> | 17 | #include <linux/timex.h> |
19 | #include <linux/io.h> | 18 | #include <linux/io.h> |
20 | 19 | ||
20 | #include <asm/msr.h> | ||
21 | |||
21 | #define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long | 22 | #define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long |
22 | as it is unused */ | 23 | as it is unused */ |
23 | 24 | ||
25 | #define PFX "powernow-k6: " | ||
24 | static unsigned int busfreq; /* FSB, in 10 kHz */ | 26 | static unsigned int busfreq; /* FSB, in 10 kHz */ |
25 | static unsigned int max_multiplier; | 27 | static unsigned int max_multiplier; |
26 | 28 | ||
@@ -47,8 +49,8 @@ static struct cpufreq_frequency_table clock_ratio[] = { | |||
47 | */ | 49 | */ |
48 | static int powernow_k6_get_cpu_multiplier(void) | 50 | static int powernow_k6_get_cpu_multiplier(void) |
49 | { | 51 | { |
50 | u64 invalue = 0; | 52 | u64 invalue = 0; |
51 | u32 msrval; | 53 | u32 msrval; |
52 | 54 | ||
53 | msrval = POWERNOW_IOPORT + 0x1; | 55 | msrval = POWERNOW_IOPORT + 0x1; |
54 | wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */ | 56 | wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */ |
@@ -68,12 +70,12 @@ static int powernow_k6_get_cpu_multiplier(void) | |||
68 | */ | 70 | */ |
69 | static void powernow_k6_set_state(unsigned int best_i) | 71 | static void powernow_k6_set_state(unsigned int best_i) |
70 | { | 72 | { |
71 | unsigned long outvalue = 0, invalue = 0; | 73 | unsigned long outvalue = 0, invalue = 0; |
72 | unsigned long msrval; | 74 | unsigned long msrval; |
73 | struct cpufreq_freqs freqs; | 75 | struct cpufreq_freqs freqs; |
74 | 76 | ||
75 | if (clock_ratio[best_i].index > max_multiplier) { | 77 | if (clock_ratio[best_i].index > max_multiplier) { |
76 | printk(KERN_ERR "cpufreq: invalid target frequency\n"); | 78 | printk(KERN_ERR PFX "invalid target frequency\n"); |
77 | return; | 79 | return; |
78 | } | 80 | } |
79 | 81 | ||
@@ -119,7 +121,8 @@ static int powernow_k6_verify(struct cpufreq_policy *policy) | |||
119 | * powernow_k6_setpolicy - sets a new CPUFreq policy | 121 | * powernow_k6_setpolicy - sets a new CPUFreq policy |
120 | * @policy: new policy | 122 | * @policy: new policy |
121 | * @target_freq: the target frequency | 123 | * @target_freq: the target frequency |
122 | * @relation: how that frequency relates to achieved frequency (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H) | 124 | * @relation: how that frequency relates to achieved frequency |
125 | * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H) | ||
123 | * | 126 | * |
124 | * sets a new CPUFreq policy | 127 | * sets a new CPUFreq policy |
125 | */ | 128 | */ |
@@ -127,9 +130,10 @@ static int powernow_k6_target(struct cpufreq_policy *policy, | |||
127 | unsigned int target_freq, | 130 | unsigned int target_freq, |
128 | unsigned int relation) | 131 | unsigned int relation) |
129 | { | 132 | { |
130 | unsigned int newstate = 0; | 133 | unsigned int newstate = 0; |
131 | 134 | ||
132 | if (cpufreq_frequency_table_target(policy, &clock_ratio[0], target_freq, relation, &newstate)) | 135 | if (cpufreq_frequency_table_target(policy, &clock_ratio[0], |
136 | target_freq, relation, &newstate)) | ||
133 | return -EINVAL; | 137 | return -EINVAL; |
134 | 138 | ||
135 | powernow_k6_set_state(newstate); | 139 | powernow_k6_set_state(newstate); |
@@ -140,7 +144,7 @@ static int powernow_k6_target(struct cpufreq_policy *policy, | |||
140 | 144 | ||
141 | static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | 145 | static int powernow_k6_cpu_init(struct cpufreq_policy *policy) |
142 | { | 146 | { |
143 | unsigned int i; | 147 | unsigned int i, f; |
144 | int result; | 148 | int result; |
145 | 149 | ||
146 | if (policy->cpu != 0) | 150 | if (policy->cpu != 0) |
@@ -152,10 +156,11 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | |||
152 | 156 | ||
153 | /* table init */ | 157 | /* table init */ |
154 | for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { | 158 | for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { |
155 | if (clock_ratio[i].index > max_multiplier) | 159 | f = clock_ratio[i].index; |
160 | if (f > max_multiplier) | ||
156 | clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; | 161 | clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; |
157 | else | 162 | else |
158 | clock_ratio[i].frequency = busfreq * clock_ratio[i].index; | 163 | clock_ratio[i].frequency = busfreq * f; |
159 | } | 164 | } |
160 | 165 | ||
161 | /* cpuinfo and default policy values */ | 166 | /* cpuinfo and default policy values */ |
@@ -185,7 +190,9 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy) | |||
185 | 190 | ||
186 | static unsigned int powernow_k6_get(unsigned int cpu) | 191 | static unsigned int powernow_k6_get(unsigned int cpu) |
187 | { | 192 | { |
188 | return busfreq * powernow_k6_get_cpu_multiplier(); | 193 | unsigned int ret; |
194 | ret = (busfreq * powernow_k6_get_cpu_multiplier()); | ||
195 | return ret; | ||
189 | } | 196 | } |
190 | 197 | ||
191 | static struct freq_attr *powernow_k6_attr[] = { | 198 | static struct freq_attr *powernow_k6_attr[] = { |
@@ -221,7 +228,7 @@ static int __init powernow_k6_init(void) | |||
221 | return -ENODEV; | 228 | return -ENODEV; |
222 | 229 | ||
223 | if (!request_region(POWERNOW_IOPORT, 16, "PowerNow!")) { | 230 | if (!request_region(POWERNOW_IOPORT, 16, "PowerNow!")) { |
224 | printk("cpufreq: PowerNow IOPORT region already used.\n"); | 231 | printk(KERN_INFO PFX "PowerNow IOPORT region already used.\n"); |
225 | return -EIO; | 232 | return -EIO; |
226 | } | 233 | } |
227 | 234 | ||
@@ -246,7 +253,8 @@ static void __exit powernow_k6_exit(void) | |||
246 | } | 253 | } |
247 | 254 | ||
248 | 255 | ||
249 | MODULE_AUTHOR("Arjan van de Ven, Dave Jones <davej@redhat.com>, Dominik Brodowski <linux@brodo.de>"); | 256 | MODULE_AUTHOR("Arjan van de Ven, Dave Jones <davej@redhat.com>, " |
257 | "Dominik Brodowski <linux@brodo.de>"); | ||
250 | MODULE_DESCRIPTION("PowerNow! driver for AMD K6-2+ / K6-3+ processors."); | 258 | MODULE_DESCRIPTION("PowerNow! driver for AMD K6-2+ / K6-3+ processors."); |
251 | MODULE_LICENSE("GPL"); | 259 | MODULE_LICENSE("GPL"); |
252 | 260 | ||