Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Move VIA_C7TEMP to the cpufeaturebus.
details: https://anonhg.NetBSD.org/src/rev/dd46cb6f6ec5
branches: trunk
changeset: 762623:dd46cb6f6ec5
user: jruoho <jruoho%NetBSD.org@localhost>
date: Thu Feb 24 13:58:39 2011 +0000
description:
Move VIA_C7TEMP to the cpufeaturebus.
diffstat:
sys/arch/i386/conf/ALL | 8 +-
sys/arch/i386/conf/GENERIC | 8 +-
sys/arch/x86/conf/files.x86 | 12 +--
sys/arch/x86/x86/cpu.c | 10 +++-
sys/arch/x86/x86/identcpu.c | 17 +-----
sys/arch/x86/x86/viac7temp.c | 112 ++++++++++++++++++++++++++++++------------
6 files changed, 101 insertions(+), 66 deletions(-)
diffs (truncated from 355 to 300 lines):
diff -r 0dedca8e3d6a -r dd46cb6f6ec5 sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL Thu Feb 24 13:19:36 2011 +0000
+++ b/sys/arch/i386/conf/ALL Thu Feb 24 13:58:39 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.295 2011/02/24 10:56:01 jruoho Exp $
+# $NetBSD: ALL,v 1.296 2011/02/24 13:58:39 jruoho Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@@ -17,7 +17,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "ALL-$Revision: 1.295 $"
+#ident "ALL-$Revision: 1.296 $"
maxusers 64 # estimated number of users
@@ -34,6 +34,7 @@
est0 at cpu0 # Intel Enhanced SpeedStep (non-ACPI)
padlock0 at cpu0 # VIA PadLock
powernow0 at cpu0 # AMD PowerNow! and Cool'n'Quiet (non-ACPI)
+viac7temp* at cpu? # VIA C7 temperature sensor
# Intel(R) On Demand Clock Modulation (aka ODCM)
options INTEL_ONDEMAND_CLOCKMOD
@@ -682,9 +683,6 @@
alipm* at pci? dev ? function ?
iic* at alipm?
-# VIA C7 Temperature sensor
-options VIA_C7TEMP
-
# Intel ICH SMBus controller
ichsmb* at pci? dev ? function ?
iic* at ichsmb?
diff -r 0dedca8e3d6a -r dd46cb6f6ec5 sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC Thu Feb 24 13:19:36 2011 +0000
+++ b/sys/arch/i386/conf/GENERIC Thu Feb 24 13:58:39 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1022 2011/02/24 10:56:01 jruoho Exp $
+# $NetBSD: GENERIC,v 1.1023 2011/02/24 13:58:39 jruoho Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.1022 $"
+#ident "GENERIC-$Revision: 1.1023 $"
maxusers 64 # estimated number of users
@@ -42,6 +42,7 @@
est0 at cpu0 # Intel Enhanced SpeedStep (non-ACPI)
#padlock0 at cpu0 # VIA PadLock
powernow0 at cpu0 # AMD PowerNow! and Cool'n'Quiet (non-ACPI)
+viac7temp* at cpu? # VIA C7 temperature sensor
# Intel(R) On Demand Clock Modulation (aka ODCM)
#options INTEL_ONDEMAND_CLOCKMOD
@@ -636,9 +637,6 @@
alipm* at pci? dev ? function ?
iic* at alipm?
-# VIA C7 Temperature sensor
-options VIA_C7TEMP
-
# Intel ICH SMBus controller
ichsmb* at pci? dev ? function ?
iic* at ichsmb?
diff -r 0dedca8e3d6a -r dd46cb6f6ec5 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86 Thu Feb 24 13:19:36 2011 +0000
+++ b/sys/arch/x86/conf/files.x86 Thu Feb 24 13:58:39 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.x86,v 1.61 2011/02/24 10:56:02 jruoho Exp $
+# $NetBSD: files.x86,v 1.62 2011/02/24 13:58:39 jruoho Exp $
# options for MP configuration through the MP spec
defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -16,9 +16,6 @@
# Pentium 4+ Thermal Monitor ODCM (aka On Demand Clock Modulation)
defflag opt_intel_odcm.h INTEL_ONDEMAND_CLOCKMOD
-# VIA C7 Temperature sensor
-defflag opt_via_c7temp.h VIA_C7TEMP: sysmon_envsys
-
# To be able to test for NetBSD/xen in shared files
defflag opt_xen.h DO_NOT_DEFINE
@@ -51,6 +48,10 @@
attach powernow at cpufeaturebus
file arch/x86/x86/powernow.c powernow
+device viac7temp: sysmon_envsys
+attach viac7temp at cpufeaturebus
+file arch/x86/x86/viac7temp.c viac7temp
+
file arch/x86/x86/apic.c ioapic | lapic
file arch/x86/x86/bus_dma.c
file arch/x86/x86/bus_space.c
@@ -102,9 +103,6 @@
# Intel On Demand Clock Modulation
file arch/x86/x86/iclockmod.c intel_ondemand_clockmod
-# VIA C7 Temperature sensor
-file arch/x86/x86/viac7temp.c via_c7temp
-
# IPMI device
device ipmi: sysmon_envsys, sysmon_wdog
attach ipmi at ipmibus
diff -r 0dedca8e3d6a -r dd46cb6f6ec5 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c Thu Feb 24 13:19:36 2011 +0000
+++ b/sys/arch/x86/x86/cpu.c Thu Feb 24 13:58:39 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.84 2011/02/24 10:56:02 jruoho Exp $ */
+/* $NetBSD: cpu.c,v 1.85 2011/02/24 13:58:39 jruoho Exp $ */
/*-
* Copyright (c) 2000, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.84 2011/02/24 10:56:02 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.85 2011/02/24 13:58:39 jruoho Exp $");
#include "opt_ddb.h"
#include "opt_mpbios.h" /* for MPDEBUG */
@@ -487,6 +487,12 @@
ci->ci_tempsensor = config_found_ia(self,
"cpufeaturebus", &cfaa, NULL);
}
+
+ if (ci->ci_tempsensor == NULL) {
+ cfaa.name = "viac7temp";
+ ci->ci_tempsensor = config_found_ia(self,
+ "cpufeaturebus", &cfaa, NULL);
+ }
}
return 0;
diff -r 0dedca8e3d6a -r dd46cb6f6ec5 sys/arch/x86/x86/identcpu.c
--- a/sys/arch/x86/x86/identcpu.c Thu Feb 24 13:19:36 2011 +0000
+++ b/sys/arch/x86/x86/identcpu.c Thu Feb 24 13:58:39 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: identcpu.c,v 1.26 2011/02/24 10:56:02 jruoho Exp $ */
+/* $NetBSD: identcpu.c,v 1.27 2011/02/24 13:58:39 jruoho Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,10 +30,9 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.26 2011/02/24 10:56:02 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.27 2011/02/24 13:58:39 jruoho Exp $");
#include "opt_intel_odcm.h"
-#include "opt_via_c7temp.h"
#include "opt_xen.h"
#include <sys/param.h>
@@ -796,18 +795,6 @@
i386_use_fxsave = 0;
#endif /* i386 */
-#ifdef VIA_C7TEMP
- if (cpu_vendor == CPUVENDOR_IDT &&
- CPUID2FAMILY(ci->ci_signature) == 6 &&
- CPUID2MODEL(ci->ci_signature) >= 0x9) {
- uint32_t descs[4];
-
- x86_cpuid(0xc0000000, descs);
- if (descs[0] >= 0xc0000002) /* has temp sensor */
- viac7temp_register(ci);
- }
-#endif
-
#ifdef INTEL_ONDEMAND_CLOCKMOD
if (cpuid_level >= 1) {
clockmod_init();
diff -r 0dedca8e3d6a -r dd46cb6f6ec5 sys/arch/x86/x86/viac7temp.c
--- a/sys/arch/x86/x86/viac7temp.c Thu Feb 24 13:19:36 2011 +0000
+++ b/sys/arch/x86/x86/viac7temp.c Thu Feb 24 13:58:39 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: viac7temp.c,v 1.3 2011/02/13 17:47:56 jmcneill Exp $ */
+/* $NetBSD: viac7temp.c,v 1.4 2011/02/24 13:58:39 jruoho Exp $ */
/*-
* Copyright (c) 2009 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,83 +27,131 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.3 2011/02/13 17:47:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.4 2011/02/24 13:58:39 jruoho Exp $");
#include <sys/param.h>
+#include <sys/device.h>
#include <sys/kmem.h>
#include <sys/xcall.h>
-#include <sys/cpu.h>
-#include <sys/device.h>
#include <dev/sysmon/sysmonvar.h>
#include <machine/cpuvar.h>
+#include <machine/cpufunc.h>
+#include <machine/cputypes.h>
#include <machine/specialreg.h>
-#include <machine/cpufunc.h>
struct viac7temp_softc {
+ device_t sc_dev;
struct cpu_info *sc_ci;
struct sysmon_envsys *sc_sme;
- envsys_data_t sc_sensor;
+ envsys_data_t sc_sensor;
};
+static int viac7temp_match(device_t, cfdata_t, void *);
+static void viac7temp_attach(device_t, device_t, void *);
+static int viac7temp_detach(device_t, int);
static void viac7temp_refresh(struct sysmon_envsys *, envsys_data_t *);
static void viac7temp_refresh_xcall(void *, void *);
-void
-viac7temp_register(struct cpu_info *ci)
+CFATTACH_DECL_NEW(viac7temp, sizeof(struct viac7temp_softc),
+ viac7temp_match, viac7temp_attach, viac7temp_detach, NULL);
+
+static int
+viac7temp_match(device_t parent, cfdata_t cf, void *aux)
{
- struct viac7temp_softc *sc;
+ struct cpufeature_attach_args *cfaa = aux;
+ struct cpu_info *ci = cfaa->ci;
+ uint32_t family, model;
+ uint32_t descs[4];
+
+ if (strcmp(cfaa->name, "viac7temp") != 0)
+ return 0;
+
+ if (cpu_vendor != CPUVENDOR_IDT)
+ return 0;
+
+ model = CPUID2MODEL(ci->ci_signature);
+ family = CPUID2FAMILY(ci->ci_signature);
- sc = kmem_zalloc(sizeof(struct viac7temp_softc), KM_SLEEP);
+ if (family != 0x06 || model < 0x09)
+ return 0;
+
+ x86_cpuid(0xc0000000, descs);
+
+ if (descs[0] >= 0xc0000002)
+ return 1;
+
+ return 0;
+}
+
+static void
+viac7temp_attach(device_t parent, device_t self, void *aux)
+{
+ struct viac7temp_softc *sc = device_private(self);
+ struct cpufeature_attach_args *cfaa = aux;
+ struct cpu_info *ci = cfaa->ci;
sc->sc_ci = ci;
+ sc->sc_dev = self;
+
sc->sc_sensor.units = ENVSYS_STEMP;
sc->sc_sensor.flags = ENVSYS_FMONLIMITS;
- strlcpy(sc->sc_sensor.desc, "temperature",
+
+ (void)strlcpy(sc->sc_sensor.desc, "temperature",
sizeof(sc->sc_sensor.desc));
sc->sc_sme = sysmon_envsys_create();
- if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor)) {
- sysmon_envsys_destroy(sc->sc_sme);
- goto bad;
- }
- /*
- * Hook into the system monitor.
- */
- sc->sc_sme->sme_name = device_xname(ci->ci_dev);
+ if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor) != 0)
+ goto fail;
+
sc->sc_sme->sme_cookie = sc;
+ sc->sc_sme->sme_name = device_xname(self);
sc->sc_sme->sme_refresh = viac7temp_refresh;
- if (sysmon_envsys_register(sc->sc_sme)) {
- aprint_error_dev(ci->ci_dev,
- "unable to register with sysmon\n");
Home |
Main Index |
Thread Index |
Old Index