blob: 136c4e333be771d91826c839cdbcf5d138a9ccf2 [file] [log] [blame]
Luca Ceresolif6fcefa2020-01-29 16:19:51 +01001=============================
2Introduction to I2C and SMBus
3=============================
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
Luca Ceresoli096c22f2020-01-29 16:19:27 +01005I²C (pronounce: I squared C and written I2C in the kernel documentation) is
6a protocol developed by Philips. It is a slow two-wire protocol (variable
7speed, up to 400 kHz), with a high speed extension (3.4 MHz). It provides
8an inexpensive bus for connecting many types of devices with infrequent or
9low bandwidth communications needs. I2C is widely used with embedded
10systems. Some systems use variants that don't meet branding requirements,
11and so are not advertised as being I2C but come under different names,
12e.g. TWI (Two Wire Interface), IIC.
13
14The official I2C specification is the `"I2C-bus specification and user
15manual" (UM10204) <https://www.nxp.com/docs/en/user-guide/UM10204.pdf>`_
16published by NXP Semiconductors.
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
David Brownell4298cfc2007-05-01 23:26:31 +020018SMBus (System Management Bus) is based on the I2C protocol, and is mostly
19a subset of I2C protocols and signaling. Many I2C devices will work on an
20SMBus, but some SMBus protocols add semantics beyond what is required to
21achieve I2C branding. Modern PC mainboards rely on SMBus. The most common
22devices connected through SMBus are RAM modules configured using I2C EEPROMs,
23and hardware monitoring chips.
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
David Brownell4298cfc2007-05-01 23:26:31 +020025Because the SMBus is mostly a subset of the generalized I2C bus, we can
26use its protocols on many I2C systems. However, there are systems that don't
27meet both SMBus and I2C electrical constraints; and others which can't
28implement all the common SMBus protocol semantics or messages.
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30
31Terminology
32===========
33
Luca Ceresoli020bc5b2020-01-29 16:19:28 +010034Using the terminology from the official documentation, the I2C bus connects
35one or more *master* chips and one or more *slave* chips.
Mauro Carvalho Chehabccf988b2019-07-26 09:51:16 -030036
Mauro Carvalho Chehab36536a02020-04-14 18:48:52 +020037.. kernel-figure:: i2c_bus.svg
Luca Ceresoli020bc5b2020-01-29 16:19:28 +010038 :alt: Simple I2C bus with one master and 3 slaves
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Luca Ceresoli020bc5b2020-01-29 16:19:28 +010040 Simple I2C bus
David Brownell4298cfc2007-05-01 23:26:31 +020041
Luca Ceresoli020bc5b2020-01-29 16:19:28 +010042A **master** chip is a node that starts communications with slaves. In the
43Linux kernel implementation it is called an **adapter** or bus. Adapter
44drivers are in the ``drivers/i2c/busses/`` subdirectory.
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Luca Ceresoli020bc5b2020-01-29 16:19:28 +010046An **algorithm** contains general code that can be used to implement a
47whole class of I2C adapters. Each specific adapter driver either depends on
48an algorithm driver in the ``drivers/i2c/algos/`` subdirectory, or includes
49its own implementation.
50
51A **slave** chip is a node that responds to communications when addressed
52by the master. In Linux it is called a **client**. Client drivers are kept
53in a directory specific to the feature they provide, for example
54``drivers/media/gpio/`` for GPIO expanders and ``drivers/media/i2c/`` for
55video-related chips.
56
57For the example configuration in figure, you will need a driver for your
58I2C adapter, and drivers for your I2C devices (usually one driver for each
59device).