1 .\" Copyright (c) 2006, M. Warner Losh
2 .\" Copyright (c) 1998, Nicolas Souchu
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nd I2C generic I/O device driver
41 device driver provides generic I/O to any
44 In order to control I2C devices, use
48 .Bl -tag -width ".Dv I2CRPTSTART"
50 .Pq Vt "struct iiccmd"
51 Sends the start condition to the slave specified by the
56 element consists of a 7-bit address and a read/write bit
57 (i.e., 7-bit address << 1 | r/w).
58 If the read/write bit is set a read operation is initiated, if the read/write
59 bit is cleared a write operation is initiated.
60 All other elements are ignored.
62 .Pq Vt "struct iiccmd"
63 Sends the repeated start condition to the slave specified by the
66 The slave address should be specified as in
68 All other elements are ignored.
70 No argument is passed.
71 Sends the stop condition to the bus.
72 This terminates the current transaction.
74 .Pq Vt "struct iiccmd"
76 The argument is completely ignored.
78 .Pq Vt "struct iiccmd"
81 The bus should already be started.
87 element is the number of bytes to write.
90 element is a boolean flag.
91 It is non-zero when additional write commands will follow.
94 element is a pointer to the data to write to the bus.
96 .Pq Vt "struct iiccmd"
99 The bus should already be started.
105 element is the number of bytes to write.
108 element is a boolean flag.
109 It is non-zero when additional write commands will follow.
112 element is a pointer to where to store the data read from the bus.
113 Short reads on the bus produce undefined results.
115 .Pq Vt "struct iic_rdwr_data"
116 Generic read/write interface.
117 Allows for an arbitrary number of commands to be sent to
118 an arbitrary number of devices on the bus.
119 A read transfer is specified if
123 Otherwise the transfer is a write transfer.
126 element specifies the 7-bit address with the read/write bit for the transfer.
127 The read/write bit will be handled by the iicbus stack based on the specified
131 element is the number of
132 .Pq Vt "struct iic_msg"
134 .Pq Vt "struct iic_rdwr_data" .
137 element is a buffer for that data.
138 This ioctl is intended to be
143 The following data structures are defined in
145 and referenced above:
146 .Bd -literal -offset indent
154 /* Designed to be compatible with linux's struct i2c_msg */
159 #define IIC_M_RD 0x0001 /* read vs write */
160 uint16_t len; /* msg length */
164 struct iic_rdwr_data {
165 struct iic_msg *msgs;
170 It is also possible to use read/write routines, then I2C start/stop handshake is
174 However, the address used for the read/write routines is the one
187 manual page first appeared in
192 manual page was written by
201 All other interfaces suffer from some kind of race.