diff options
author | Kevin Lo <kevlo@cvs.openbsd.org> | 2009-09-20 15:37:25 +0000 |
---|---|---|
committer | Kevin Lo <kevlo@cvs.openbsd.org> | 2009-09-20 15:37:25 +0000 |
commit | 28685deadaee80d11edf63ab705a896433e4f3c5 (patch) | |
tree | 8983ca91c2ec3f22ea64a775da4ee4911a70c281 /sys/arch/i386 | |
parent | f2b7b5f2a213854221814c0276708a24c4bbf6d9 (diff) |
add support for VIA Nano cpu core temperature sensor
ok deraadt@
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 31 | ||||
-rw-r--r-- | sys/arch/i386/include/specialreg.h | 5 |
2 files changed, 34 insertions, 2 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 6e0727f4fce..b30bca12551 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.459 2009/08/11 18:46:32 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.460 2009/09/20 15:37:23 kevlo Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -309,6 +309,7 @@ void amd_family6_setperf_setup(struct cpu_info *); void amd_family6_setup(struct cpu_info *); void cyrix3_setperf_setup(struct cpu_info *); void cyrix3_cpu_setup(struct cpu_info *); +void via_update_sensor(void *args); void cyrix6x86_cpu_setup(struct cpu_info *); void natsem6x86_cpu_setup(struct cpu_info *); void intel586_cpu_setup(struct cpu_info *); @@ -1164,11 +1165,39 @@ cyrix3_cpu_setup(struct cpu_info *ci) } printf("\n"); + + /* Setup the sensors structures */ + strlcpy(ci->ci_sensordev.xname, ci->ci_dev.dv_xname, + sizeof(ci->ci_sensordev.xname)); + ci->ci_sensor.type = SENSOR_TEMP; + sensor_task_register(ci, via_update_sensor, 5); + sensor_attach(&ci->ci_sensordev, &ci->ci_sensor); + sensordev_install(&ci->ci_sensordev); + break; } } void +via_update_sensor(void *args) +{ + struct cpu_info *ci = (struct cpu_info *) args; + u_int64_t msr; + + if (ci->ci_model == 0xf) { + msr = rdmsr(MSR_CENT_TMTEMPERATURE); + ci->ci_sensor.value = (msr & 0xffffff); + /* micro degrees */ + ci->ci_sensor.value *= 1000000; + ci->ci_sensor.value += 273150000; + ci->ci_sensor.flags &= ~SENSOR_FINVALID; + } else { + ci->ci_sensor.value = 0; + ci->ci_sensor.flags |= SENSOR_FINVALID; + } +} + +void cyrix6x86_cpu_setup(struct cpu_info *ci) { extern int clock_broken_latch; diff --git a/sys/arch/i386/include/specialreg.h b/sys/arch/i386/include/specialreg.h index af65c0be9ea..9ecfa024a50 100644 --- a/sys/arch/i386/include/specialreg.h +++ b/sys/arch/i386/include/specialreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: specialreg.h,v 1.34 2008/08/13 15:46:21 art Exp $ */ +/* $OpenBSD: specialreg.h,v 1.35 2009/09/20 15:37:24 kevlo Exp $ */ /* $NetBSD: specialreg.h,v 1.7 1994/10/27 04:16:26 cgd Exp $ */ /*- @@ -244,6 +244,9 @@ #define MSR_MC3_ADDR 0x412 #define MSR_MC3_MISC 0x413 +/* VIA MSR */ +#define MSR_CENT_TMTEMPERATURE 0x1423 /* Thermal monitor temperature */ + /* AMD MSRs */ #define MSR_K6_EPMR 0xc0000086 #define MSR_K7_EVNTSEL0 0xc0010000 |