diff --git a/INSTALL b/INSTALL index 2ccd21e1..15a88864 100644 --- a/INSTALL +++ b/INSTALL @@ -30,6 +30,9 @@ this package. Some interesting variables: The prefix which is added to most directory locations below. * MODDIR (/lib/modules/extra/misc) The directory where 'make install' installs your modules. +* ETCDIR (/etc) + The directory where 'make install' installs the example configuration file + if none is found there. * LIBDIR ($(PREFIX)/lib) The directory where 'make install' installs the shared and static libraries. * BINDIR ($(PREFIX)/bin) @@ -78,14 +81,21 @@ If you have installed the modules, as described within doc/modules, you can do 'modprobe isa && modprobe piix4 && modprobe lm78 && modprobe i2c-proc' (the last is optional) from any directory to reach the same situation. -This package also contains a library of functions which can be used to +Do not panic if some (or all) of the values in the /proc/sys/dev/sensors/*/* +files do not seem to correspond to anything in earlier versions. Starting +with lm_sensors version 2.1.0, these files will reflect the real chip +measurements, without any scaling or adjusting. This is most obvious for +the voltage files. You can specify the conversion factors in a configuration +file. Use an application linked to libsensors to read these real values. + +This package contains a library of functions which can be used to access sensor data in a more programmer-friendly way. It will be built as both a shared and a static library, and installed in your LIB directory (normally /usr/local/lib). It needs a configuration file, which is usually called 'sensors.conf', and can be placed in /etc, /usr/lib/sensors, /usr/local/lib/sensors, /usr/lib, or /usr/local/lib. [NOTE: No real -standard config file is written yet. A very simple example can be found in -the prog/sensors directory.] +config file documentation is written yet. A relatively well-commented +example can be found in the etc directory.] Where version 1 of this package had the human-readable /proc/sensors file, this version includes a user-space program which gathers all data diff --git a/Makefile b/Makefile index 6e8c3afd..1df24a90 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,10 @@ PREFIX := /usr/local # This is the directory into which the modules will be installed. MODDIR := /lib/modules/extra/misc +# This is the directory where sensors.conf will be installed, if no other +# configuration file is found +ETCDIR := /etc + # You should not need to change this. It is the directory into which the # library files (both static and shared) will be installed. LIBDIR := $(PREFIX)/lib @@ -95,7 +99,7 @@ LIBINCLUDEDIR := $(INCLUDEDIR)/sensors # to do this. # The subdirectories we need to build things in -SRCDIRS := src lib prog/sensors +SRCDIRS := src lib prog/sensors etc ifeq ($(I2C),1) SRCDIRS += i2c i2c/detect i2c/drivers i2c/eeprom endif diff --git a/README b/README index 283e6271..b4df41d7 100644 --- a/README +++ b/README @@ -53,7 +53,7 @@ support both ways of accessing them. Because the SMBus is just a special case of the generalized I2C bus, we can simulate the SMBus protocol on plain I2C busses. These busses are -sometimes used in other parts of your computer. If a supported chips is +sometimes used in other parts of your computer. If a supported chip is attached to one of these additional busses, they can be used too. Please read INSTALL before trying to compile and install these modules. diff --git a/README.directories b/README.directories index a03648b9..7412fd9a 100644 --- a/README.directories +++ b/README.directories @@ -7,12 +7,14 @@ The directories within this package: (mod-????????.tar.gz). * doc Documentation about the modules within this package +* etc + Configuration files * i2c Simon Vogl's i2c module, including any necessary patches, excluding any files which are removed by 'make clean'. -* src - Our own module code. * lib The user-space sensors support library code * prog Several supporting programs, some of them use the library, some do not. +* src + Our own module code. diff --git a/etc/Module.mk b/etc/Module.mk new file mode 100644 index 00000000..f76a2ed5 --- /dev/null +++ b/etc/Module.mk @@ -0,0 +1,36 @@ +# Module.mk - Makefile for a Linux module for reading sensor data. +# Copyright (c) 1998 Frodo Looijaard +# +# 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. + +# Note that MODULE_DIR (the directory in which this file resides) is a +# 'simply expanded variable'. That means that its value is substituted +# verbatim in the rules, until it is redefined. +MODULE_DIR := etc + +ETCTARGET := $(MODULE_DIR)/sensors.conf.eg +ETCINSTALL := $(ETCDIR)/sensors.conf + + +# No all rule + +install-etc: + $(MKDIR) $(ETCDIR) + if [ ! -e $(ETCINSTALL) ] ; then \ + $(INSTALL) -o root -g root -m 644 $(ETCTARGET) $(ETCINSTALL); \ + fi +install :: install-etc + +# No clean rule diff --git a/etc/sensors.conf.eg b/etc/sensors.conf.eg new file mode 100644 index 00000000..1d870522 --- /dev/null +++ b/etc/sensors.conf.eg @@ -0,0 +1,120 @@ +# Hardware sensors configuration file + +# This configuration file will be used by all applcations linked to +# libsensors. + +# Hash marks introduce comments, which continue until the end of a line +# +# Identifiers consisting of only digits and letters can be used +# unquoted; other identifiers must be quoted. Escape characters within +# quotes operate like those in C. + +# A 'chip' line specifies what the following 'label', 'compute', 'set' and +# (not yet implemented) 'valid' lines refer to. In this case, until the +# next 'chip' line, everything refers to all lm78, lm78-j and lm79 +# chips. Other examples are *-isa-* for everything on the ISA bus, and +# lm78-j-i2c-*-4e for all lm78-j chips on address 0x4e of any I2C bus. +# +# If more chip statements match a specific chip, they are all considered. +# Later lines overrule earlier lines, so if you set the in0 label for +# lm78-* to "This", and later on the in0 label for lm78-isa-* to "That", +# "That" is used for LM78 chips on the ISA bus, and "This" for LM78 +# chips on a non-ISA bus. + +chip "lm78-*" "lm78-j-*" "lm79-*" + +# A label line describes what a certain feature stands for on your +# mainboard. Programs can retrieve these names and display them. +# If no label is specified for a certain feature, the default name +# (ie. 'fan1' for fan1) is used. + +# If you specify a label for in1, this label is also used for in1_min and +# in1_max, unless they have their own labels declared. There are several +# of these logical groups. + +# These are as advised in the LM78 and LM79 data sheets, and used on almost +# any # mainboard we have seen. + + label in0 "VCore 1" + label in1 "VCore 2" + label in2 "+3.3V" + label in3 "+5V" + label in4 "+12V" + label in5 "-12V" + label in6 "-5V" + +# A compute line describes how to scale a certain feature. There are +# two expressions in it: the first describes how the /proc value must +# be translated to a user value, the second how a user value must be +# translated to a /proc value. 'val' is the value to operate on. + +# Like for the label statement, there are logical groups here. They are +# sometimes a bit different, though. For example, fan1_div is in the +# logical label group of fan1 (it gets the same label if none is declared +# for it), but it is not in the compute group of fan1 (as it uses a +# completely different system of values). + +# For positive voltages (in0..in4), two resistors are used, with the following +# formula (R1,R2: resistor values, Vs: read voltage, Vin: pin voltage) +# R1 = R2 * (Vs/Vin - 1) +# For negative voltages (in5, in6) two resistors are used, with the following +# formula (Rin,Rf: resistor values, Vs: read voltage, Vin: pin voltage) +# Rin = (Vs * Rf) / Vin + +# Here are the official LM78 and LM79 data sheet values. +# Vs R1,Rin R2,Rf Vin +# in3 +5.0 6.8 10 +2.98 +# in4 +12.0 30 10 +3.00 +# in5 -12.0 240 60 +3.00 +# in6 -5.0 100 60 +3.00 + +# These would lead to these declarations: +# compute in3 ((6.8/10)+1)*val , val/((6.8/10)+1) +# compute in4 ((30/10)+1)*val , val/((30/10)+1) +# compute in5 -(240/60)*val , -val/(240/60) +# compute in6 -(100/60)*val , -val/(100/60) + +# On almost any mainboard we have seen, the Winbond compute values lead to +# much better results, though. + +# Vs R1,Rin R2,Rf Vin +# in4 +12.0 28 10 +3.00 +# in5 -12.0 210 60.4 +3.00 +# in6 -5.0 90.9 60.4 +3.00 + +# These leads to these declarations: + compute in3 ((6.8/10)+1)*val , val/((6.8/10)+1) + compute in4 ((28/10)+1)*val , val/((28/10)+1) + compute in5 -(210/60.4)*val , -val/(210/60.4) + compute in6 -(90.9/60.4)*val , -val/(90.9/60.4) + +# Set statements set things like limits. Complete expressions can be +# used. Not everything can sensibly be set: setting 'in0', for example, +# is impossible! These settings # are put through the compute translations; +# so if we specify '12.8' # for in6, '3.2' will actually be written! + +# Though set statements are correctly parsed at this moment, nothing will +# be done with them yet by libsensors + +# Invalid statements tell certain features are not wanted. User programs can +# still read them if they really want, though; this is just an advisory +# marking. 'in0' would also invalidate 'in0_max' and 'in0_min'. +# The invalid keyword is not yet recognized by the parser. + + +# There is one other feature: the 'bus' statement. An example is below. + +bus "i2c-0" "SMBus PIIX4 adapter at e800" "Non-I2C SMBus adapter" + +# If we refer from now on to 'i2c-0' in 'chip' lines, this will run-time +# be matched to this bus. So even if the PIIX4 is called 'i2c-5' at that +# moment, because five other adapters were detected first, 'i2c-0' in +# the config file would always only match this physical bus. In the above +# config file, this feature is not needed; but the next lines would +# only affect the LM75 chips on the PIIX4 adapter: + +chip "lm75-i2c-0-*" + +# You should really use the output of /proc/bus/chips to generate bus lines, +# because one mistyped characted will inhibit the match. Wildcards are not +# yet supported; spaces at the end are ignored, though. diff --git a/kernel/chips/lm78.c b/kernel/chips/lm78.c index 319af658..a9cb5c06 100644 --- a/kernel/chips/lm78.c +++ b/kernel/chips/lm78.c @@ -65,11 +65,8 @@ /* Conversions. Rounding is only done on the TO_REG variants. */ -static int lm78_in_conv[7] = {10000, 10000, 10000, 16892, 38000, - -34768, -15050 }; -#define IN_TO_REG(val,nr) (((((val) * 100000 / lm78_in_conv[nr]) + 8) / 16) \ - & 0xff) -#define IN_FROM_REG(val,nr) (((val) * 16 * lm78_in_conv[nr]) / 100000) +#define IN_TO_REG(val,nr) (((val) * 10 + 8)/16) +#define IN_FROM_REG(val,nr) (((val) * 16) / 10) #define FAN_TO_REG(val) ((val)==0?255:((1350000+(val))/((val)*2)) & 0xff) #define FAN_FROM_REG(val) ((val)==0?-1:(val)==255?0:1350000/((val)*2)) @@ -84,14 +81,15 @@ static int lm78_in_conv[7] = {10000, 10000, 10000, 16892, 38000, #define DIV_FROM_REG(val) (1 << (val)) #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) -/* Initial limits */ +/* Initial limits. To keep them sane, we use the 'standard' translation as + specified in the LM78 sheet. Use the config file to set better limits. */ #define LM78_INIT_IN_0 (vid==350?280:vid) #define LM78_INIT_IN_1 (vid==350?280:vid) #define LM78_INIT_IN_2 330 -#define LM78_INIT_IN_3 500 -#define LM78_INIT_IN_4 1200 -#define LM78_INIT_IN_5 -1200 -#define LM78_INIT_IN_6 -500 +#define LM78_INIT_IN_3 (((500) * 100)/168) +#define LM78_INIT_IN_4 (((1200) * 10)/38) +#define LM78_INIT_IN_5 (((-1200) * -604)/2100) +#define LM78_INIT_IN_6 (((-500) * -604)/909) #define LM78_INIT_IN_PERCENTAGE 10 diff --git a/src/lm78.c b/src/lm78.c index 319af658..a9cb5c06 100644 --- a/src/lm78.c +++ b/src/lm78.c @@ -65,11 +65,8 @@ /* Conversions. Rounding is only done on the TO_REG variants. */ -static int lm78_in_conv[7] = {10000, 10000, 10000, 16892, 38000, - -34768, -15050 }; -#define IN_TO_REG(val,nr) (((((val) * 100000 / lm78_in_conv[nr]) + 8) / 16) \ - & 0xff) -#define IN_FROM_REG(val,nr) (((val) * 16 * lm78_in_conv[nr]) / 100000) +#define IN_TO_REG(val,nr) (((val) * 10 + 8)/16) +#define IN_FROM_REG(val,nr) (((val) * 16) / 10) #define FAN_TO_REG(val) ((val)==0?255:((1350000+(val))/((val)*2)) & 0xff) #define FAN_FROM_REG(val) ((val)==0?-1:(val)==255?0:1350000/((val)*2)) @@ -84,14 +81,15 @@ static int lm78_in_conv[7] = {10000, 10000, 10000, 16892, 38000, #define DIV_FROM_REG(val) (1 << (val)) #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) -/* Initial limits */ +/* Initial limits. To keep them sane, we use the 'standard' translation as + specified in the LM78 sheet. Use the config file to set better limits. */ #define LM78_INIT_IN_0 (vid==350?280:vid) #define LM78_INIT_IN_1 (vid==350?280:vid) #define LM78_INIT_IN_2 330 -#define LM78_INIT_IN_3 500 -#define LM78_INIT_IN_4 1200 -#define LM78_INIT_IN_5 -1200 -#define LM78_INIT_IN_6 -500 +#define LM78_INIT_IN_3 (((500) * 100)/168) +#define LM78_INIT_IN_4 (((1200) * 10)/38) +#define LM78_INIT_IN_5 (((-1200) * -604)/2100) +#define LM78_INIT_IN_6 (((-500) * -604)/909) #define LM78_INIT_IN_PERCENTAGE 10