I2C bus multiplexing

From Linux i2c Wiki
Revision as of 08:48, 29 November 2012 by Jdelvare (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Support for I2C bus multiplexing was written by Rodolfo Giometti and Michael Lawnick with the help of Jean Delvare. It was first available in kernel version 2.6.36.

Summary of Implementation

This implementation lets the I2C core handle multiplexed I2C bus topologies by presenting each multiplexed segment as an independent I2C adapter. For instance if your system has one I2C controller and one two ways multiplexer, you will have tree adapters into your system: one representing the trunk and two representing the two multiplexer's branches.

Implementation Details

If your system has one (or more) I2C controller(s) and one (or more) I2C multiplexer(s), you should be able to access each I2C device on any segment without doing "strange" operations but i2c classic ones. In other words, the user shouldn't have to know the I2C bus topology details nor the multiplexer internals. By considering each i2c multiplexer branch as an independent segment we can reach the goal, in fact the user simply can exchange data with an I2C device by accessing to the relevant segment.

ASCII art time:

+------------+   segment 0 (i2c-0)
| controller |-------+--------+----------+---
+------------+       |        |          |
                     |        |          |
                     |    +-------+  +-------+
                     |    | dev A |  | dev B |
                     |    +-------+  +-------+
                     |
                     |                    +-------+  +-------+
                     |                    | dev C |  | dev D |
                     |                    +-------+  +-------+
                     |                        |          |
                  +-----+   segment 1 (i2c-1) |          |
                  |     |---------------------+---       |
                  | MUX |                                |
                  |     |--------------------------------+---
                  +-----+   segment 2 (i2c-2)

To access to device "A" the user simply refers to adapter i2c-0 witch in turn gets access to segment 0. Similarly, to access to device "D" the user refers to i2c-2 which in turn gets access to segment 2. Simple, isn't it?

All issues related to the multiplexer internal settings, in order to manage the switching between branch 1 and 2, are managed internally by the multiplexer chip driver and are totally transparent for the user. Core main functions of that magic are i2c-mux select() and deselect() which are called by the core before and after each i2c transfer as appropriate.

Personal tools