diff options
author | Alex Shumsky <alexthreed@gmail.com> | 2024-10-15 23:29:31 +0300 |
---|---|---|
committer | Heiko Schocher <hs@denx.de> | 2024-10-21 06:32:40 +0200 |
commit | f315a4813186ca098a6c698754a06b8297d400f6 (patch) | |
tree | e78165d0292fd70ea752d4cd11d09506ecac69b0 /drivers/i2c/i2c-gpio.c | |
parent | f7c9839a612158b0f07527153d815e901cdea3f8 (diff) |
i2c: i2c-gpio: add support for i2c-gpio,sda-output-only
Some I2C slave devices are read-only and don't even answer with NACK.
For example FD65x segment LED controllers.
Make them usable with i2c-gpio,sda-output-only that are already supported
by Linux 6.3+.
Signed-off-by: Alex Shumsky <alexthreed@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c/i2c-gpio.c')
-rw-r--r-- | drivers/i2c/i2c-gpio.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c index e0a575fb4a4..00aef40e341 100644 --- a/drivers/i2c/i2c-gpio.c +++ b/drivers/i2c/i2c-gpio.c @@ -101,7 +101,7 @@ static int i2c_gpio_read_bit(struct i2c_gpio_bus *bus, int delay) bus->set_scl(bus, 1); udelay(delay); - value = bus->get_sda(bus); + value = bus->get_sda ? bus->get_sda(bus) : 0; udelay(delay); bus->set_scl(bus, 0); udelay(2 * delay); @@ -256,6 +256,9 @@ static int i2c_gpio_read_data(struct i2c_gpio_bus *bus, uchar chip, { unsigned int delay = bus->udelay; + if (!bus->get_sda) + return -EOPNOTSUPP; + debug("%s: chip %x buffer: %p len %d\n", __func__, chip, buffer, len); while (len-- > 0) @@ -353,7 +356,10 @@ static int i2c_gpio_of_to_plat(struct udevice *dev) bus->udelay = dev_read_u32_default(dev, "i2c-gpio,delay-us", DEFAULT_UDELAY); - bus->get_sda = i2c_gpio_sda_get; + if (dev_read_bool(dev, "i2c-gpio,sda-output-only")) + bus->get_sda = NULL; + else + bus->get_sda = i2c_gpio_sda_get; bus->set_sda = i2c_gpio_sda_set; if (dev_read_bool(dev, "i2c-gpio,scl-output-only")) bus->set_scl = i2c_gpio_scl_set_output_only; |