Luca Ceresoli | f6fcefa | 2020-01-29 16:19:51 +0100 | [diff] [blame] | 1 | ============================= |
| 2 | Introduction to I2C and SMBus |
| 3 | ============================= |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
Luca Ceresoli | 096c22f | 2020-01-29 16:19:27 +0100 | [diff] [blame] | 5 | I²C (pronounce: I squared C and written I2C in the kernel documentation) is |
| 6 | a protocol developed by Philips. It is a slow two-wire protocol (variable |
| 7 | speed, up to 400 kHz), with a high speed extension (3.4 MHz). It provides |
| 8 | an inexpensive bus for connecting many types of devices with infrequent or |
| 9 | low bandwidth communications needs. I2C is widely used with embedded |
| 10 | systems. Some systems use variants that don't meet branding requirements, |
| 11 | and so are not advertised as being I2C but come under different names, |
| 12 | e.g. TWI (Two Wire Interface), IIC. |
| 13 | |
Deep Majumder | c116fe1 | 2021-11-19 11:44:01 +0530 | [diff] [blame] | 14 | The latest official I2C specification is the `"I2C-bus specification and user |
| 15 | manual" (UM10204) <https://www.nxp.com/webapp/Download?colCode=UM10204>`_ |
| 16 | published by NXP Semiconductors. However, you need to log-in to the site to |
| 17 | access the PDF. An older version of the specification (revision 6) is archived |
| 18 | `here <https://web.archive.org/web/20210813122132/https://www.nxp.com/docs/en/user-guide/UM10204.pdf>`_. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
David Brownell | 4298cfc | 2007-05-01 23:26:31 +0200 | [diff] [blame] | 20 | SMBus (System Management Bus) is based on the I2C protocol, and is mostly |
| 21 | a subset of I2C protocols and signaling. Many I2C devices will work on an |
| 22 | SMBus, but some SMBus protocols add semantics beyond what is required to |
| 23 | achieve I2C branding. Modern PC mainboards rely on SMBus. The most common |
| 24 | devices connected through SMBus are RAM modules configured using I2C EEPROMs, |
| 25 | and hardware monitoring chips. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
David Brownell | 4298cfc | 2007-05-01 23:26:31 +0200 | [diff] [blame] | 27 | Because the SMBus is mostly a subset of the generalized I2C bus, we can |
| 28 | use its protocols on many I2C systems. However, there are systems that don't |
| 29 | meet both SMBus and I2C electrical constraints; and others which can't |
| 30 | implement all the common SMBus protocol semantics or messages. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | |
| 33 | Terminology |
| 34 | =========== |
| 35 | |
Luca Ceresoli | 020bc5b | 2020-01-29 16:19:28 +0100 | [diff] [blame] | 36 | Using the terminology from the official documentation, the I2C bus connects |
| 37 | one or more *master* chips and one or more *slave* chips. |
Mauro Carvalho Chehab | ccf988b | 2019-07-26 09:51:16 -0300 | [diff] [blame] | 38 | |
Mauro Carvalho Chehab | 36536a0 | 2020-04-14 18:48:52 +0200 | [diff] [blame] | 39 | .. kernel-figure:: i2c_bus.svg |
Luca Ceresoli | 020bc5b | 2020-01-29 16:19:28 +0100 | [diff] [blame] | 40 | :alt: Simple I2C bus with one master and 3 slaves |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Luca Ceresoli | 020bc5b | 2020-01-29 16:19:28 +0100 | [diff] [blame] | 42 | Simple I2C bus |
David Brownell | 4298cfc | 2007-05-01 23:26:31 +0200 | [diff] [blame] | 43 | |
Luca Ceresoli | 020bc5b | 2020-01-29 16:19:28 +0100 | [diff] [blame] | 44 | A **master** chip is a node that starts communications with slaves. In the |
| 45 | Linux kernel implementation it is called an **adapter** or bus. Adapter |
| 46 | drivers are in the ``drivers/i2c/busses/`` subdirectory. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Luca Ceresoli | 020bc5b | 2020-01-29 16:19:28 +0100 | [diff] [blame] | 48 | An **algorithm** contains general code that can be used to implement a |
| 49 | whole class of I2C adapters. Each specific adapter driver either depends on |
| 50 | an algorithm driver in the ``drivers/i2c/algos/`` subdirectory, or includes |
| 51 | its own implementation. |
| 52 | |
| 53 | A **slave** chip is a node that responds to communications when addressed |
| 54 | by the master. In Linux it is called a **client**. Client drivers are kept |
| 55 | in a directory specific to the feature they provide, for example |
| 56 | ``drivers/media/gpio/`` for GPIO expanders and ``drivers/media/i2c/`` for |
| 57 | video-related chips. |
| 58 | |
| 59 | For the example configuration in figure, you will need a driver for your |
| 60 | I2C adapter, and drivers for your I2C devices (usually one driver for each |
| 61 | device). |