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/amd64 | |
parent | f2b7b5f2a213854221814c0276708a24c4bbf6d9 (diff) |
add support for VIA Nano cpu core temperature sensor
ok deraadt@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/identcpu.c | 27 | ||||
-rw-r--r-- | sys/arch/amd64/include/specialreg.h | 5 |
2 files changed, 29 insertions, 3 deletions
diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index 922d1c13f27..bb6e107ccfd 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.21 2009/07/22 20:33:12 deraadt Exp $ */ +/* $OpenBSD: identcpu.c,v 1.22 2009/09/20 15:37:23 kevlo Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -155,6 +155,8 @@ void (*setperf_setup)(struct cpu_info *); void via_nano_setup(struct cpu_info *ci); +void via_update_sensor(void *args); + void via_nano_setup(struct cpu_info *ci) { @@ -244,6 +246,20 @@ via_nano_setup(struct cpu_info *ci) } void +via_update_sensor(void *args) +{ + struct cpu_info *ci = (struct cpu_info *) args; + u_int64_t msr; + + 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; +} + +void identifycpu(struct cpu_info *ci) { u_int64_t last_tsc; @@ -356,8 +372,15 @@ identifycpu(struct cpu_info *ci) vendor[2] == 0x444d4163) /* DMAc */ amd64_errata(ci); - if (strncmp(cpu_model, "VIA Nano processor", 18) == 0) + if (strncmp(cpu_model, "VIA Nano processor", 18) == 0) { ci->cpu_setup = via_nano_setup; + 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); + } } void diff --git a/sys/arch/amd64/include/specialreg.h b/sys/arch/amd64/include/specialreg.h index b825a206d9e..909f0a99d62 100644 --- a/sys/arch/amd64/include/specialreg.h +++ b/sys/arch/amd64/include/specialreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: specialreg.h,v 1.14 2009/05/31 03:20:10 matthieu Exp $ */ +/* $OpenBSD: specialreg.h,v 1.15 2009/09/20 15:37:23 kevlo Exp $ */ /* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */ /* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */ @@ -257,6 +257,9 @@ #define MSR_MC3_ADDR 0x412 #define MSR_MC3_MISC 0x413 +/* VIA MSR */ +#define MSR_CENT_TMTEMPERATURE 0x1423 /* Thermal monitor temperature */ + /* * AMD K6/K7 MSRs. */ |