]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - Documentation/i2c/i2c-stub
Merge branch 'fixes' of git://git.armlinux.org.uk/~rmk/linux-arm
[mirror_ubuntu-bionic-kernel.git] / Documentation / i2c / i2c-stub
CommitLineData
1da177e4
LT
1MODULE: i2c-stub
2
3DESCRIPTION:
4
6f16b75a 5This module is a very simple fake I2C/SMBus driver. It implements six
47103178 6types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w)
6f16b75a 7word data, (r/w) I2C block data, and (r/w) SMBus block data.
1da177e4 8
9d90c1fd
JD
9You need to provide chip addresses as a module parameter when loading this
10driver, which will then only react to SMBus commands to these addresses.
7a8d29ce 11
1da177e4 12No hardware is needed nor associated with this module. It will accept write
9d90c1fd
JD
13quick commands to the specified addresses; it will respond to the other
14commands (also to the specified addresses) by reading from or writing to
15arrays in memory. It will also spam the kernel logs for every command it
16handles.
1da177e4
LT
17
18A pointer register with auto-increment is implemented for all byte
19operations. This allows for continuous byte reads like those supported by
20EEPROMs, among others.
21
6f16b75a
GR
22SMBus block command support is disabled by default, and must be enabled
23explicitly by setting the respective bits (0x03000000) in the functionality
24module parameter.
25
26SMBus block commands must be written to configure an SMBus command for
27SMBus block operations. Writes can be partial. Block read commands always
28return the number of bytes selected with the largest write so far.
29
1da177e4
LT
30The typical use-case is like this:
31 1. load this module
6471b689
JD
32 2. use i2cset (from the i2c-tools project) to pre-load some data
33 3. load the target chip driver module
1da177e4
LT
34 4. observe its behavior in the kernel log
35
b3af547e
JD
36There's a script named i2c-stub-from-dump in the i2c-tools package which
37can load register values automatically from a chip dump.
38
7a8d29ce
JD
39PARAMETERS:
40
9d90c1fd
JD
41int chip_addr[10]:
42 The SMBus addresses to emulate chips at.
7a8d29ce 43
38f41f28
JD
44unsigned long functionality:
45 Functionality override, to disable some commands. See I2C_FUNC_*
46 constants in <linux/i2c.h> for the suitable values. For example,
47 value 0x1f0000 would only enable the quick, byte and byte data
48 commands.
49
2408c17f
JD
50u8 bank_reg[10]
51u8 bank_mask[10]
52u8 bank_start[10]
53u8 bank_end[10]:
54 Optional bank settings. They tell which bits in which register
55 select the active bank, as well as the range of banked registers.
56
1da177e4
LT
57CAVEATS:
58
1da177e4
LT
59If your target driver polls some byte or word waiting for it to change, the
60stub could lock it up. Use i2cset to unlock it.
61
1da177e4
LT
62If you spam it hard enough, printk can be lossy. This module really wants
63something like relayfs.
64