mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-15 17:34:43 +00:00
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>
This commit is contained in:
parent
f7c9839a61
commit
f315a48131
2 changed files with 10 additions and 2 deletions
|
@ -20,6 +20,8 @@ Optional:
|
||||||
Run deblocking sequence when the driver gets probed.
|
Run deblocking sequence when the driver gets probed.
|
||||||
* i2c-gpio,scl-output-only;
|
* i2c-gpio,scl-output-only;
|
||||||
Set if SCL is an output only
|
Set if SCL is an output only
|
||||||
|
* i2c-gpio,sda-output-only;
|
||||||
|
Set if SDA is an output only
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ static int i2c_gpio_read_bit(struct i2c_gpio_bus *bus, int delay)
|
||||||
|
|
||||||
bus->set_scl(bus, 1);
|
bus->set_scl(bus, 1);
|
||||||
udelay(delay);
|
udelay(delay);
|
||||||
value = bus->get_sda(bus);
|
value = bus->get_sda ? bus->get_sda(bus) : 0;
|
||||||
udelay(delay);
|
udelay(delay);
|
||||||
bus->set_scl(bus, 0);
|
bus->set_scl(bus, 0);
|
||||||
udelay(2 * delay);
|
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;
|
unsigned int delay = bus->udelay;
|
||||||
|
|
||||||
|
if (!bus->get_sda)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
debug("%s: chip %x buffer: %p len %d\n", __func__, chip, buffer, len);
|
debug("%s: chip %x buffer: %p len %d\n", __func__, chip, buffer, len);
|
||||||
|
|
||||||
while (len-- > 0)
|
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",
|
bus->udelay = dev_read_u32_default(dev, "i2c-gpio,delay-us",
|
||||||
DEFAULT_UDELAY);
|
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;
|
bus->set_sda = i2c_gpio_sda_set;
|
||||||
if (dev_read_bool(dev, "i2c-gpio,scl-output-only"))
|
if (dev_read_bool(dev, "i2c-gpio,scl-output-only"))
|
||||||
bus->set_scl = i2c_gpio_scl_set_output_only;
|
bus->set_scl = i2c_gpio_scl_set_output_only;
|
||||||
|
|
Loading…
Add table
Reference in a new issue