Skip to content

Commit

Permalink
gpiolib: add support for bias pull disable
Browse files Browse the repository at this point in the history
This change prepares the gpio core to look at firmware flags and set
'FLAG_BIAS_DISABLE' if necessary. It works in similar way to
'GPIO_PULL_DOWN' and 'GPIO_PULL_UP'.

Change-Id: If81650ab9679825e42a19cd104e2b4fe09d47e85
Signed-off-by: Nuno Sá <[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/+/312113
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 708e617 commit 7524535
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3879,16 +3879,20 @@ int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
if (lflags & GPIO_OPEN_SOURCE)
set_bit(FLAG_OPEN_SOURCE, &desc->flags);

if ((lflags & GPIO_PULL_UP) && (lflags & GPIO_PULL_DOWN)) {
if (((lflags & GPIO_PULL_UP) && (lflags & GPIO_PULL_DOWN)) ||
((lflags & GPIO_PULL_UP) && (lflags & GPIO_PULL_DISABLE)) ||
((lflags & GPIO_PULL_DOWN) && (lflags & GPIO_PULL_DISABLE))) {
gpiod_err(desc,
"both pull-up and pull-down enabled, invalid configuration\n");
"multiple pull-up, pull-down or pull-disable enabled, invalid configuration\n");
return -EINVAL;
}

if (lflags & GPIO_PULL_UP)
set_bit(FLAG_PULL_UP, &desc->flags);
else if (lflags & GPIO_PULL_DOWN)
set_bit(FLAG_PULL_DOWN, &desc->flags);
else if (lflags & GPIO_PULL_DISABLE)
set_bit(FLAG_BIAS_DISABLE, &desc->flags);

ret = gpiod_set_transitory(desc, (lflags & GPIO_TRANSITORY));
if (ret < 0)
Expand Down
1 change: 1 addition & 0 deletions include/linux/gpio/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum gpio_lookup_flags {
GPIO_TRANSITORY = (1 << 3),
GPIO_PULL_UP = (1 << 4),
GPIO_PULL_DOWN = (1 << 5),
GPIO_PULL_DISABLE = (1 << 6),

GPIO_LOOKUP_FLAGS_DEFAULT = GPIO_ACTIVE_HIGH | GPIO_PERSISTENT,
};
Expand Down

0 comments on commit 7524535

Please sign in to comment.