diff options
-rw-r--r-- | arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 351 |
1 files changed, 226 insertions, 125 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c index 6428aa17b40e..4dd7e3bdee23 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c | |||
@@ -33,10 +33,10 @@ | |||
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 | 41 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI |
42 | #include <linux/acpi.h> | 42 | #include <linux/acpi.h> |
@@ -71,7 +71,8 @@ static u32 find_khz_freq_from_fid(u32 fid) | |||
71 | return 1000 * find_freq_from_fid(fid); | 71 | return 1000 * find_freq_from_fid(fid); |
72 | } | 72 | } |
73 | 73 | ||
74 | static u32 find_khz_freq_from_pstate(struct cpufreq_frequency_table *data, u32 pstate) | 74 | static u32 find_khz_freq_from_pstate(struct cpufreq_frequency_table *data, |
75 | u32 pstate) | ||
75 | { | 76 | { |
76 | return data[pstate].frequency; | 77 | return data[pstate].frequency; |
77 | } | 78 | } |
@@ -186,7 +187,9 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid) | |||
186 | return 1; | 187 | return 1; |
187 | } | 188 | } |
188 | 189 | ||
189 | lo = fid | (data->currvid << MSR_C_LO_VID_SHIFT) | MSR_C_LO_INIT_FID_VID; | 190 | lo = fid; |
191 | lo |= (data->currvid << MSR_C_LO_VID_SHIFT); | ||
192 | lo |= MSR_C_LO_INIT_FID_VID; | ||
190 | 193 | ||
191 | dprintk("writing fid 0x%x, lo 0x%x, hi 0x%x\n", | 194 | dprintk("writing fid 0x%x, lo 0x%x, hi 0x%x\n", |
192 | fid, lo, data->plllock * PLL_LOCK_CONVERSION); | 195 | fid, lo, data->plllock * PLL_LOCK_CONVERSION); |
@@ -194,7 +197,9 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid) | |||
194 | do { | 197 | do { |
195 | wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION); | 198 | wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION); |
196 | if (i++ > 100) { | 199 | if (i++ > 100) { |
197 | printk(KERN_ERR PFX "Hardware error - pending bit very stuck - no further pstate changes possible\n"); | 200 | printk(KERN_ERR PFX |
201 | "Hardware error - pending bit very stuck - " | ||
202 | "no further pstate changes possible\n"); | ||
198 | return 1; | 203 | return 1; |
199 | } | 204 | } |
200 | } while (query_current_values_with_pending_wait(data)); | 205 | } while (query_current_values_with_pending_wait(data)); |
@@ -202,14 +207,16 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid) | |||
202 | count_off_irt(data); | 207 | count_off_irt(data); |
203 | 208 | ||
204 | if (savevid != data->currvid) { | 209 | if (savevid != data->currvid) { |
205 | printk(KERN_ERR PFX "vid change on fid trans, old 0x%x, new 0x%x\n", | 210 | printk(KERN_ERR PFX |
206 | savevid, data->currvid); | 211 | "vid change on fid trans, old 0x%x, new 0x%x\n", |
212 | savevid, data->currvid); | ||
207 | return 1; | 213 | return 1; |
208 | } | 214 | } |
209 | 215 | ||
210 | if (fid != data->currfid) { | 216 | if (fid != data->currfid) { |
211 | printk(KERN_ERR PFX "fid trans failed, fid 0x%x, curr 0x%x\n", fid, | 217 | printk(KERN_ERR PFX |
212 | data->currfid); | 218 | "fid trans failed, fid 0x%x, curr 0x%x\n", fid, |
219 | data->currfid); | ||
213 | return 1; | 220 | return 1; |
214 | } | 221 | } |
215 | 222 | ||
@@ -228,7 +235,9 @@ static int write_new_vid(struct powernow_k8_data *data, u32 vid) | |||
228 | return 1; | 235 | return 1; |
229 | } | 236 | } |
230 | 237 | ||
231 | lo = data->currfid | (vid << MSR_C_LO_VID_SHIFT) | MSR_C_LO_INIT_FID_VID; | 238 | lo = data->currfid; |
239 | lo |= (vid << MSR_C_LO_VID_SHIFT); | ||
240 | lo |= MSR_C_LO_INIT_FID_VID; | ||
232 | 241 | ||
233 | dprintk("writing vid 0x%x, lo 0x%x, hi 0x%x\n", | 242 | dprintk("writing vid 0x%x, lo 0x%x, hi 0x%x\n", |
234 | vid, lo, STOP_GRANT_5NS); | 243 | vid, lo, STOP_GRANT_5NS); |
@@ -236,20 +245,24 @@ static int write_new_vid(struct powernow_k8_data *data, u32 vid) | |||
236 | do { | 245 | do { |
237 | wrmsr(MSR_FIDVID_CTL, lo, STOP_GRANT_5NS); | 246 | wrmsr(MSR_FIDVID_CTL, lo, STOP_GRANT_5NS); |
238 | if (i++ > 100) { | 247 | if (i++ > 100) { |
239 | printk(KERN_ERR PFX "internal error - pending bit very stuck - no further pstate changes possible\n"); | 248 | printk(KERN_ERR PFX "internal error - pending bit " |
249 | "very stuck - no further pstate " | ||
250 | "changes possible\n"); | ||
240 | return 1; | 251 | return 1; |
241 | } | 252 | } |
242 | } while (query_current_values_with_pending_wait(data)); | 253 | } while (query_current_values_with_pending_wait(data)); |
243 | 254 | ||
244 | if (savefid != data->currfid) { | 255 | if (savefid != data->currfid) { |
245 | printk(KERN_ERR PFX "fid changed on vid trans, old 0x%x new 0x%x\n", | 256 | printk(KERN_ERR PFX "fid changed on vid trans, old " |
257 | "0x%x new 0x%x\n", | ||
246 | savefid, data->currfid); | 258 | savefid, data->currfid); |
247 | return 1; | 259 | return 1; |
248 | } | 260 | } |
249 | 261 | ||
250 | if (vid != data->currvid) { | 262 | if (vid != data->currvid) { |
251 | printk(KERN_ERR PFX "vid trans failed, vid 0x%x, curr 0x%x\n", vid, | 263 | printk(KERN_ERR PFX "vid trans failed, vid 0x%x, " |
252 | data->currvid); | 264 | "curr 0x%x\n", |
265 | vid, data->currvid); | ||
253 | return 1; | 266 | return 1; |
254 | } | 267 | } |
255 | 268 | ||
@@ -261,7 +274,8 @@ static int write_new_vid(struct powernow_k8_data *data, u32 vid) | |||
261 | * Decreasing vid codes represent increasing voltages: | 274 | * 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. | 275 | * vid of 0 is 1.550V, vid of 0x1e is 0.800V, vid of VID_OFF is off. |
263 | */ | 276 | */ |
264 | static int decrease_vid_code_by_step(struct powernow_k8_data *data, u32 reqvid, u32 step) | 277 | static int decrease_vid_code_by_step(struct powernow_k8_data *data, |
278 | u32 reqvid, u32 step) | ||
265 | { | 279 | { |
266 | if ((data->currvid - reqvid) > step) | 280 | if ((data->currvid - reqvid) > step) |
267 | reqvid = data->currvid - step; | 281 | reqvid = data->currvid - step; |
@@ -283,7 +297,8 @@ static int transition_pstate(struct powernow_k8_data *data, u32 pstate) | |||
283 | } | 297 | } |
284 | 298 | ||
285 | /* Change Opteron/Athlon64 fid and vid, by the 3 phases. */ | 299 | /* 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) | 300 | static int transition_fid_vid(struct powernow_k8_data *data, |
301 | u32 reqfid, u32 reqvid) | ||
287 | { | 302 | { |
288 | if (core_voltage_pre_transition(data, reqvid)) | 303 | if (core_voltage_pre_transition(data, reqvid)) |
289 | return 1; | 304 | return 1; |
@@ -298,7 +313,8 @@ static int transition_fid_vid(struct powernow_k8_data *data, u32 reqfid, u32 req | |||
298 | return 1; | 313 | return 1; |
299 | 314 | ||
300 | if ((reqfid != data->currfid) || (reqvid != data->currvid)) { | 315 | 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", | 316 | printk(KERN_ERR PFX "failed (cpu%d): req 0x%x 0x%x, " |
317 | "curr 0x%x 0x%x\n", | ||
302 | smp_processor_id(), | 318 | smp_processor_id(), |
303 | reqfid, reqvid, data->currfid, data->currvid); | 319 | reqfid, reqvid, data->currfid, data->currvid); |
304 | return 1; | 320 | return 1; |
@@ -311,13 +327,15 @@ static int transition_fid_vid(struct powernow_k8_data *data, u32 reqfid, u32 req | |||
311 | } | 327 | } |
312 | 328 | ||
313 | /* Phase 1 - core voltage transition ... setup voltage */ | 329 | /* Phase 1 - core voltage transition ... setup voltage */ |
314 | static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid) | 330 | static int core_voltage_pre_transition(struct powernow_k8_data *data, |
331 | u32 reqvid) | ||
315 | { | 332 | { |
316 | u32 rvosteps = data->rvo; | 333 | u32 rvosteps = data->rvo; |
317 | u32 savefid = data->currfid; | 334 | u32 savefid = data->currfid; |
318 | u32 maxvid, lo; | 335 | u32 maxvid, lo; |
319 | 336 | ||
320 | dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, reqvid 0x%x, rvo 0x%x\n", | 337 | dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, " |
338 | "reqvid 0x%x, rvo 0x%x\n", | ||
321 | smp_processor_id(), | 339 | smp_processor_id(), |
322 | data->currfid, data->currvid, reqvid, data->rvo); | 340 | data->currfid, data->currvid, reqvid, data->rvo); |
323 | 341 | ||
@@ -340,7 +358,7 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid | |||
340 | } else { | 358 | } else { |
341 | dprintk("ph1: changing vid for rvo, req 0x%x\n", | 359 | dprintk("ph1: changing vid for rvo, req 0x%x\n", |
342 | data->currvid - 1); | 360 | data->currvid - 1); |
343 | if (decrease_vid_code_by_step(data, data->currvid - 1, 1)) | 361 | if (decrease_vid_code_by_step(data, data->currvid-1, 1)) |
344 | return 1; | 362 | return 1; |
345 | rvosteps--; | 363 | rvosteps--; |
346 | } | 364 | } |
@@ -350,7 +368,8 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid | |||
350 | return 1; | 368 | return 1; |
351 | 369 | ||
352 | if (savefid != data->currfid) { | 370 | if (savefid != data->currfid) { |
353 | printk(KERN_ERR PFX "ph1 err, currfid changed 0x%x\n", data->currfid); | 371 | printk(KERN_ERR PFX "ph1 err, currfid changed 0x%x\n", |
372 | data->currfid); | ||
354 | return 1; | 373 | return 1; |
355 | } | 374 | } |
356 | 375 | ||
@@ -363,20 +382,24 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid | |||
363 | /* Phase 2 - core frequency transition */ | 382 | /* Phase 2 - core frequency transition */ |
364 | static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) | 383 | static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) |
365 | { | 384 | { |
366 | u32 vcoreqfid, vcocurrfid, vcofiddiff, fid_interval, savevid = data->currvid; | 385 | u32 vcoreqfid, vcocurrfid, vcofiddiff; |
386 | u32 fid_interval, savevid = data->currvid; | ||
367 | 387 | ||
368 | if ((reqfid < HI_FID_TABLE_BOTTOM) && (data->currfid < HI_FID_TABLE_BOTTOM)) { | 388 | if ((reqfid < HI_FID_TABLE_BOTTOM) && |
369 | printk(KERN_ERR PFX "ph2: illegal lo-lo transition 0x%x 0x%x\n", | 389 | (data->currfid < HI_FID_TABLE_BOTTOM)) { |
370 | reqfid, data->currfid); | 390 | printk(KERN_ERR PFX "ph2: illegal lo-lo transition " |
391 | "0x%x 0x%x\n", reqfid, data->currfid); | ||
371 | return 1; | 392 | return 1; |
372 | } | 393 | } |
373 | 394 | ||
374 | if (data->currfid == reqfid) { | 395 | if (data->currfid == reqfid) { |
375 | printk(KERN_ERR PFX "ph2 null fid transition 0x%x\n", data->currfid); | 396 | printk(KERN_ERR PFX "ph2 null fid transition 0x%x\n", |
397 | data->currfid); | ||
376 | return 0; | 398 | return 0; |
377 | } | 399 | } |
378 | 400 | ||
379 | dprintk("ph2 (cpu%d): starting, currfid 0x%x, currvid 0x%x, reqfid 0x%x\n", | 401 | dprintk("ph2 (cpu%d): starting, currfid 0x%x, currvid 0x%x, " |
402 | "reqfid 0x%x\n", | ||
380 | smp_processor_id(), | 403 | smp_processor_id(), |
381 | data->currfid, data->currvid, reqfid); | 404 | data->currfid, data->currvid, reqfid); |
382 | 405 | ||
@@ -390,14 +413,14 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) | |||
390 | 413 | ||
391 | if (reqfid > data->currfid) { | 414 | if (reqfid > data->currfid) { |
392 | if (data->currfid > LO_FID_TABLE_TOP) { | 415 | if (data->currfid > LO_FID_TABLE_TOP) { |
393 | if (write_new_fid(data, data->currfid + fid_interval)) { | 416 | if (write_new_fid(data, |
417 | data->currfid + fid_interval)) | ||
394 | return 1; | 418 | return 1; |
395 | } | ||
396 | } else { | 419 | } else { |
397 | if (write_new_fid | 420 | if (write_new_fid |
398 | (data, 2 + convert_fid_to_vco_fid(data->currfid))) { | 421 | (data, |
422 | 2 + convert_fid_to_vco_fid(data->currfid))) | ||
399 | return 1; | 423 | return 1; |
400 | } | ||
401 | } | 424 | } |
402 | } else { | 425 | } else { |
403 | if (write_new_fid(data, data->currfid - fid_interval)) | 426 | if (write_new_fid(data, data->currfid - fid_interval)) |
@@ -417,7 +440,8 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) | |||
417 | 440 | ||
418 | if (data->currfid != reqfid) { | 441 | if (data->currfid != reqfid) { |
419 | printk(KERN_ERR PFX | 442 | printk(KERN_ERR PFX |
420 | "ph2: mismatch, failed fid transition, curr 0x%x, req 0x%x\n", | 443 | "ph2: mismatch, failed fid transition, " |
444 | "curr 0x%x, req 0x%x\n", | ||
421 | data->currfid, reqfid); | 445 | data->currfid, reqfid); |
422 | return 1; | 446 | return 1; |
423 | } | 447 | } |
@@ -435,7 +459,8 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) | |||
435 | } | 459 | } |
436 | 460 | ||
437 | /* Phase 3 - core voltage transition flow ... jump to the final vid. */ | 461 | /* 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) | 462 | static int core_voltage_post_transition(struct powernow_k8_data *data, |
463 | u32 reqvid) | ||
439 | { | 464 | { |
440 | u32 savefid = data->currfid; | 465 | u32 savefid = data->currfid; |
441 | u32 savereqvid = reqvid; | 466 | u32 savereqvid = reqvid; |
@@ -457,7 +482,8 @@ static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvi | |||
457 | 482 | ||
458 | if (data->currvid != reqvid) { | 483 | if (data->currvid != reqvid) { |
459 | printk(KERN_ERR PFX | 484 | printk(KERN_ERR PFX |
460 | "ph3: failed vid transition\n, req 0x%x, curr 0x%x", | 485 | "ph3: failed vid transition\n, " |
486 | "req 0x%x, curr 0x%x", | ||
461 | reqvid, data->currvid); | 487 | reqvid, data->currvid); |
462 | return 1; | 488 | return 1; |
463 | } | 489 | } |
@@ -508,7 +534,8 @@ static int check_supported_cpu(unsigned int cpu) | |||
508 | if ((eax & CPUID_XFAM) == CPUID_XFAM_K8) { | 534 | if ((eax & CPUID_XFAM) == CPUID_XFAM_K8) { |
509 | if (((eax & CPUID_USE_XFAM_XMOD) != CPUID_USE_XFAM_XMOD) || | 535 | if (((eax & CPUID_USE_XFAM_XMOD) != CPUID_USE_XFAM_XMOD) || |
510 | ((eax & CPUID_XMOD) > CPUID_XMOD_REV_MASK)) { | 536 | ((eax & CPUID_XMOD) > CPUID_XMOD_REV_MASK)) { |
511 | printk(KERN_INFO PFX "Processor cpuid %x not supported\n", eax); | 537 | printk(KERN_INFO PFX |
538 | "Processor cpuid %x not supported\n", eax); | ||
512 | goto out; | 539 | goto out; |
513 | } | 540 | } |
514 | 541 | ||
@@ -520,8 +547,10 @@ static int check_supported_cpu(unsigned int cpu) | |||
520 | } | 547 | } |
521 | 548 | ||
522 | cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx); | 549 | cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx); |
523 | if ((edx & P_STATE_TRANSITION_CAPABLE) != P_STATE_TRANSITION_CAPABLE) { | 550 | if ((edx & P_STATE_TRANSITION_CAPABLE) |
524 | printk(KERN_INFO PFX "Power state transitions not supported\n"); | 551 | != P_STATE_TRANSITION_CAPABLE) { |
552 | printk(KERN_INFO PFX | ||
553 | "Power state transitions not supported\n"); | ||
525 | goto out; | 554 | goto out; |
526 | } | 555 | } |
527 | } else { /* must be a HW Pstate capable processor */ | 556 | } else { /* must be a HW Pstate capable processor */ |
@@ -539,7 +568,8 @@ out: | |||
539 | return rc; | 568 | return rc; |
540 | } | 569 | } |
541 | 570 | ||
542 | static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 maxvid) | 571 | static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, |
572 | u8 maxvid) | ||
543 | { | 573 | { |
544 | unsigned int j; | 574 | unsigned int j; |
545 | u8 lastfid = 0xff; | 575 | u8 lastfid = 0xff; |
@@ -550,12 +580,14 @@ static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 | |||
550 | j, pst[j].vid); | 580 | j, pst[j].vid); |
551 | return -EINVAL; | 581 | return -EINVAL; |
552 | } | 582 | } |
553 | if (pst[j].vid < data->rvo) { /* vid + rvo >= 0 */ | 583 | if (pst[j].vid < data->rvo) { |
584 | /* vid + rvo >= 0 */ | ||
554 | printk(KERN_ERR FW_BUG PFX "0 vid exceeded with pstate" | 585 | printk(KERN_ERR FW_BUG PFX "0 vid exceeded with pstate" |
555 | " %d\n", j); | 586 | " %d\n", j); |
556 | return -ENODEV; | 587 | return -ENODEV; |
557 | } | 588 | } |
558 | if (pst[j].vid < maxvid + data->rvo) { /* vid + rvo >= maxvid */ | 589 | if (pst[j].vid < maxvid + data->rvo) { |
590 | /* vid + rvo >= maxvid */ | ||
559 | printk(KERN_ERR FW_BUG PFX "maxvid exceeded with pstate" | 591 | printk(KERN_ERR FW_BUG PFX "maxvid exceeded with pstate" |
560 | " %d\n", j); | 592 | " %d\n", j); |
561 | return -ENODEV; | 593 | return -ENODEV; |
@@ -579,23 +611,31 @@ static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 | |||
579 | return -EINVAL; | 611 | return -EINVAL; |
580 | } | 612 | } |
581 | if (lastfid > LO_FID_TABLE_TOP) | 613 | if (lastfid > LO_FID_TABLE_TOP) |
582 | printk(KERN_INFO FW_BUG PFX "first fid not from lo freq table\n"); | 614 | printk(KERN_INFO FW_BUG PFX |
615 | "first fid not from lo freq table\n"); | ||
583 | 616 | ||
584 | return 0; | 617 | return 0; |
585 | } | 618 | } |
586 | 619 | ||
620 | static void invalidate_entry(struct powernow_k8_data *data, unsigned int entry) | ||
621 | { | ||
622 | data->powernow_table[entry].frequency = CPUFREQ_ENTRY_INVALID; | ||
623 | } | ||
624 | |||
587 | static void print_basics(struct powernow_k8_data *data) | 625 | static void print_basics(struct powernow_k8_data *data) |
588 | { | 626 | { |
589 | int j; | 627 | int j; |
590 | for (j = 0; j < data->numps; j++) { | 628 | for (j = 0; j < data->numps; j++) { |
591 | if (data->powernow_table[j].frequency != CPUFREQ_ENTRY_INVALID) { | 629 | if (data->powernow_table[j].frequency != |
630 | CPUFREQ_ENTRY_INVALID) { | ||
592 | if (cpu_family == CPU_HW_PSTATE) { | 631 | if (cpu_family == CPU_HW_PSTATE) { |
593 | printk(KERN_INFO PFX " %d : pstate %d (%d MHz)\n", | 632 | printk(KERN_INFO PFX |
594 | j, | 633 | " %d : pstate %d (%d MHz)\n", j, |
595 | data->powernow_table[j].index, | 634 | data->powernow_table[j].index, |
596 | data->powernow_table[j].frequency/1000); | 635 | data->powernow_table[j].frequency/1000); |
597 | } else { | 636 | } else { |
598 | printk(KERN_INFO PFX " %d : fid 0x%x (%d MHz), vid 0x%x\n", | 637 | printk(KERN_INFO PFX |
638 | " %d : fid 0x%x (%d MHz), vid 0x%x\n", | ||
599 | j, | 639 | j, |
600 | data->powernow_table[j].index & 0xff, | 640 | data->powernow_table[j].index & 0xff, |
601 | data->powernow_table[j].frequency/1000, | 641 | data->powernow_table[j].frequency/1000, |
@@ -604,20 +644,25 @@ static void print_basics(struct powernow_k8_data *data) | |||
604 | } | 644 | } |
605 | } | 645 | } |
606 | if (data->batps) | 646 | if (data->batps) |
607 | printk(KERN_INFO PFX "Only %d pstates on battery\n", data->batps); | 647 | printk(KERN_INFO PFX "Only %d pstates on battery\n", |
648 | data->batps); | ||
608 | } | 649 | } |
609 | 650 | ||
610 | static int fill_powernow_table(struct powernow_k8_data *data, struct pst_s *pst, u8 maxvid) | 651 | static int fill_powernow_table(struct powernow_k8_data *data, |
652 | struct pst_s *pst, u8 maxvid) | ||
611 | { | 653 | { |
612 | struct cpufreq_frequency_table *powernow_table; | 654 | struct cpufreq_frequency_table *powernow_table; |
613 | unsigned int j; | 655 | unsigned int j; |
614 | 656 | ||
615 | if (data->batps) { /* use ACPI support to get full speed on mains power */ | 657 | if (data->batps) { |
616 | printk(KERN_WARNING PFX "Only %d pstates usable (use ACPI driver for full range\n", data->batps); | 658 | /* use ACPI support to get full speed on mains power */ |
659 | printk(KERN_WARNING PFX | ||
660 | "Only %d pstates usable (use ACPI driver for full " | ||
661 | "range\n", data->batps); | ||
617 | data->numps = data->batps; | 662 | data->numps = data->batps; |
618 | } | 663 | } |
619 | 664 | ||
620 | for ( j=1; j<data->numps; j++ ) { | 665 | for (j = 1; j < data->numps; j++) { |
621 | if (pst[j-1].fid >= pst[j].fid) { | 666 | if (pst[j-1].fid >= pst[j].fid) { |
622 | printk(KERN_ERR PFX "PST out of sequence\n"); | 667 | printk(KERN_ERR PFX "PST out of sequence\n"); |
623 | return -EINVAL; | 668 | return -EINVAL; |
@@ -640,9 +685,11 @@ static int fill_powernow_table(struct powernow_k8_data *data, struct pst_s *pst, | |||
640 | } | 685 | } |
641 | 686 | ||
642 | for (j = 0; j < data->numps; j++) { | 687 | for (j = 0; j < data->numps; j++) { |
688 | int freq; | ||
643 | powernow_table[j].index = pst[j].fid; /* lower 8 bits */ | 689 | powernow_table[j].index = pst[j].fid; /* lower 8 bits */ |
644 | powernow_table[j].index |= (pst[j].vid << 8); /* upper 8 bits */ | 690 | powernow_table[j].index |= (pst[j].vid << 8); /* upper 8 bits */ |
645 | powernow_table[j].frequency = find_khz_freq_from_fid(pst[j].fid); | 691 | freq = find_khz_freq_from_fid(pst[j].fid); |
692 | powernow_table[j].frequency = freq; | ||
646 | } | 693 | } |
647 | powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; | 694 | powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; |
648 | powernow_table[data->numps].index = 0; | 695 | powernow_table[data->numps].index = 0; |
@@ -658,7 +705,8 @@ static int fill_powernow_table(struct powernow_k8_data *data, struct pst_s *pst, | |||
658 | print_basics(data); | 705 | print_basics(data); |
659 | 706 | ||
660 | for (j = 0; j < data->numps; j++) | 707 | for (j = 0; j < data->numps; j++) |
661 | if ((pst[j].fid==data->currfid) && (pst[j].vid==data->currvid)) | 708 | if ((pst[j].fid == data->currfid) && |
709 | (pst[j].vid == data->currvid)) | ||
662 | return 0; | 710 | return 0; |
663 | 711 | ||
664 | dprintk("currfid/vid do not match PST, ignoring\n"); | 712 | dprintk("currfid/vid do not match PST, ignoring\n"); |
@@ -698,7 +746,8 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
698 | } | 746 | } |
699 | 747 | ||
700 | data->vstable = psb->vstable; | 748 | data->vstable = psb->vstable; |
701 | dprintk("voltage stabilization time: %d(*20us)\n", data->vstable); | 749 | dprintk("voltage stabilization time: %d(*20us)\n", |
750 | data->vstable); | ||
702 | 751 | ||
703 | dprintk("flags2: 0x%x\n", psb->flags2); | 752 | dprintk("flags2: 0x%x\n", psb->flags2); |
704 | data->rvo = psb->flags2 & 3; | 753 | data->rvo = psb->flags2 & 3; |
@@ -713,11 +762,12 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
713 | 762 | ||
714 | dprintk("numpst: 0x%x\n", psb->num_tables); | 763 | dprintk("numpst: 0x%x\n", psb->num_tables); |
715 | cpst = psb->num_tables; | 764 | cpst = psb->num_tables; |
716 | if ((psb->cpuid == 0x00000fc0) || (psb->cpuid == 0x00000fe0) ){ | 765 | if ((psb->cpuid == 0x00000fc0) || |
766 | (psb->cpuid == 0x00000fe0)) { | ||
717 | thiscpuid = cpuid_eax(CPUID_PROCESSOR_SIGNATURE); | 767 | thiscpuid = cpuid_eax(CPUID_PROCESSOR_SIGNATURE); |
718 | if ((thiscpuid == 0x00000fc0) || (thiscpuid == 0x00000fe0) ) { | 768 | if ((thiscpuid == 0x00000fc0) || |
769 | (thiscpuid == 0x00000fe0)) | ||
719 | cpst = 1; | 770 | cpst = 1; |
720 | } | ||
721 | } | 771 | } |
722 | if (cpst != 1) { | 772 | if (cpst != 1) { |
723 | printk(KERN_ERR FW_BUG PFX "numpst must be 1\n"); | 773 | printk(KERN_ERR FW_BUG PFX "numpst must be 1\n"); |
@@ -732,7 +782,8 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
732 | 782 | ||
733 | data->numps = psb->numps; | 783 | data->numps = psb->numps; |
734 | dprintk("numpstates: 0x%x\n", data->numps); | 784 | dprintk("numpstates: 0x%x\n", data->numps); |
735 | return fill_powernow_table(data, (struct pst_s *)(psb+1), maxvid); | 785 | return fill_powernow_table(data, |
786 | (struct pst_s *)(psb+1), maxvid); | ||
736 | } | 787 | } |
737 | /* | 788 | /* |
738 | * If you see this message, complain to BIOS manufacturer. If | 789 | * If you see this message, complain to BIOS manufacturer. If |
@@ -750,23 +801,27 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
750 | } | 801 | } |
751 | 802 | ||
752 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI | 803 | #ifdef CONFIG_X86_POWERNOW_K8_ACPI |
753 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) | 804 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, |
805 | unsigned int index) | ||
754 | { | 806 | { |
807 | acpi_integer control; | ||
808 | |||
755 | if (!data->acpi_data.state_count || (cpu_family == CPU_HW_PSTATE)) | 809 | if (!data->acpi_data.state_count || (cpu_family == CPU_HW_PSTATE)) |
756 | return; | 810 | return; |
757 | 811 | ||
758 | data->irt = (data->acpi_data.states[index].control >> IRT_SHIFT) & IRT_MASK; | 812 | control = data->acpi_data.states[index].control; data->irt = (control |
759 | data->rvo = (data->acpi_data.states[index].control >> RVO_SHIFT) & RVO_MASK; | 813 | >> IRT_SHIFT) & IRT_MASK; data->rvo = (control >> |
760 | data->exttype = (data->acpi_data.states[index].control >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK; | 814 | RVO_SHIFT) & RVO_MASK; data->exttype = (control |
761 | data->plllock = (data->acpi_data.states[index].control >> PLL_L_SHIFT) & PLL_L_MASK; | 815 | >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK; |
762 | data->vidmvs = 1 << ((data->acpi_data.states[index].control >> MVS_SHIFT) & MVS_MASK); | 816 | 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; | 817 | << ((control >> MVS_SHIFT) & MVS_MASK); data->vstable = |
764 | } | 818 | (control >> VST_SHIFT) & VST_MASK; } |
765 | 819 | ||
766 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | 820 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) |
767 | { | 821 | { |
768 | struct cpufreq_frequency_table *powernow_table; | 822 | struct cpufreq_frequency_table *powernow_table; |
769 | int ret_val = -ENODEV; | 823 | int ret_val = -ENODEV; |
824 | acpi_integer space_id; | ||
770 | 825 | ||
771 | if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { | 826 | if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { |
772 | dprintk("register performance failed: bad ACPI data\n"); | 827 | dprintk("register performance failed: bad ACPI data\n"); |
@@ -779,11 +834,12 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
779 | goto err_out; | 834 | goto err_out; |
780 | } | 835 | } |
781 | 836 | ||
782 | if ((data->acpi_data.control_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) || | 837 | space_id = data->acpi_data.control_register.space_id; |
783 | (data->acpi_data.status_register.space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) { | 838 | if ((space_id != ACPI_ADR_SPACE_FIXED_HARDWARE) || |
839 | (space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) { | ||
784 | dprintk("Invalid control/status registers (%x - %x)\n", | 840 | dprintk("Invalid control/status registers (%x - %x)\n", |
785 | data->acpi_data.control_register.space_id, | 841 | data->acpi_data.control_register.space_id, |
786 | data->acpi_data.status_register.space_id); | 842 | space_id); |
787 | goto err_out; | 843 | goto err_out; |
788 | } | 844 | } |
789 | 845 | ||
@@ -802,7 +858,8 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
802 | if (ret_val) | 858 | if (ret_val) |
803 | goto err_out_mem; | 859 | goto err_out_mem; |
804 | 860 | ||
805 | powernow_table[data->acpi_data.state_count].frequency = CPUFREQ_TABLE_END; | 861 | powernow_table[data->acpi_data.state_count].frequency = |
862 | CPUFREQ_TABLE_END; | ||
806 | powernow_table[data->acpi_data.state_count].index = 0; | 863 | powernow_table[data->acpi_data.state_count].index = 0; |
807 | data->powernow_table = powernow_table; | 864 | data->powernow_table = powernow_table; |
808 | 865 | ||
@@ -830,13 +887,15 @@ err_out_mem: | |||
830 | err_out: | 887 | err_out: |
831 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); | 888 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); |
832 | 889 | ||
833 | /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */ | 890 | /* data->acpi_data.state_count informs us at ->exit() |
891 | * whether ACPI was used */ | ||
834 | data->acpi_data.state_count = 0; | 892 | data->acpi_data.state_count = 0; |
835 | 893 | ||
836 | return ret_val; | 894 | return ret_val; |
837 | } | 895 | } |
838 | 896 | ||
839 | static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table) | 897 | static int fill_powernow_table_pstate(struct powernow_k8_data *data, |
898 | struct cpufreq_frequency_table *powernow_table) | ||
840 | { | 899 | { |
841 | int i; | 900 | int i; |
842 | u32 hi = 0, lo = 0; | 901 | u32 hi = 0, lo = 0; |
@@ -848,84 +907,101 @@ static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpuf | |||
848 | 907 | ||
849 | index = data->acpi_data.states[i].control & HW_PSTATE_MASK; | 908 | index = data->acpi_data.states[i].control & HW_PSTATE_MASK; |
850 | if (index > data->max_hw_pstate) { | 909 | if (index > data->max_hw_pstate) { |
851 | printk(KERN_ERR PFX "invalid pstate %d - bad value %d.\n", i, index); | 910 | printk(KERN_ERR PFX "invalid pstate %d - " |
852 | printk(KERN_ERR PFX "Please report to BIOS manufacturer\n"); | 911 | "bad value %d.\n", i, index); |
853 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 912 | printk(KERN_ERR PFX "Please report to BIOS " |
913 | "manufacturer\n"); | ||
914 | invalidate_entry(data, i); | ||
854 | continue; | 915 | continue; |
855 | } | 916 | } |
856 | rdmsr(MSR_PSTATE_DEF_BASE + index, lo, hi); | 917 | rdmsr(MSR_PSTATE_DEF_BASE + index, lo, hi); |
857 | if (!(hi & HW_PSTATE_VALID_MASK)) { | 918 | if (!(hi & HW_PSTATE_VALID_MASK)) { |
858 | dprintk("invalid pstate %d, ignoring\n", index); | 919 | dprintk("invalid pstate %d, ignoring\n", index); |
859 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 920 | invalidate_entry(data, i); |
860 | continue; | 921 | continue; |
861 | } | 922 | } |
862 | 923 | ||
863 | powernow_table[i].index = index; | 924 | powernow_table[i].index = index; |
864 | 925 | ||
865 | powernow_table[i].frequency = data->acpi_data.states[i].core_frequency * 1000; | 926 | powernow_table[i].frequency = |
927 | data->acpi_data.states[i].core_frequency * 1000; | ||
866 | } | 928 | } |
867 | return 0; | 929 | return 0; |
868 | } | 930 | } |
869 | 931 | ||
870 | static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table) | 932 | static int fill_powernow_table_fidvid(struct powernow_k8_data *data, |
933 | struct cpufreq_frequency_table *powernow_table) | ||
871 | { | 934 | { |
872 | int i; | 935 | int i; |
873 | int cntlofreq = 0; | 936 | int cntlofreq = 0; |
937 | |||
874 | for (i = 0; i < data->acpi_data.state_count; i++) { | 938 | for (i = 0; i < data->acpi_data.state_count; i++) { |
875 | u32 fid; | 939 | u32 fid; |
876 | u32 vid; | 940 | u32 vid; |
941 | u32 freq, index; | ||
942 | acpi_integer status, control; | ||
877 | 943 | ||
878 | if (data->exttype) { | 944 | if (data->exttype) { |
879 | fid = data->acpi_data.states[i].status & EXT_FID_MASK; | 945 | status = data->acpi_data.states[i].status; |
880 | vid = (data->acpi_data.states[i].status >> VID_SHIFT) & EXT_VID_MASK; | 946 | fid = status & EXT_FID_MASK; |
947 | vid = (status >> VID_SHIFT) & EXT_VID_MASK; | ||
881 | } else { | 948 | } else { |
882 | fid = data->acpi_data.states[i].control & FID_MASK; | 949 | control = data->acpi_data.states[i].control; |
883 | vid = (data->acpi_data.states[i].control >> VID_SHIFT) & VID_MASK; | 950 | fid = control & FID_MASK; |
951 | vid = (control >> VID_SHIFT) & VID_MASK; | ||
884 | } | 952 | } |
885 | 953 | ||
886 | dprintk(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); | 954 | dprintk(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); |
887 | 955 | ||
888 | powernow_table[i].index = fid; /* lower 8 bits */ | 956 | index = fid | (vid<<8); |
889 | powernow_table[i].index |= (vid << 8); /* upper 8 bits */ | 957 | powernow_table[i].index = index; |
890 | powernow_table[i].frequency = find_khz_freq_from_fid(fid); | 958 | |
959 | freq = find_khz_freq_from_fid(fid); | ||
960 | powernow_table[i].frequency = freq; | ||
891 | 961 | ||
892 | /* verify frequency is OK */ | 962 | /* verify frequency is OK */ |
893 | if ((powernow_table[i].frequency > (MAX_FREQ * 1000)) || | 963 | if ((freq > (MAX_FREQ * 1000)) || (freq < (MIN_FREQ * 1000))) { |
894 | (powernow_table[i].frequency < (MIN_FREQ * 1000))) { | 964 | dprintk("invalid freq %u kHz, ignoring\n", freq); |
895 | dprintk("invalid freq %u kHz, ignoring\n", powernow_table[i].frequency); | 965 | invalidate_entry(data, i); |
896 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | ||
897 | continue; | 966 | continue; |
898 | } | 967 | } |
899 | 968 | ||
900 | /* verify voltage is OK - BIOSs are using "off" to indicate invalid */ | 969 | /* verify voltage is OK - |
970 | * BIOSs are using "off" to indicate invalid */ | ||
901 | if (vid == VID_OFF) { | 971 | if (vid == VID_OFF) { |
902 | dprintk("invalid vid %u, ignoring\n", vid); | 972 | dprintk("invalid vid %u, ignoring\n", vid); |
903 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 973 | invalidate_entry(data, i); |
904 | continue; | 974 | continue; |
905 | } | 975 | } |
906 | 976 | ||
907 | /* verify only 1 entry from the lo frequency table */ | 977 | /* verify only 1 entry from the lo frequency table */ |
908 | if (fid < HI_FID_TABLE_BOTTOM) { | 978 | if (fid < HI_FID_TABLE_BOTTOM) { |
909 | if (cntlofreq) { | 979 | if (cntlofreq) { |
910 | /* if both entries are the same, ignore this one ... */ | 980 | /* if both entries are the same, |
911 | if ((powernow_table[i].frequency != powernow_table[cntlofreq].frequency) || | 981 | * ignore this one ... */ |
912 | (powernow_table[i].index != powernow_table[cntlofreq].index)) { | 982 | if ((freq != powernow_table[cntlofreq].frequency) || |
913 | printk(KERN_ERR PFX "Too many lo freq table entries\n"); | 983 | (index != powernow_table[cntlofreq].index)) { |
984 | printk(KERN_ERR PFX | ||
985 | "Too many lo freq table " | ||
986 | "entries\n"); | ||
914 | return 1; | 987 | return 1; |
915 | } | 988 | } |
916 | 989 | ||
917 | dprintk("double low frequency table entry, ignoring it.\n"); | 990 | dprintk("double low frequency table entry, " |
918 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 991 | "ignoring it.\n"); |
992 | invalidate_entry(data, i); | ||
919 | continue; | 993 | continue; |
920 | } else | 994 | } else |
921 | cntlofreq = i; | 995 | cntlofreq = i; |
922 | } | 996 | } |
923 | 997 | ||
924 | if (powernow_table[i].frequency != (data->acpi_data.states[i].core_frequency * 1000)) { | 998 | if (freq != (data->acpi_data.states[i].core_frequency * 1000)) { |
925 | printk(KERN_INFO PFX "invalid freq entries %u kHz vs. %u kHz\n", | 999 | printk(KERN_INFO PFX "invalid freq entries " |
926 | powernow_table[i].frequency, | 1000 | "%u kHz vs. %u kHz\n", freq, |
927 | (unsigned int) (data->acpi_data.states[i].core_frequency * 1000)); | 1001 | (unsigned int) |
928 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 1002 | (data->acpi_data.states[i].core_frequency |
1003 | * 1000)); | ||
1004 | invalidate_entry(data, i); | ||
929 | continue; | 1005 | continue; |
930 | } | 1006 | } |
931 | } | 1007 | } |
@@ -935,7 +1011,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) | 1011 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) |
936 | { | 1012 | { |
937 | if (data->acpi_data.state_count) | 1013 | if (data->acpi_data.state_count) |
938 | acpi_processor_unregister_performance(&data->acpi_data, data->cpu); | 1014 | acpi_processor_unregister_performance(&data->acpi_data, |
1015 | data->cpu); | ||
939 | free_cpumask_var(data->acpi_data.shared_cpu_map); | 1016 | free_cpumask_var(data->acpi_data.shared_cpu_map); |
940 | } | 1017 | } |
941 | 1018 | ||
@@ -954,14 +1031,25 @@ static int get_transition_latency(struct powernow_k8_data *data) | |||
954 | } | 1031 | } |
955 | 1032 | ||
956 | #else | 1033 | #else |
957 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) { return -ENODEV; } | 1034 | static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) |
958 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) { return; } | 1035 | { |
959 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) { return; } | 1036 | return -ENODEV; |
1037 | } | ||
1038 | static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) | ||
1039 | { | ||
1040 | return; | ||
1041 | } | ||
1042 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, | ||
1043 | unsigned int index) | ||
1044 | { | ||
1045 | return; | ||
1046 | } | ||
960 | static int get_transition_latency(struct powernow_k8_data *data) { return 0; } | 1047 | static int get_transition_latency(struct powernow_k8_data *data) { return 0; } |
961 | #endif /* CONFIG_X86_POWERNOW_K8_ACPI */ | 1048 | #endif /* CONFIG_X86_POWERNOW_K8_ACPI */ |
962 | 1049 | ||
963 | /* Take a frequency, and issue the fid/vid transition command */ | 1050 | /* Take a frequency, and issue the fid/vid transition command */ |
964 | static int transition_frequency_fidvid(struct powernow_k8_data *data, unsigned int index) | 1051 | static int transition_frequency_fidvid(struct powernow_k8_data *data, |
1052 | unsigned int index) | ||
965 | { | 1053 | { |
966 | u32 fid = 0; | 1054 | u32 fid = 0; |
967 | u32 vid = 0; | 1055 | u32 vid = 0; |
@@ -989,7 +1077,8 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, unsigned i | |||
989 | return 0; | 1077 | return 0; |
990 | } | 1078 | } |
991 | 1079 | ||
992 | if ((fid < HI_FID_TABLE_BOTTOM) && (data->currfid < HI_FID_TABLE_BOTTOM)) { | 1080 | if ((fid < HI_FID_TABLE_BOTTOM) && |
1081 | (data->currfid < HI_FID_TABLE_BOTTOM)) { | ||
993 | printk(KERN_ERR PFX | 1082 | printk(KERN_ERR PFX |
994 | "ignoring illegal change in lo freq table-%x to 0x%x\n", | 1083 | "ignoring illegal change in lo freq table-%x to 0x%x\n", |
995 | data->currfid, fid); | 1084 | data->currfid, fid); |
@@ -1017,7 +1106,8 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, unsigned i | |||
1017 | } | 1106 | } |
1018 | 1107 | ||
1019 | /* Take a frequency, and issue the hardware pstate transition command */ | 1108 | /* Take a frequency, and issue the hardware pstate transition command */ |
1020 | static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned int index) | 1109 | static int transition_frequency_pstate(struct powernow_k8_data *data, |
1110 | unsigned int index) | ||
1021 | { | 1111 | { |
1022 | u32 pstate = 0; | 1112 | u32 pstate = 0; |
1023 | int res, i; | 1113 | int res, i; |
@@ -1029,7 +1119,8 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i | |||
1029 | pstate = index & HW_PSTATE_MASK; | 1119 | pstate = index & HW_PSTATE_MASK; |
1030 | if (pstate > data->max_hw_pstate) | 1120 | if (pstate > data->max_hw_pstate) |
1031 | return 0; | 1121 | return 0; |
1032 | freqs.old = find_khz_freq_from_pstate(data->powernow_table, data->currpstate); | 1122 | freqs.old = find_khz_freq_from_pstate(data->powernow_table, |
1123 | data->currpstate); | ||
1033 | freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate); | 1124 | freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate); |
1034 | 1125 | ||
1035 | for_each_cpu_mask_nr(i, *(data->available_cores)) { | 1126 | for_each_cpu_mask_nr(i, *(data->available_cores)) { |
@@ -1048,7 +1139,8 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i | |||
1048 | } | 1139 | } |
1049 | 1140 | ||
1050 | /* Driver entry point to switch to the target frequency */ | 1141 | /* Driver entry point to switch to the target frequency */ |
1051 | static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation) | 1142 | static int powernowk8_target(struct cpufreq_policy *pol, |
1143 | unsigned targfreq, unsigned relation) | ||
1052 | { | 1144 | { |
1053 | cpumask_t oldmask; | 1145 | cpumask_t oldmask; |
1054 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); | 1146 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); |
@@ -1087,14 +1179,18 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi | |||
1087 | dprintk("targ: curr fid 0x%x, vid 0x%x\n", | 1179 | dprintk("targ: curr fid 0x%x, vid 0x%x\n", |
1088 | data->currfid, data->currvid); | 1180 | data->currfid, data->currvid); |
1089 | 1181 | ||
1090 | if ((checkvid != data->currvid) || (checkfid != data->currfid)) { | 1182 | if ((checkvid != data->currvid) || |
1183 | (checkfid != data->currfid)) { | ||
1091 | printk(KERN_INFO PFX | 1184 | printk(KERN_INFO PFX |
1092 | "error - out of sync, fix 0x%x 0x%x, vid 0x%x 0x%x\n", | 1185 | "error - out of sync, fix 0x%x 0x%x, " |
1093 | checkfid, data->currfid, checkvid, data->currvid); | 1186 | "vid 0x%x 0x%x\n", |
1187 | checkfid, data->currfid, | ||
1188 | checkvid, data->currvid); | ||
1094 | } | 1189 | } |
1095 | } | 1190 | } |
1096 | 1191 | ||
1097 | if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate)) | 1192 | if (cpufreq_frequency_table_target(pol, data->powernow_table, |
1193 | targfreq, relation, &newstate)) | ||
1098 | goto err_out; | 1194 | goto err_out; |
1099 | 1195 | ||
1100 | mutex_lock(&fidvid_mutex); | 1196 | mutex_lock(&fidvid_mutex); |
@@ -1114,7 +1210,8 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi | |||
1114 | mutex_unlock(&fidvid_mutex); | 1210 | mutex_unlock(&fidvid_mutex); |
1115 | 1211 | ||
1116 | if (cpu_family == CPU_HW_PSTATE) | 1212 | if (cpu_family == CPU_HW_PSTATE) |
1117 | pol->cur = find_khz_freq_from_pstate(data->powernow_table, newstate); | 1213 | pol->cur = find_khz_freq_from_pstate(data->powernow_table, |
1214 | newstate); | ||
1118 | else | 1215 | else |
1119 | pol->cur = find_khz_freq_from_fid(data->currfid); | 1216 | pol->cur = find_khz_freq_from_fid(data->currfid); |
1120 | ret = 0; | 1217 | ret = 0; |
@@ -1164,10 +1261,11 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1164 | */ | 1261 | */ |
1165 | if (num_online_cpus() != 1) { | 1262 | if (num_online_cpus() != 1) { |
1166 | #ifndef CONFIG_ACPI_PROCESSOR | 1263 | #ifndef CONFIG_ACPI_PROCESSOR |
1167 | printk(KERN_ERR PFX "ACPI Processor support is required " | 1264 | printk(KERN_ERR PFX |
1168 | "for SMP systems but is absent. Please load the " | 1265 | "ACPI Processor support is required for " |
1169 | "ACPI Processor module before starting this " | 1266 | "SMP systems but is absent. Please load the " |
1170 | "driver.\n"); | 1267 | "ACPI Processor module before starting this " |
1268 | "driver.\n"); | ||
1171 | #else | 1269 | #else |
1172 | printk(KERN_ERR FW_BUG PFX "Your BIOS does not provide" | 1270 | printk(KERN_ERR FW_BUG PFX "Your BIOS does not provide" |
1173 | " ACPI _PSS objects in a way that Linux " | 1271 | " ACPI _PSS objects in a way that Linux " |
@@ -1228,7 +1326,8 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1228 | data->available_cores = pol->cpus; | 1326 | data->available_cores = pol->cpus; |
1229 | 1327 | ||
1230 | if (cpu_family == CPU_HW_PSTATE) | 1328 | if (cpu_family == CPU_HW_PSTATE) |
1231 | pol->cur = find_khz_freq_from_pstate(data->powernow_table, data->currpstate); | 1329 | pol->cur = find_khz_freq_from_pstate(data->powernow_table, |
1330 | data->currpstate); | ||
1232 | else | 1331 | else |
1233 | pol->cur = find_khz_freq_from_fid(data->currfid); | 1332 | pol->cur = find_khz_freq_from_fid(data->currfid); |
1234 | dprintk("policy current frequency %d kHz\n", pol->cur); | 1333 | dprintk("policy current frequency %d kHz\n", pol->cur); |
@@ -1245,7 +1344,8 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1245 | cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu); | 1344 | cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu); |
1246 | 1345 | ||
1247 | if (cpu_family == CPU_HW_PSTATE) | 1346 | if (cpu_family == CPU_HW_PSTATE) |
1248 | dprintk("cpu_init done, current pstate 0x%x\n", data->currpstate); | 1347 | dprintk("cpu_init done, current pstate 0x%x\n", |
1348 | data->currpstate); | ||
1249 | else | 1349 | else |
1250 | dprintk("cpu_init done, current fid 0x%x, vid 0x%x\n", | 1350 | dprintk("cpu_init done, current fid 0x%x, vid 0x%x\n", |
1251 | data->currfid, data->currvid); | 1351 | data->currfid, data->currvid); |
@@ -1262,7 +1362,7 @@ err_out: | |||
1262 | return -ENODEV; | 1362 | return -ENODEV; |
1263 | } | 1363 | } |
1264 | 1364 | ||
1265 | static int __devexit powernowk8_cpu_exit (struct cpufreq_policy *pol) | 1365 | static int __devexit powernowk8_cpu_exit(struct cpufreq_policy *pol) |
1266 | { | 1366 | { |
1267 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); | 1367 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); |
1268 | 1368 | ||
@@ -1279,7 +1379,7 @@ static int __devexit powernowk8_cpu_exit (struct cpufreq_policy *pol) | |||
1279 | return 0; | 1379 | return 0; |
1280 | } | 1380 | } |
1281 | 1381 | ||
1282 | static unsigned int powernowk8_get (unsigned int cpu) | 1382 | static unsigned int powernowk8_get(unsigned int cpu) |
1283 | { | 1383 | { |
1284 | struct powernow_k8_data *data; | 1384 | struct powernow_k8_data *data; |
1285 | cpumask_t oldmask = current->cpus_allowed; | 1385 | cpumask_t oldmask = current->cpus_allowed; |
@@ -1315,7 +1415,7 @@ out: | |||
1315 | return khz; | 1415 | return khz; |
1316 | } | 1416 | } |
1317 | 1417 | ||
1318 | static struct freq_attr* powernow_k8_attr[] = { | 1418 | static struct freq_attr *powernow_k8_attr[] = { |
1319 | &cpufreq_freq_attr_scaling_available_freqs, | 1419 | &cpufreq_freq_attr_scaling_available_freqs, |
1320 | NULL, | 1420 | NULL, |
1321 | }; | 1421 | }; |
@@ -1360,7 +1460,8 @@ static void __exit powernowk8_exit(void) | |||
1360 | cpufreq_unregister_driver(&cpufreq_amd64_driver); | 1460 | cpufreq_unregister_driver(&cpufreq_amd64_driver); |
1361 | } | 1461 | } |
1362 | 1462 | ||
1363 | MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com> and Mark Langsdorf <mark.langsdorf@amd.com>"); | 1463 | MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com> and " |
1464 | "Mark Langsdorf <mark.langsdorf@amd.com>"); | ||
1364 | MODULE_DESCRIPTION("AMD Athlon 64 and Opteron processor frequency driver."); | 1465 | MODULE_DESCRIPTION("AMD Athlon 64 and Opteron processor frequency driver."); |
1365 | MODULE_LICENSE("GPL"); | 1466 | MODULE_LICENSE("GPL"); |
1366 | 1467 | ||