Skip to content

Commit

Permalink
gpiolib: of: support bias pull disable
Browse files Browse the repository at this point in the history
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.

Change-Id: I4ea291dbd4165f5744cc0677a7d20dfed3fa1f3b
Signed-off-by: Nuno Sá <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Bartosz Golaszewski <[email protected]>
Signed-off-by: Amelie Delaunay <[email protected]>
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/312114
Tested-by: Eric FOURMONT <[email protected]>
Reviewed-by: Eric FOURMONT <[email protected]>
Domain-Review: Eric FOURMONT <[email protected]>
  • Loading branch information
nunojsa authored and fourmone committed Jul 31, 2023
1 parent 7524535 commit 1a3de8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/gpio/gpiolib-of.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions include/linux/of_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1a3de8e

Please sign in to comment.