xref: /openbmc/linux/Documentation/i2c/i2c-topology.rst (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1f6fcefa1SLuca Ceresoli================================
2f6fcefa1SLuca CeresoliI2C muxes and complex topologies
3f6fcefa1SLuca Ceresoli================================
4ccf988b6SMauro Carvalho Chehab
52f07c05fSLuca CeresoliThere are a couple of reasons for building more complex I2C topologies
62f07c05fSLuca Ceresolithan a straight-forward I2C bus with one adapter and one or more devices.
7ccf988b6SMauro Carvalho Chehab
812c035a1SLuca CeresoliSome example use cases are:
912c035a1SLuca Ceresoli
10ccf988b6SMauro Carvalho Chehab1. A mux may be needed on the bus to prevent address collisions.
11ccf988b6SMauro Carvalho Chehab
12ccf988b6SMauro Carvalho Chehab2. The bus may be accessible from some external bus master, and arbitration
13ccf988b6SMauro Carvalho Chehab   may be needed to determine if it is ok to access the bus.
14ccf988b6SMauro Carvalho Chehab
15ccf988b6SMauro Carvalho Chehab3. A device (particularly RF tuners) may want to avoid the digital noise
162f07c05fSLuca Ceresoli   from the I2C bus, at least most of the time, and sits behind a gate
17ccf988b6SMauro Carvalho Chehab   that has to be operated before the device can be accessed.
18ccf988b6SMauro Carvalho Chehab
19*92d5d643SLuca CeresoliSeveral types of hardware components such as I2C muxes, I2C gates and I2C
20*92d5d643SLuca Ceresoliarbitrators allow to handle such needs.
21*92d5d643SLuca Ceresoli
22*92d5d643SLuca CeresoliThese components are represented as I2C adapter trees by Linux, where
23ccf988b6SMauro Carvalho Chehabeach adapter has a parent adapter (except the root adapter) and zero or
24ccf988b6SMauro Carvalho Chehabmore child adapters. The root adapter is the actual adapter that issues
252f07c05fSLuca CeresoliI2C transfers, and all adapters with a parent are part of an "i2c-mux"
26ccf988b6SMauro Carvalho Chehabobject (quoted, since it can also be an arbitrator or a gate).
27ccf988b6SMauro Carvalho Chehab
28ccf988b6SMauro Carvalho ChehabDepending of the particular mux driver, something happens when there is
292f07c05fSLuca Ceresolian I2C transfer on one of its child adapters. The mux driver can
30ccf988b6SMauro Carvalho Chehabobviously operate a mux, but it can also do arbitration with an external
31ccf988b6SMauro Carvalho Chehabbus master or open a gate. The mux driver has two operations for this,
32ccf988b6SMauro Carvalho Chehabselect and deselect. select is called before the transfer and (the
33ccf988b6SMauro Carvalho Chehaboptional) deselect is called after the transfer.
34ccf988b6SMauro Carvalho Chehab
35ccf988b6SMauro Carvalho Chehab
36ccf988b6SMauro Carvalho ChehabLocking
37ccf988b6SMauro Carvalho Chehab=======
38ccf988b6SMauro Carvalho Chehab
392f07c05fSLuca CeresoliThere are two variants of locking available to I2C muxes, they can be
40*92d5d643SLuca Ceresolimux-locked or parent-locked muxes.
41ccf988b6SMauro Carvalho Chehab
42ccf988b6SMauro Carvalho Chehab
43ccf988b6SMauro Carvalho ChehabMux-locked muxes
44ccf988b6SMauro Carvalho Chehab----------------
45ccf988b6SMauro Carvalho Chehab
46ccf988b6SMauro Carvalho ChehabMux-locked muxes does not lock the entire parent adapter during the
47ccf988b6SMauro Carvalho Chehabfull select-transfer-deselect transaction, only the muxes on the parent
48ccf988b6SMauro Carvalho Chehabadapter are locked. Mux-locked muxes are mostly interesting if the
492f07c05fSLuca Ceresoliselect and/or deselect operations must use I2C transfers to complete
50ccf988b6SMauro Carvalho Chehabtheir tasks. Since the parent adapter is not fully locked during the
512f07c05fSLuca Ceresolifull transaction, unrelated I2C transfers may interleave the different
52ccf988b6SMauro Carvalho Chehabstages of the transaction. This has the benefit that the mux driver
53ccf988b6SMauro Carvalho Chehabmay be easier and cleaner to implement, but it has some caveats.
54ccf988b6SMauro Carvalho Chehab
55ccf988b6SMauro Carvalho ChehabMux-locked Example
56*92d5d643SLuca Ceresoli~~~~~~~~~~~~~~~~~~
57ccf988b6SMauro Carvalho Chehab
58ccf988b6SMauro Carvalho Chehab::
59ccf988b6SMauro Carvalho Chehab
60ccf988b6SMauro Carvalho Chehab                   .----------.     .--------.
61ccf988b6SMauro Carvalho Chehab    .--------.     |   mux-   |-----| dev D1 |
62ccf988b6SMauro Carvalho Chehab    |  root  |--+--|  locked  |     '--------'
63ccf988b6SMauro Carvalho Chehab    '--------'  |  |  mux M1  |--.  .--------.
64ccf988b6SMauro Carvalho Chehab                |  '----------'  '--| dev D2 |
65ccf988b6SMauro Carvalho Chehab                |  .--------.       '--------'
66ccf988b6SMauro Carvalho Chehab                '--| dev D3 |
67ccf988b6SMauro Carvalho Chehab                   '--------'
68ccf988b6SMauro Carvalho Chehab
69ccf988b6SMauro Carvalho ChehabWhen there is an access to D1, this happens:
70ccf988b6SMauro Carvalho Chehab
7148ca3b7fSLuca Ceresoli 1. Someone issues an I2C transfer to D1.
72ccf988b6SMauro Carvalho Chehab 2. M1 locks muxes on its parent (the root adapter in this case).
73ccf988b6SMauro Carvalho Chehab 3. M1 calls ->select to ready the mux.
7448ca3b7fSLuca Ceresoli 4. M1 (presumably) does some I2C transfers as part of its select.
7548ca3b7fSLuca Ceresoli    These transfers are normal I2C transfers that locks the parent
76ccf988b6SMauro Carvalho Chehab    adapter.
7748ca3b7fSLuca Ceresoli 5. M1 feeds the I2C transfer from step 1 to its parent adapter as a
7848ca3b7fSLuca Ceresoli    normal I2C transfer that locks the parent adapter.
79ccf988b6SMauro Carvalho Chehab 6. M1 calls ->deselect, if it has one.
80ccf988b6SMauro Carvalho Chehab 7. Same rules as in step 4, but for ->deselect.
81ccf988b6SMauro Carvalho Chehab 8. M1 unlocks muxes on its parent.
82ccf988b6SMauro Carvalho Chehab
83ccf988b6SMauro Carvalho ChehabThis means that accesses to D2 are lockout out for the full duration
84ccf988b6SMauro Carvalho Chehabof the entire operation. But accesses to D3 are possibly interleaved
85ccf988b6SMauro Carvalho Chehabat any point.
86ccf988b6SMauro Carvalho Chehab
87*92d5d643SLuca CeresoliMux-locked caveats
88*92d5d643SLuca Ceresoli~~~~~~~~~~~~~~~~~~
89*92d5d643SLuca Ceresoli
90*92d5d643SLuca CeresoliWhen using a mux-locked mux, be aware of the following restrictions:
91*92d5d643SLuca Ceresoli
92*92d5d643SLuca Ceresoli[ML1]
93*92d5d643SLuca Ceresoli  If you build a topology with a mux-locked mux being the parent
94*92d5d643SLuca Ceresoli  of a parent-locked mux, this might break the expectation from the
95*92d5d643SLuca Ceresoli  parent-locked mux that the root adapter is locked during the
96*92d5d643SLuca Ceresoli  transaction.
97*92d5d643SLuca Ceresoli
98*92d5d643SLuca Ceresoli[ML2]
99*92d5d643SLuca Ceresoli  It is not safe to build arbitrary topologies with two (or more)
100*92d5d643SLuca Ceresoli  mux-locked muxes that are not siblings, when there are address
101*92d5d643SLuca Ceresoli  collisions between the devices on the child adapters of these
102*92d5d643SLuca Ceresoli  non-sibling muxes.
103*92d5d643SLuca Ceresoli
104*92d5d643SLuca Ceresoli  I.e. the select-transfer-deselect transaction targeting e.g. device
105*92d5d643SLuca Ceresoli  address 0x42 behind mux-one may be interleaved with a similar
106*92d5d643SLuca Ceresoli  operation targeting device address 0x42 behind mux-two. The
107*92d5d643SLuca Ceresoli  intent with such a topology would in this hypothetical example
108*92d5d643SLuca Ceresoli  be that mux-one and mux-two should not be selected simultaneously,
109*92d5d643SLuca Ceresoli  but mux-locked muxes do not guarantee that in all topologies.
110*92d5d643SLuca Ceresoli
111*92d5d643SLuca Ceresoli[ML3]
112*92d5d643SLuca Ceresoli  A mux-locked mux cannot be used by a driver for auto-closing
113*92d5d643SLuca Ceresoli  gates/muxes, i.e. something that closes automatically after a given
114*92d5d643SLuca Ceresoli  number (one, in most cases) of I2C transfers. Unrelated I2C transfers
115*92d5d643SLuca Ceresoli  may creep in and close prematurely.
116*92d5d643SLuca Ceresoli
117*92d5d643SLuca Ceresoli[ML4]
118*92d5d643SLuca Ceresoli  If any non-I2C operation in the mux driver changes the I2C mux state,
119*92d5d643SLuca Ceresoli  the driver has to lock the root adapter during that operation.
120*92d5d643SLuca Ceresoli  Otherwise garbage may appear on the bus as seen from devices
121*92d5d643SLuca Ceresoli  behind the mux, when an unrelated I2C transfer is in flight during
122*92d5d643SLuca Ceresoli  the non-I2C mux-changing operation.
123*92d5d643SLuca Ceresoli
124ccf988b6SMauro Carvalho Chehab
125ccf988b6SMauro Carvalho ChehabParent-locked muxes
126ccf988b6SMauro Carvalho Chehab-------------------
127ccf988b6SMauro Carvalho Chehab
128ccf988b6SMauro Carvalho ChehabParent-locked muxes lock the parent adapter during the full select-
129ccf988b6SMauro Carvalho Chehabtransfer-deselect transaction. The implication is that the mux driver
1302f07c05fSLuca Ceresolihas to ensure that any and all I2C transfers through that parent
1312f07c05fSLuca Ceresoliadapter during the transaction are unlocked I2C transfers (using e.g.
132*92d5d643SLuca Ceresoli__i2c_transfer), or a deadlock will follow.
133ccf988b6SMauro Carvalho Chehab
134ccf988b6SMauro Carvalho ChehabParent-locked Example
135*92d5d643SLuca Ceresoli~~~~~~~~~~~~~~~~~~~~~
136ccf988b6SMauro Carvalho Chehab
137ccf988b6SMauro Carvalho Chehab::
138ccf988b6SMauro Carvalho Chehab
139ccf988b6SMauro Carvalho Chehab                   .----------.     .--------.
140ccf988b6SMauro Carvalho Chehab    .--------.     |  parent- |-----| dev D1 |
141ccf988b6SMauro Carvalho Chehab    |  root  |--+--|  locked  |     '--------'
142ccf988b6SMauro Carvalho Chehab    '--------'  |  |  mux M1  |--.  .--------.
143ccf988b6SMauro Carvalho Chehab                |  '----------'  '--| dev D2 |
144ccf988b6SMauro Carvalho Chehab                |  .--------.       '--------'
145ccf988b6SMauro Carvalho Chehab                '--| dev D3 |
146ccf988b6SMauro Carvalho Chehab                   '--------'
147ccf988b6SMauro Carvalho Chehab
148ccf988b6SMauro Carvalho ChehabWhen there is an access to D1, this happens:
149ccf988b6SMauro Carvalho Chehab
15048ca3b7fSLuca Ceresoli 1.  Someone issues an I2C transfer to D1.
151ccf988b6SMauro Carvalho Chehab 2.  M1 locks muxes on its parent (the root adapter in this case).
152ccf988b6SMauro Carvalho Chehab 3.  M1 locks its parent adapter.
153ccf988b6SMauro Carvalho Chehab 4.  M1 calls ->select to ready the mux.
15448ca3b7fSLuca Ceresoli 5.  If M1 does any I2C transfers (on this root adapter) as part of
15548ca3b7fSLuca Ceresoli     its select, those transfers must be unlocked I2C transfers so
156ccf988b6SMauro Carvalho Chehab     that they do not deadlock the root adapter.
15748ca3b7fSLuca Ceresoli 6.  M1 feeds the I2C transfer from step 1 to the root adapter as an
15848ca3b7fSLuca Ceresoli     unlocked I2C transfer, so that it does not deadlock the parent
159ccf988b6SMauro Carvalho Chehab     adapter.
160ccf988b6SMauro Carvalho Chehab 7.  M1 calls ->deselect, if it has one.
161ccf988b6SMauro Carvalho Chehab 8.  Same rules as in step 5, but for ->deselect.
162ccf988b6SMauro Carvalho Chehab 9.  M1 unlocks its parent adapter.
163ccf988b6SMauro Carvalho Chehab 10. M1 unlocks muxes on its parent.
164ccf988b6SMauro Carvalho Chehab
165ccf988b6SMauro Carvalho ChehabThis means that accesses to both D2 and D3 are locked out for the full
166ccf988b6SMauro Carvalho Chehabduration of the entire operation.
167ccf988b6SMauro Carvalho Chehab
168*92d5d643SLuca CeresoliParent-locked Caveats
169*92d5d643SLuca Ceresoli~~~~~~~~~~~~~~~~~~~~~
170*92d5d643SLuca Ceresoli
171*92d5d643SLuca CeresoliWhen using a parent-locked mux, be aware of the following restrictions:
172*92d5d643SLuca Ceresoli
173*92d5d643SLuca Ceresoli[PL1]
174*92d5d643SLuca Ceresoli  If you build a topology with a parent-locked mux being the child
175*92d5d643SLuca Ceresoli  of another mux, this might break a possible assumption from the
176*92d5d643SLuca Ceresoli  child mux that the root adapter is unused between its select op
177*92d5d643SLuca Ceresoli  and the actual transfer (e.g. if the child mux is auto-closing
178*92d5d643SLuca Ceresoli  and the parent mux issues I2C transfers as part of its select).
179*92d5d643SLuca Ceresoli  This is especially the case if the parent mux is mux-locked, but
180*92d5d643SLuca Ceresoli  it may also happen if the parent mux is parent-locked.
181*92d5d643SLuca Ceresoli
182*92d5d643SLuca Ceresoli[PL2]
183*92d5d643SLuca Ceresoli  If select/deselect calls out to other subsystems such as gpio,
184*92d5d643SLuca Ceresoli  pinctrl, regmap or iio, it is essential that any I2C transfers
185*92d5d643SLuca Ceresoli  caused by these subsystems are unlocked. This can be convoluted to
186*92d5d643SLuca Ceresoli  accomplish, maybe even impossible if an acceptably clean solution
187*92d5d643SLuca Ceresoli  is sought.
188*92d5d643SLuca Ceresoli
189ccf988b6SMauro Carvalho Chehab
190ccf988b6SMauro Carvalho ChehabComplex Examples
191ccf988b6SMauro Carvalho Chehab================
192ccf988b6SMauro Carvalho Chehab
193ccf988b6SMauro Carvalho ChehabParent-locked mux as parent of parent-locked mux
194ccf988b6SMauro Carvalho Chehab------------------------------------------------
195ccf988b6SMauro Carvalho Chehab
196ccf988b6SMauro Carvalho ChehabThis is a useful topology, but it can be bad::
197ccf988b6SMauro Carvalho Chehab
198ccf988b6SMauro Carvalho Chehab                   .----------.     .----------.     .--------.
199ccf988b6SMauro Carvalho Chehab    .--------.     |  parent- |-----|  parent- |-----| dev D1 |
200ccf988b6SMauro Carvalho Chehab    |  root  |--+--|  locked  |     |  locked  |     '--------'
201ccf988b6SMauro Carvalho Chehab    '--------'  |  |  mux M1  |--.  |  mux M2  |--.  .--------.
202ccf988b6SMauro Carvalho Chehab                |  '----------'  |  '----------'  '--| dev D2 |
203ccf988b6SMauro Carvalho Chehab                |  .--------.    |  .--------.       '--------'
204ccf988b6SMauro Carvalho Chehab                '--| dev D4 |    '--| dev D3 |
205ccf988b6SMauro Carvalho Chehab                   '--------'       '--------'
206ccf988b6SMauro Carvalho Chehab
207ccf988b6SMauro Carvalho ChehabWhen any device is accessed, all other devices are locked out for
208ccf988b6SMauro Carvalho Chehabthe full duration of the operation (both muxes lock their parent,
209ccf988b6SMauro Carvalho Chehaband specifically when M2 requests its parent to lock, M1 passes
210ccf988b6SMauro Carvalho Chehabthe buck to the root adapter).
211ccf988b6SMauro Carvalho Chehab
212ccf988b6SMauro Carvalho ChehabThis topology is bad if M2 is an auto-closing mux and M1->select
2132f07c05fSLuca Ceresoliissues any unlocked I2C transfers on the root adapter that may leak
214ccf988b6SMauro Carvalho Chehabthrough and be seen by the M2 adapter, thus closing M2 prematurely.
215ccf988b6SMauro Carvalho Chehab
216ccf988b6SMauro Carvalho Chehab
217ccf988b6SMauro Carvalho ChehabMux-locked mux as parent of mux-locked mux
218ccf988b6SMauro Carvalho Chehab------------------------------------------
219ccf988b6SMauro Carvalho Chehab
220ccf988b6SMauro Carvalho ChehabThis is a good topology::
221ccf988b6SMauro Carvalho Chehab
222ccf988b6SMauro Carvalho Chehab                   .----------.     .----------.     .--------.
223ccf988b6SMauro Carvalho Chehab    .--------.     |   mux-   |-----|   mux-   |-----| dev D1 |
224ccf988b6SMauro Carvalho Chehab    |  root  |--+--|  locked  |     |  locked  |     '--------'
225ccf988b6SMauro Carvalho Chehab    '--------'  |  |  mux M1  |--.  |  mux M2  |--.  .--------.
226ccf988b6SMauro Carvalho Chehab                |  '----------'  |  '----------'  '--| dev D2 |
227ccf988b6SMauro Carvalho Chehab                |  .--------.    |  .--------.       '--------'
228ccf988b6SMauro Carvalho Chehab                '--| dev D4 |    '--| dev D3 |
229ccf988b6SMauro Carvalho Chehab                   '--------'       '--------'
230ccf988b6SMauro Carvalho Chehab
231ccf988b6SMauro Carvalho ChehabWhen device D1 is accessed, accesses to D2 are locked out for the
232ccf988b6SMauro Carvalho Chehabfull duration of the operation (muxes on the top child adapter of M1
233ccf988b6SMauro Carvalho Chehabare locked). But accesses to D3 and D4 are possibly interleaved at
234*92d5d643SLuca Ceresoliany point.
235*92d5d643SLuca Ceresoli
236*92d5d643SLuca CeresoliAccesses to D3 locks out D1 and D2, but accesses to D4 are still possibly
237*92d5d643SLuca Ceresoliinterleaved.
238ccf988b6SMauro Carvalho Chehab
239ccf988b6SMauro Carvalho Chehab
240ccf988b6SMauro Carvalho ChehabMux-locked mux as parent of parent-locked mux
241ccf988b6SMauro Carvalho Chehab---------------------------------------------
242ccf988b6SMauro Carvalho Chehab
243ccf988b6SMauro Carvalho ChehabThis is probably a bad topology::
244ccf988b6SMauro Carvalho Chehab
245ccf988b6SMauro Carvalho Chehab                   .----------.     .----------.     .--------.
246ccf988b6SMauro Carvalho Chehab    .--------.     |   mux-   |-----|  parent- |-----| dev D1 |
247ccf988b6SMauro Carvalho Chehab    |  root  |--+--|  locked  |     |  locked  |     '--------'
248ccf988b6SMauro Carvalho Chehab    '--------'  |  |  mux M1  |--.  |  mux M2  |--.  .--------.
249ccf988b6SMauro Carvalho Chehab                |  '----------'  |  '----------'  '--| dev D2 |
250ccf988b6SMauro Carvalho Chehab                |  .--------.    |  .--------.       '--------'
251ccf988b6SMauro Carvalho Chehab                '--| dev D4 |    '--| dev D3 |
252ccf988b6SMauro Carvalho Chehab                   '--------'       '--------'
253ccf988b6SMauro Carvalho Chehab
254ccf988b6SMauro Carvalho ChehabWhen device D1 is accessed, accesses to D2 and D3 are locked out
255ccf988b6SMauro Carvalho Chehabfor the full duration of the operation (M1 locks child muxes on the
256ccf988b6SMauro Carvalho Chehabroot adapter). But accesses to D4 are possibly interleaved at any
257ccf988b6SMauro Carvalho Chehabpoint.
258ccf988b6SMauro Carvalho Chehab
259ccf988b6SMauro Carvalho ChehabThis kind of topology is generally not suitable and should probably
260ccf988b6SMauro Carvalho Chehabbe avoided. The reason is that M2 probably assumes that there will
2612f07c05fSLuca Ceresolibe no I2C transfers during its calls to ->select and ->deselect, and
262ccf988b6SMauro Carvalho Chehabif there are, any such transfers might appear on the slave side of M2
2632f07c05fSLuca Ceresolias partial I2C transfers, i.e. garbage or worse. This might cause
264ccf988b6SMauro Carvalho Chehabdevice lockups and/or other problems.
265ccf988b6SMauro Carvalho Chehab
266ccf988b6SMauro Carvalho ChehabThe topology is especially troublesome if M2 is an auto-closing
267ccf988b6SMauro Carvalho Chehabmux. In that case, any interleaved accesses to D4 might close M2
26848ca3b7fSLuca Ceresoliprematurely, as might any I2C transfers part of M1->select.
269ccf988b6SMauro Carvalho Chehab
270ccf988b6SMauro Carvalho ChehabBut if M2 is not making the above stated assumption, and if M2 is not
271ccf988b6SMauro Carvalho Chehabauto-closing, the topology is fine.
272ccf988b6SMauro Carvalho Chehab
273ccf988b6SMauro Carvalho Chehab
274ccf988b6SMauro Carvalho ChehabParent-locked mux as parent of mux-locked mux
275ccf988b6SMauro Carvalho Chehab---------------------------------------------
276ccf988b6SMauro Carvalho Chehab
277ccf988b6SMauro Carvalho ChehabThis is a good topology::
278ccf988b6SMauro Carvalho Chehab
279ccf988b6SMauro Carvalho Chehab                   .----------.     .----------.     .--------.
280ccf988b6SMauro Carvalho Chehab    .--------.     |  parent- |-----|   mux-   |-----| dev D1 |
281ccf988b6SMauro Carvalho Chehab    |  root  |--+--|  locked  |     |  locked  |     '--------'
282ccf988b6SMauro Carvalho Chehab    '--------'  |  |  mux M1  |--.  |  mux M2  |--.  .--------.
283ccf988b6SMauro Carvalho Chehab                |  '----------'  |  '----------'  '--| dev D2 |
284ccf988b6SMauro Carvalho Chehab                |  .--------.    |  .--------.       '--------'
285ccf988b6SMauro Carvalho Chehab                '--| dev D4 |    '--| dev D3 |
286ccf988b6SMauro Carvalho Chehab                   '--------'       '--------'
287ccf988b6SMauro Carvalho Chehab
288ccf988b6SMauro Carvalho ChehabWhen D1 is accessed, accesses to D2 are locked out for the full
289ccf988b6SMauro Carvalho Chehabduration of the operation (muxes on the top child adapter of M1
290ccf988b6SMauro Carvalho Chehabare locked). Accesses to D3 and D4 are possibly interleaved at
291ccf988b6SMauro Carvalho Chehabany point, just as is expected for mux-locked muxes.
292ccf988b6SMauro Carvalho Chehab
293ccf988b6SMauro Carvalho ChehabWhen D3 or D4 are accessed, everything else is locked out. For D3
294ccf988b6SMauro Carvalho Chehabaccesses, M1 locks the root adapter. For D4 accesses, the root
295ccf988b6SMauro Carvalho Chehabadapter is locked directly.
296ccf988b6SMauro Carvalho Chehab
297ccf988b6SMauro Carvalho Chehab
298ccf988b6SMauro Carvalho ChehabTwo mux-locked sibling muxes
299ccf988b6SMauro Carvalho Chehab----------------------------
300ccf988b6SMauro Carvalho Chehab
301ccf988b6SMauro Carvalho ChehabThis is a good topology::
302ccf988b6SMauro Carvalho Chehab
303ccf988b6SMauro Carvalho Chehab                                    .--------.
304ccf988b6SMauro Carvalho Chehab                   .----------.  .--| dev D1 |
305ccf988b6SMauro Carvalho Chehab                   |   mux-   |--'  '--------'
306ccf988b6SMauro Carvalho Chehab                .--|  locked  |     .--------.
307ccf988b6SMauro Carvalho Chehab                |  |  mux M1  |-----| dev D2 |
308ccf988b6SMauro Carvalho Chehab                |  '----------'     '--------'
309ccf988b6SMauro Carvalho Chehab                |  .----------.     .--------.
310ccf988b6SMauro Carvalho Chehab    .--------.  |  |   mux-   |-----| dev D3 |
311ccf988b6SMauro Carvalho Chehab    |  root  |--+--|  locked  |     '--------'
312ccf988b6SMauro Carvalho Chehab    '--------'  |  |  mux M2  |--.  .--------.
313ccf988b6SMauro Carvalho Chehab                |  '----------'  '--| dev D4 |
314ccf988b6SMauro Carvalho Chehab                |  .--------.       '--------'
315ccf988b6SMauro Carvalho Chehab                '--| dev D5 |
316ccf988b6SMauro Carvalho Chehab                   '--------'
317ccf988b6SMauro Carvalho Chehab
318ccf988b6SMauro Carvalho ChehabWhen D1 is accessed, accesses to D2, D3 and D4 are locked out. But
319ccf988b6SMauro Carvalho Chehabaccesses to D5 may be interleaved at any time.
320ccf988b6SMauro Carvalho Chehab
321ccf988b6SMauro Carvalho Chehab
322ccf988b6SMauro Carvalho ChehabTwo parent-locked sibling muxes
323ccf988b6SMauro Carvalho Chehab-------------------------------
324ccf988b6SMauro Carvalho Chehab
325ccf988b6SMauro Carvalho ChehabThis is a good topology::
326ccf988b6SMauro Carvalho Chehab
327ccf988b6SMauro Carvalho Chehab                                    .--------.
328ccf988b6SMauro Carvalho Chehab                   .----------.  .--| dev D1 |
329ccf988b6SMauro Carvalho Chehab                   |  parent- |--'  '--------'
330ccf988b6SMauro Carvalho Chehab                .--|  locked  |     .--------.
331ccf988b6SMauro Carvalho Chehab                |  |  mux M1  |-----| dev D2 |
332ccf988b6SMauro Carvalho Chehab                |  '----------'     '--------'
333ccf988b6SMauro Carvalho Chehab                |  .----------.     .--------.
334ccf988b6SMauro Carvalho Chehab    .--------.  |  |  parent- |-----| dev D3 |
335ccf988b6SMauro Carvalho Chehab    |  root  |--+--|  locked  |     '--------'
336ccf988b6SMauro Carvalho Chehab    '--------'  |  |  mux M2  |--.  .--------.
337ccf988b6SMauro Carvalho Chehab                |  '----------'  '--| dev D4 |
338ccf988b6SMauro Carvalho Chehab                |  .--------.       '--------'
339ccf988b6SMauro Carvalho Chehab                '--| dev D5 |
340ccf988b6SMauro Carvalho Chehab                   '--------'
341ccf988b6SMauro Carvalho Chehab
342ccf988b6SMauro Carvalho ChehabWhen any device is accessed, accesses to all other devices are locked
343ccf988b6SMauro Carvalho Chehabout.
344ccf988b6SMauro Carvalho Chehab
345ccf988b6SMauro Carvalho Chehab
346ccf988b6SMauro Carvalho ChehabMux-locked and parent-locked sibling muxes
347ccf988b6SMauro Carvalho Chehab------------------------------------------
348ccf988b6SMauro Carvalho Chehab
349ccf988b6SMauro Carvalho ChehabThis is a good topology::
350ccf988b6SMauro Carvalho Chehab
351ccf988b6SMauro Carvalho Chehab                                    .--------.
352ccf988b6SMauro Carvalho Chehab                   .----------.  .--| dev D1 |
353ccf988b6SMauro Carvalho Chehab                   |   mux-   |--'  '--------'
354ccf988b6SMauro Carvalho Chehab                .--|  locked  |     .--------.
355ccf988b6SMauro Carvalho Chehab                |  |  mux M1  |-----| dev D2 |
356ccf988b6SMauro Carvalho Chehab                |  '----------'     '--------'
357ccf988b6SMauro Carvalho Chehab                |  .----------.     .--------.
358ccf988b6SMauro Carvalho Chehab    .--------.  |  |  parent- |-----| dev D3 |
359ccf988b6SMauro Carvalho Chehab    |  root  |--+--|  locked  |     '--------'
360ccf988b6SMauro Carvalho Chehab    '--------'  |  |  mux M2  |--.  .--------.
361ccf988b6SMauro Carvalho Chehab                |  '----------'  '--| dev D4 |
362ccf988b6SMauro Carvalho Chehab                |  .--------.       '--------'
363ccf988b6SMauro Carvalho Chehab                '--| dev D5 |
364ccf988b6SMauro Carvalho Chehab                   '--------'
365ccf988b6SMauro Carvalho Chehab
366ccf988b6SMauro Carvalho ChehabWhen D1 or D2 are accessed, accesses to D3 and D4 are locked out while
367ccf988b6SMauro Carvalho Chehabaccesses to D5 may interleave. When D3 or D4 are accessed, accesses to
368ccf988b6SMauro Carvalho Chehaball other devices are locked out.
369*92d5d643SLuca Ceresoli
370*92d5d643SLuca Ceresoli
371*92d5d643SLuca CeresoliMux type of existing device drivers
372*92d5d643SLuca Ceresoli===================================
373*92d5d643SLuca Ceresoli
374*92d5d643SLuca CeresoliWhether a device is mux-locked or parent-locked depends on its
375*92d5d643SLuca Ceresoliimplementation. The following list was correct at the time of writing:
376*92d5d643SLuca Ceresoli
377*92d5d643SLuca CeresoliIn drivers/i2c/muxes/:
378*92d5d643SLuca Ceresoli
379*92d5d643SLuca Ceresoli======================    =============================================
380*92d5d643SLuca Ceresolii2c-arb-gpio-challenge    Parent-locked
381*92d5d643SLuca Ceresolii2c-mux-gpio              Normally parent-locked, mux-locked iff
382*92d5d643SLuca Ceresoli                          all involved gpio pins are controlled by the
383*92d5d643SLuca Ceresoli                          same I2C root adapter that they mux.
384*92d5d643SLuca Ceresolii2c-mux-gpmux             Normally parent-locked, mux-locked iff
385*92d5d643SLuca Ceresoli                          specified in device-tree.
386*92d5d643SLuca Ceresolii2c-mux-ltc4306           Mux-locked
387*92d5d643SLuca Ceresolii2c-mux-mlxcpld           Parent-locked
388*92d5d643SLuca Ceresolii2c-mux-pca9541           Parent-locked
389*92d5d643SLuca Ceresolii2c-mux-pca954x           Parent-locked
390*92d5d643SLuca Ceresolii2c-mux-pinctrl           Normally parent-locked, mux-locked iff
391*92d5d643SLuca Ceresoli                          all involved pinctrl devices are controlled
392*92d5d643SLuca Ceresoli                          by the same I2C root adapter that they mux.
393*92d5d643SLuca Ceresolii2c-mux-reg               Parent-locked
394*92d5d643SLuca Ceresoli======================    =============================================
395*92d5d643SLuca Ceresoli
396*92d5d643SLuca CeresoliIn drivers/iio/:
397*92d5d643SLuca Ceresoli
398*92d5d643SLuca Ceresoli======================    =============================================
399*92d5d643SLuca Ceresoligyro/mpu3050              Mux-locked
400*92d5d643SLuca Ceresoliimu/inv_mpu6050/          Mux-locked
401*92d5d643SLuca Ceresoli======================    =============================================
402*92d5d643SLuca Ceresoli
403*92d5d643SLuca CeresoliIn drivers/media/:
404*92d5d643SLuca Ceresoli
405*92d5d643SLuca Ceresoli=======================   =============================================
406*92d5d643SLuca Ceresolidvb-frontends/lgdt3306a   Mux-locked
407*92d5d643SLuca Ceresolidvb-frontends/m88ds3103   Parent-locked
408*92d5d643SLuca Ceresolidvb-frontends/rtl2830     Parent-locked
409*92d5d643SLuca Ceresolidvb-frontends/rtl2832     Mux-locked
410*92d5d643SLuca Ceresolidvb-frontends/si2168      Mux-locked
411*92d5d643SLuca Ceresoliusb/cx231xx/              Parent-locked
412*92d5d643SLuca Ceresoli=======================   =============================================
413