Inter-IC (I2C) Driver
i.MX51 EVK Linux Reference Manual
24-2
Freescale Semiconductor
24.3
Hardware Operation
The I
2
C module provides the functionality of a standard I
2
C master and slave. It is designed to be
compatible with the standard Philips I
2
C bus protocol. The module supports up to 64 different clock
frequencies that can be programmed by setting a value to the Frequency Divider Register (IFDR). It also
generates an interrupt when one of the following occurs:
•
One byte transfer is completed
•
Address is received that matches its own specific address in slave-receive mode
•
Arbitration is lost
24.4
Software Operation
The I
2
C driver for Linux has two parts: an I
2
C bus driver and an I
2
C chip driver.
24.4.1
I
2
C Bus Driver Software Operation
The I
2
C 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 I
2
C bus. The algorithm structure contains a pointer to a function
that is called whenever the I
2
C chip driver wants to communicate with an I
2
C device.
During startup, the I
2
C bus adapter is registered with the I
2
C core when the driver is loaded. Certain
architectures have more than one I
2
C module. If so, the driver registers separate
i2c_adapter
structures for
each I
2
C module with the I
2
C core. These adapters are unregistered (removed) when the driver is unloaded.
After transmitting each packet, the I
2
C 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 I
2
C bus driver uses wait queues for its operation, other device drivers
should be careful not to call the I
2
C API methods from an interrupt mode.
24.4.2
I
2
C Device Driver Software Operation
The I
2
C driver controls an individual I
2
C device on the I
2
C bus. A structure,
i2c_driver
, describes the I
2
C
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 I
2
C devices, after the driver is
loaded. The
attach_adapter
callback function is called whenever a new I
2
C bus driver is loaded in the
system. When the I
2
C 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.
Summary of Contents for i.MX51 EVK
Page 1: ...Part Number 924 76374 Rev 10 11 01 11 2010 i MX51 EVK Linux Reference Manual...
Page 14: ...i MX51 EVK Linux Reference Manual xiv Freescale Semiconductor...
Page 18: ...i MX51 EVK Linux Reference Manual xviii Freescale Semiconductor...
Page 24: ...i MX51 EVK Linux Reference Manual xxiv Freescale Semiconductor...
Page 38: ...Machine Specific Layer MSL i MX51 EVK Linux Reference Manual 2 8 Freescale Semiconductor...
Page 52: ...MC13892 Digitizer Driver i MX51 EVK Linux Reference Manual 5 4 Freescale Semiconductor...
Page 64: ...TV Encoder TVE Driver i MX51 EVK Linux Reference Manual 10 4 Freescale Semiconductor...
Page 82: ...Video for Linux Two V4L2 Driver i MX51 EVK Linux Reference Manual 12 8 Freescale Semiconductor...
Page 86: ...i MX5 Dual Display i MX51 EVK Linux Reference Manual 13 4 Freescale Semiconductor...
Page 100: ...X Windows Acceleration i MX51 EVK Linux Reference Manual 16 6 Freescale Semiconductor...
Page 118: ...Low Level Keypad Driver i MX51 EVK Linux Reference Manual 20 6 Freescale Semiconductor...
Page 134: ...Security Drivers i MX51 EVK Linux Reference Manual 22 10 Freescale Semiconductor...
Page 148: ...Inter IC I2C Driver i MX51 EVK Linux Reference Manual 24 4 Freescale Semiconductor...
Page 178: ...ARC USB Driver i MX51 EVK Linux Reference Manual 29 10 Freescale Semiconductor...
Page 194: ...OProfile i MX51 EVK Linux Reference Manual 33 6 Freescale Semiconductor...