[PATCH] i2c: add dm_i2c_probe_chip() to detect chip presence
hs at denx.de
Sun Jan 1 08:48:32 CET 2023
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 at remarkable.no>
> Cc: Eirik Schultz <schultzern at gmail.com>
> Cc: Heiko Schocher <hs at denx.de>
> Cc: Simon Glass <sjg at 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 at denx.de>
Please add a test, as Simon requested, thanks!
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
More information about the U-Boot