Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | MODULE: i2c-stub |
| 2 | |
| 3 | DESCRIPTION: |
| 4 | |
| 5 | This module is a very simple fake I2C/SMBus driver. It implements four |
| 6 | types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, and |
| 7 | (r/w) word data. |
| 8 | |
Jean Delvare | 9d90c1f | 2007-10-13 23:56:31 +0200 | [diff] [blame] | 9 | You need to provide chip addresses as a module parameter when loading this |
| 10 | driver, which will then only react to SMBus commands to these addresses. |
Jean Delvare | 7a8d29c | 2006-08-13 23:46:44 +0200 | [diff] [blame] | 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | No hardware is needed nor associated with this module. It will accept write |
Jean Delvare | 9d90c1f | 2007-10-13 23:56:31 +0200 | [diff] [blame] | 13 | quick commands to the specified addresses; it will respond to the other |
| 14 | commands (also to the specified addresses) by reading from or writing to |
| 15 | arrays in memory. It will also spam the kernel logs for every command it |
| 16 | handles. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | A pointer register with auto-increment is implemented for all byte |
| 19 | operations. This allows for continuous byte reads like those supported by |
| 20 | EEPROMs, among others. |
| 21 | |
| 22 | The typical use-case is like this: |
| 23 | 1. load this module |
| 24 | 2. use i2cset (from lm_sensors project) to pre-load some data |
| 25 | 3. load the target sensors chip driver module |
| 26 | 4. observe its behavior in the kernel log |
| 27 | |
Jean Delvare | b3af547 | 2008-01-27 18:14:45 +0100 | [diff] [blame] | 28 | There's a script named i2c-stub-from-dump in the i2c-tools package which |
| 29 | can load register values automatically from a chip dump. |
| 30 | |
Jean Delvare | 7a8d29c | 2006-08-13 23:46:44 +0200 | [diff] [blame] | 31 | PARAMETERS: |
| 32 | |
Jean Delvare | 9d90c1f | 2007-10-13 23:56:31 +0200 | [diff] [blame] | 33 | int chip_addr[10]: |
| 34 | The SMBus addresses to emulate chips at. |
Jean Delvare | 7a8d29c | 2006-08-13 23:46:44 +0200 | [diff] [blame] | 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | CAVEATS: |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | If your target driver polls some byte or word waiting for it to change, the |
| 39 | stub could lock it up. Use i2cset to unlock it. |
| 40 | |
| 41 | If the hardware for your driver has banked registers (e.g. Winbond sensors |
| 42 | chips) this module will not work well - although it could be extended to |
| 43 | support that pretty easily. |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | If you spam it hard enough, printk can be lossy. This module really wants |
| 46 | something like relayfs. |
| 47 | |