vt1211 module for 2.6 kernel

by Lars Ekman (emil71se at bredband . net)

This driver is now obsolete

WARNING
The vt1211 module has finally made it to the kernel and is included in 2.6.19.

Please use the official version. Here is a note from maintainers;

        It is particularly important because we made some interface
        changes to both the driver and libsensors to comply with the
        sysfs interface guidelines, so it is expected that people
        using your driver with a recent version of lm_sensors (2.10.1
        or later) will encounter problems, in particular with
        temperatures. If your page would warn them about that, I hope
        we'll receive less complaints about this particular issue.

This may be the last update of this page. Thanks for all comments and contributions.

Best Regards, Lars Ekman.

Introduction

The vt1211 is a sensor chip used for instance on the EPIA-CL Mini-ITX board which I have. The board has a fan-less VIA-eden processor, and I have not connected the fan in the box. I am worried about the temperature, so I want to monitor it.

The driver for vt1211 has not been ported to kernel version 2.6 by the lm_sensors project yet. The port has been listed as in progress for several months so I decided to port it myself and hopefully give something back to the open source community.

Just to cearify; the vt1211 sensor driver was written by Mark D. Studebaker, I have just made adaptations for the 2.6 kernels.

Maintenance of the vt1211 driver (Sun Jan 22)

I am currently not using my Mini-ITX so I will not personally update the driver for new kernels. I will however add contibuted updates to this page. So is anybody makes an update I am grateful if you send it to me, or a link to where it can be found.

There is an ongoing work to put the vt1211 driver into the kernel tree, but it is kind of slow.

News

Tue Dec 19 09:03:33 CET 2006
The vt1211-2.6.18.2.patch.gz was compressed twice. (my misstake, sorry)
Mon Dec 11 18:24:12 CET 2006
The vt1211 is included in 2.6.19.
Sun Nov 19 10:02:33 CET 2006
Added a patch for 2.6.18.2 and a pre-built module for 2.6.18-1.2239.fc5.
Sun Aug 20 20:14:28 CEST 2006
Added a pre-built vt1211.ko for Fedora Core 5 (2.6.17-1.2174_FC5).
Thu Jul 20 21:50:41 CEST 2006
Added a kernel patch for 2.6.17.
Wed Jul 5 18:40:44 CEST 2006
Added an installation guide for the vt1211 on a Mandriva 2006 box. Added a pre-built vt1211 driver for the ubuntu i386 kernel version 2.6.15-25-i386.
Thu Apr 27 19:12:00 CEST 2006
Added a new driver for 2.6.16. Constants removed from the kernel headers now included in the driver.
Thu Feb 23 22:22:50 CET 2006
Added another 2.6.15 driver. Hopefully this one works.
Mon Feb 20 19:24:07 CET 2006
Withdraw the 2.6.15 patch which gives a EACCESS (permission denied error). The 2.6.15 vt1211.c is still included, but with a comment. Comment about PD-6000E added.
Sun Feb 5 20:56:21 CET 2006
Added a vt1211.c for 2.6.16-rc2. See more info below.
Fri Jan 27 21:06:03 CET 2006
Added Permission Denied info for the 2.6.15 version.
Sun Jan 22 09:31:09 CET 2006
Added new Maintenance of the vt1211 driver paragraph.

Added new 2.6.15 patch. This patch was contributed by a user. I have only made the patch. My thanks for the contribution.

The module

Latest version

Two contributed updates.

Patch for 2.6.18.2;

Pre-built module for 2.6.18-1.2239.fc5;

Older versions

This is reported to work for 2.6.17;

And here is a pre-built version for Fedora Core 5 (2.6.17-1.2174_FC5). Note that pre-built drivers does not work for everyone due to version missmatches, but if it works it might save some time.

Reported to work with 2.6.16;

Here is a part of the mail explaining what' done;

        I've tried to compile the 2.6.15 driver against 2.6.16 tree
        and failed. There are two reasons - first, the id for VT1211
        driver has been removed for the kernel header and second - the
        i2c_driver struct has changed: now the name and owner fields
        are stored inside another structure embedded in i2c_driver
        struct.  I've redefined the old id in driver file (since Linux
        seems to use lm sensors id-s anyhow) and changed the structure
        initialization. Please publish this file on your page.  I've
        tested with 2.6.16.11.

Here is a pre-built driver for ubuntu i386 kernel version 2.6.15-25-i386;

And an installation guide for the vt1211 on a Mandriva 2006 box;

Here is the source and a kernel patch for older kernels;

NOTE
The 2.6.13 kernel requires an updated vt1211 driver from the patch below. Older versions of the driver gives an Oops when a sysfs file is accessed on 2.6.13.
NOTE
The 2.6.14 kernel requires yet another updated driver. The /sys files are created in a new place, I don't know if that is as it should be. For example; /sys/devices/platform/i2c-9191/9191-6000/temp3_input

The driver has been updated for release to the linux kernel. Here is a summary of the changes compared to the earlier version;

The driver can be built manually with;

        echo "obj-m := vt1211.o" > Makefile
        make -C /path/to/your/kernel2.6/source/dir SUBDIRS=$PWD modules

Read the Documentation/kbuild/modules.txt in your kernel directory for more info about how to build modules.

Older kernels than 2.11.x (e.g Debian)

NOTE
This patch will not work with older kernels. In particular is will fail on Debian which uses 2.6.8 (I think?). See the work-around below. Hopefully I will get time to make another patch shortly.

The normal_i2c_range and normal_isa_range was removed when preparing the module for integation in the kernel-tree for 2.6.11. Older kernels requires those parameters.

Please try a patch available under the Older versions section on my web page.

Or ou can simply add the removed lines (tested by others). If so add before line 74 where you get the error;

...
static unsigned short normal_i2c[] = { I2C_CLIENT_END };
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };

SENSORS_INSMOD_1(vt1211);
...

Intall the module

Install it with the usual module-init-tools;

        insmod i2c-sensor.ko
        insmod vt1211.ko

The example is my commands. You may use modprobe , or require more or less modules to be loaded before vt1211.ko.

NOTE
The i2c-isa.ko module is required, else the 0-6000 directories will be missing. It seems like modprobe can miss this. A user had this problem on Fedora Core 3 test2.

Check the result by examining the /sys files;

# cd /sys/devices/platform/i2c-0/0-6000/
# ls
alarms           fan2_pwm         in4_max          temp3_input
detach_state     fan2_pwm_enable  in4_min          temp3_max
fan1_div         in0_ref          in5_input        temp3_max_hyst
fan1_input       in2_input        in5_max          temp4_input
fan1_min         in2_max          in5_min          temp4_max
fan1_pwm         in2_min          name             temp4_max_hyst
fan1_pwm_enable  in3_input        power            vrm
fan2_div         in3_max          temp2_input
fan2_input       in3_min          temp2_max
fan2_min         in4_input        temp2_max_hyst
# cat temp3_input in[2345]_input
99250
1190
1900
2090
2020

The i2c-0/0-6000 is an address and may differ on your system.

Register convertion

The values in the files under /sys are raw un-converted register values. These will be converted to readable values by some program like sensors . Or you can check the formulas in sensors.conf and convert them yourself;

        # compute temp3  (@ - 65) / 0.9686,  (@ * 0.9686) + 65
        echo "scale=2; (99.250-65)/0.9686" | bc -q
        35.36

So the register value 99250 is converted to 35.36 degree Celsius. The example uses bc for the computation. Note that the value from the driver is divided by the multiplier .

The sensors.conf from lm_sensors works fine on my EPIA-CL except for the Core voltage konstant which should be 1.0.

However the EPIA-M boards seems to need a modified sensors.conf . Since I do not own a EPIA-M myself I can only provide files cotributed by others. Here are some;

sensors.conf.txt
A sensors.conf for the EPIA-M 10000N board from Simon. This is also reported to work with the PD-6000E board.
sensors2.conf.txt
Another contributed sensors.conf for the EPIA-M 10000N, found at VIAARENA in Oct 2003.

Here are a configuration for gkrellm that corresponds to the standard sensors.conf. It works fine on my EPIA-CL board, but will probably not be accurate for EPIA-M boards.

gkrellm multipliers for EPIA-CL (probably not EPIA-M)
Register Factor Offset
temp3 (CPU) 1.0324 -67.1071
in2 (Core) 1.0438 -0.031
in3 (+5V) 2.5050 -0.075
in4 (+12V) 5.9512 -0.178
in5 (+3.3V) 1.6579 -0.050
NOTE
If you have a sensors.conf or gkrellm multipliers for other boards, please send them to me and I will include them in this section.

Configuration

It is possible to configure some sensors for either temp or voltage ( in ). This is done by writing to the file;

This file contains a bitmask for the sensors. The following table is taken from the sensors.conf file;

uch_config bits
Sensor Voltage Mode Temp Mode config bit
Reading 1 temp3
UCH1/Reading2 in0 temp2 0x04 (4)
UCH2 in1 temp4 0x08 (8)
UCH3 in2 temp5 0x10 (16)
UCH4 in3 temp6 0x20 (32)
UCH5 in4 temp7 0x40 (64)
3.3V in5

Usually this is set by BIOS and should not be changed.

A fix in libsensors so that uch_config can be set by sensors -s is checked in.

Testing

I know there are tools for reading the sensors, but I have only tested this by printing the files under /sys. My Mini-ITX system is a primitive diskless system so installing tools (especially perl based) requires too much job.

I have tried to compare the CPU temperature and the voltages towards the PC Health Status menu on the BIOS screen. The voltage values are about the same. The CPU temperature from the vt1211 module seems a bit (~4 degrees) higher than the BIOS value. I do not know why or which is most correct, but I think its the same if you run the original 2.4 version of the module.

The fan_pwm is supposed to control the fan speed. I connected the fan in my system but could not control it. I read something on the viaarena forum that the fan on my board is connected to 12V always, so this is not necessarily a fault. I think the value is written ok by the driver, but the HW refuses to accept it. Example;

# echo 1 > fan2_pwm_enable
# echo 50 > fan2_pwm; cat fan2_pwm
50
# cat fan2_pwm
255

The value 50 seems to be written, but when the HW value is re-read by the driver it is back to 255 (100% fan speed).

The thermistor sensors (temp2 and temp4) are not used on my board so I can not test them. The translation formula is again taken from /etc/sensors.conf and seems a bit simplified compared to via686a.

Most other values I have just tried to read and write. No alarms tested. Some things like the vrm I do not understand, so I can't test them.

Older versions

The older version of this driver contained register convertions and did not include all sensor files by default. Here is some information about the old version of the driver. It should be considered obsolete.

Patches and packages

Stefan Plattner has provided alternative ways of installing the vt1211 driver. These are easier than the instruction above for most Linux users.

First the vt1211 driver as a patch to the kernel instead of a stand-alone module.

And a ready to use debian package of kernel 2.6.8 with all the relevant epia patches plus supermount is available here.

My thanks to Stefan for providing these packages.

On request I have made a kernel path for the 2.6.10 kernel. The module is not altered at all;

The 2.6.10 patch works for 2.6.10 but with warnings. Here is a version for 2.6.11. The module is still the same.

Conversion Confusion

When I made the port i read these documents in the Documentation/i2c/ directory in the kernel source;

The examples below is taken from kernel 2.6.8.1. In the porting-clients you can read;

        "Use the file names specified in Documentation/i2c/sysfs-interface
         for the individual files. Also convert the units these files read 
         and write to the specified ones."

The units in sysfs-interface is for instance instance;

        temp[1-4]_input Temperature input value.
                Unit: millidegree Celcius
                Read only value.

From this I concluded that the conversions should be done inside the driver. This is also done in the other VIA driver, the via686a.c . But I was wrong ...

I got a mail from Simon who owns a new EPIA-M 10000N board. On his board the register conversions are different. For instance;

        temp3 (@*@*0.0046)-(@*0.088)-0.748, (@*0.9686)+65

Here is the sensors.conf for the EPIA-M 10000N board from Simon;

Here is another contributed sensors.conf for the EPIA-M 10000N, found at VIAARENA about 12 month ago (Oct 2003);

For other (older) boards the sensors.conf in the lm_sensors package will probably do nicely.

Reading the sysfs-interface again more carefully I found;

        ... the conversions cannot be hard coded into the driver and
        have to be done in user space.

        For this reason, even if we aim at a chip-independant
        libsensors, it will still require a configuration file
        (e.g. /etc/sensors.conf) for proper values conversion,
        labeling of inputs and hiding of unused inputs.

So the register values should not be converted by the driver. But the register values should still be multiplied by a factor inside the driver.

Register multipliers
Multiplier 2.4 kernel 2.6 kernel
TEMP_MULTIPLIER 10 1000
IN_MULTIPLIER (volt) 1(?) 10(?)

The IN_MULTIPLIER I think is incorrect in my 2.4 version (from lm_sensors-2.8.5) it should be 10 to fit the sensors.conf formulas. Further I think the the value should really be 1000 in the 2.6 version. Here is an example with IN_MULTIPLIER=10;

        # compute in4 ((@ * 100) - 3) / (0.1754 * 95.8), ...
        > cat /sys/devices/platform/i2c-0/0-6000/in4_input
        2080
        > echo "((2080*100)-3)/(0.1754*95.8)" | bc -q
        12378

This is the 12V in milli-volt, so it looks OK. But the formula contains (@*100) which no other sensor-chip driver has. So I really think that IN_MULTIPLIER=1000 should be used, and the formula should be;

        compute in4 (@ - 3) / (0.1754 * 95.8),

As you might understand I am a bit confused about this, but is is clear that the conversion should not be done by the driver. So The internal register conversion is disabled by default, but can be re-enabled. The register multipliers are macros and easy to alter.

It shouldn't be very hard to alter the driver and the translation files (e.g /etc/sensors.conf) to get correct values, but if anybody knows the correct way, please let me know.

Generated: Tue Dec 19 09:04:26 2006