diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-gpio.c | 27 | ||||
-rw-r--r-- | drivers/i2c/i2c-mux.c | 2 |
2 files changed, 18 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 708193344a..5ab43fe935 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -94,18 +94,25 @@ static int of_i2c_gpio_probe(struct device_node *np, if (!IS_ENABLED(CONFIG_OFDEVICE)) return -ENODEV; - if (of_gpio_count(np) < 2) - return -ENODEV; + pdata->sda_pin = of_get_named_gpio_flags(np, "sda-gpios", 0, NULL); + pdata->scl_pin = of_get_named_gpio_flags(np, "scl-gpios", 0, NULL); + + if ((!gpio_is_valid(pdata->sda_pin) || !gpio_is_valid(pdata->scl_pin)) + && (of_gpio_count(np) >= 2)) { + /* Note: The gpios property is marked as deprecated */ + ret = of_get_gpio(np, 0); + if (ret < 0) + return ret; + pdata->sda_pin = ret; - ret = of_get_gpio(np, 0); - if (ret < 0) - return ret; - pdata->sda_pin = ret; + ret = of_get_gpio(np, 1); + if (ret < 0) + return ret; + pdata->scl_pin = ret; + } - ret = of_get_gpio(np, 1); - if (ret < 0) - return ret; - pdata->scl_pin = ret; + if (!gpio_is_valid(pdata->sda_pin) || !gpio_is_valid(pdata->scl_pin)) + return -ENODEV; of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay); diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index f87e1fadb6..ab31da61d6 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -96,7 +96,7 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, /* * Try to populate the mux adapter's device_node, expands to - * nothing if !CONFIG_OF. + * nothing if !CONFIG_OFDEVICE. */ if (mux_dev->device_node) { struct device_node *child; |