diff options
Diffstat (limited to 'arch/x86/kernel/cpu/cpufreq/powernow-k8.c')
-rw-r--r-- | arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 386 |
1 files changed, 233 insertions, 153 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c index 6428aa17b40e..a15ac94e0b9b 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c | |||
@@ -33,16 +33,14 @@ | |||
33 | #include <linux/string.h> | 33 | #include <linux/string.h> |
34 | #include <linux/cpumask.h> | 34 | #include <linux/cpumask.h> |
35 | #include <linux/sched.h> /* for current / set_cpus_allowed() */ | 35 | #include <linux/sched.h> /* for current / set_cpus_allowed() */ |
36 | #include <linux/io.h> | ||
37 | #include <linux/delay.h> | ||
36 | 38 | ||
37 | #include <asm/msr.h> | 39 | #include <asm/msr.h> |
38 | #include <asm/io.h> | ||
39 | #include <asm/delay.h> | ||
40 | 40 | ||
41 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI | ||
42 | #include <linux/acpi.h> | 41 | #include <linux/acpi.h> |
43 | #include <linux/mutex.h> | 42 | #include <linux/mutex.h> |
44 | #include <acpi/processor.h> | 43 | #include <acpi/processor.h> |
45 | #endif | ||
46 | 44 | ||
47 | #define PFX "powernow-k8: " | 45 | #define PFX "powernow-k8: " |
48 | #define VERSION "version 2.20.00" | 46 | #define VERSION "version 2.20.00" |
@@ -71,7 +69,8 @@ static u32 find_khz_freq_from_fid(u32 fid) | |||
71 | return 1000 * find_freq_from_fid(fid); | 69 | return 1000 * find_freq_from_fid(fid); |
72 | } | 70 | } |
73 | 71 | ||
74 | static u32 find_khz_freq_from_pstate(struct cpufreq_frequency_table *data, u32 pstate) | 72 | static u32 find_khz_freq_from_pstate(struct cpufreq_frequency_table *data, |
73 | u32 pstate) | ||
75 | { | 74 | { |
76 | return data[pstate].frequency; | 75 | return data[pstate].frequency; |
77 | } | 76 | } |
@@ -186,7 +185,9 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid) | |||
186 | return 1; | 185 | return 1; |
187 | } | 186 | } |
188 | 187 | ||
189 | lo = fid | (data->currvid << MSR_C_LO_VID_SHIFT) | MSR_C_LO_INIT_FID_VID; | 188 | lo = fid; |
189 | lo |= (data->currvid << MSR_C_LO_VID_SHIFT); | ||
190 | lo |= MSR_C_LO_INIT_FID_VID; | ||
190 | 191 | ||
191 | dprintk("writing fid 0x%x, lo 0x%x, hi 0x%x\n", | 192 | dprintk("writing fid 0x%x, lo 0x%x, hi 0x%x\n", |
192 | fid, lo, data->plllock * PLL_LOCK_CONVERSION); | 193 | fid, lo, data->plllock * PLL_LOCK_CONVERSION); |
@@ -194,7 +195,9 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid) | |||
194 | do { | 195 | do { |
195 | wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION); | 196 | wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION); |
196 | if (i++ > 100) { | 197 | if (i++ > 100) { |
197 | printk(KERN_ERR PFX "Hardware error - pending bit very stuck - no further pstate changes possible\n"); | 198 | printk(KERN_ERR PFX |
199 | "Hardware error - pending bit very stuck - " | ||
200 | "no further pstate changes possible\n"); | ||
198 | return 1; | 201 | return 1; |
199 | } | 202 | } |
200 | } while (query_current_values_with_pending_wait(data)); | 203 | } while (query_current_values_with_pending_wait(data)); |
@@ -202,14 +205,16 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid) | |||
202 | count_off_irt(data); | 205 | count_off_irt(data); |
203 | 206 | ||
204 | if (savevid != data->currvid) { | 207 | if (savevid != data->currvid) { |
205 | printk(KERN_ERR PFX "vid change on fid trans, old 0x%x, new 0x%x\n", | 208 | printk(KERN_ERR PFX |
206 | savevid, data->currvid); | 209 | "vid change on fid trans, old 0x%x, new 0x%x\n", |
210 | savevid, data->currvid); | ||
207 | return 1; | 211 | return 1; |
208 | } | 212 | } |
209 | 213 | ||
210 | if (fid != data->currfid) { | 214 | if (fid != data->currfid) { |
211 | printk(KERN_ERR PFX "fid trans failed, fid 0x%x, curr 0x%x\n", fid, | 215 | printk(KERN_ERR PFX |
212 | data->currfid); | 216 | "fid trans failed, fid 0x%x, curr 0x%x\n", fid, |
217 | data->currfid); | ||
213 | return 1; | 218 | return 1; |
214 | } | 219 | } |
215 | 220 | ||
@@ -228,7 +233,9 @@ static int write_new_vid(struct powernow_k8_data *data, u32 vid) | |||
228 | return 1; | 233 | return 1; |
229 | } | 234 | } |
230 | 235 | ||
231 | lo = data->currfid | (vid << MSR_C_LO_VID_SHIFT) | MSR_C_LO_INIT_FID_VID; | 236 | lo = data->currfid; |
237 | lo |= (vid << MSR_C_LO_VID_SHIFT); | ||
238 | lo |= MSR_C_LO_INIT_FID_VID; | ||
232 | 239 | ||
233 | dprintk("writing vid 0x%x, lo 0x%x, hi 0x%x\n", | 240 | dprintk("writing vid 0x%x, lo 0x%x, hi 0x%x\n", |
234 | vid, lo, STOP_GRANT_5NS); | 241 | vid, lo, STOP_GRANT_5NS); |
@@ -236,20 +243,24 @@ static int write_new_vid(struct powernow_k8_data *data, u32 vid) | |||
236 | do { | 243 | do { |
237 | wrmsr(MSR_FIDVID_CTL, lo, STOP_GRANT_5NS); | 244 | wrmsr(MSR_FIDVID_CTL, lo, STOP_GRANT_5NS); |
238 | if (i++ > 100) { | 245 | if (i++ > 100) { |
239 | printk(KERN_ERR PFX "internal error - pending bit very stuck - no further pstate changes possible\n"); | 246 | printk(KERN_ERR PFX "internal error - pending bit " |
247 | "very stuck - no further pstate " | ||
248 | "changes possible\n"); | ||
240 | return 1; | 249 | return 1; |
241 | } | 250 | } |
242 | } while (query_current_values_with_pending_wait(data)); | 251 | } while (query_current_values_with_pending_wait(data)); |
243 | 252 | ||
244 | if (savefid != data->currfid) { | 253 | if (savefid != data->currfid) { |
245 | printk(KERN_ERR PFX "fid changed on vid trans, old 0x%x new 0x%x\n", | 254 | printk(KERN_ERR PFX "fid changed on vid trans, old " |
255 | "0x%x new 0x%x\n", | ||
246 | savefid, data->currfid); | 256 | savefid, data->currfid); |
247 | return 1; | 257 | return 1; |
248 | } | 258 | } |
249 | 259 | ||
250 | if (vid != data->currvid) { | 260 | if (vid != data->currvid) { |
251 | printk(KERN_ERR PFX "vid trans failed, vid 0x%x, curr 0x%x\n", vid, | 261 | printk(KERN_ERR PFX "vid trans failed, vid 0x%x, " |
252 | data->currvid); | 262 | "curr 0x%x\n", |
263 | vid, data->currvid); | ||
253 | return 1; | 264 | return 1; |
254 | } | 265 | } |
255 | 266 | ||
@@ -261,7 +272,8 @@ static int write_new_vid(struct powernow_k8_data *data, u32 vid) | |||
261 | * Decreasing vid codes represent increasing voltages: | 272 | * Decreasing vid codes represent increasing voltages: |
262 | * vid of 0 is 1.550V, vid of 0x1e is 0.800V, vid of VID_OFF is off. | 273 | * vid of 0 is 1.550V, vid of 0x1e is 0.800V, vid of VID_OFF is off. |
263 | */ | 274 | */ |
264 | static int decrease_vid_code_by_step(struct powernow_k8_data *data, u32 reqvid, u32 step) | 275 | static int decrease_vid_code_by_step(struct powernow_k8_data *data, |
276 | u32 reqvid, u32 step) | ||
265 | { | 277 | { |
266 | if ((data->currvid - reqvid) > step) | 278 | if ((data->currvid - reqvid) > step) |
267 | reqvid = data->currvid - step; | 279 | reqvid = data->currvid - step; |
@@ -283,7 +295,8 @@ static int transition_pstate(struct powernow_k8_data *data, u32 pstate) | |||
283 | } | 295 | } |
284 | 296 | ||
285 | /* Change Opteron/Athlon64 fid and vid, by the 3 phases. */ | 297 | /* Change Opteron/Athlon64 fid and vid, by the 3 phases. */ |
286 | static int transition_fid_vid(struct powernow_k8_data *data, u32 reqfid, u32 reqvid) | 298 | static int transition_fid_vid(struct powernow_k8_data *data, |
299 | u32 reqfid, u32 reqvid) | ||
287 | { | 300 | { |
288 | if (core_voltage_pre_transition(data, reqvid)) | 301 | if (core_voltage_pre_transition(data, reqvid)) |
289 | return 1; | 302 | return 1; |
@@ -298,7 +311,8 @@ static int transition_fid_vid(struct powernow_k8_data *data, u32 reqfid, u32 req | |||
298 | return 1; | 311 | return 1; |
299 | 312 | ||
300 | if ((reqfid != data->currfid) || (reqvid != data->currvid)) { | 313 | if ((reqfid != data->currfid) || (reqvid != data->currvid)) { |
301 | printk(KERN_ERR PFX "failed (cpu%d): req 0x%x 0x%x, curr 0x%x 0x%x\n", | 314 | printk(KERN_ERR PFX "failed (cpu%d): req 0x%x 0x%x, " |
315 | "curr 0x%x 0x%x\n", | ||
302 | smp_processor_id(), | 316 | smp_processor_id(), |
303 | reqfid, reqvid, data->currfid, data->currvid); | 317 | reqfid, reqvid, data->currfid, data->currvid); |
304 | return 1; | 318 | return 1; |
@@ -311,13 +325,15 @@ static int transition_fid_vid(struct powernow_k8_data *data, u32 reqfid, u32 req | |||
311 | } | 325 | } |
312 | 326 | ||
313 | /* Phase 1 - core voltage transition ... setup voltage */ | 327 | /* Phase 1 - core voltage transition ... setup voltage */ |
314 | static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid) | 328 | static int core_voltage_pre_transition(struct powernow_k8_data *data, |
329 | u32 reqvid) | ||
315 | { | 330 | { |
316 | u32 rvosteps = data->rvo; | 331 | u32 rvosteps = data->rvo; |
317 | u32 savefid = data->currfid; | 332 | u32 savefid = data->currfid; |
318 | u32 maxvid, lo; | 333 | u32 maxvid, lo; |
319 | 334 | ||
320 | dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, reqvid 0x%x, rvo 0x%x\n", | 335 | dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, " |
336 | "reqvid 0x%x, rvo 0x%x\n", | ||
321 | smp_processor_id(), | 337 | smp_processor_id(), |
322 | data->currfid, data->currvid, reqvid, data->rvo); | 338 | data->currfid, data->currvid, reqvid, data->rvo); |
323 | 339 | ||
@@ -340,7 +356,7 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid | |||
340 | } else { | 356 | } else { |
341 | dprintk("ph1: changing vid for rvo, req 0x%x\n", | 357 | dprintk("ph1: changing vid for rvo, req 0x%x\n", |
342 | data->currvid - 1); | 358 | data->currvid - 1); |
343 | if (decrease_vid_code_by_step(data, data->currvid - 1, 1)) | 359 | if (decrease_vid_code_by_step(data, data->currvid-1, 1)) |
344 | return 1; | 360 | return 1; |
345 | rvosteps--; | 361 | rvosteps--; |
346 | } | 362 | } |
@@ -350,7 +366,8 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid | |||
350 | return 1; | 366 | return 1; |
351 | 367 | ||
352 | if (savefid != data->currfid) { | 368 | if (savefid != data->currfid) { |
353 | printk(KERN_ERR PFX "ph1 err, currfid changed 0x%x\n", data->currfid); | 369 | printk(KERN_ERR PFX "ph1 err, currfid changed 0x%x\n", |
370 | data->currfid); | ||
354 | return 1; | 371 | return 1; |
355 | } | 372 | } |
356 | 373 | ||
@@ -363,20 +380,24 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid | |||
363 | /* Phase 2 - core frequency transition */ | 380 | /* Phase 2 - core frequency transition */ |
364 | static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) | 381 | static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) |
365 | { | 382 | { |
366 | u32 vcoreqfid, vcocurrfid, vcofiddiff, fid_interval, savevid = data->currvid; | 383 | u32 vcoreqfid, vcocurrfid, vcofiddiff; |
384 | u32 fid_interval, savevid = data->currvid; | ||
367 | 385 | ||
368 | if ((reqfid < HI_FID_TABLE_BOTTOM) && (data->currfid < HI_FID_TABLE_BOTTOM)) { | 386 | if ((reqfid < HI_FID_TABLE_BOTTOM) && |
369 | printk(KERN_ERR PFX "ph2: illegal lo-lo transition 0x%x 0x%x\n", | 387 | (data->currfid < HI_FID_TABLE_BOTTOM)) { |
370 | reqfid, data->currfid); | 388 | printk(KERN_ERR PFX "ph2: illegal lo-lo transition " |
389 | "0x%x 0x%x\n", reqfid, data->currfid); | ||
371 | return 1; | 390 | return 1; |
372 | } | 391 | } |
373 | 392 | ||
374 | if (data->currfid == reqfid) { | 393 | if (data->currfid == reqfid) { |
375 | printk(KERN_ERR PFX "ph2 null fid transition 0x%x\n", data->currfid); | 394 | printk(KERN_ERR PFX "ph2 null fid transition 0x%x\n", |
395 | data->currfid); | ||
376 | return 0; | 396 | return 0; |
377 | } | 397 | } |
378 | 398 | ||
379 | dprintk("ph2 (cpu%d): starting, currfid 0x%x, currvid 0x%x, reqfid 0x%x\n", | 399 | dprintk("ph2 (cpu%d): starting, currfid 0x%x, currvid 0x%x, " |
400 | "reqfid 0x%x\n", | ||
380 | smp_processor_id(), | 401 | smp_processor_id(), |
381 | data->currfid, data->currvid, reqfid); | 402 | data->currfid, data->currvid, reqfid); |
382 | 403 | ||
@@ -390,14 +411,14 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) | |||
390 | 411 | ||
391 | if (reqfid > data->currfid) { | 412 | if (reqfid > data->currfid) { |
392 | if (data->currfid > LO_FID_TABLE_TOP) { | 413 | if (data->currfid > LO_FID_TABLE_TOP) { |
393 | if (write_new_fid(data, data->currfid + fid_interval)) { | 414 | if (write_new_fid(data, |
415 | data->currfid + fid_interval)) | ||
394 | return 1; | 416 | return 1; |
395 | } | ||
396 | } else { | 417 | } else { |
397 | if (write_new_fid | 418 | if (write_new_fid |
398 | (data, 2 + convert_fid_to_vco_fid(data->currfid))) { | 419 | (data, |
420 | 2 + convert_fid_to_vco_fid(data->currfid))) | ||
399 | return 1; | 421 | return 1; |
400 | } | ||
401 | } | 422 | } |
402 | } else { | 423 | } else { |
403 | if (write_new_fid(data, data->currfid - fid_interval)) | 424 | if (write_new_fid(data, data->currfid - fid_interval)) |
@@ -417,7 +438,8 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) | |||
417 | 438 | ||
418 | if (data->currfid != reqfid) { | 439 | if (data->currfid != reqfid) { |
419 | printk(KERN_ERR PFX | 440 | printk(KERN_ERR PFX |
420 | "ph2: mismatch, failed fid transition, curr 0x%x, req 0x%x\n", | 441 | "ph2: mismatch, failed fid transition, " |
442 | "curr 0x%x, req 0x%x\n", | ||
421 | data->currfid, reqfid); | 443 | data->currfid, reqfid); |
422 | return 1; | 444 | return 1; |
423 | } | 445 | } |
@@ -435,7 +457,8 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) | |||
435 | } | 457 | } |
436 | 458 | ||
437 | /* Phase 3 - core voltage transition flow ... jump to the final vid. */ | 459 | /* Phase 3 - core voltage transition flow ... jump to the final vid. */ |
438 | static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvid) | 460 | static int core_voltage_post_transition(struct powernow_k8_data *data, |
461 | u32 reqvid) | ||
439 | { | 462 | { |
440 | u32 savefid = data->currfid; | 463 | u32 savefid = data->currfid; |
441 | u32 savereqvid = reqvid; | 464 | u32 savereqvid = reqvid; |
@@ -457,7 +480,8 @@ static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvi | |||
457 | 480 | ||
458 | if (data->currvid != reqvid) { | 481 | if (data->currvid != reqvid) { |
459 | printk(KERN_ERR PFX | 482 | printk(KERN_ERR PFX |
460 | "ph3: failed vid transition\n, req 0x%x, curr 0x%x", | 483 | "ph3: failed vid transition\n, " |
484 | "req 0x%x, curr 0x%x", | ||
461 | reqvid, data->currvid); | 485 | reqvid, data->currvid); |
462 | return 1; | 486 | return 1; |
463 | } | 487 | } |
@@ -508,7 +532,8 @@ static int check_supported_cpu(unsigned int cpu) | |||
508 | if ((eax & CPUID_XFAM) == CPUID_XFAM_K8) { | 532 | if ((eax & CPUID_XFAM) == CPUID_XFAM_K8) { |
509 | if (((eax & CPUID_USE_XFAM_XMOD) != CPUID_USE_XFAM_XMOD) || | 533 | if (((eax & CPUID_USE_XFAM_XMOD) != CPUID_USE_XFAM_XMOD) || |
510 | ((eax & CPUID_XMOD) > CPUID_XMOD_REV_MASK)) { | 534 | ((eax & CPUID_XMOD) > CPUID_XMOD_REV_MASK)) { |
511 | printk(KERN_INFO PFX "Processor cpuid %x not supported\n", eax); | 535 | printk(KERN_INFO PFX |
536 | "Processor cpuid %x not supported\n", eax); | ||
512 | goto out; | 537 | goto out; |
513 | } | 538 | } |
514 | 539 | ||
@@ -520,8 +545,10 @@ static int check_supported_cpu(unsigned int cpu) | |||
520 | } | 545 | } |
521 | 546 | ||
522 | cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx); | 547 | cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx); |
523 | if ((edx & P_STATE_TRANSITION_CAPABLE) != P_STATE_TRANSITION_CAPABLE) { | 548 | if ((edx & P_STATE_TRANSITION_CAPABLE) |
524 | printk(KERN_INFO PFX "Power state transitions not supported\n"); | 549 | != P_STATE_TRANSITION_CAPABLE) { |
550 | printk(KERN_INFO PFX | ||
551 | "Power state transitions not supported\n"); | ||
525 | goto out; | 552 | goto out; |
526 | } | 553 | } |
527 | } else { /* must be a HW Pstate capable processor */ | 554 | } else { /* must be a HW Pstate capable processor */ |
@@ -539,7 +566,8 @@ out: | |||
539 | return rc; | 566 | return rc; |
540 | } | 567 | } |
541 | 568 | ||
542 | static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 maxvid) | 569 | static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, |
570 | u8 maxvid) | ||
543 | { | 571 | { |
544 | unsigned int j; | 572 | unsigned int j; |
545 | u8 lastfid = 0xff; | 573 | u8 lastfid = 0xff; |
@@ -550,12 +578,14 @@ static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 | |||
550 | j, pst[j].vid); | 578 | j, pst[j].vid); |
551 | return -EINVAL; | 579 | return -EINVAL; |
552 | } | 580 | } |
553 | if (pst[j].vid < data->rvo) { /* vid + rvo >= 0 */ | 581 | if (pst[j].vid < data->rvo) { |
582 | /* vid + rvo >= 0 */ | ||
554 | printk(KERN_ERR FW_BUG PFX "0 vid exceeded with pstate" | 583 | printk(KERN_ERR FW_BUG PFX "0 vid exceeded with pstate" |
555 | " %d\n", j); | 584 | " %d\n", j); |
556 | return -ENODEV; | 585 | return -ENODEV; |
557 | } | 586 | } |
558 | if (pst[j].vid < maxvid + data->rvo) { /* vid + rvo >= maxvid */ | 587 | if (pst[j].vid < maxvid + data->rvo) { |
588 | /* vid + rvo >= maxvid */ | ||
559 | printk(KERN_ERR FW_BUG PFX "maxvid exceeded with pstate" | 589 | printk(KERN_ERR FW_BUG PFX "maxvid exceeded with pstate" |
560 | " %d\n", j); | 590 | " %d\n", j); |
561 | return -ENODEV; | 591 | return -ENODEV; |
@@ -579,23 +609,31 @@ static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 | |||
579 | return -EINVAL; | 609 | return -EINVAL; |
580 | } | 610 | } |
581 | if (lastfid > LO_FID_TABLE_TOP) | 611 | if (lastfid > LO_FID_TABLE_TOP) |
582 | printk(KERN_INFO FW_BUG PFX "first fid not from lo freq table\n"); | 612 | printk(KERN_INFO FW_BUG PFX |
613 | "first fid not from lo freq table\n"); | ||
583 | 614 | ||
584 | return 0; | 615 | return 0; |
585 | } | 616 | } |
586 | 617 | ||
618 | static void invalidate_entry(struct powernow_k8_data *data, unsigned int entry) | ||
619 | { | ||
620 | data->powernow_table[entry].frequency = CPUFREQ_ENTRY_INVALID; | ||
621 | } | ||
622 | |||
587 | static void print_basics(struct powernow_k8_data *data) | 623 | static void print_basics(struct powernow_k8_data *data) |
588 | { | 624 | { |
589 | int j; | 625 | int j; |
590 | for (j = 0; j < data->numps; j++) { | 626 | for (j = 0; j < data->numps; j++) { |
591 | if (data->powernow_table[j].frequency != CPUFREQ_ENTRY_INVALID) { | 627 | if (data->powernow_table[j].frequency != |
628 | CPUFREQ_ENTRY_INVALID) { | ||
592 | if (cpu_family == CPU_HW_PSTATE) { | 629 | if (cpu_family == CPU_HW_PSTATE) { |
593 | printk(KERN_INFO PFX " %d : pstate %d (%d MHz)\n", | 630 | printk(KERN_INFO PFX |
594 | j, | 631 | " %d : pstate %d (%d MHz)\n", j, |
595 | data->powernow_table[j].index, | 632 | data->powernow_table[j].index, |
596 | data->powernow_table[j].frequency/1000); | 633 | data->powernow_table[j].frequency/1000); |
597 | } else { | 634 | } else { |
598 | printk(KERN_INFO PFX " %d : fid 0x%x (%d MHz), vid 0x%x\n", | 635 | printk(KERN_INFO PFX |
636 | " %d : fid 0x%x (%d MHz), vid 0x%x\n", | ||
599 | j, | 637 | j, |
600 | data->powernow_table[j].index & 0xff, | 638 | data->powernow_table[j].index & 0xff, |
601 | data->powernow_table[j].frequency/1000, | 639 | data->powernow_table[j].frequency/1000, |
@@ -604,20 +642,25 @@ static void print_basics(struct powernow_k8_data *data) | |||
604 | } | 642 | } |
605 | } | 643 | } |
606 | if (data->batps) | 644 | if (data->batps) |
607 | printk(KERN_INFO PFX "Only %d pstates on battery\n", data->batps); | 645 | printk(KERN_INFO PFX "Only %d pstates on battery\n", |
646 | data->batps); | ||
608 | } | 647 | } |
609 | 648 | ||
610 | static int fill_powernow_table(struct powernow_k8_data *data, struct pst_s *pst, u8 maxvid) | 649 | static int fill_powernow_table(struct powernow_k8_data *data, |
650 | struct pst_s *pst, u8 maxvid) | ||
611 | { | 651 | { |
612 | struct cpufreq_frequency_table *powernow_table; | 652 | struct cpufreq_frequency_table *powernow_table; |
613 | unsigned int j; | 653 | unsigned int j; |
614 | 654 | ||
615 | if (data->batps) { /* use ACPI support to get full speed on mains power */ | 655 | if (data->batps) { |
616 | printk(KERN_WARNING PFX "Only %d pstates usable (use ACPI driver for full range\n", data->batps); | 656 | /* use ACPI support to get full speed on mains power */ |
657 | printk(KERN_WARNING PFX | ||
658 | "Only %d pstates usable (use ACPI driver for full " | ||
659 | "range\n", data->batps); | ||
617 | data->numps = data->batps; | 660 | data->numps = data->batps; |
618 | } | 661 | } |
619 | 662 | ||
620 | for ( j=1; j<data->numps; j++ ) { | 663 | for (j = 1; j < data->numps; j++) { |
621 | if (pst[j-1].fid >= pst[j].fid) { | 664 | if (pst[j-1].fid >= pst[j].fid) { |
622 | printk(KERN_ERR PFX "PST out of sequence\n"); | 665 | printk(KERN_ERR PFX "PST out of sequence\n"); |
623 | return -EINVAL; | 666 | return -EINVAL; |
@@ -640,9 +683,11 @@ static int fill_powernow_table(struct powernow_k8_data *data, struct pst_s *pst, | |||
640 | } | 683 | } |
641 | 684 | ||
642 | for (j = 0; j < data->numps; j++) { | 685 | for (j = 0; j < data->numps; j++) { |
686 | int freq; | ||
643 | powernow_table[j].index = pst[j].fid; /* lower 8 bits */ | 687 | powernow_table[j].index = pst[j].fid; /* lower 8 bits */ |
644 | powernow_table[j].index |= (pst[j].vid << 8); /* upper 8 bits */ | 688 | powernow_table[j].index |= (pst[j].vid << 8); /* upper 8 bits */ |
645 | powernow_table[j].frequency = find_khz_freq_from_fid(pst[j].fid); | 689 | freq = find_khz_freq_from_fid(pst[j].fid); |
690 | powernow_table[j].frequency = freq; | ||
646 | } | 691 | } |
647 | powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; | 692 | powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; |
648 | powernow_table[data->numps].index = 0; | 693 | powernow_table[data->numps].index = 0; |
@@ -658,7 +703,8 @@ static int fill_powernow_table(struct powernow_k8_data *data, struct pst_s *pst, | |||
658 | print_basics(data); | 703 | print_basics(data); |
659 | 704 | ||
660 | for (j = 0; j < data->numps; j++) | 705 | for (j = 0; j < data->numps; j++) |
661 | if ((pst[j].fid==data->currfid) && (pst[j].vid==data->currvid)) | 706 | if ((pst[j].fid == data->currfid) && |
707 | (pst[j].vid == data->currvid)) | ||
662 | return 0; | 708 | return 0; |
663 | 709 | ||
664 | dprintk("currfid/vid do not match PST, ignoring\n"); | 710 | dprintk("currfid/vid do not match PST, ignoring\n"); |
@@ -698,7 +744,8 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
698 | } | 744 | } |
699 | 745 | ||
700 | data->vstable = psb->vstable; | 746 | data->vstable = psb->vstable; |
701 | dprintk("voltage stabilization time: %d(*20us)\n", data->vstable); | 747 | dprintk("voltage stabilization time: %d(*20us)\n", |
748 | data->vstable); | ||
702 | 749 | ||
703 | dprintk("flags2: 0x%x\n", psb->flags2); | 750 | dprintk("flags2: 0x%x\n", psb->flags2); |
704 | data->rvo = psb->flags2 & 3; | 751 | data->rvo = psb->flags2 & 3; |
@@ -713,11 +760,12 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
713 | 760 | ||
714 | dprintk("numpst: 0x%x\n", psb->num_tables); | 761 | dprintk("numpst: 0x%x\n", psb->num_tables); |
715 | cpst = psb->num_tables; | 762 | cpst = psb->num_tables; |
716 | if ((psb->cpuid == 0x00000fc0) || (psb->cpuid == 0x00000fe0) ){ | 763 | if ((psb->cpuid == 0x00000fc0) || |
764 | (psb->cpuid == 0x00000fe0)) { | ||
717 | thiscpuid = cpuid_eax(CPUID_PROCESSOR_SIGNATURE); | 765 | thiscpuid = cpuid_eax(CPUID_PROCESSOR_SIGNATURE); |
718 | if ((thiscpuid == 0x00000fc0) || (thiscpuid == 0x00000fe0) ) { | 766 | if ((thiscpuid == 0x00000fc0) || |
767 | (thiscpuid == 0x00000fe0)) | ||
719 | cpst = 1; | 768 | cpst = 1; |
720 | } | ||
721 | } | 769 | } |
722 | if (cpst != 1) { | 770 | if (cpst != 1) { |
723 | printk(KERN_ERR FW_BUG PFX "numpst must be 1\n"); | 771 | printk(KERN_ERR FW_BUG PFX "numpst must be 1\n"); |
@@ -732,7 +780,8 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
732 | 780 | ||
733 | data->numps = psb->numps; | 781 | data->numps = psb->numps; |
734 | dprintk("numpstates: 0x%x\n", data->numps); | 782 | dprintk("numpstates: 0x%x\n", data->numps); |
735 | return fill_powernow_table(data, (struct pst_s *)(psb+1), maxvid); | 783 | return fill_powernow_table(data, |
784 | (struct pst_s *)(psb+1), maxvid); | ||
736 | } | 785 | } |
737 | /* | 786 | /* |
738 | * If you see this message, complain to BIOS manufacturer. If | 787 | * If you see this message, complain to BIOS manufacturer. If |
@@ -745,28 +794,31 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
745 | * BIOS and Kernel Developer's Guide, which is available on | 794 | * BIOS and Kernel Developer's Guide, which is available on |
746 | * www.amd.com | 795 | * www.amd.com |
747 | */ | 796 | */ |
748 | printk(KERN_ERR PFX "BIOS error - no PSB or ACPI _PSS objects\n"); | 797 | printk(KERN_ERR FW_BUG PFX "No PSB or ACPI _PSS objects\n"); |
749 | return -ENODEV; | 798 | return -ENODEV; |
750 | } | 799 | } |
751 | 800 | ||
752 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI | 801 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, |
753 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) | 802 | unsigned int index) |
754 | { | 803 | { |
804 | acpi_integer control; | ||
805 | |||
755 | if (!data->acpi_data.state_count || (cpu_family == CPU_HW_PSTATE)) | 806 | if (!data->acpi_data.state_count || (cpu_family == CPU_HW_PSTATE)) |
756 | return; | 807 | return; |
757 | 808 | ||
758 | data->irt = (data->acpi_data.states[index].control >> IRT_SHIFT) & IRT_MASK; | 809 | control = data->acpi_data.states[index].control; data->irt = (control |
759 | data->rvo = (data->acpi_data.states[index].control >> RVO_SHIFT) & RVO_MASK; | 810 | >> IRT_SHIFT) & IRT_MASK; data->rvo = (control >> |
760 | data->exttype = (data->acpi_data.states[index].control >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK; | 811 | RVO_SHIFT) & RVO_MASK; data->exttype = (control |
761 | data->plllock = (data->acpi_data.states[index].control >> PLL_L_SHIFT) & PLL_L_MASK; | 812 | >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK; |
762 | data->vidmvs = 1 << ((data->acpi_data.states[index].control >> MVS_SHIFT) & MVS_MASK); | 813 | data->plllock = (control >> PLL_L_SHIFT) & PLL_L_MASK; data->vidmvs = 1 |
763 | data->vstable = (data->acpi_data.states[index].control >> VST_SHIFT) & VST_MASK; | 814 | << ((control >> MVS_SHIFT) & MVS_MASK); data->vstable = |
764 | } | 815 | (control >> VST_SHIFT) & VST_MASK; } |
765 | 816 | ||
766 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | 817 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) |
767 | { | 818 | { |
768 | struct cpufreq_frequency_table *powernow_table; | 819 | struct cpufreq_frequency_table *powernow_table; |
769 | int ret_val = -ENODEV; | 820 | int ret_val = -ENODEV; |
821 | acpi_integer space_id; | ||
770 | 822 | ||
771 | if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { | 823 | if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { |
772 | dprintk("register performance failed: bad ACPI data\n"); | 824 | dprintk("register performance failed: bad ACPI data\n"); |
@@ -779,11 +831,12 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
779 | goto err_out; | 831 | goto err_out; |
780 | } | 832 | } |
781 | 833 | ||
782 | if ((data->acpi_data.control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) || | 834 | space_id = data->acpi_data.control_register.space_id; |
783 | (data->acpi_data.status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) { | 835 | if ((space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) || |
836 | (space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) { | ||
784 | dprintk("Invalid control/status registers (%x - %x)\n", | 837 | dprintk("Invalid control/status registers (%x - %x)\n", |
785 | data->acpi_data.control_register.space_id, | 838 | data->acpi_data.control_register.space_id, |
786 | data->acpi_data.status_register.space_id); | 839 | space_id); |
787 | goto err_out; | 840 | goto err_out; |
788 | } | 841 | } |
789 | 842 | ||
@@ -802,7 +855,8 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
802 | if (ret_val) | 855 | if (ret_val) |
803 | goto err_out_mem; | 856 | goto err_out_mem; |
804 | 857 | ||
805 | powernow_table[data->acpi_data.state_count].frequency = CPUFREQ_TABLE_END; | 858 | powernow_table[data->acpi_data.state_count].frequency = |
859 | CPUFREQ_TABLE_END; | ||
806 | powernow_table[data->acpi_data.state_count].index = 0; | 860 | powernow_table[data->acpi_data.state_count].index = 0; |
807 | data->powernow_table = powernow_table; | 861 | data->powernow_table = powernow_table; |
808 | 862 | ||
@@ -830,13 +884,15 @@ err_out_mem: | |||
830 | err_out: | 884 | err_out: |
831 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); | 885 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); |
832 | 886 | ||
833 | /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */ | 887 | /* data->acpi_data.state_count informs us at ->exit() |
888 | * whether ACPI was used */ | ||
834 | data->acpi_data.state_count = 0; | 889 | data->acpi_data.state_count = 0; |
835 | 890 | ||
836 | return ret_val; | 891 | return ret_val; |
837 | } | 892 | } |
838 | 893 | ||
839 | static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table) | 894 | static int fill_powernow_table_pstate(struct powernow_k8_data *data, |
895 | struct cpufreq_frequency_table *powernow_table) | ||
840 | { | 896 | { |
841 | int i; | 897 | int i; |
842 | u32 hi = 0, lo = 0; | 898 | u32 hi = 0, lo = 0; |
@@ -848,84 +904,101 @@ static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpuf | |||
848 | 904 | ||
849 | index = data->acpi_data.states[i].control & HW_PSTATE_MASK; | 905 | index = data->acpi_data.states[i].control & HW_PSTATE_MASK; |
850 | if (index > data->max_hw_pstate) { | 906 | if (index > data->max_hw_pstate) { |
851 | printk(KERN_ERR PFX "invalid pstate %d - bad value %d.\n", i, index); | 907 | printk(KERN_ERR PFX "invalid pstate %d - " |
852 | printk(KERN_ERR PFX "Please report to BIOS manufacturer\n"); | 908 | "bad value %d.\n", i, index); |
853 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 909 | printk(KERN_ERR PFX "Please report to BIOS " |
910 | "manufacturer\n"); | ||
911 | invalidate_entry(data, i); | ||
854 | continue; | 912 | continue; |
855 | } | 913 | } |
856 | rdmsr(MSR_PSTATE_DEF_BASE + index, lo, hi); | 914 | rdmsr(MSR_PSTATE_DEF_BASE + index, lo, hi); |
857 | if (!(hi & HW_PSTATE_VALID_MASK)) { | 915 | if (!(hi & HW_PSTATE_VALID_MASK)) { |
858 | dprintk("invalid pstate %d, ignoring\n", index); | 916 | dprintk("invalid pstate %d, ignoring\n", index); |
859 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 917 | invalidate_entry(data, i); |
860 | continue; | 918 | continue; |
861 | } | 919 | } |
862 | 920 | ||
863 | powernow_table[i].index = index; | 921 | powernow_table[i].index = index; |
864 | 922 | ||
865 | powernow_table[i].frequency = data->acpi_data.states[i].core_frequency * 1000; | 923 | powernow_table[i].frequency = |
924 | data->acpi_data.states[i].core_frequency * 1000; | ||
866 | } | 925 | } |
867 | return 0; | 926 | return 0; |
868 | } | 927 | } |
869 | 928 | ||
870 | static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table) | 929 | static int fill_powernow_table_fidvid(struct powernow_k8_data *data, |
930 | struct cpufreq_frequency_table *powernow_table) | ||
871 | { | 931 | { |
872 | int i; | 932 | int i; |
873 | int cntlofreq = 0; | 933 | int cntlofreq = 0; |
934 | |||
874 | for (i = 0; i < data->acpi_data.state_count; i++) { | 935 | for (i = 0; i < data->acpi_data.state_count; i++) { |
875 | u32 fid; | 936 | u32 fid; |
876 | u32 vid; | 937 | u32 vid; |
938 | u32 freq, index; | ||
939 | acpi_integer status, control; | ||
877 | 940 | ||
878 | if (data->exttype) { | 941 | if (data->exttype) { |
879 | fid = data->acpi_data.states[i].status & EXT_FID_MASK; | 942 | status = data->acpi_data.states[i].status; |
880 | vid = (data->acpi_data.states[i].status >> VID_SHIFT) & EXT_VID_MASK; | 943 | fid = status & EXT_FID_MASK; |
944 | vid = (status >> VID_SHIFT) & EXT_VID_MASK; | ||
881 | } else { | 945 | } else { |
882 | fid = data->acpi_data.states[i].control & FID_MASK; | 946 | control = data->acpi_data.states[i].control; |
883 | vid = (data->acpi_data.states[i].control >> VID_SHIFT) & VID_MASK; | 947 | fid = control & FID_MASK; |
948 | vid = (control >> VID_SHIFT) & VID_MASK; | ||
884 | } | 949 | } |
885 | 950 | ||
886 | dprintk(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); | 951 | dprintk(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); |
887 | 952 | ||
888 | powernow_table[i].index = fid; /* lower 8 bits */ | 953 | index = fid | (vid<<8); |
889 | powernow_table[i].index |= (vid << 8); /* upper 8 bits */ | 954 | powernow_table[i].index = index; |
890 | powernow_table[i].frequency = find_khz_freq_from_fid(fid); | 955 | |
956 | freq = find_khz_freq_from_fid(fid); | ||
957 | powernow_table[i].frequency = freq; | ||
891 | 958 | ||
892 | /* verify frequency is OK */ | 959 | /* verify frequency is OK */ |
893 | if ((powernow_table[i].frequency > (MAX_FREQ * 1000)) || | 960 | if ((freq > (MAX_FREQ * 1000)) || (freq < (MIN_FREQ * 1000))) { |
894 | (powernow_table[i].frequency < (MIN_FREQ * 1000))) { | 961 | dprintk("invalid freq %u kHz, ignoring\n", freq); |
895 | dprintk("invalid freq %u kHz, ignoring\n", powernow_table[i].frequency); | 962 | invalidate_entry(data, i); |
896 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | ||
897 | continue; | 963 | continue; |
898 | } | 964 | } |
899 | 965 | ||
900 | /* verify voltage is OK - BIOSs are using "off" to indicate invalid */ | 966 | /* verify voltage is OK - |
967 | * BIOSs are using "off" to indicate invalid */ | ||
901 | if (vid == VID_OFF) { | 968 | if (vid == VID_OFF) { |
902 | dprintk("invalid vid %u, ignoring\n", vid); | 969 | dprintk("invalid vid %u, ignoring\n", vid); |
903 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 970 | invalidate_entry(data, i); |
904 | continue; | 971 | continue; |
905 | } | 972 | } |
906 | 973 | ||
907 | /* verify only 1 entry from the lo frequency table */ | 974 | /* verify only 1 entry from the lo frequency table */ |
908 | if (fid < HI_FID_TABLE_BOTTOM) { | 975 | if (fid < HI_FID_TABLE_BOTTOM) { |
909 | if (cntlofreq) { | 976 | if (cntlofreq) { |
910 | /* if both entries are the same, ignore this one ... */ | 977 | /* if both entries are the same, |
911 | if ((powernow_table[i].frequency != powernow_table[cntlofreq].frequency) || | 978 | * ignore this one ... */ |
912 | (powernow_table[i].index != powernow_table[cntlofreq].index)) { | 979 | if ((freq != powernow_table[cntlofreq].frequency) || |
913 | printk(KERN_ERR PFX "Too many lo freq table entries\n"); | 980 | (index != powernow_table[cntlofreq].index)) { |
981 | printk(KERN_ERR PFX | ||
982 | "Too many lo freq table " | ||
983 | "entries\n"); | ||
914 | return 1; | 984 | return 1; |
915 | } | 985 | } |
916 | 986 | ||
917 | dprintk("double low frequency table entry, ignoring it.\n"); | 987 | dprintk("double low frequency table entry, " |
918 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 988 | "ignoring it.\n"); |
989 | invalidate_entry(data, i); | ||
919 | continue; | 990 | continue; |
920 | } else | 991 | } else |
921 | cntlofreq = i; | 992 | cntlofreq = i; |
922 | } | 993 | } |
923 | 994 | ||
924 | if (powernow_table[i].frequency != (data->acpi_data.states[i].core_frequency * 1000)) { | 995 | if (freq != (data->acpi_data.states[i].core_frequency * 1000)) { |
925 | printk(KERN_INFO PFX "invalid freq entries %u kHz vs. %u kHz\n", | 996 | printk(KERN_INFO PFX "invalid freq entries " |
926 | powernow_table[i].frequency, | 997 | "%u kHz vs. %u kHz\n", freq, |
927 | (unsigned int) (data->acpi_data.states[i].core_frequency * 1000)); | 998 | (unsigned int) |
928 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 999 | (data->acpi_data.states[i].core_frequency |
1000 | * 1000)); | ||
1001 | invalidate_entry(data, i); | ||
929 | continue; | 1002 | continue; |
930 | } | 1003 | } |
931 | } | 1004 | } |
@@ -935,7 +1008,8 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpuf | |||
935 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) | 1008 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) |
936 | { | 1009 | { |
937 | if (data->acpi_data.state_count) | 1010 | if (data->acpi_data.state_count) |
938 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); | 1011 | acpi_processor_unregister_performance(&data->acpi_data, |
1012 | data->cpu); | ||
939 | free_cpumask_var(data->acpi_data.shared_cpu_map); | 1013 | free_cpumask_var(data->acpi_data.shared_cpu_map); |
940 | } | 1014 | } |
941 | 1015 | ||
@@ -953,15 +1027,9 @@ static int get_transition_latency(struct powernow_k8_data *data) | |||
953 | return 1000 * max_latency; | 1027 | return 1000 * max_latency; |
954 | } | 1028 | } |
955 | 1029 | ||
956 | #else | ||
957 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) { return -ENODEV; } | ||
958 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) { return; } | ||
959 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) { return; } | ||
960 | static int get_transition_latency(struct powernow_k8_data *data) { return 0; } | ||
961 | #endif /* CONFIG_X86_POWERNOW_K8_ACPI */ | ||
962 | |||
963 | /* Take a frequency, and issue the fid/vid transition command */ | 1030 | /* Take a frequency, and issue the fid/vid transition command */ |
964 | static int transition_frequency_fidvid(struct powernow_k8_data *data, unsigned int index) | 1031 | static int transition_frequency_fidvid(struct powernow_k8_data *data, |
1032 | unsigned int index) | ||
965 | { | 1033 | { |
966 | u32 fid = 0; | 1034 | u32 fid = 0; |
967 | u32 vid = 0; | 1035 | u32 vid = 0; |
@@ -989,7 +1057,8 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, unsigned i | |||
989 | return 0; | 1057 | return 0; |
990 | } | 1058 | } |
991 | 1059 | ||
992 | if ((fid < HI_FID_TABLE_BOTTOM) && (data->currfid < HI_FID_TABLE_BOTTOM)) { | 1060 | if ((fid < HI_FID_TABLE_BOTTOM) && |
1061 | (data->currfid < HI_FID_TABLE_BOTTOM)) { | ||
993 | printk(KERN_ERR PFX | 1062 | printk(KERN_ERR PFX |
994 | "ignoring illegal change in lo freq table-%x to 0x%x\n", | 1063 | "ignoring illegal change in lo freq table-%x to 0x%x\n", |
995 | data->currfid, fid); | 1064 | data->currfid, fid); |
@@ -1017,7 +1086,8 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, unsigned i | |||
1017 | } | 1086 | } |
1018 | 1087 | ||
1019 | /* Take a frequency, and issue the hardware pstate transition command */ | 1088 | /* Take a frequency, and issue the hardware pstate transition command */ |
1020 | static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned int index) | 1089 | static int transition_frequency_pstate(struct powernow_k8_data *data, |
1090 | unsigned int index) | ||
1021 | { | 1091 | { |
1022 | u32 pstate = 0; | 1092 | u32 pstate = 0; |
1023 | int res, i; | 1093 | int res, i; |
@@ -1029,7 +1099,8 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i | |||
1029 | pstate = index & HW_PSTATE_MASK; | 1099 | pstate = index & HW_PSTATE_MASK; |
1030 | if (pstate > data->max_hw_pstate) | 1100 | if (pstate > data->max_hw_pstate) |
1031 | return 0; | 1101 | return 0; |
1032 | freqs.old = find_khz_freq_from_pstate(data->powernow_table, data->currpstate); | 1102 | freqs.old = find_khz_freq_from_pstate(data->powernow_table, |
1103 | data->currpstate); | ||
1033 | freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate); | 1104 | freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate); |
1034 | 1105 | ||
1035 | for_each_cpu_mask_nr(i, *(data->available_cores)) { | 1106 | for_each_cpu_mask_nr(i, *(data->available_cores)) { |
@@ -1048,7 +1119,8 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i | |||
1048 | } | 1119 | } |
1049 | 1120 | ||
1050 | /* Driver entry point to switch to the target frequency */ | 1121 | /* Driver entry point to switch to the target frequency */ |
1051 | static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation) | 1122 | static int powernowk8_target(struct cpufreq_policy *pol, |
1123 | unsigned targfreq, unsigned relation) | ||
1052 | { | 1124 | { |
1053 | cpumask_t oldmask; | 1125 | cpumask_t oldmask; |
1054 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); | 1126 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); |
@@ -1087,14 +1159,18 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi | |||
1087 | dprintk("targ: curr fid 0x%x, vid 0x%x\n", | 1159 | dprintk("targ: curr fid 0x%x, vid 0x%x\n", |
1088 | data->currfid, data->currvid); | 1160 | data->currfid, data->currvid); |
1089 | 1161 | ||
1090 | if ((checkvid != data->currvid) || (checkfid != data->currfid)) { | 1162 | if ((checkvid != data->currvid) || |
1163 | (checkfid != data->currfid)) { | ||
1091 | printk(KERN_INFO PFX | 1164 | printk(KERN_INFO PFX |
1092 | "error - out of sync, fix 0x%x 0x%x, vid 0x%x 0x%x\n", | 1165 | "error - out of sync, fix 0x%x 0x%x, " |
1093 | checkfid, data->currfid, checkvid, data->currvid); | 1166 | "vid 0x%x 0x%x\n", |
1167 | checkfid, data->currfid, | ||
1168 | checkvid, data->currvid); | ||
1094 | } | 1169 | } |
1095 | } | 1170 | } |
1096 | 1171 | ||
1097 | if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate)) | 1172 | if (cpufreq_frequency_table_target(pol, data->powernow_table, |
1173 | targfreq, relation, &newstate)) | ||
1098 | goto err_out; | 1174 | goto err_out; |
1099 | 1175 | ||
1100 | mutex_lock(&fidvid_mutex); | 1176 | mutex_lock(&fidvid_mutex); |
@@ -1114,7 +1190,8 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi | |||
1114 | mutex_unlock(&fidvid_mutex); | 1190 | mutex_unlock(&fidvid_mutex); |
1115 | 1191 | ||
1116 | if (cpu_family == CPU_HW_PSTATE) | 1192 | if (cpu_family == CPU_HW_PSTATE) |
1117 | pol->cur = find_khz_freq_from_pstate(data->powernow_table, newstate); | 1193 | pol->cur = find_khz_freq_from_pstate(data->powernow_table, |
1194 | newstate); | ||
1118 | else | 1195 | else |
1119 | pol->cur = find_khz_freq_from_fid(data->currfid); | 1196 | pol->cur = find_khz_freq_from_fid(data->currfid); |
1120 | ret = 0; | 1197 | ret = 0; |
@@ -1141,6 +1218,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1141 | struct powernow_k8_data *data; | 1218 | struct powernow_k8_data *data; |
1142 | cpumask_t oldmask; | 1219 | cpumask_t oldmask; |
1143 | int rc; | 1220 | int rc; |
1221 | static int print_once; | ||
1144 | 1222 | ||
1145 | if (!cpu_online(pol->cpu)) | 1223 | if (!cpu_online(pol->cpu)) |
1146 | return -ENODEV; | 1224 | return -ENODEV; |
@@ -1163,33 +1241,31 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1163 | * an UP version, and is deprecated by AMD. | 1241 | * an UP version, and is deprecated by AMD. |
1164 | */ | 1242 | */ |
1165 | if (num_online_cpus() != 1) { | 1243 | if (num_online_cpus() != 1) { |
1166 | #ifndef CONFIG_ACPI_PROCESSOR | 1244 | /* |
1167 | printk(KERN_ERR PFX "ACPI Processor support is required " | 1245 | * Replace this one with print_once as soon as such a |
1168 | "for SMP systems but is absent. Please load the " | 1246 | * thing gets introduced |
1169 | "ACPI Processor module before starting this " | 1247 | */ |
1170 | "driver.\n"); | 1248 | if (!print_once) { |
1171 | #else | 1249 | WARN_ONCE(1, KERN_ERR FW_BUG PFX "Your BIOS " |
1172 | printk(KERN_ERR FW_BUG PFX "Your BIOS does not provide" | 1250 | "does not provide ACPI _PSS objects " |
1173 | " ACPI _PSS objects in a way that Linux " | 1251 | "in a way that Linux understands. " |
1174 | "understands. Please report this to the Linux " | 1252 | "Please report this to the Linux ACPI" |
1175 | "ACPI maintainers and complain to your BIOS " | 1253 | " maintainers and complain to your " |
1176 | "vendor.\n"); | 1254 | "BIOS vendor.\n"); |
1177 | #endif | 1255 | print_once++; |
1178 | kfree(data); | 1256 | } |
1179 | return -ENODEV; | 1257 | goto err_out; |
1180 | } | 1258 | } |
1181 | if (pol->cpu != 0) { | 1259 | if (pol->cpu != 0) { |
1182 | printk(KERN_ERR FW_BUG PFX "No ACPI _PSS objects for " | 1260 | printk(KERN_ERR FW_BUG PFX "No ACPI _PSS objects for " |
1183 | "CPU other than CPU0. Complain to your BIOS " | 1261 | "CPU other than CPU0. Complain to your BIOS " |
1184 | "vendor.\n"); | 1262 | "vendor.\n"); |
1185 | kfree(data); | 1263 | goto err_out; |
1186 | return -ENODEV; | ||
1187 | } | 1264 | } |
1188 | rc = find_psb_table(data); | 1265 | rc = find_psb_table(data); |
1189 | if (rc) { | 1266 | if (rc) |
1190 | kfree(data); | 1267 | goto err_out; |
1191 | return -ENODEV; | 1268 | |
1192 | } | ||
1193 | /* Take a crude guess here. | 1269 | /* Take a crude guess here. |
1194 | * That guess was in microseconds, so multiply with 1000 */ | 1270 | * That guess was in microseconds, so multiply with 1000 */ |
1195 | pol->cpuinfo.transition_latency = ( | 1271 | pol->cpuinfo.transition_latency = ( |
@@ -1204,16 +1280,16 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1204 | 1280 | ||
1205 | if (smp_processor_id() != pol->cpu) { | 1281 | if (smp_processor_id() != pol->cpu) { |
1206 | printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); | 1282 | printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); |
1207 | goto err_out; | 1283 | goto err_out_unmask; |
1208 | } | 1284 | } |
1209 | 1285 | ||
1210 | if (pending_bit_stuck()) { | 1286 | if (pending_bit_stuck()) { |
1211 | printk(KERN_ERR PFX "failing init, change pending bit set\n"); | 1287 | printk(KERN_ERR PFX "failing init, change pending bit set\n"); |
1212 | goto err_out; | 1288 | goto err_out_unmask; |
1213 | } | 1289 | } |
1214 | 1290 | ||
1215 | if (query_current_values_with_pending_wait(data)) | 1291 | if (query_current_values_with_pending_wait(data)) |
1216 | goto err_out; | 1292 | goto err_out_unmask; |
1217 | 1293 | ||
1218 | if (cpu_family == CPU_OPTERON) | 1294 | if (cpu_family == CPU_OPTERON) |
1219 | fidvid_msr_init(); | 1295 | fidvid_msr_init(); |
@@ -1228,7 +1304,8 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1228 | data->available_cores = pol->cpus; | 1304 | data->available_cores = pol->cpus; |
1229 | 1305 | ||
1230 | if (cpu_family == CPU_HW_PSTATE) | 1306 | if (cpu_family == CPU_HW_PSTATE) |
1231 | pol->cur = find_khz_freq_from_pstate(data->powernow_table, data->currpstate); | 1307 | pol->cur = find_khz_freq_from_pstate(data->powernow_table, |
1308 | data->currpstate); | ||
1232 | else | 1309 | else |
1233 | pol->cur = find_khz_freq_from_fid(data->currfid); | 1310 | pol->cur = find_khz_freq_from_fid(data->currfid); |
1234 | dprintk("policy current frequency %d kHz\n", pol->cur); | 1311 | dprintk("policy current frequency %d kHz\n", pol->cur); |
@@ -1245,7 +1322,8 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1245 | cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu); | 1322 | cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu); |
1246 | 1323 | ||
1247 | if (cpu_family == CPU_HW_PSTATE) | 1324 | if (cpu_family == CPU_HW_PSTATE) |
1248 | dprintk("cpu_init done, current pstate 0x%x\n", data->currpstate); | 1325 | dprintk("cpu_init done, current pstate 0x%x\n", |
1326 | data->currpstate); | ||
1249 | else | 1327 | else |
1250 | dprintk("cpu_init done, current fid 0x%x, vid 0x%x\n", | 1328 | dprintk("cpu_init done, current fid 0x%x, vid 0x%x\n", |
1251 | data->currfid, data->currvid); | 1329 | data->currfid, data->currvid); |
@@ -1254,15 +1332,16 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1254 | 1332 | ||
1255 | return 0; | 1333 | return 0; |
1256 | 1334 | ||
1257 | err_out: | 1335 | err_out_unmask: |
1258 | set_cpus_allowed_ptr(current, &oldmask); | 1336 | set_cpus_allowed_ptr(current, &oldmask); |
1259 | powernow_k8_cpu_exit_acpi(data); | 1337 | powernow_k8_cpu_exit_acpi(data); |
1260 | 1338 | ||
1339 | err_out: | ||
1261 | kfree(data); | 1340 | kfree(data); |
1262 | return -ENODEV; | 1341 | return -ENODEV; |
1263 | } | 1342 | } |
1264 | 1343 | ||
1265 | static int __devexit powernowk8_cpu_exit (struct cpufreq_policy *pol) | 1344 | static int __devexit powernowk8_cpu_exit(struct cpufreq_policy *pol) |
1266 | { | 1345 | { |
1267 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); | 1346 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); |
1268 | 1347 | ||
@@ -1279,7 +1358,7 @@ static int __devexit powernowk8_cpu_exit (struct cpufreq_policy *pol) | |||
1279 | return 0; | 1358 | return 0; |
1280 | } | 1359 | } |
1281 | 1360 | ||
1282 | static unsigned int powernowk8_get (unsigned int cpu) | 1361 | static unsigned int powernowk8_get(unsigned int cpu) |
1283 | { | 1362 | { |
1284 | struct powernow_k8_data *data; | 1363 | struct powernow_k8_data *data; |
1285 | cpumask_t oldmask = current->cpus_allowed; | 1364 | cpumask_t oldmask = current->cpus_allowed; |
@@ -1315,7 +1394,7 @@ out: | |||
1315 | return khz; | 1394 | return khz; |
1316 | } | 1395 | } |
1317 | 1396 | ||
1318 | static struct freq_attr* powernow_k8_attr[] = { | 1397 | static struct freq_attr *powernow_k8_attr[] = { |
1319 | &cpufreq_freq_attr_scaling_available_freqs, | 1398 | &cpufreq_freq_attr_scaling_available_freqs, |
1320 | NULL, | 1399 | NULL, |
1321 | }; | 1400 | }; |
@@ -1360,7 +1439,8 @@ static void __exit powernowk8_exit(void) | |||
1360 | cpufreq_unregister_driver(&cpufreq_amd64_driver); | 1439 | cpufreq_unregister_driver(&cpufreq_amd64_driver); |
1361 | } | 1440 | } |
1362 | 1441 | ||
1363 | MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com> and Mark Langsdorf <mark.langsdorf@amd.com>"); | 1442 | MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com> and " |
1443 | "Mark Langsdorf <mark.langsdorf@amd.com>"); | ||
1364 | MODULE_DESCRIPTION("AMD Athlon 64 and Opteron processor frequency driver."); | 1444 | MODULE_DESCRIPTION("AMD Athlon 64 and Opteron processor frequency driver."); |
1365 | MODULE_LICENSE("GPL"); | 1445 | MODULE_LICENSE("GPL"); |
1366 | 1446 | ||