xref: /OK3568_Linux_fs/kernel/Documentation/driver-api/i2c.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunI\ :sup:`2`\ C and SMBus Subsystem
2*4882a593Smuzhiyun==================================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunI\ :sup:`2`\ C (or without fancy typography, "I2C") is an acronym for
5*4882a593Smuzhiyunthe "Inter-IC" bus, a simple bus protocol which is widely used where low
6*4882a593Smuzhiyundata rate communications suffice. Since it's also a licensed trademark,
7*4882a593Smuzhiyunsome vendors use another name (such as "Two-Wire Interface", TWI) for
8*4882a593Smuzhiyunthe same bus. I2C only needs two signals (SCL for clock, SDA for data),
9*4882a593Smuzhiyunconserving board real estate and minimizing signal quality issues. Most
10*4882a593SmuzhiyunI2C devices use seven bit addresses, and bus speeds of up to 400 kHz;
11*4882a593Smuzhiyunthere's a high speed extension (3.4 MHz) that's not yet found wide use.
12*4882a593SmuzhiyunI2C is a multi-master bus; open drain signaling is used to arbitrate
13*4882a593Smuzhiyunbetween masters, as well as to handshake and to synchronize clocks from
14*4882a593Smuzhiyunslower clients.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunThe Linux I2C programming interfaces support the master side of bus
17*4882a593Smuzhiyuninteractions and the slave side. The programming interface is
18*4882a593Smuzhiyunstructured around two kinds of driver, and two kinds of device. An I2C
19*4882a593Smuzhiyun"Adapter Driver" abstracts the controller hardware; it binds to a
20*4882a593Smuzhiyunphysical device (perhaps a PCI device or platform_device) and exposes a
21*4882a593Smuzhiyun:c:type:`struct i2c_adapter <i2c_adapter>` representing each
22*4882a593SmuzhiyunI2C bus segment it manages. On each I2C bus segment will be I2C devices
23*4882a593Smuzhiyunrepresented by a :c:type:`struct i2c_client <i2c_client>`.
24*4882a593SmuzhiyunThose devices will be bound to a :c:type:`struct i2c_driver
25*4882a593Smuzhiyun<i2c_driver>`, which should follow the standard Linux driver model. There
26*4882a593Smuzhiyunare functions to perform various I2C protocol operations; at this writing
27*4882a593Smuzhiyunall such functions are usable only from task context.
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunThe System Management Bus (SMBus) is a sibling protocol. Most SMBus
30*4882a593Smuzhiyunsystems are also I2C conformant. The electrical constraints are tighter
31*4882a593Smuzhiyunfor SMBus, and it standardizes particular protocol messages and idioms.
32*4882a593SmuzhiyunControllers that support I2C can also support most SMBus operations, but
33*4882a593SmuzhiyunSMBus controllers don't support all the protocol options that an I2C
34*4882a593Smuzhiyuncontroller will. There are functions to perform various SMBus protocol
35*4882a593Smuzhiyunoperations, either using I2C primitives or by issuing SMBus commands to
36*4882a593Smuzhiyuni2c_adapter devices which don't support those I2C operations.
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun.. kernel-doc:: include/linux/i2c.h
39*4882a593Smuzhiyun   :internal:
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun.. kernel-doc:: drivers/i2c/i2c-boardinfo.c
42*4882a593Smuzhiyun   :functions: i2c_register_board_info
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun.. kernel-doc:: drivers/i2c/i2c-core-base.c
45*4882a593Smuzhiyun   :export:
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun.. kernel-doc:: drivers/i2c/i2c-core-smbus.c
48*4882a593Smuzhiyun   :export:
49