Rework the way PowerNow! and Cool'n'Quiet features are detected and
displayed, to make the code much simpler and easier to follow. Also, use bitmask_printf() to make output consistent with other stuff. Use CPUID2FAMILY() where appropriate.
This commit is contained in:
parent
14573dd3a8
commit
c72f004e7c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: identcpu.c,v 1.6 2006/08/07 20:58:23 xtraeme Exp $ */
|
||||
/* $NetBSD: identcpu.c,v 1.7 2006/10/04 13:18:10 cube Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Wasabi Systems, Inc.
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.6 2006/08/07 20:58:23 xtraeme Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.7 2006/10/04 13:18:10 cube Exp $");
|
||||
|
||||
#include "opt_powernow_k8.h"
|
||||
|
||||
|
@ -103,17 +103,10 @@ identifycpu(struct cpu_info *ci)
|
|||
x86_print_cacheinfo(ci);
|
||||
|
||||
#ifdef POWERNOW_K8
|
||||
if (cpu_model[0] == 'A' || cpu_model[0] == 'O') {
|
||||
uint32_t rval;
|
||||
uint8_t featflag;
|
||||
|
||||
rval = powernow_probe(ci, 0xf00);
|
||||
if (rval) {
|
||||
featflag = powernow_extflags(ci, rval);
|
||||
if (featflag)
|
||||
if (CPUID2FAMILY(ci->ci_signature) == 15 &&
|
||||
(cpu_model[0] == 'A' || cpu_model[0] == 'O') &&
|
||||
powernow_probe(ci))
|
||||
k8_powernow_init();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: identcpu.c,v 1.43 2006/10/02 19:59:24 xtraeme Exp $ */
|
||||
/* $NetBSD: identcpu.c,v 1.44 2006/10/04 13:18:10 cube Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.43 2006/10/02 19:59:24 xtraeme Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.44 2006/10/04 13:18:10 cube Exp $");
|
||||
|
||||
#include "opt_cputype.h"
|
||||
#include "opt_enhanced_speedstep.h"
|
||||
|
@ -1603,26 +1603,20 @@ identifycpu(struct cpu_info *ci)
|
|||
#endif /* ENHANCED_SPEEDSTEP */
|
||||
|
||||
#if defined(POWERNOW_K7) || defined(POWERNOW_K8)
|
||||
if (vendor == CPUVENDOR_AMD) {
|
||||
uint32_t rval;
|
||||
uint8_t featflag;
|
||||
|
||||
rval = powernow_probe(ci, 0x600);
|
||||
if (rval) {
|
||||
featflag = powernow_extflags(ci, rval);
|
||||
if (vendor == CPUVENDOR_AMD && powernow_probe(ci)) {
|
||||
switch (CPUID2FAMILY(ci->ci_signature)) {
|
||||
#ifdef POWERNOW_K7
|
||||
if (featflag)
|
||||
case 6:
|
||||
k7_powernow_init();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
rval = powernow_probe(ci, 0xf00);
|
||||
if (rval) {
|
||||
featflag = powernow_extflags(ci, rval);
|
||||
#ifdef POWERNOW_K8
|
||||
if (featflag)
|
||||
case 15:
|
||||
k8_powernow_init();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* POWERNOW_K7 || POWERNOW_K8 */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: powernow.h,v 1.5 2006/08/27 10:10:55 xtraeme Exp $ */
|
||||
/* $NetBSD: powernow.h,v 1.6 2006/10/04 13:18:10 cube Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 Martin Végiard.
|
||||
|
@ -175,8 +175,7 @@ struct powernow_pst_s {
|
|||
uint8_t n_states;
|
||||
};
|
||||
|
||||
uint32_t powernow_probe(struct cpu_info *, uint32_t);
|
||||
int powernow_extflags(struct cpu_info *, uint32_t);
|
||||
int powernow_probe(struct cpu_info *);
|
||||
|
||||
/* i386/i386/powernow_k7.c */
|
||||
void k7_powernow_init(void);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: powernow_common.c,v 1.2 2006/08/07 20:58:23 xtraeme Exp $ */
|
||||
/* $NetBSD: powernow_common.c,v 1.3 2006/10/04 13:18:10 cube Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
/*
|
||||
* Copyright (c) 2006 The NetBSD Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Juan Romero Pardines.
|
||||
* This code is derived from software contributed to the NetBSD Foundation
|
||||
* by Quentin Garnier.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -36,97 +36,37 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Common functions for PowerNow drivers.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: powernow_common.c,v 1.2 2006/08/07 20:58:23 xtraeme Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: powernow_common.c,v 1.3 2006/10/04 13:18:10 cube Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <x86/include/powernow.h>
|
||||
|
||||
/*
|
||||
* CPUID Extended function 8000_0007h.
|
||||
*
|
||||
* Reference documentation:
|
||||
*
|
||||
* - AMD Processor Recognition Application Note. December 2005.
|
||||
* Section 2.4. Advanced Power Management Features.
|
||||
*
|
||||
*/
|
||||
|
||||
struct powernow_extflags {
|
||||
int mask;
|
||||
const char *name;
|
||||
} pnow_extflag[] = {
|
||||
{ 0x01, "TS" }, /* Thermal Sensor */
|
||||
{ 0x02, "FID" }, /* Frequency ID Control */
|
||||
{ 0x04, "VID" }, /* Voltage ID Control */
|
||||
{ 0x08, "TTP" }, /* Thermal Trip */
|
||||
{ 0x10, "TM" }, /* Thermal Control */
|
||||
{ 0x20, "STC" }, /* Software Thermal Control */
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
uint32_t
|
||||
powernow_probe(struct cpu_info *ci, uint32_t val)
|
||||
{
|
||||
uint32_t descs[4];
|
||||
|
||||
CPUID(0x80000000, descs[0], descs[1], descs[2], descs[3]);
|
||||
|
||||
if (descs[0] >= 0x80000007) {
|
||||
CPUID(0x80000007, descs[0], descs[1], descs[2], descs[3]);
|
||||
if (descs[3] & 0x06) {
|
||||
if ((ci->ci_signature & 0xF00) == val)
|
||||
return descs[3];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
powernow_extflags(struct cpu_info *ci, uint32_t feature_flag)
|
||||
powernow_probe(struct cpu_info *ci)
|
||||
{
|
||||
int family, j, rval;
|
||||
char *cpuname;
|
||||
uint32_t regs[4];
|
||||
char line[80];
|
||||
|
||||
rval = 0;
|
||||
CPUID(0x80000000, regs[0], regs[1], regs[2], regs[3]);
|
||||
|
||||
family = (ci->ci_signature >> 8) & 15;
|
||||
cpuname = ci->ci_dev->dv_xname;
|
||||
/* We need CPUID(0x80000007) */
|
||||
if (regs[0] < 7)
|
||||
return 0;
|
||||
CPUID(0x80000007, regs[0], regs[1], regs[2], regs[3]);
|
||||
|
||||
/* Print out available cpuid extended features. */
|
||||
aprint_normal("%s: AMD Power Management features:", cpuname);
|
||||
for (j = 0; pnow_extflag[j].name != NULL; j++) {
|
||||
if (feature_flag & pnow_extflag[j].mask)
|
||||
aprint_normal(" %s", pnow_extflag[j].name);
|
||||
}
|
||||
aprint_normal("\n");
|
||||
bitmask_snprintf(regs[3], "\20\6STC\5TM\4TTP\3VID\2FID\1TS", line,
|
||||
sizeof line);
|
||||
aprint_normal("%s: AMD Power Management features: %s\n",
|
||||
device_xname(ci->ci_dev), line);
|
||||
|
||||
/*
|
||||
* Check for FID and VID cpuid extended feature flag, if they
|
||||
* are available, it's ok to continue enabling powernow.
|
||||
* For now we're only interested in FID and VID for frequency scaling.
|
||||
*/
|
||||
if ((feature_flag & pnow_extflag[1].mask) &&
|
||||
(feature_flag & pnow_extflag[2].mask)) {
|
||||
switch (family) {
|
||||
case 6:
|
||||
rval = 6;
|
||||
break;
|
||||
case 15:
|
||||
rval = 15;
|
||||
break;
|
||||
default:
|
||||
rval = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
return (regs[3] & AMD_PN_FID_VID) == AMD_PN_FID_VID;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue