1ccf988b6SMauro Carvalho Chehab========
2ccf988b6SMauro Carvalho Chehabi2c-stub
3ccf988b6SMauro Carvalho Chehab========
4ccf988b6SMauro Carvalho Chehab
5ccf988b6SMauro Carvalho ChehabDescription
6ccf988b6SMauro Carvalho Chehab===========
7ccf988b6SMauro Carvalho Chehab
8ccf988b6SMauro Carvalho ChehabThis module is a very simple fake I2C/SMBus driver.  It implements six
9ccf988b6SMauro Carvalho Chehabtypes of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w)
10ccf988b6SMauro Carvalho Chehabword data, (r/w) I2C block data, and (r/w) SMBus block data.
11ccf988b6SMauro Carvalho Chehab
12ccf988b6SMauro Carvalho ChehabYou need to provide chip addresses as a module parameter when loading this
13ccf988b6SMauro Carvalho Chehabdriver, which will then only react to SMBus commands to these addresses.
14ccf988b6SMauro Carvalho Chehab
15ccf988b6SMauro Carvalho ChehabNo hardware is needed nor associated with this module.  It will accept write
16ccf988b6SMauro Carvalho Chehabquick commands to the specified addresses; it will respond to the other
17ccf988b6SMauro Carvalho Chehabcommands (also to the specified addresses) by reading from or writing to
18ccf988b6SMauro Carvalho Chehabarrays in memory.  It will also spam the kernel logs for every command it
19ccf988b6SMauro Carvalho Chehabhandles.
20ccf988b6SMauro Carvalho Chehab
21ccf988b6SMauro Carvalho ChehabA pointer register with auto-increment is implemented for all byte
22ccf988b6SMauro Carvalho Chehaboperations.  This allows for continuous byte reads like those supported by
23ccf988b6SMauro Carvalho ChehabEEPROMs, among others.
24ccf988b6SMauro Carvalho Chehab
25ccf988b6SMauro Carvalho ChehabSMBus block command support is disabled by default, and must be enabled
26ccf988b6SMauro Carvalho Chehabexplicitly by setting the respective bits (0x03000000) in the functionality
27ccf988b6SMauro Carvalho Chehabmodule parameter.
28ccf988b6SMauro Carvalho Chehab
29ccf988b6SMauro Carvalho ChehabSMBus block commands must be written to configure an SMBus command for
30ccf988b6SMauro Carvalho ChehabSMBus block operations. Writes can be partial. Block read commands always
31ccf988b6SMauro Carvalho Chehabreturn the number of bytes selected with the largest write so far.
32ccf988b6SMauro Carvalho Chehab
33ccf988b6SMauro Carvalho ChehabThe typical use-case is like this:
34ccf988b6SMauro Carvalho Chehab
35ccf988b6SMauro Carvalho Chehab	1. load this module
36ccf988b6SMauro Carvalho Chehab	2. use i2cset (from the i2c-tools project) to pre-load some data
37ccf988b6SMauro Carvalho Chehab	3. load the target chip driver module
38ccf988b6SMauro Carvalho Chehab	4. observe its behavior in the kernel log
39ccf988b6SMauro Carvalho Chehab
40ccf988b6SMauro Carvalho ChehabThere's a script named i2c-stub-from-dump in the i2c-tools package which
41ccf988b6SMauro Carvalho Chehabcan load register values automatically from a chip dump.
42ccf988b6SMauro Carvalho Chehab
43ccf988b6SMauro Carvalho ChehabParameters
44ccf988b6SMauro Carvalho Chehab==========
45ccf988b6SMauro Carvalho Chehab
46ccf988b6SMauro Carvalho Chehabint chip_addr[10]:
47ccf988b6SMauro Carvalho Chehab	The SMBus addresses to emulate chips at.
48ccf988b6SMauro Carvalho Chehab
49ccf988b6SMauro Carvalho Chehabunsigned long functionality:
50ccf988b6SMauro Carvalho Chehab	Functionality override, to disable some commands. See I2C_FUNC_*
51ccf988b6SMauro Carvalho Chehab	constants in <linux/i2c.h> for the suitable values. For example,
52ccf988b6SMauro Carvalho Chehab	value 0x1f0000 would only enable the quick, byte and byte data
53ccf988b6SMauro Carvalho Chehab	commands.
54ccf988b6SMauro Carvalho Chehab
55ccf988b6SMauro Carvalho Chehabu8 bank_reg[10], u8 bank_mask[10], u8 bank_start[10], u8 bank_end[10]:
56ccf988b6SMauro Carvalho Chehab	Optional bank settings. They tell which bits in which register
57ccf988b6SMauro Carvalho Chehab	select the active bank, as well as the range of banked registers.
58ccf988b6SMauro Carvalho Chehab
59ccf988b6SMauro Carvalho ChehabCaveats
60ccf988b6SMauro Carvalho Chehab=======
61ccf988b6SMauro Carvalho Chehab
62ccf988b6SMauro Carvalho ChehabIf your target driver polls some byte or word waiting for it to change, the
63ccf988b6SMauro Carvalho Chehabstub could lock it up.  Use i2cset to unlock it.
64ccf988b6SMauro Carvalho Chehab
65ccf988b6SMauro Carvalho ChehabIf you spam it hard enough, printk can be lossy.  This module really wants
66ccf988b6SMauro Carvalho Chehabsomething like relayfs.
67