Path: blob/main/sys/contrib/device-tree/Bindings/i2c/i2c-arb-gpio-challenge.txt
48378 views
GPIO-based I2C Arbitration Using a Challenge & Response Mechanism1=================================================================2This uses GPIO lines and a challenge & response mechanism to arbitrate who is3the master of an I2C bus in a multimaster situation.45In many cases using GPIOs to arbitrate is not needed and a design can use6the standard I2C multi-master rules. Using GPIOs is generally useful in7the case where there is a device on the bus that has errata and/or bugs8that makes standard multimaster mode not feasible.910Note that this scheme works well enough but has some downsides:11* It is nonstandard (not using standard I2C multimaster)12* Having two masters on a bus in general makes it relatively hard to debug13problems (hard to tell if i2c issues were caused by one master, another, or14some device on the bus).151617Algorithm:1819All masters on the bus have a 'bus claim' line which is an output that the20others can see. These are all active low with pull-ups enabled. We'll21describe these lines as:2223- OUR_CLAIM: output from us signaling to other hosts that we want the bus24- THEIR_CLAIMS: output from others signaling that they want the bus2526The basic algorithm is to assert your line when you want the bus, then make27sure that the other side doesn't want it also. A detailed explanation is best28done with an example.2930Let's say we want to claim the bus. We:311. Assert OUR_CLAIM.322. Waits a little bit for the other sides to notice (slew time, say 1033microseconds).343. Check THEIR_CLAIMS. If none are asserted then the we have the bus and we are35done.364. Otherwise, wait for a few milliseconds and see if THEIR_CLAIMS are released.375. If not, back off, release the claim and wait for a few more milliseconds.386. Go back to 1 (until retry time has expired).394041Required properties:42- compatible: i2c-arb-gpio-challenge43- our-claim-gpio: The GPIO that we use to claim the bus.44- their-claim-gpios: The GPIOs that the other sides use to claim the bus.45Note that some implementations may only support a single other master.46- I2C arbitration bus node. See i2c-arb.txt in this directory.4748Optional properties:49- slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us.50- wait-retry-us: we'll attempt another claim after this many microseconds.51Default is 3000 us.52- wait-free-us: we'll give up after this many microseconds. Default is 50000 us.535455Example:56i2c@12ca0000 {57compatible = "acme,some-i2c-device";58#address-cells = <1>;59#size-cells = <0>;60};6162i2c-arbitrator {63compatible = "i2c-arb-gpio-challenge";6465i2c-parent = <&{/i2c@12CA0000}>;6667our-claim-gpio = <&gpf0 3 1>;68their-claim-gpios = <&gpe0 4 1>;69slew-delay-us = <10>;70wait-retry-us = <3000>;71wait-free-us = <50000>;7273i2c-arb {74#address-cells = <1>;75#size-cells = <0>;7677i2c@52 {78// Normal I2C device79};80};81};828384