xref: /OK3568_Linux_fs/kernel/Documentation/i2c/summary.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun=============================
2*4882a593SmuzhiyunIntroduction to I2C and SMBus
3*4882a593Smuzhiyun=============================
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunI²C (pronounce: I squared C and written I2C in the kernel documentation) is
6*4882a593Smuzhiyuna protocol developed by Philips. It is a slow two-wire protocol (variable
7*4882a593Smuzhiyunspeed, up to 400 kHz), with a high speed extension (3.4 MHz).  It provides
8*4882a593Smuzhiyunan inexpensive bus for connecting many types of devices with infrequent or
9*4882a593Smuzhiyunlow bandwidth communications needs.  I2C is widely used with embedded
10*4882a593Smuzhiyunsystems.  Some systems use variants that don't meet branding requirements,
11*4882a593Smuzhiyunand so are not advertised as being I2C but come under different names,
12*4882a593Smuzhiyune.g. TWI (Two Wire Interface), IIC.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunThe official I2C specification is the `"I2C-bus specification and user
15*4882a593Smuzhiyunmanual" (UM10204) <https://www.nxp.com/docs/en/user-guide/UM10204.pdf>`_
16*4882a593Smuzhiyunpublished by NXP Semiconductors.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunSMBus (System Management Bus) is based on the I2C protocol, and is mostly
19*4882a593Smuzhiyuna subset of I2C protocols and signaling.  Many I2C devices will work on an
20*4882a593SmuzhiyunSMBus, but some SMBus protocols add semantics beyond what is required to
21*4882a593Smuzhiyunachieve I2C branding.  Modern PC mainboards rely on SMBus.  The most common
22*4882a593Smuzhiyundevices connected through SMBus are RAM modules configured using I2C EEPROMs,
23*4882a593Smuzhiyunand hardware monitoring chips.
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunBecause the SMBus is mostly a subset of the generalized I2C bus, we can
26*4882a593Smuzhiyunuse its protocols on many I2C systems.  However, there are systems that don't
27*4882a593Smuzhiyunmeet both SMBus and I2C electrical constraints; and others which can't
28*4882a593Smuzhiyunimplement all the common SMBus protocol semantics or messages.
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun
31*4882a593SmuzhiyunTerminology
32*4882a593Smuzhiyun===========
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunUsing the terminology from the official documentation, the I2C bus connects
35*4882a593Smuzhiyunone or more *master* chips and one or more *slave* chips.
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun.. kernel-figure::  i2c_bus.svg
38*4882a593Smuzhiyun   :alt:    Simple I2C bus with one master and 3 slaves
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun   Simple I2C bus
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunA **master** chip is a node that starts communications with slaves. In the
43*4882a593SmuzhiyunLinux kernel implementation it is called an **adapter** or bus. Adapter
44*4882a593Smuzhiyundrivers are in the ``drivers/i2c/busses/`` subdirectory.
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunAn **algorithm** contains general code that can be used to implement a
47*4882a593Smuzhiyunwhole class of I2C adapters. Each specific adapter driver either depends on
48*4882a593Smuzhiyunan algorithm driver in the ``drivers/i2c/algos/`` subdirectory, or includes
49*4882a593Smuzhiyunits own implementation.
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunA **slave** chip is a node that responds to communications when addressed
52*4882a593Smuzhiyunby the master. In Linux it is called a **client**. Client drivers are kept
53*4882a593Smuzhiyunin a directory specific to the feature they provide, for example
54*4882a593Smuzhiyun``drivers/media/gpio/`` for GPIO expanders and ``drivers/media/i2c/`` for
55*4882a593Smuzhiyunvideo-related chips.
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunFor the example configuration in figure, you will need a driver for your
58*4882a593SmuzhiyunI2C adapter, and drivers for your I2C devices (usually one driver for each
59*4882a593Smuzhiyundevice).
60