0001 ========
0002 i2c-stub
0003 ========
0004
0005 Description
0006 ===========
0007
0008 This module is a very simple fake I2C/SMBus driver. It implements six
0009 types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w)
0010 word data, (r/w) I2C block data, and (r/w) SMBus block data.
0011
0012 You need to provide chip addresses as a module parameter when loading this
0013 driver, which will then only react to SMBus commands to these addresses.
0014
0015 No hardware is needed nor associated with this module. It will accept write
0016 quick commands to the specified addresses; it will respond to the other
0017 commands (also to the specified addresses) by reading from or writing to
0018 arrays in memory. It will also spam the kernel logs for every command it
0019 handles.
0020
0021 A pointer register with auto-increment is implemented for all byte
0022 operations. This allows for continuous byte reads like those supported by
0023 EEPROMs, among others.
0024
0025 SMBus block command support is disabled by default, and must be enabled
0026 explicitly by setting the respective bits (0x03000000) in the functionality
0027 module parameter.
0028
0029 SMBus block commands must be written to configure an SMBus command for
0030 SMBus block operations. Writes can be partial. Block read commands always
0031 return the number of bytes selected with the largest write so far.
0032
0033 The typical use-case is like this:
0034
0035 1. load this module
0036 2. use i2cset (from the i2c-tools project) to pre-load some data
0037 3. load the target chip driver module
0038 4. observe its behavior in the kernel log
0039
0040 There's a script named i2c-stub-from-dump in the i2c-tools package which
0041 can load register values automatically from a chip dump.
0042
0043 Parameters
0044 ==========
0045
0046 int chip_addr[10]:
0047 The SMBus addresses to emulate chips at.
0048
0049 unsigned long functionality:
0050 Functionality override, to disable some commands. See I2C_FUNC_*
0051 constants in <linux/i2c.h> for the suitable values. For example,
0052 value 0x1f0000 would only enable the quick, byte and byte data
0053 commands.
0054
0055 u8 bank_reg[10], u8 bank_mask[10], u8 bank_start[10], u8 bank_end[10]:
0056 Optional bank settings. They tell which bits in which register
0057 select the active bank, as well as the range of banked registers.
0058
0059 Caveats
0060 =======
0061
0062 If your target driver polls some byte or word waiting for it to change, the
0063 stub could lock it up. Use i2cset to unlock it.
0064
0065 If you spam it hard enough, printk can be lossy. This module really wants
0066 something like relayfs.