i2c-arb-gpio-challenge.txt 2.9 KB

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