@@ -16,24 +16,27 @@ Note that this is a device for testing and debugging. It should not be enabled
1616in a production build. And while there is some versioning and we try hard to
1717keep backward compatibility, there is no stable ABI guaranteed!
1818
19- Instantiating the device is regular. Example for bus 0, address 0x30:
19+ Instantiating the device is regular. Example for bus 0, address 0x30::
2020
21- # echo "slave-testunit 0x1030" > /sys/bus/i2c/devices/i2c-0/new_device
21+ # echo "slave-testunit 0x1030" > /sys/bus/i2c/devices/i2c-0/new_device
2222
2323After that, you will have a write-only device listening. Reads will just return
2424an 8-bit version number of the testunit. When writing, the device consists of 4
25258-bit registers and, except for some "partial" commands, all registers must be
2626written to start a testcase, i.e. you usually write 4 bytes to the device. The
2727registers are:
2828
29- 0x00 CMD - which test to trigger
30- 0x01 DATAL - configuration byte 1 for the test
31- 0x02 DATAH - configuration byte 2 for the test
32- 0x03 DELAY - delay in n * 10ms until test is started
29+ .. csv-table ::
30+ :header: "Offset", "Name", "Description"
3331
34- Using 'i2cset' from the i2c-tools package, the generic command looks like:
32+ 0x00, CMD, which test to trigger
33+ 0x01, DATAL, configuration byte 1 for the test
34+ 0x02, DATAH, configuration byte 2 for the test
35+ 0x03, DELAY, delay in n * 10ms until test is started
3536
36- # i2cset -y <bus_num> <testunit_address> <CMD> <DATAL> <DATAH> <DELAY> i
37+ Using 'i2cset' from the i2c-tools package, the generic command looks like::
38+
39+ # i2cset -y <bus_num> <testunit_address> <CMD> <DATAL> <DATAH> <DELAY> i
3740
3841DELAY is a generic parameter which will delay the execution of the test in CMD.
3942While a command is running (including the delay), new commands will not be
@@ -45,44 +48,83 @@ result in the transfer not being acknowledged.
4548Commands
4649--------
4750
48- 0x00 NOOP (reserved for future use)
51+ 0x00 NOOP
52+ ~~~~~~~~~
53+
54+ Reserved for future use.
55+
56+ 0x01 READ_BYTES
57+ ~~~~~~~~~~~~~~~
58+
59+ .. list-table ::
60+ :header-rows: 1
61+
62+ * - CMD
63+ - DATAL
64+ - DATAH
65+ - DELAY
66+
67+ * - 0x01
68+ - address to read data from (lower 7 bits, highest bit currently unused)
69+ - number of bytes to read
70+ - n * 10ms
71+
72+ Also needs master mode. This is useful to test if your bus master driver is
73+ handling multi-master correctly. You can trigger the testunit to read bytes
74+ from another device on the bus. If the bus master under test also wants to
75+ access the bus at the same time, the bus will be busy. Example to read 128
76+ bytes from device 0x50 after 50ms of delay::
77+
78+ # i2cset -y 0 0x30 0x01 0x50 0x80 0x05 i
79+
80+ 0x02 SMBUS_HOST_NOTIFY
81+ ~~~~~~~~~~~~~~~~~~~~~~
82+
83+ .. list-table ::
84+ :header-rows: 1
85+
86+ * - CMD
87+ - DATAL
88+ - DATAH
89+ - DELAY
4990
50- 0x01 READ_BYTES (also needs master mode)
51- DATAL - address to read data from (lower 7 bits, highest bit currently unused)
52- DATAH - number of bytes to read
91+ * - 0x02
92+ - low byte of the status word to send
93+ - high byte of the status word to send
94+ - n * 10ms
5395
54- This is useful to test if your bus master driver is handling multi-master
55- correctly. You can trigger the testunit to read bytes from another device on
56- the bus. If the bus master under test also wants to access the bus at the same
57- time, the bus will be busy. Example to read 128 bytes from device 0x50 after
58- 50ms of delay:
96+ Also needs master mode. This test will send an SMBUS_HOST_NOTIFY message to the
97+ host. Note that the status word is currently ignored in the Linux Kernel.
98+ Example to send a notification after 10ms::
5999
60- # i2cset -y 0 0x30 0x01 0x50 0x80 0x05 i
100+ # i2cset -y 0 0x30 0x02 0x42 0x64 0x01 i
61101
62- 0x02 SMBUS_HOST_NOTIFY (also needs master mode)
63- DATAL - low byte of the status word to send
64- DATAH - high byte of the status word to send
102+ 0x03 SMBUS_BLOCK_PROC_CALL
103+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
65104
66- This test will send an SMBUS_HOST_NOTIFY message to the host. Note that the
67- status word is currently ignored in the Linux Kernel. Example to send a
68- notification after 10ms:
105+ .. list-table ::
106+ :header-rows: 1
69107
70- # i2cset -y 0 0x30 0x02 0x42 0x64 0x01 i
108+ * - CMD
109+ - DATAL
110+ - DATAH
111+ - DELAY
71112
72- 0x03 SMBUS_BLOCK_PROC_CALL (partial command)
73- DATAL - must be '1', i.e. one further byte will be written
74- DATAH - number of bytes to be sent back
75- DELAY - not applicable , partial command!
113+ * - 0x03
114+ - must be '1', i.e. one further byte will be written
115+ - number of bytes to be sent back
116+ - leave out , partial command!
76117
77- This test will respond to a block process call as defined by the SMBus
78- specification. The one data byte written specifies how many bytes will be sent
79- back in the following read transfer. Note that in this read transfer, the
80- testunit will prefix the length of the bytes to follow. So, if your host bus
81- driver emulates SMBus calls like the majority does, it needs to support the
82- I2C_M_RECV_LEN flag of an i2c_msg. This is a good testcase for it. The returned
83- data consists of the length first, and then of an array of bytes from length-1
84- to 0. Here is an example which emulates i2c_smbus_block_process_call() using
85- i2ctransfer (you need i2c-tools v4.2 or later):
118+ Partial command. This test will respond to a block process call as defined by
119+ the SMBus specification. The one data byte written specifies how many bytes
120+ will be sent back in the following read transfer. Note that in this read
121+ transfer, the testunit will prefix the length of the bytes to follow. So, if
122+ your host bus driver emulates SMBus calls like the majority does, it needs to
123+ support the I2C_M_RECV_LEN flag of an i2c_msg. This is a good testcase for it.
124+ The returned data consists of the length first, and then of an array of bytes
125+ from length-1 to 0. Here is an example which emulates
126+ i2c_smbus_block_process_call() using i2ctransfer (you need i2c-tools v4.2 or
127+ later)::
86128
87- # i2ctransfer -y 0 w3@0x30 0x03 0x01 0x10 r?
88- 0x10 0x0f 0x0e 0x0d 0x0c 0x0b 0x0a 0x09 0x08 0x07 0x06 0x05 0x04 0x03 0x02 0x01 0x00
129+ # i2ctransfer -y 0 w3@0x30 0x03 0x01 0x10 r?
130+ 0x10 0x0f 0x0e 0x0d 0x0c 0x0b 0x0a 0x09 0x08 0x07 0x06 0x05 0x04 0x03 0x02 0x01 0x00
0 commit comments