Basic installation is uncomplicated. Run 'make all' followed by an optional
'make install'. Makefile settings you might want to change:

* SMP
  Set this to 1 on SMP systems (it should be set if it was set in the 
  main Linux kernel Makefile). There is a magic grep invocation which
  should do this automatically if you have your complete Linux source
  in /usr/src/linux. Please check whether gcc is invoked with a -D__SMP__
  argument on SMP systems, and without it on non-SMP systems!
* DEBUG
  If you set this to 1, some debugging information is generated, for
  example when reading /proc/sensors. Not recommended.
* DEVELOP
  If you set this to 1, gcc may issue many warnings.
* MODDIR
  The directory into which 'make install' installs the module. If it does
  not exist, it will be created (and all its parents too).
* INCLUDEDIR
  The directory into which 'make install' installs the include files. If 
  it does not exist, it will be created (and all its parents too).
* MODNAME
  If you have other similar modules, you may want to change the module
  name. Note that the module name has changed around versions 1.2.3;
  you may safely remove lm78.o and sensors_mod.o if they are old versions
  of our module once you find this new versions works satisfactory.
* FORCE_PIIX4_ENABLE
  This should never be required except in rare cases, but it has been
  reported that some Dell machine have Bios code which fails to
  completely initialize the SMBus interface on the PIIX4.  When set
  to 1 this option will forcefully enable the PIIX4's (if detected) 
  SMBus interface.  This assumes that i/o space addressing has been 
  properly set up by the Bios (which our code does not check for!).
  NOTE: Using this option defeats the purpose of the safty used to 
  prevent use of an uninitialized interface.

To test this module, you can run 'make all' followed by 'insmod ./lm_sensors.o'
and examine /proc/sensors.

If it bails out with saying 'System call ... already in use!' you should
edit smbus.h and change the definition of __NR_smbus_action to a free
syscall number. Please let us know in this case which package in conflicting!

If you decide you want to keep on using it, install it in a kernel-independent
module directory (like /lib/modules/extra/misc) by calling 'make install'
(with the same flags you used to compile it!). Now call 'depmod -a'. From now 
on, you can insert the module by calling 'modprobe lm_sensors' (there is no
longer any need to be in the right directory, or to insert smbus.o first).
If you add a link from /lib/modules/boot to this module, it will probably
be loaded automatically when you boot (the actual path to install this link
in will depend on your distribution). 

If you do not want to install it in a system directory, you can also add
something like this in your rc.local file:

if [ -f /root/sensors_mod.o ]
then
        echo "Installing Hardware Health Monitoring..."
        # insmod /root/smbus.o  # Uncomment if smbus.o is a separate module
	insmod /root/lm_sensors.o
	# Set initial non-standard limits
        echo "0 3" > /proc/sys/dev/lm_sensors/in1
        echo "0" > /proc/sys/dev/lm_sensors/fan1
	# My temp-1 (an LM75) controls a fan (thermostat style), so 
	#  let's set it a little low for fun and watch it turn on and off
        echo "35 30" > /proc/sys/dev/lm_sensors/temp-1
        echo "3000" > /proc/sys/dev/lm_sensors/fan2
        echo "0" > /proc/sys/dev/lm_sensors/fan3
fi

When the module is loaded, you can do 'cat /proc/sensors' and you should
see something like this:

Vcore:  +2.83V  (min = +2.52V,  max = +3.08V)
Vcore2: +0.25V  (min = +0.00V,  max = +3.00V)
+3.3V:  +3.40V  (min = +2.97V,  max = +3.63V)
+5V:    +5.05V  (min = +4.48V,  max = +5.48V)
+12V:   +11.91V (min = +10.82V, max = +13.19V)
-12V:   -12.07V (min = -10.79V, max = -13.18V)
-5V:    -5.05V  (min = -4.50V,  max = -5.49V)
Fan1:   0 rpm           (min=0 rpm)             (not connected?)
Fan2:   4116 rpm        (min=3000 rpm)   
Fan3:   0 rpm           (min=0 rpm)             (not connected?)
Mainboard: 26 C (min = 0 C,     max = 50 C)
Other alarms: (none)
VID:     2.80
Temp-1: +30.0 C (Tos = +35.0 C, Thyst = +30.0 C)

That's it!

If the auto-detection is not satisfactory (or even plain wrong), you can
use several variables with insmod to tune this:
  chip        Which chip must be assumed. No detection is done if you 
              specify this! Valid values: lm78, lm78-j, lm79, lm80, 
              w83781d, probe. Default: probe.
  smbus       Whether the LM78 should be accessed through the ISA bus (0) or 
              the SMBus (1). The default is 'try ISA first, then SMBus' (-1).
  isa_addr    The ISA I/O address of the LM78. Default: 0x290
  smbus_addr  The SMBus address of the LM78. Default: probe 0x20 to 0x2f.
  lm75_addr   The SMBus addresses of LM75 chips. Upto eight addresses can
              be specified, separated by commas. Default: probe 0x48 to 0x4f.
  no_lm78     Disable all probing and access to LM78 chips and clones
              (this disables everything except possibly a few temperature
              readings). Default: 0
  no_lm75     Disable all probing and access to LM75 chips and clones.
              Default: 0
  winb_smbus  If a w83781d is detected or specified, it is normally
              completely accessed through the ISA bus. By setting this to
              1, you force it to emulate LM75 chips instead and access them
              through the SMBus. Default: 0

An example:
  insmod lm_sensors.o chip=lm79 smbus=1 smbus_addr=0x2d

If you have compiled a separate smbus module (by setting the SMBUS_MODULE
variable in the Makefile), you can use these variables when you insmod it:
  forced      If set (1), forces the module to remain in memory, even if no
              SMBus was detected. This is important, as you would otherwise
              not be able to insmod lm_sensors.o. Default: 0

You can set the min/max levels by catting values to the files in 
/proc/sys/dev/lm_sensors. If you have not changed any #defines in
lm78.h, it should look like this:

  in0      minimum, maximum and current Vcore sensor values
  in1      minimum, maximum and current Vcore2 sensor values
  in2      minimum, maximum and current +3.3V sensor values
  in3      minimum, maximum and current +5V sensor values
  in4      minimum, maximum and current +12V sensor values
  in5      minimum, maximum and current -5V sensor values
  in6      minimum, maximum and current -12V sensor values
  fan1     minimum and current fan 1 rpm sensor values
  fan2     minimum and current fan 2 rpm sensor values
  fan3     minimum and current fan 3 rpm sensor values
  temp     minimum, maximum and current mainboard temperature sensor values 
  vid      current VCore voltage according to the VID lines
  alarm    current raised alarms
  temp-0   os, hyst and current values of first temperature sensor
  ......
  temp-7   os, hyst and current values of last temperature sensor

Note that if something is not available in hardware, the corresponding file
will not be created.

Note that an alarm will go off if the temperature comes above the os;
it will continue until the temperature drops again below hyst.

You can examine these values by catting them (less will not work!). You
can change them by echoing new values to them. Of course, you can only
change minima and maxima, not current values!

Examples:
  echo 11.5 12.5 > +12V  # Set min to 11.5V, max to 12.5V.
  echo 3000 > Fan2       # Set min to 3000 rpm.
  echo 40 > temp         # Set min temperature to 40C, do not change max
  echo 5000 2000 > Fan3  # Set min to 5000 rpm, second value is ignored

Note that there may be slight rounding problems, and the sensors can not
understand all values. So you should not be surprised if you set the +12V
minimum to 12.5, and find that it displays 12.48 or something like that.

The min is always the value closest to zero, and max the one the most far
removed. So for a negative voltage sensor, min can be -4.5, and max -5.5,
and all is as it should be.

The alarm file contains a bitvector. Please see lm_sensors.h to determine
what each bit means. You are much better off using /proc/sensors to see
what alarms are raised.

PLEASE_NOTE: The LM78 reports 0x80 for _nominal_ volatge levels, but there
isn't a set standard for which voltage inputs correspond to what power supply
sources.  So, even if your values 'look' correct, be sure your BIOS reports
the following:

IN0: Vcore 1
IN1: Vcore 2
IN2: 3.3V
IN3: 5.0V
IN4: 12.0V
IN5: -12V
IN6: -5.0V

You can now change several configuration parameters both at compile-time
and at run-time. At compile-time this is done by modifying the file
lmconfig.h. At run-time you can do this by echoing new values to files
within /proc/sys/dev/lm_sensors:

  config-in-labels: The labels for voltages displayed in /proc/sensors
  config-fan-labels: The labels for fans displayed in /proc/sensors
  config-temp-labels: The labels for temperature chips in /proc/sensors
  config-in-conv: Conversion factors for voltages
  config-fan-div: Internal fan division numbers
  config-present: Which sensors are displayed in /proc/sensors.

If you want to change the labels, you should keep in mind that each label
has a maximum length (currently 6 characters). If you try to use longer
labels, they will be automatically cut off. Labels are separated by
whitespace (so it is impossible to use a space within a label). Even if
a sensor is disabled, you still have to give it a label.

The conversion factors are the factors used to scale the voltage of the
sensors to the displayed voltages (both in /proc/sys/dev/lm_sensors files
and in /proc/sensors). Usually, the defaults should be all right.

Each fan has a division number: 1, 2, 4 or 8. Which one you set does not
really matter, as long as the fan-speed is within measure range. Setting
it lower will offer better resolution, though. Note that the third fan
division number can only be changed for Winbond chips; for other chips,
it will always be 2.

Each sensor can be removed from /proc/sensors, by setting the appropriate
bit in config-present to 0. You can reenable them later on. You can not
set bits to 1 if the corresponding sensor was not hardware-detected.
The first number is for the voltage sensors, the second for the fans, 
the third for the VID-lines, the fourth for the mainboard temperature
sensor and the last for any additional (for example LM75) temperature
sensors.
To disable IN4 (usually +12V), for example, set bit 4 of the first number 
to 0.

If something has not been detected in hardware, you will always find
<NA> or 0 at the corresponding field.

All the files in /proc/sys/dev/lm_sensors can also be accessed through
the sysctl interface. Use the 'sysctl' syscall to do this. There is an
example of the code needed in the doc subdirectory. Note that floats
are a no-no within the kernel; therefore, all numbers are scaled to
fit within integers. You can find more information in include file
lm_sensors.h.

If you want to write your own programs or modules which use devices on
the SMBus, you should check doc/SMBus. It explains all exported functions.

Keep us posted on any problems, bugs, and success stories! :')


Enjoy!


Phil, Frodo, and Alex
