elixir-circuits / circuits_i2c

Communicate over I2C from Elixir
Apache License 2.0
62 stars 12 forks source link

Avoid 0-length writes for detecting I2C devices #129

Open fhunleth opened 1 year ago

fhunleth commented 1 year ago

On devices like the Beaglebone (AM335x), there's a 0-length write quirk. The result is that I2C device detection fails. The kernel log contains:

18:12:45.886 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x0003, size 0, write)
18:12:45.887 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x0004, size 0, write)
18:12:45.899 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x0005, size 0, write)
18:12:45.913 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x0006, size 0, write)
18:12:45.927 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x0007, size 0, write)
18:12:45.938 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x0008, size 0, write)
18:12:45.950 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x0009, size 0, write)
18:12:45.961 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x000a, size 0, write)
18:12:45.973 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x000b, size 0, write)
18:12:45.986 [error] i2c i2c-0: adapter quirk: no zero length (addr 0x000c, size 0, write)
18:12:59.921 [warn] i2c_quirk_error: 176 callbacks suppressed

On other devices, the 0-length writes work great.

Therefore, detection should be updated to check whether they're supported and to only use them if they are.