blob: a0fe7a04a3bd50d311179a9cc24ab82c52cd0152 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001MODULE: i2c-stub
2
3DESCRIPTION:
4
Guenter Roeck6f16b752014-07-17 09:56:03 -07005This module is a very simple fake I2C/SMBus driver. It implements six
Jean Delvare47103172009-12-06 17:06:28 +01006types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w)
Guenter Roeck6f16b752014-07-17 09:56:03 -07007word data, (r/w) I2C block data, and (r/w) SMBus block data.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Jean Delvare9d90c1f2007-10-13 23:56:31 +02009You need to provide chip addresses as a module parameter when loading this
10driver, which will then only react to SMBus commands to these addresses.
Jean Delvare7a8d29c2006-08-13 23:46:44 +020011
Linus Torvalds1da177e2005-04-16 15:20:36 -070012No hardware is needed nor associated with this module. It will accept write
Jean Delvare9d90c1f2007-10-13 23:56:31 +020013quick 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
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
Guenter Roeck6f16b752014-07-17 09:56:03 -070022SMBus 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070030The typical use-case is like this:
31 1. load this module
Jean Delvare6471b682009-12-06 17:06:30 +010032 2. use i2cset (from the i2c-tools project) to pre-load some data
33 3. load the target chip driver module
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 4. observe its behavior in the kernel log
35
Jean Delvareb3af5472008-01-27 18:14:45 +010036There's a script named i2c-stub-from-dump in the i2c-tools package which
37can load register values automatically from a chip dump.
38
Jean Delvare7a8d29c2006-08-13 23:46:44 +020039PARAMETERS:
40
Jean Delvare9d90c1f2007-10-13 23:56:31 +020041int chip_addr[10]:
42 The SMBus addresses to emulate chips at.
Jean Delvare7a8d29c2006-08-13 23:46:44 +020043
Jean Delvare38f41f22009-12-06 17:06:29 +010044unsigned 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070050CAVEATS:
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052If your target driver polls some byte or word waiting for it to change, the
53stub could lock it up. Use i2cset to unlock it.
54
55If the hardware for your driver has banked registers (e.g. Winbond sensors
56chips) this module will not work well - although it could be extended to
57support that pretty easily.
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059If you spam it hard enough, printk can be lossy. This module really wants
60something like relayfs.
61