diff options
author | Kevin Lo <kevlo@cvs.openbsd.org> | 2009-10-07 02:15:49 +0000 |
---|---|---|
committer | Kevin Lo <kevlo@cvs.openbsd.org> | 2009-10-07 02:15:49 +0000 |
commit | 913cfce4b8445d6ebee715b633da195797de6144 (patch) | |
tree | ea839ba9c84f62e265c70ae2686de60bc04948d3 /sys/arch/amd64 | |
parent | b1852bac0a302c0bf5763ac719e7bd4bcbc02564 (diff) |
add support for the temperature sensor of VIA Nano and C7-M CPUs.
some improvements suggested by jsg@
"commit" deraadt@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/identcpu.c | 30 | ||||
-rw-r--r-- | sys/arch/amd64/include/specialreg.h | 5 |
2 files changed, 32 insertions, 3 deletions
diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index 1dbdca1f8a7..90f71996406 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.23 2009/09/20 21:58:31 jsg Exp $ */ +/* $OpenBSD: identcpu.c,v 1.24 2009/10/07 02:15:48 kevlo Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -243,6 +243,23 @@ via_nano_setup(struct cpu_info *ci) } } +#ifndef SMALL_KERNEL +void via_update_sensor(void *args); +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; +} +#endif + void identifycpu(struct cpu_info *ci) { @@ -356,8 +373,17 @@ 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; +#ifndef SMALL_KERNEL + 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); +#endif + } } void diff --git a/sys/arch/amd64/include/specialreg.h b/sys/arch/amd64/include/specialreg.h index a9151b6f4f2..9ea389d0b52 100644 --- a/sys/arch/amd64/include/specialreg.h +++ b/sys/arch/amd64/include/specialreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: specialreg.h,v 1.16 2009/09/20 21:58:31 jsg Exp $ */ +/* $OpenBSD: specialreg.h,v 1.17 2009/10/07 02:15:48 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. */ |