Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86 Add support for VIA C7 temperature sensors (opt...
details: https://anonhg.NetBSD.org/src/rev/e059393b8d90
branches: trunk
changeset: 747803:e059393b8d90
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Oct 02 18:50:03 2009 +0000
description:
Add support for VIA C7 temperature sensors (options VIA_C7TEMP)
diffstat:
sys/arch/x86/conf/files.x86 | 8 ++-
sys/arch/x86/include/cpuvar.h | 7 ++-
sys/arch/x86/x86/identcpu.c | 17 +++++-
sys/arch/x86/x86/viac7temp.c | 115 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 143 insertions(+), 4 deletions(-)
diffs (218 lines):
diff -r febebb5f7544 -r e059393b8d90 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86 Fri Oct 02 18:17:16 2009 +0000
+++ b/sys/arch/x86/conf/files.x86 Fri Oct 02 18:50:03 2009 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.x86,v 1.52 2009/04/30 00:07:23 rmind Exp $
+# $NetBSD: files.x86,v 1.53 2009/10/02 18:50:03 jmcneill Exp $
# options for MP configuration through the MP spec
defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -26,6 +26,9 @@
# AMD Powernow/Cool`n'Quiet Technology
defflag opt_powernow_k8.h POWERNOW_K8
+# VIA C7 Temperature sensor
+defflag opt_via_c7temp.h VIA_C7TEMP: sysmon_envsys
+
# VIA PadLock support
defflag opt_viapadlock.h VIA_PADLOCK: opencrypto
file arch/x86/x86/via_padlock.c via_padlock
@@ -104,6 +107,9 @@
# Intel On-Die Temperature sensor
file arch/x86/x86/coretemp.c intel_coretemp
+# 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 febebb5f7544 -r e059393b8d90 sys/arch/x86/include/cpuvar.h
--- a/sys/arch/x86/include/cpuvar.h Fri Oct 02 18:17:16 2009 +0000
+++ b/sys/arch/x86/include/cpuvar.h Fri Oct 02 18:50:03 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuvar.h,v 1.30 2009/10/02 15:05:42 jmcneill Exp $ */
+/* $NetBSD: cpuvar.h,v 1.31 2009/10/02 18:50:03 jmcneill Exp $ */
/*-
* Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -92,6 +92,7 @@
#ifndef XEN
#include "opt_intel_coretemp.h"
#include "opt_intel_odcm.h"
+#include "opt_via_c7temp.h"
#endif
#endif /* defined(_KERNEL_OPT) */
@@ -118,6 +119,10 @@
void x86_cpu_idle_xen(void);
#endif
+#ifdef VIA_C7TEMP
+void viac7temp_register(struct cpu_info *);
+#endif
+
#ifdef INTEL_CORETEMP
void coretemp_register(struct cpu_info *);
#endif
diff -r febebb5f7544 -r e059393b8d90 sys/arch/x86/x86/identcpu.c
--- a/sys/arch/x86/x86/identcpu.c Fri Oct 02 18:17:16 2009 +0000
+++ b/sys/arch/x86/x86/identcpu.c Fri Oct 02 18:50:03 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: identcpu.c,v 1.16 2009/04/30 00:07:23 rmind Exp $ */
+/* $NetBSD: identcpu.c,v 1.17 2009/10/02 18:50:03 jmcneill Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,11 +30,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.16 2009/04/30 00:07:23 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.17 2009/10/02 18:50:03 jmcneill Exp $");
#include "opt_enhanced_speedstep.h"
#include "opt_intel_odcm.h"
#include "opt_intel_coretemp.h"
+#include "opt_via_c7temp.h"
#include "opt_powernow_k8.h"
#include "opt_xen.h"
#ifdef i386 /* XXX */
@@ -751,6 +752,18 @@
coretemp_register(ci);
#endif
+#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
+
#if defined(POWERNOW_K7) || defined(POWERNOW_K8)
if (cpu_vendor == CPUVENDOR_AMD && powernow_probe(ci)) {
switch (CPUID2FAMILY(ci->ci_signature)) {
diff -r febebb5f7544 -r e059393b8d90 sys/arch/x86/x86/viac7temp.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x86/x86/viac7temp.c Fri Oct 02 18:50:03 2009 +0000
@@ -0,0 +1,115 @@
+/* $NetBSD: viac7temp.c,v 1.1 2009/10/02 18:50:03 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2009 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.1 2009/10/02 18:50:03 jmcneill Exp $");
+
+#include <sys/param.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/specialreg.h>
+#include <machine/cpufunc.h>
+
+struct viac7temp_softc {
+ struct cpu_info *sc_ci;
+ struct sysmon_envsys *sc_sme;
+ envsys_data_t sc_sensor;
+};
+
+static void viac7temp_refresh(struct sysmon_envsys *, envsys_data_t *);
+static void viac7temp_refresh_xcall(void *, void *);
+
+void
+viac7temp_register(struct cpu_info *ci)
+{
+ struct viac7temp_softc *sc;
+
+ sc = kmem_zalloc(sizeof(struct viac7temp_softc), KM_SLEEP);
+
+ sc->sc_sensor.units = ENVSYS_STEMP;
+ sc->sc_sensor.flags = 0;
+ sc->sc_sensor.monitor = true;
+ 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);
+ sc->sc_sme->sme_cookie = sc;
+ 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");
+ sysmon_envsys_destroy(sc->sc_sme);
+ goto bad;
+ }
+
+ return;
+
+bad:
+ kmem_free(sc, sizeof(struct viac7temp_softc));
+}
+
+static void
+viac7temp_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
+{
+ struct viac7temp_softc *sc = sme->sme_cookie;
+ uint64_t where;
+
+ where = xc_unicast(0, viac7temp_refresh_xcall, sc, edata, sc->sc_ci);
+ xc_wait(where);
+}
+
+static void
+viac7temp_refresh_xcall(void *arg0, void *arg1)
+{
+ /* struct viac7temp_softc *sc = (struct viac7temp_softc *)arg0; */
+ envsys_data_t *edata = (envsys_data_t *)arg1;
+ uint32_t descs[4];
+
+ x86_cpuid(0xc0000002, descs);
+
+ edata->value_cur = descs[0] >> 8;
+ edata->value_cur *= 1000000;
+ edata->value_cur += 273150000;
+ edata->state = ENVSYS_SVALID;
+}
Home |
Main Index |
Thread Index |
Old Index