brintos

brintos / linux-shallow public Read only

0
0
Text · 3.4 KiB · 6845c11 Raw
97 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3=======================4I2C Address Translators5=======================6 7Author: Luca Ceresoli <luca@lucaceresoli.net>8Author: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>9 10Description11-----------12 13An I2C Address Translator (ATR) is a device with an I2C slave parent14("upstream") port and N I2C master child ("downstream") ports, and15forwards transactions from upstream to the appropriate downstream port16with a modified slave address. The address used on the parent bus is17called the "alias" and is (potentially) different from the physical18slave address of the child bus. Address translation is done by the19hardware.20 21An ATR looks similar to an i2c-mux except:22 - the address on the parent and child busses can be different23 - there is normally no need to select the child port; the alias used on the24   parent bus implies it25 26The ATR functionality can be provided by a chip with many other features.27The kernel i2c-atr provides a helper to implement an ATR within a driver.28 29The ATR creates a new I2C "child" adapter on each child bus. Adding30devices on the child bus ends up in invoking the driver code to select31an available alias. Maintaining an appropriate pool of available aliases32and picking one for each new device is up to the driver implementer. The33ATR maintains a table of currently assigned alias and uses it to modify34all I2C transactions directed to devices on the child buses.35 36A typical example follows.37 38Topology::39 40                      Slave X @ 0x1041              .-----.   |42  .-----.     |     |---+---- B43  | CPU |--A--| ATR |44  `-----'     |     |---+---- C45              `-----'   |46                      Slave Y @ 0x1047 48Alias table:49 50A, B and C are three physical I2C busses, electrically independent from51each other. The ATR receives the transactions initiated on bus A and52propagates them on bus B or bus C or none depending on the device address53in the transaction and based on the alias table.54 55Alias table:56 57.. table::58 59   ===============   =====60   Client            Alias61   ===============   =====62   X (bus B, 0x10)   0x2063   Y (bus C, 0x10)   0x3064   ===============   =====65 66Transaction:67 68 - Slave X driver requests a transaction (on adapter B), slave address 0x1069 - ATR driver finds slave X is on bus B and has alias 0x20, rewrites70   messages with address 0x20, forwards to adapter A71 - Physical I2C transaction on bus A, slave address 0x2072 - ATR chip detects transaction on address 0x20, finds it in table,73   propagates transaction on bus B with address translated to 0x10,74   keeps clock stretched on bus A waiting for reply75 - Slave X chip (on bus B) detects transaction at its own physical76   address 0x10 and replies normally77 - ATR chip stops clock stretching and forwards reply on bus A,78   with address translated back to 0x2079 - ATR driver receives the reply, rewrites messages with address 0x1080   as they were initially81 - Slave X driver gets back the msgs[], with reply and address 0x1082 83Usage:84 85 1. In the driver (typically in the probe function) add an ATR by86    calling i2c_atr_new() passing attach/detach callbacks87 2. When the attach callback is called pick an appropriate alias,88    configure it in the chip and return the chosen alias in the89    alias_id parameter90 3. When the detach callback is called, deconfigure the alias from91    the chip and put the alias back in the pool for later usage92 93I2C ATR functions and data structures94-------------------------------------95 96.. kernel-doc:: include/linux/i2c-atr.h97