Skip to content

Commit c269df8

Browse files
nunojsabrgl
authored andcommitted
gpiolib: add support for bias pull disable
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'. Signed-off-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
1 parent 28ba057 commit c269df8

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3945,16 +3945,20 @@ int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
39453945
if (lflags & GPIO_OPEN_SOURCE)
39463946
set_bit(FLAG_OPEN_SOURCE, &desc->flags);
39473947

3948-
if ((lflags & GPIO_PULL_UP) && (lflags & GPIO_PULL_DOWN)) {
3948+
if (((lflags & GPIO_PULL_UP) && (lflags & GPIO_PULL_DOWN)) ||
3949+
((lflags & GPIO_PULL_UP) && (lflags & GPIO_PULL_DISABLE)) ||
3950+
((lflags & GPIO_PULL_DOWN) && (lflags & GPIO_PULL_DISABLE))) {
39493951
gpiod_err(desc,
3950-
"both pull-up and pull-down enabled, invalid configuration\n");
3952+
"multiple pull-up, pull-down or pull-disable enabled, invalid configuration\n");
39513953
return -EINVAL;
39523954
}
39533955

39543956
if (lflags & GPIO_PULL_UP)
39553957
set_bit(FLAG_PULL_UP, &desc->flags);
39563958
else if (lflags & GPIO_PULL_DOWN)
39573959
set_bit(FLAG_PULL_DOWN, &desc->flags);
3960+
else if (lflags & GPIO_PULL_DISABLE)
3961+
set_bit(FLAG_BIAS_DISABLE, &desc->flags);
39583962

39593963
ret = gpiod_set_transitory(desc, (lflags & GPIO_TRANSITORY));
39603964
if (ret < 0)

include/linux/gpio/machine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ enum gpio_lookup_flags {
1414
GPIO_TRANSITORY = (1 << 3),
1515
GPIO_PULL_UP = (1 << 4),
1616
GPIO_PULL_DOWN = (1 << 5),
17+
GPIO_PULL_DISABLE = (1 << 6),
1718

1819
GPIO_LOOKUP_FLAGS_DEFAULT = GPIO_ACTIVE_HIGH | GPIO_PERSISTENT,
1920
};

0 commit comments

Comments
 (0)