
Hello Johan,
On 19.12.22 20:57, Johan Korsnes wrote:
Add function to determine whether a chip is present. This check is typically implemented by writing the chip address to the bus and checking that the chip replies with an ACK.
The already existing dm_i2c_probe() will attempt to bind/probe the relevant driver if the chip is present. This makes it unsuitable for situations where one only wants to know the presence of a chip.
Signed-off-by: Johan Korsnes johan.korsnes@remarkable.no Cc: Eirik Schultz schultzern@gmail.com Cc: Heiko Schocher hs@denx.de Cc: Simon Glass sjg@chromium.org
Previously, I've used i2c_probe() to determine whether or not an i2c chip is present on an i2c bus. With the introduction of the driver model this function is deprecated. Fortunately, I found dm_i2c_probe(), which I expected to perform the same check, it was even documented to be suitable for this purpose:
dm_i2c_probe() - probe a particular chip address This can be useful to check for the existence of a chip on the bus. It is typically implemented by writing the chip address to the bus and checking that the chip replies with an ACK.
Unfortunately, it does not seem to be a replacement. It seems dm_i2c_probe() will attempt to bind/probe a driver if the chip is present, and will in turn return the return value from the driver probe/bind attempt.
drivers/i2c/i2c-uclass.c | 11 +++++++++++ include/i2c.h | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-)
Reviewed-by: Heiko Schocher hs@denx.de
Please add a test, as Simon requested, thanks!
bye, Heiko