linux/Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt
<<
>>
Prefs
   1GPIO-based I2C Arbitration Using a Challenge & Response Mechanism
   2=================================================================
   3This uses GPIO lines and a challenge & response mechanism to arbitrate who is
   4the master of an I2C bus in a multimaster situation.
   5
   6In many cases using GPIOs to arbitrate is not needed and a design can use
   7the standard I2C multi-master rules.  Using GPIOs is generally useful in
   8the case where there is a device on the bus that has errata and/or bugs
   9that makes standard multimaster mode not feasible.
  10
  11
  12Algorithm:
  13
  14All masters on the bus have a 'bus claim' line which is an output that the
  15others can see. These are all active low with pull-ups enabled.  We'll
  16describe these lines as:
  17
  18- OUR_CLAIM: output from us signaling to other hosts that we want the bus
  19- THEIR_CLAIMS: output from others signaling that they want the bus
  20
  21The basic algorithm is to assert your line when you want the bus, then make
  22sure that the other side doesn't want it also.  A detailed explanation is best
  23done with an example.
  24
  25Let's say we want to claim the bus.  We:
  261. Assert OUR_CLAIM.
  272. Waits a little bit for the other sides to notice (slew time, say 10
  28   microseconds).
  293. Check THEIR_CLAIMS.  If none are asserted then the we have the bus and we are
  30   done.
  314. Otherwise, wait for a few milliseconds and see if THEIR_CLAIMS are released.
  325. If not, back off, release the claim and wait for a few more milliseconds.
  336. Go back to 1 (until retry time has expired).
  34
  35
  36Required properties:
  37- compatible: i2c-arb-gpio-challenge
  38- our-claim-gpio: The GPIO that we use to claim the bus.
  39- their-claim-gpios: The GPIOs that the other sides use to claim the bus.
  40  Note that some implementations may only support a single other master.
  41- Standard I2C mux properties. See mux.txt in this directory.
  42- Single I2C child bus node at reg 0. See mux.txt in this directory.
  43
  44Optional properties:
  45- slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us.
  46- wait-retry-us: we'll attempt another claim after this many microseconds.
  47    Default is 3000 us.
  48- wait-free-us: we'll give up after this many microseconds. Default is 50000 us.
  49
  50
  51Example:
  52        i2c@12CA0000 {
  53                compatible = "acme,some-i2c-device";
  54                #address-cells = <1>;
  55                #size-cells = <0>;
  56        };
  57
  58        i2c-arbitrator {
  59                compatible = "i2c-arb-gpio-challenge";
  60                #address-cells = <1>;
  61                #size-cells = <0>;
  62
  63                i2c-parent = <&{/i2c@12CA0000}>;
  64
  65                our-claim-gpio = <&gpf0 3 1>;
  66                their-claim-gpios = <&gpe0 4 1>;
  67                slew-delay-us = <10>;
  68                wait-retry-us = <3000>;
  69                wait-free-us = <50000>;
  70
  71                i2c@0 {
  72                        reg = <0>;
  73                        #address-cells = <1>;
  74                        #size-cells = <0>;
  75
  76                        i2c@52 {
  77                                // Normal I2C device
  78                        };
  79                };
  80        };
  81