Lines Matching +full:i2c +full:- +full:mux
1 I2C topology
4 There are a couple of reasons for building more complex i2c topologies
5 than a straight-forward i2c bus with one adapter and one or more devices.
7 1. A mux may be needed on the bus to prevent address collisions.
13 from the i2c bus, at least most of the time, and sits behind a gate
18 These constructs are represented as i2c adapter trees by Linux, where
21 i2c transfers, and all adapters with a parent are part of an "i2c-mux"
24 Depending of the particular mux driver, something happens when there is
25 an i2c transfer on one of its child adapters. The mux driver can
26 obviously operate a mux, but it can also do arbitration with an external
27 bus master or open a gate. The mux driver has two operations for this,
35 There are two variants of locking available to i2c muxes, they can be
36 mux-locked or parent-locked muxes. As is evident from below, it can be
37 useful to know if a mux is mux-locked or if it is parent-locked. The
40 In drivers/i2c/muxes/
41 i2c-arb-gpio-challenge Parent-locked
42 i2c-mux-gpio Normally parent-locked, mux-locked iff
44 same i2c root adapter that they mux.
45 i2c-mux-gpmux Normally parent-locked, mux-locked iff
46 specified in device-tree.
47 i2c-mux-ltc4306 Mux-locked
48 i2c-mux-mlxcpld Parent-locked
49 i2c-mux-pca9541 Parent-locked
50 i2c-mux-pca954x Parent-locked
51 i2c-mux-pinctrl Normally parent-locked, mux-locked iff
53 by the same i2c root adapter that they mux.
54 i2c-mux-reg Parent-locked
57 gyro/mpu3050 Mux-locked
58 imu/inv_mpu6050/ Mux-locked
61 dvb-frontends/lgdt3306a Mux-locked
62 dvb-frontends/m88ds3103 Parent-locked
63 dvb-frontends/rtl2830 Parent-locked
64 dvb-frontends/rtl2832 Mux-locked
65 dvb-frontends/si2168 Mux-locked
66 usb/cx231xx/ Parent-locked
69 Mux-locked muxes
70 ----------------
72 Mux-locked muxes does not lock the entire parent adapter during the
73 full select-transfer-deselect transaction, only the muxes on the parent
74 adapter are locked. Mux-locked muxes are mostly interesting if the
75 select and/or deselect operations must use i2c transfers to complete
77 full transaction, unrelated i2c transfers may interleave the different
78 stages of the transaction. This has the benefit that the mux driver
81 ML1. If you build a topology with a mux-locked mux being the parent
82 of a parent-locked mux, this might break the expectation from the
83 parent-locked mux that the root adapter is locked during the
87 mux-locked muxes that are not siblings, when there are address
89 non-sibling muxes.
91 I.e. the select-transfer-deselect transaction targeting e.g. device
92 address 0x42 behind mux-one may be interleaved with a similar
93 operation targeting device address 0x42 behind mux-two. The
95 be that mux-one and mux-two should not be selected simultaneously,
96 but mux-locked muxes do not guarantee that in all topologies.
98 ML3. A mux-locked mux cannot be used by a driver for auto-closing
100 number (one, in most cases) of i2c transfers. Unrelated i2c transfers
103 ML4. If any non-i2c operation in the mux driver changes the i2c mux state,
106 behind the mux, when an unrelated i2c transfer is in flight during
107 the non-i2c mux-changing operation.
110 Mux-locked Example
111 ------------------
113 .----------. .--------.
114 .--------. | mux- |-----| dev D1 |
115 | root |--+--| locked | '--------'
116 '--------' | | mux M1 |--. .--------.
117 | '----------' '--| dev D2 |
118 | .--------. '--------'
119 '--| dev D3 |
120 '--------'
124 1. Someone issues an i2c-transfer to D1.
126 3. M1 calls ->select to ready the mux.
127 4. M1 (presumably) does some i2c-transfers as part of its select.
128 These transfers are normal i2c-transfers that locks the parent
130 5. M1 feeds the i2c-transfer from step 1 to its parent adapter as a
131 normal i2c-transfer that locks the parent adapter.
132 6. M1 calls ->deselect, if it has one.
133 7. Same rules as in step 4, but for ->deselect.
141 Parent-locked muxes
142 -------------------
144 Parent-locked muxes lock the parent adapter during the full select-
145 transfer-deselect transaction. The implication is that the mux driver
146 has to ensure that any and all i2c transfers through that parent
147 adapter during the transaction are unlocked i2c transfers (using e.g.
151 PL1. If you build a topology with a parent-locked mux being the child
152 of another mux, this might break a possible assumption from the
153 child mux that the root adapter is unused between its select op
154 and the actual transfer (e.g. if the child mux is auto-closing
155 and the parent mux issus i2c-transfers as part of its select).
156 This is especially the case if the parent mux is mux-locked, but
157 it may also happen if the parent mux is parent-locked.
160 pinctrl, regmap or iio, it is essential that any i2c transfers
166 Parent-locked Example
167 ---------------------
169 .----------. .--------.
170 .--------. | parent- |-----| dev D1 |
171 | root |--+--| locked | '--------'
172 '--------' | | mux M1 |--. .--------.
173 | '----------' '--| dev D2 |
174 | .--------. '--------'
175 '--| dev D3 |
176 '--------'
180 1. Someone issues an i2c-transfer to D1.
183 4. M1 calls ->select to ready the mux.
184 5. If M1 does any i2c-transfers (on this root adapter) as part of
185 its select, those transfers must be unlocked i2c-transfers so
187 6. M1 feeds the i2c-transfer from step 1 to the root adapter as an
188 unlocked i2c-transfer, so that it does not deadlock the parent
190 7. M1 calls ->deselect, if it has one.
191 8. Same rules as in step 5, but for ->deselect.
203 Parent-locked mux as parent of parent-locked mux
204 ------------------------------------------------
208 .----------. .----------. .--------.
209 .--------. | parent- |-----| parent- |-----| dev D1 |
210 | root |--+--| locked | | locked | '--------'
211 '--------' | | mux M1 |--. | mux M2 |--. .--------.
212 | '----------' | '----------' '--| dev D2 |
213 | .--------. | .--------. '--------'
214 '--| dev D4 | '--| dev D3 |
215 '--------' '--------'
222 This topology is bad if M2 is an auto-closing mux and M1->select
223 issues any unlocked i2c transfers on the root adapter that may leak
227 Mux-locked mux as parent of mux-locked mux
228 ------------------------------------------
232 .----------. .----------. .--------.
233 .--------. | mux- |-----| mux- |-----| dev D1 |
234 | root |--+--| locked | | locked | '--------'
235 '--------' | | mux M1 |--. | mux M2 |--. .--------.
236 | '----------' | '----------' '--| dev D2 |
237 | .--------. | .--------. '--------'
238 '--| dev D4 | '--| dev D3 |
239 '--------' '--------'
248 Mux-locked mux as parent of parent-locked mux
249 ---------------------------------------------
253 .----------. .----------. .--------.
254 .--------. | mux- |-----| parent- |-----| dev D1 |
255 | root |--+--| locked | | locked | '--------'
256 '--------' | | mux M1 |--. | mux M2 |--. .--------.
257 | '----------' | '----------' '--| dev D2 |
258 | .--------. | .--------. '--------'
259 '--| dev D4 | '--| dev D3 |
260 '--------' '--------'
269 be no i2c transfers during its calls to ->select and ->deselect, and
271 as partial i2c transfers, i.e. garbage or worse. This might cause
274 The topology is especially troublesome if M2 is an auto-closing
275 mux. In that case, any interleaved accesses to D4 might close M2
276 prematurely, as might any i2c-transfers part of M1->select.
279 auto-closing, the topology is fine.
282 Parent-locked mux as parent of mux-locked mux
283 ---------------------------------------------
287 .----------. .----------. .--------.
288 .--------. | parent- |-----| mux- |-----| dev D1 |
289 | root |--+--| locked | | locked | '--------'
290 '--------' | | mux M1 |--. | mux M2 |--. .--------.
291 | '----------' | '----------' '--| dev D2 |
292 | .--------. | .--------. '--------'
293 '--| dev D4 | '--| dev D3 |
294 '--------' '--------'
299 any point, just as is expected for mux-locked muxes.
306 Two mux-locked sibling muxes
307 ----------------------------
311 .--------.
312 .----------. .--| dev D1 |
313 | mux- |--' '--------'
314 .--| locked | .--------.
315 | | mux M1 |-----| dev D2 |
316 | '----------' '--------'
317 | .----------. .--------.
318 .--------. | | mux- |-----| dev D3 |
319 | root |--+--| locked | '--------'
320 '--------' | | mux M2 |--. .--------.
321 | '----------' '--| dev D4 |
322 | .--------. '--------'
323 '--| dev D5 |
324 '--------'
330 Two parent-locked sibling muxes
331 -------------------------------
335 .--------.
336 .----------. .--| dev D1 |
337 | parent- |--' '--------'
338 .--| locked | .--------.
339 | | mux M1 |-----| dev D2 |
340 | '----------' '--------'
341 | .----------. .--------.
342 .--------. | | parent- |-----| dev D3 |
343 | root |--+--| locked | '--------'
344 '--------' | | mux M2 |--. .--------.
345 | '----------' '--| dev D4 |
346 | .--------. '--------'
347 '--| dev D5 |
348 '--------'
354 Mux-locked and parent-locked sibling muxes
355 ------------------------------------------
359 .--------.
360 .----------. .--| dev D1 |
361 | mux- |--' '--------'
362 .--| locked | .--------.
363 | | mux M1 |-----| dev D2 |
364 | '----------' '--------'
365 | .----------. .--------.
366 .--------. | | parent- |-----| dev D3 |
367 | root |--+--| locked | '--------'
368 '--------' | | mux M2 |--. .--------.
369 | '----------' '--| dev D4 |
370 | .--------. '--------'
371 '--| dev D5 |
372 '--------'