gpiolib: of: support bias pull disable
authorNuno Sá <nuno.sa@analog.com>
Wed, 13 Jul 2022 13:14:19 +0000 (15:14 +0200)
committerBartosz Golaszewski <brgl@bgdev.pl>
Tue, 19 Jul 2022 08:24:01 +0000 (10:24 +0200)
On top of looking at PULL_UP and PULL_DOWN flags, also look at
PULL_DISABLE and set the appropriate GPIO flag. The GPIO core will then
pass down this to controllers that support it.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
drivers/gpio/gpiolib-of.c
include/linux/of_gpio.h

index f80307be37d5b5f262ec557c952407971652077d..a037b50bef330d9ef774435316615b36f8bd8b15 100644 (file)
@@ -354,6 +354,9 @@ struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node,
        if (flags & OF_GPIO_PULL_DOWN)
                lflags |= GPIO_PULL_DOWN;
 
+       if (flags & OF_GPIO_PULL_DISABLE)
+               lflags |= GPIO_PULL_DISABLE;
+
        ret = gpiod_configure_flags(desc, propname, lflags, dflags);
        if (ret < 0) {
                gpiod_put(desc);
@@ -556,6 +559,8 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
                *flags |= GPIO_PULL_UP;
        if (of_flags & OF_GPIO_PULL_DOWN)
                *flags |= GPIO_PULL_DOWN;
+       if (of_flags & OF_GPIO_PULL_DISABLE)
+               *flags |= GPIO_PULL_DISABLE;
 
        return desc;
 }
@@ -621,6 +626,8 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
                *lflags |= GPIO_PULL_UP;
        if (xlate_flags & OF_GPIO_PULL_DOWN)
                *lflags |= GPIO_PULL_DOWN;
+       if (xlate_flags & OF_GPIO_PULL_DISABLE)
+               *lflags |= GPIO_PULL_DISABLE;
 
        if (of_property_read_bool(np, "input"))
                *dflags |= GPIOD_IN;
index 8bf2ea85965366ee20ec2fc1d6bcae6c46804eb2..a5166eb9343752f261312ee244e712976ba48cfc 100644 (file)
@@ -29,6 +29,7 @@ enum of_gpio_flags {
        OF_GPIO_TRANSITORY = 0x8,
        OF_GPIO_PULL_UP = 0x10,
        OF_GPIO_PULL_DOWN = 0x20,
+       OF_GPIO_PULL_DISABLE = 0x40,
 };
 
 #ifdef CONFIG_OF_GPIO