Ronja logo
I2C2P Usage
Twibright logo

Supported operating systems

Currently, only Linux kernel driver is written for 2.4 and 2.6 series. If your operating system differs, you have to write a driver according to Programming specification of I2C2P.

Downloading kernel source tree

Decide if you want to use your existing Linux kernel source tree on your disk or download brand new one. If you want to download a new one, download a linux kernel source tree from 2.4 or 2.6 series and unpack. You end up with a directory named for example linux-2.6.10.

Downloading the patch

Download the i2c2p.patch and place it into the linux kernel directory (e. g. linux-2.6.10).


Enter the linux kernel source tree directory (e.. g. linux-2.6.10) and issue the patch command:

clock@beton:~/linux-2.6.10$ patch -Np1 -i i2c2p.patch 
patching file drivers/i2c/busses/i2c-parport.c
patching file drivers/i2c/busses/i2c-parport.h
Failure looks like this:
clock@beton:~/linux-2.6.10$ patch -Np1 -i i2c2p.patch 
patching file Documentation/i2c/dev-interface
Hunk #1 FAILED at 3.
Hunk #2 FAILED at 19.
2 out of 2 hunks FAILED -- saving rejects to file Documentation/i2c/dev-interface.rej
patching file drivers/i2c/busses/i2c-parport.c
patching file drivers/i2c/busses/i2c-parport.h
If you encounter failure and your kernel is from 2.4 or 2.6 series, then it's a problem of I2C2P and please contact the user support.

(Re)compiling and installing the kernel

(Re)compile and install the kernel as usual. (It's the job of Linux kernel project to supply informations how this should be properly done.)

Compiled-in vs. modular driver

The module that handles I2C2P is a general-purpose driver for parallel port I2C adapters called i2c-parport. It can be either a modules i2c-parport or be compiled in directly from make menuconfig, Device Drivers, I2C Support, I2C Hardware Bus support, Parallel port adapter.

There are two ways how to pass parameters to linux kernel drivers. One is commandline during boot (lilo, grub etc.) which is used when the code is hard-compiled inside kernel. The other is module parameters that are passed to insmod od modprobe commands. The latter way is used when the code is compiled as a module.

The module parameters are documented this way:

clock@oberon:~$ modinfo i2c-parport
parm:           type:Type of adapter:
 0 = Philips adapter
 1 = home brew teletext adapter
 2 = Velleman K8000 adapter
 3 = ELV adapter
 4 = ADM1032 evaluation board
 5 = ADM1025, ADM1030 and ADM1031 evaluation boards
 6 = Twibright I2C2P adapter

author:         Jean Delvare 
description:    I2C bus over parallel port
license:        GPL
vermagic:       2.6.9 PENTIUM4 gcc-3.3

You can make boot time parameter from module parameter. For example modprobe i2c-parport type=6 can be written at boot time as i2c-parport.type=6. See Documentation/kernel-parameters.txt for more info.


Choose whether you would like to use module or hard-compiled driver according to your own personal taste.

Example module configuration

To use the I2C bus meaningfully, you have to connect something to it. In this example we connected a PCF8591 chip which is supported by Linux kernel by module called pcf8591. The pcf8591 module also has its own module paramters, that are related to the PCF8591 chips' features and also to the I2C bus stuff like addresses etc.:

clock@oberon:~$ modinfo pcf8591
parm:           force:List of adapter,address pairs to boldly assume to be present
parm:           force_pcf8591:List of adapter,address pairs which are unquestionably assumed to contain a `pcf8591' chip
parm:           probe:List of adapter,address pairs to scan additionally
parm:           probe_range:List of adapter,start-addr,end-addr triples to scan additionally
parm:           ignore:List of adapter,address pairs not to scan
parm:           ignore_range:List of adapter,start-addr,end-addr triples not to scan
parm:           input_mode:Analog input mode:
 0 = four single ended inputs
 1 = three differential inputs
 2 = single ended and differential mixed
 3 = two differential inputs

author:         Aurelien Jarno 
description:    PCF8591 driver
license:        GPL
vermagic:       2.6.9 PENTIUM4 gcc-3.3
The PCF8591 was placed on this experimental board (not related to I2C2P project):
Gallery[161a] Gallery[161b]
On that board, PCF8591 was connected to measure temperature of two calibrated temperature sensors glued down to a common piece of copper.

Therefore we put this into /etc/conf.d/local.start on our Gentoo distribution:

( modprobe i2c-parport type=6 \
&& modprobe pcf8591 force=1,0x004f input_mode=0 ) &

Put something like that into suitable file on your system that is being executed on startup. Note that the modprobe i2c-parport type=6 command is invariant for you, because we are having an "Twibright I2C2P adapter", as described by modinfo i2c-parport. The other details depend on how you want to particularly use your I2C2P adapter.

Connecting I2C2P physically

Connect the I2C2P adaptor into your parallel port directly or using an etender cable. It is necessary to remove hexagonal nuts from parport or replace nuts by screws on extender cable because the connector on I2C2P already contains nuts and they can't be taken away, because the connector would fall apart.

Connect 5V I2C bus into the RJ12 connector including 5V feed. Here is the I2C RJ12 connector pinout. Turn the 5V power of I2C on.
Gallery[1618] Gallery[1619]

User-land programs

Now set up and run your possible additional userland programs that talk to the connected device(s). We user the sensors program. Its usage involved some further configuration of its system-wide configuration file. After that, the program displays temperature of the temperature sensors:

clock@oberon:~$ sensors
Adapter: Parallel port adapter
Temp. 1:   22.07 V
Temp. 2:   23.19 V
Output:     0.00 V (enabled)
Gallery[161c] Gallery[161d] Gallery[161e]

Send feedback to (c)1998-2004 Karel 'Clock' Kulhavý