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 | 7a8d29c | 2006-08-13 23:46:44 +0200 | [diff] [blame] | 9 | You need to provide a chip address as a module parameter when loading |
| 10 | this driver, which will then only react to SMBus commands to this address. |
| 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 | 7a8d29c | 2006-08-13 23:46:44 +0200 | [diff] [blame] | 13 | quick commands to one address; it will respond to the other commands (also |
| 14 | to one address) by reading from or writing to an array in memory. It will |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | also spam the kernel logs for every command it handles. |
| 16 | |
| 17 | A pointer register with auto-increment is implemented for all byte |
| 18 | operations. This allows for continuous byte reads like those supported by |
| 19 | EEPROMs, among others. |
| 20 | |
| 21 | The typical use-case is like this: |
| 22 | 1. load this module |
| 23 | 2. use i2cset (from lm_sensors project) to pre-load some data |
| 24 | 3. load the target sensors chip driver module |
| 25 | 4. observe its behavior in the kernel log |
| 26 | |
Jean Delvare | 7a8d29c | 2006-08-13 23:46:44 +0200 | [diff] [blame] | 27 | PARAMETERS: |
| 28 | |
| 29 | int chip_addr: |
| 30 | The SMBus address to emulate a chip at. |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | CAVEATS: |
| 33 | |
| 34 | There are independent arrays for byte/data and word/data commands. Depending |
| 35 | on if/how a target driver mixes them, you'll need to be careful. |
| 36 | |
| 37 | If your target driver polls some byte or word waiting for it to change, the |
| 38 | stub could lock it up. Use i2cset to unlock it. |
| 39 | |
| 40 | If the hardware for your driver has banked registers (e.g. Winbond sensors |
| 41 | chips) this module will not work well - although it could be extended to |
| 42 | support that pretty easily. |
| 43 | |
Jean Delvare | 7a8d29c | 2006-08-13 23:46:44 +0200 | [diff] [blame] | 44 | Only one chip address is supported - although this module could be |
| 45 | extended to support more. |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | If you spam it hard enough, printk can be lossy. This module really wants |
| 48 | something like relayfs. |
| 49 | |