Lines Matching +full:slave +full:- +full:if

2 Linux I2C slave interface description
5 by Wolfram Sang <wsa@sang-engineering.com> in 2014-15
7 Linux can also be an I2C slave if the I2C controller in use has slave
8 functionality. For that to work, one needs slave support in the bus driver plus
10 example for the latter is the slave-eeprom driver, which acts as a dual memory
12 EEPROM, the Linux I2C slave can access the content via sysfs and handle data as
16 use a character device, be in-kernel only, or something completely different::
19 e.g. sysfs I2C slave events I/O registers
20 +-----------+ v +---------+ v +--------+ v +------------+
21 | Userspace +........+ Backend +-----------+ Driver +-----+ Controller |
22 +-----------+ +---------+ +--------+ +------------+
24 ----------------------------------------------------------------+-- I2C
25 --------------------------------------------------------------+---- Bus
34 I2C slave backends behave like standard I2C clients. So, you can instantiate
35 them as described in the document instantiating-devices.rst. The only
36 difference is that i2c slave backends have their own address space. So, you
38 instantiating the slave-eeprom driver from userspace at the 7 bit address 0x64
41 # echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-1/new_device
55 I2C slave events
56 ----------------
62 'client' describes the I2C slave device. 'event' is one of the special event
65 provided even if val is not used for an event, i.e. don't use NULL here. 'ret'
75 'ret': 0 if the backend is ready, otherwise some errno
80 always ack the address phase. If 'ret' is zero, backend initialization or
81 wakeup is done and further data may be received. If 'ret' is an errno, the bus
99 'ret': 0 if the byte should be acked, some errno if the byte should be nacked
101 Another I2C master has sent a byte to us which needs to be set in 'val'. If 'ret'
102 is zero, the bus driver should ack this byte. If 'ret' is an errno, then the byte
115 still shifted out. If the master sends NACK and stops reading after the byte
131 -----------------
133 If you want to write a software backend:
136 * write the slave_callback which handles the above slave events
140 Check the i2c-slave-eeprom driver as an example.
144 ------------------
146 If you want to add slave support to the bus driver:
148 * implement calls to register/unregister the slave and add those to the
150 slave address and enable slave specific interrupts. If you use runtime pm, you
152 powered on always to be able to detect its slave address. When unregistering,
155 * Catch the slave interrupts and send appropriate i2c_slave_events to the backend.
157 Note that most hardware supports being master _and_ slave on the same bus. So,
158 if you extend a bus driver, please make sure that the driver supports that as
159 well. In almost all cases, slave support does not need to disable the master
162 Check the i2c-rcar driver as an example.
166 --------------
168 It is good behaviour to always ACK the address phase, so the master knows if a
169 device is basically present or if it mysteriously disappeared. Using NACK to
172 automatically ACK when detecting their slave addresses, so there is no option
176 Currently, there is no slave event to report if the master did ACK or NACK a
177 byte when it reads from us. We could make this an optional event if the need
184 -------------
190 * Buffers should be opt-in and backend drivers will always have to support
191 byte-based transactions as the ultimate fallback anyhow because this is how
196 For reads, the data kept in the buffer might get stale if the backend just
201 error-prone.