summaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-gpio.c
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2021-08-22 03:25:43 +0300
committerHeiko Schocher <hs@denx.de>2021-08-22 12:03:55 +0300
commit7282b4352eba74e134c7ebba945338e418ec7faf (patch)
tree1ba9473836f0246e13ab722480a0abec295f06cc /drivers/i2c/i2c-gpio.c
parent0b3da993a4550d3b990989e3bcdcbbb8cf889258 (diff)
downloadu-boot-7282b4352eba74e134c7ebba945338e418ec7faf.tar.xz
i2c: i2c-gpio: Support the named GPIO binding
To avoid confusion about the order of the GPIOs, the i2c-gpio binding was updated to use a separate property for each GPIO instead of an array. However, the driver only supports the old binding. Add support for the new binding as well, so the driver continues to work as device trees are updated. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c/i2c-gpio.c')
-rw-r--r--drivers/i2c/i2c-gpio.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
index cf8f8f4035..1aedad5c8e 100644
--- a/drivers/i2c/i2c-gpio.c
+++ b/drivers/i2c/i2c-gpio.c
@@ -336,8 +336,17 @@ static int i2c_gpio_of_to_plat(struct udevice *dev)
struct i2c_gpio_bus *bus = dev_get_priv(dev);
int ret;
+ /* "gpios" is deprecated and replaced by "sda-gpios" + "scl-gpios". */
ret = gpio_request_list_by_name(dev, "gpios", bus->gpios,
ARRAY_SIZE(bus->gpios), 0);
+ if (ret == -ENOENT) {
+ ret = gpio_request_by_name(dev, "sda-gpios", 0,
+ &bus->gpios[PIN_SDA], 0);
+ if (ret < 0)
+ goto error;
+ ret = gpio_request_by_name(dev, "scl-gpios", 0,
+ &bus->gpios[PIN_SCL], 0);
+ }
if (ret < 0)
goto error;