diff mbox series

[1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders

Message ID 20200412013352.674506-1-aford173@gmail.com
State New
Headers show
Series [1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders | expand

Commit Message

Adam Ford April 12, 2020, 1:33 a.m. UTC
When using GPIO expanders attached to I2C ports, their set_config function
needs to be passed a config setting which contains options to enable pull
up or pull down bias feature.  In order to set this config properly,
the gpio parser needs to handle GPIO_PULL_UP and GPIO_PULL_DOWN.

This patch enables the flags corresponding to GPIO_PULL_UP and
GPIO_PULL_DOWN.

Signed-off-by: Adam Ford <aford173@gmail.com>

Comments

Bartosz Golaszewski April 15, 2020, 11:23 a.m. UTC | #1
niedz., 12 kwi 2020 o 03:34 Adam Ford <aford173@gmail.com> napisaƂ(a):
>
> When using GPIO expanders attached to I2C ports, their set_config function
> needs to be passed a config setting which contains options to enable pull
> up or pull down bias feature.  In order to set this config properly,
> the gpio parser needs to handle GPIO_PULL_UP and GPIO_PULL_DOWN.
>
> This patch enables the flags corresponding to GPIO_PULL_UP and
> GPIO_PULL_DOWN.
>
> Signed-off-by: Adam Ford <aford173@gmail.com>
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index c6d30f73df07..bf17afb1f66d 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -344,6 +344,12 @@ struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
>         if (transitory)
>                 lflags |= GPIO_TRANSITORY;
>
> +       if (flags & OF_GPIO_PULL_UP)
> +               lflags |= GPIO_PULL_UP;
> +
> +       if (flags & OF_GPIO_PULL_DOWN)
> +               lflags |= GPIO_PULL_DOWN;
> +
>         ret = gpiod_configure_flags(desc, propname, lflags, dflags);
>         if (ret < 0) {
>                 gpiod_put(desc);
> @@ -585,6 +591,10 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
>                 *lflags |= GPIO_ACTIVE_LOW;
>         if (xlate_flags & OF_GPIO_TRANSITORY)
>                 *lflags |= GPIO_TRANSITORY;
> +       if (xlate_flags & OF_GPIO_PULL_UP)
> +               *lflags |= GPIO_PULL_UP;
> +       if (xlate_flags & OF_GPIO_PULL_DOWN)
> +               *lflags |= GPIO_PULL_DOWN;
>
>         if (of_property_read_bool(np, "input"))
>                 *dflags |= GPIOD_IN;
> --
> 2.25.1
>

Patch applied, thanks!

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index c6d30f73df07..bf17afb1f66d 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -344,6 +344,12 @@  struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
 	if (transitory)
 		lflags |= GPIO_TRANSITORY;
 
+	if (flags & OF_GPIO_PULL_UP)
+		lflags |= GPIO_PULL_UP;
+
+	if (flags & OF_GPIO_PULL_DOWN)
+		lflags |= GPIO_PULL_DOWN;
+
 	ret = gpiod_configure_flags(desc, propname, lflags, dflags);
 	if (ret < 0) {
 		gpiod_put(desc);
@@ -585,6 +591,10 @@  static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
 		*lflags |= GPIO_ACTIVE_LOW;
 	if (xlate_flags & OF_GPIO_TRANSITORY)
 		*lflags |= GPIO_TRANSITORY;
+	if (xlate_flags & OF_GPIO_PULL_UP)
+		*lflags |= GPIO_PULL_UP;
+	if (xlate_flags & OF_GPIO_PULL_DOWN)
+		*lflags |= GPIO_PULL_DOWN;
 
 	if (of_property_read_bool(np, "input"))
 		*dflags |= GPIOD_IN;