24.2.1 I2C Bus Driver Software Operation
The I2C bus driver is described by a structure called i2c_adapter. The most important
field in this structure is struct i2c_algorithm *algo. This field is a pointer to the
i2c_algorithm structure that describes how data is transferred over the I2C bus. The
algorithm structure contains a pointer to a function that is called whenever the I2C chip
driver wants to communicate with an I2C device.
During startup, the I2C bus adapter is registered with the I2C core when the driver is
loaded. Certain architectures have more than one I2C module. If so, the driver registers
separate i2c_adapter structures for each I2C module with the I2C core. These adapters are
unregistered (removed) when the driver is unloaded.
After transmitting each packet, the I2C bus driver waits for an interrupt indicating the end
of a data transmission before transmitting the next byte. It times out and returns an error
if the transfer complete signal is not received. Because the I2C bus driver uses wait
queues for its operation, other device drivers should be careful not to call the I2C API
methods from an interrupt mode.
24.2.2 I2C Device Driver Software Operation
The I2C driver controls an individual I2C device on the I2C bus. A structure, i2c_driver,
describes the I2C chip driver. The fields of interest in this structure are flags and
attach_adapter. The flags field is set to a value I2C_DF_NOTIFY so that the chip driver
can be notified of any new I2C devices, after the driver is loaded. The attach_adapter
callback function is called whenever a new I2C bus driver is loaded in the system. When
the I2C bus driver is loaded, this driver stores the i2c_adapter structure associated with
this bus driver so that it can use the appropriate methods to transfer data.
24.3 Driver Features
The I2C driver supports the following features:
• I2C communication protocol
• I2C master mode of operation
NOTE
The I2C driver does not support the I2C slave mode of
operation.
Chapter 24 Inter-IC (I2C) Driver
i.MX 6SoloLite Linux Reference Manual, Rev. L3.0.35_4.1.0, 09/2013
Freescale Semiconductor, Inc.
151