From 8edb06b0d1632c7c6dcc7f56459f9ae435eb900c Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Sat, 20 Apr 2002 02:59:12 +0000 Subject: [PATCH] preliminary programmable VRM version support in w83781d. Replace VID_FROM_REG() with vid_from_reg() in new sensors_vid.h. Update library so it can be set in sensors.conf. Add new documentation. Update mkpatch for new file. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1352 7894878c-1315-0410-8ee3-d5d059ff63e0 --- doc/vid | 97 ++++++++++++++++++++++++++++++++++++ kernel/include/sensors.h | 1 + kernel/include/sensors_vid.h | 64 ++++++++++++++++++++++++ lib/chips.c | 19 ++++--- lib/chips.h | 3 ++ mkpatch/FILES | 1 + mkpatch/INCLUDES | 1 + prog/sensors/chips.c | 2 +- 8 files changed, 180 insertions(+), 8 deletions(-) create mode 100644 doc/vid create mode 100644 kernel/include/sensors_vid.h diff --git a/doc/vid b/doc/vid new file mode 100644 index 00000000..807eeeae --- /dev/null +++ b/doc/vid @@ -0,0 +1,97 @@ +VID pin settings +-------------------- + +The VID (Voltage Identification) pins on sensor chips +are used to read the CPU Core voltage setting. + +The VID setting can be controlled by jumpers on the board, +or, in newer motherboards, by settings in the BIOS. +On these newer boards, the BIOS programs some device's +pins which in turn controls a DC-DC Converter to set its +output to a certain voltage. These pins are also connected to +the sensor chip so that the VID setting can be read back +by applications. + +There are generally 5 VID pins. The VID codes are defined +by Intel in documents titled +"VRM X.X DC-DC Converter Design Guidelines". +(VRM = Voltage Regulator Module) +These documents are available at http://developer.intel.com. + +There are several different VRM document versions. +The common versions are as follows: + +Document Version Voltage Range Increment Processors +---------------- ------------- --------- ---------- +8.2 (8.1, 8.3) 1.30 - 2.05V 0.05V PII, PIII, Celeron + 2.1 - 3.5V 0.10V + +8.4 1.30 - 2.05V 0.05V PIII, Celeron + 4 pins only + +8.5 1.050 - 1.825V 0.05V PIII-S Tualatin + +9.0, (9.1) 1.100 - 1.850V 0.025V PIV, AMD Socket A + + +Note that versions 8.1 - 8.4 are compatible. + +lm_sensors versions through 2.6.3 support only the VRM 8.2 standard. + +Starting in lm_sensors 2.6.4 the VRM version is configurable. +To configure the sensor chip for the correct voltage range, +you must set the "vrm" correctly either via /proc or sensors.conf. + +To be compatible with previous lm_sensors versions, the vrm defaults +to version 8.2. + +To change the vrm version to 9.0, for example, do the following +after the chip module (in this example, w83781d) is loaded: + + echo 9.0 > /proc/sys/dev/sensors/w83781d-isa-0290/vrm + +Alternatively, add a line in /etc/sensors.conf in the w83781d section: + + set vrm 9.0 + +and then, after the chip module is loaded, do: + + sensors -s + +After this, reading the vid either by + + cat /proc/sys/dev/sensors/w83781d-isa-0290/vid + +or by + + sensors + +should show the new vid value. + + +The following values are legal vrm values: + + 8.2, 8.4, 8.5, 9.0 + + +Remember, the VID pins on the sensor chips are inputs only. +That means they can't be changed and there shouldn't be +any problems if you experiment with the vrm values until you +get it right. + + +Not all sensor chips have VID inputs. +For those that do, the VRM support status is listed below. + +The following chip drivers support all the VRM versions via +/etc/sensors.conf and the vrm entry in /proc: + + adm1024, adm1025, it87, lm87, mtp008, w83781d + + +The following chip drivers support only VRM 8.2 and cannot be changed: + + adm9240, gl520sm, lm78, maxilife + +If you have a board with one of these chips which needs advanced +VRM support please email us. diff --git a/kernel/include/sensors.h b/kernel/include/sensors.h index b042f75e..17bf7f33 100644 --- a/kernel/include/sensors.h +++ b/kernel/include/sensors.h @@ -70,6 +70,7 @@ #define W83781D_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ #define W83781D_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ #define W83781D_SYSCTL_VID 1300 /* Volts * 100 */ +#define W83781D_SYSCTL_VRM 1301 #define W83781D_SYSCTL_PWM1 1401 #define W83781D_SYSCTL_PWM2 1402 #define W83781D_SYSCTL_PWM3 1403 diff --git a/kernel/include/sensors_vid.h b/kernel/include/sensors_vid.h new file mode 100644 index 00000000..984f7f96 --- /dev/null +++ b/kernel/include/sensors_vid.h @@ -0,0 +1,64 @@ +/* + vrm.c - Part of lm_sensors, Linux kernel modules for hardware + monitoring + Copyright (c) 2002 Mark D. Studebaker + With assistance from Trent Piepho + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + This file contains common code for decoding VID pins. + This file is #included in various chip drivers in this directory. + As the user is unlikely to load more than one driver which + includes this code we don't worry about the wasted space. + Reference: VRM x.y DC-DC Converter Design Guidelines, + available at http://developer.intel.com +*/ + +/* + Legal val values 00 - 1F. + vrm is the Intel VRM document version. + Note: vrm version is scaled by 10 and the return value is scaled by 1000 + to avoid floating point in the kernel. +*/ + +#define DEFAULT_VRM 82 + +static int vid_from_reg(int val, int vrm); + +static int vid_from_reg(int val, int vrm) +{ + switch(vrm) { + + case 91: /* VRM 9.1 */ + case 90: /* VRM 9.0 */ + return(val == 0x1f ? 0 : + 1850 - val * 25); + + case 85: /* VRM 8.5 */ + return((val & 0x10 ? 25 : 0) + + ((val & 0x0f) > 0x04 ? 2050 : 1250) - + ((val & 0x0f) * 50)); + + case 84: /* VRM 8.4 */ + val &= 0x0f; + /* fall through */ + default: /* VRM 8.2 */ + return(val == 0x1f ? 0 : + val & 0x10 ? 5100 - (val) * 100 : + 2050 - (val) * 50); + } +} diff --git a/lib/chips.c b/lib/chips.c index 3f4264e2..5d3bdd82 100644 --- a/lib/chips.c +++ b/lib/chips.c @@ -738,9 +738,10 @@ static sensors_chip_feature w83781d_features[] = { SENSORS_W83781D_TEMP3_OVER, "temp3_over", SENSORS_W83781D_TEMP3, SENSORS_W83781D_TEMP3, SENSORS_MODE_RW, W83781D_SYSCTL_TEMP3, VALUE(1), 1 }, - { SENSORS_W83781D_VID, "vid", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, - SENSORS_MODE_R, W83781D_SYSCTL_VID, VALUE(1), 2 }, + SENSORS_MODE_R, W83781D_SYSCTL_VID, VALUE(1), 3 }, + { SENSORS_W83781D_VRM, "vrm", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, + SENSORS_MODE_R, W83781D_SYSCTL_VRM, VALUE(1), 1 }, { SENSORS_W83781D_FAN1_DIV, "fan1_div", SENSORS_W83781D_FAN1, SENSORS_NO_MAPPING, SENSORS_MODE_RW, W83781D_SYSCTL_FAN_DIV, VALUE(1), 0 }, @@ -875,9 +876,10 @@ static sensors_chip_feature as99127f_features[] = { SENSORS_W83782D_TEMP3_OVER, "temp3_over", SENSORS_W83782D_TEMP3, SENSORS_W83782D_TEMP3, SENSORS_MODE_RW, W83781D_SYSCTL_TEMP3, VALUE(1), 1 }, - { SENSORS_W83782D_VID, "vid", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, - SENSORS_MODE_R, W83781D_SYSCTL_VID, VALUE(1), 2 }, + SENSORS_MODE_R, W83781D_SYSCTL_VID, VALUE(1), 3 }, + { SENSORS_W83782D_VRM, "vrm", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, + SENSORS_MODE_R, W83781D_SYSCTL_VRM, VALUE(1), 1 }, { SENSORS_W83782D_FAN1_DIV, "fan1_div", SENSORS_W83782D_FAN1, SENSORS_NO_MAPPING, SENSORS_MODE_RW, W83781D_SYSCTL_FAN_DIV, VALUE(1), 0 }, @@ -1017,9 +1019,10 @@ static sensors_chip_feature w83782d_features[] = { SENSORS_W83782D_TEMP3_OVER, "temp3_over", SENSORS_W83782D_TEMP3, SENSORS_W83782D_TEMP3, SENSORS_MODE_RW, W83781D_SYSCTL_TEMP3, VALUE(1), 1 }, - { SENSORS_W83782D_VID, "vid", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, - SENSORS_MODE_R, W83781D_SYSCTL_VID, VALUE(1), 2 }, + SENSORS_MODE_R, W83781D_SYSCTL_VID, VALUE(1), 3 }, + { SENSORS_W83782D_VRM, "vrm", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, + SENSORS_MODE_R, W83781D_SYSCTL_VRM, VALUE(1), 1 }, { SENSORS_W83782D_FAN1_DIV, "fan1_div", SENSORS_W83782D_FAN1, SENSORS_NO_MAPPING, SENSORS_MODE_RW, W83781D_SYSCTL_FAN_DIV, VALUE(1), 0 }, @@ -1136,7 +1139,9 @@ static sensors_chip_feature w83783s_features[] = SENSORS_W83783S_TEMP2, SENSORS_MODE_RW, W83781D_SYSCTL_TEMP2, VALUE(1), 1 }, { SENSORS_W83783S_VID, "vid", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, - SENSORS_MODE_R, W83781D_SYSCTL_VID, VALUE(1), 2 }, + SENSORS_MODE_R, W83781D_SYSCTL_VID, VALUE(1), 3 }, + { SENSORS_W83783S_VRM, "vrm", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, + SENSORS_MODE_R, W83781D_SYSCTL_VRM, VALUE(1), 1 }, { SENSORS_W83783S_FAN1_DIV, "fan1_div", SENSORS_W83783S_FAN1, SENSORS_NO_MAPPING, SENSORS_MODE_RW, W83781D_SYSCTL_FAN_DIV, VALUE(1), 0 }, diff --git a/lib/chips.h b/lib/chips.h index 059b30a7..13a27b25 100644 --- a/lib/chips.h +++ b/lib/chips.h @@ -358,6 +358,7 @@ #define SENSORS_W83781D_TEMP3_HYST 58 /* RW */ #define SENSORS_W83781D_TEMP3_OVER 59 /* RW */ #define SENSORS_W83781D_VID 61 /* R */ +#define SENSORS_W83781D_VRM 62 /* RW */ #define SENSORS_W83781D_FAN1_DIV 71 /* RW */ #define SENSORS_W83781D_FAN2_DIV 72 /* RW */ #define SENSORS_W83781D_FAN3_DIV 73 /* R (yes, really! */ @@ -420,6 +421,7 @@ #define SENSORS_W83782D_TEMP3_HYST 58 /* RW */ #define SENSORS_W83782D_TEMP3_OVER 59 /* RW */ #define SENSORS_W83782D_VID 61 /* R */ +#define SENSORS_W83782D_VRM 62 /* RW */ #define SENSORS_W83782D_FAN1_DIV 71 /* RW */ #define SENSORS_W83782D_FAN2_DIV 72 /* RW */ #define SENSORS_W83782D_FAN3_DIV 73 /* R (yes, really! */ @@ -471,6 +473,7 @@ #define SENSORS_W83783S_TEMP2_HYST 55 /* RW */ #define SENSORS_W83783S_TEMP2_OVER 56 /* RW */ #define SENSORS_W83783S_VID 61 /* R */ +#define SENSORS_W83783S_VRM 62 /* RW */ #define SENSORS_W83783S_FAN1_DIV 71 /* RW */ #define SENSORS_W83783S_FAN2_DIV 72 /* RW */ #define SENSORS_W83783S_FAN3_DIV 73 /* R (yes, really! */ diff --git a/mkpatch/FILES b/mkpatch/FILES index e8d4d8b3..9e15aa54 100644 --- a/mkpatch/FILES +++ b/mkpatch/FILES @@ -37,4 +37,5 @@ kernel/chips/thmc50.c drivers/sensors/thmc50.c kernel/chips/via686a.c drivers/sensors/via686a.c kernel/chips/w83781d.c drivers/sensors/w83781d.c kernel/include/sensors.h include/linux/sensors.h +kernel/include/sensors_vid.h include/linux/sensors_vid.h mkpatch/Config.in drivers/sensors/Config.in diff --git a/mkpatch/INCLUDES b/mkpatch/INCLUDES index e8ff8c0f..4d9b8235 100644 --- a/mkpatch/INCLUDES +++ b/mkpatch/INCLUDES @@ -1,2 +1,3 @@ "i2c-isa.h" "sensors.h" +"sensors_vid.h" diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index b6f0c8db..45d231f3 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -2103,7 +2103,7 @@ void print_w83781d(const sensors_chip_name *name) !sensors_get_feature(*name,SENSORS_W83781D_VID,&cur)) { if (valid) { print_label(label,10); - printf("%+6.2f V\n",cur); + printf("%+5.3f V\n",cur); } } else { printf("ERROR: Can't get VID data!\n");