From ee849ba62574ac52e04d80f774a374d9b7558f67 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Thu, 19 May 2022 19:03:07 -0500 Subject: dev/i2c_bus: Add declaration, implementation of i2c_dev_detect() This patch adds the I2C equivalent of an SMBus quick write to an I2C device, which is used by some I2C drivers as a way to probe the existence (or absence) of a certain device on the bus, based on whether or not a 0-byte write to an I2C address is ACKed or NACKed. i2c_dev_detect() is implemented using the existing i2c bus ops transfer() function, so no further work is needed for existing controller drivers to utilize this functionality. Change-Id: I9b22bdc0343c846b235339f85d9f70b20f0f2bdd Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/64537 Tested-by: build bot (Jenkins) Reviewed-by: Martin L Roth --- src/include/device/i2c_bus.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/include/device') diff --git a/src/include/device/i2c_bus.h b/src/include/device/i2c_bus.h index 42f461dc9e..1a7e777278 100644 --- a/src/include/device/i2c_bus.h +++ b/src/include/device/i2c_bus.h @@ -13,6 +13,11 @@ struct i2c_bus_operations { int (*transfer)(struct device *, const struct i2c_msg *, size_t count); }; +/** + * Determine device presence at a given slave address. + */ +bool i2c_dev_detect(struct device *dev, unsigned int addr); + /* * Returns the first upstream facing link whose bus implements either * `i2c_bus_operations` *or* `smbus_bus_operations`. -- cgit v1.2.3