Skip to content

Commit ea06a48

Browse files
aford173brgl
authored andcommitted
gpiolib: of: improve gpiolib-of support of pull up/down on expanders
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> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
1 parent 6168444 commit ea06a48

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/gpio/gpiolib-of.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,12 @@ struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
344344
if (transitory)
345345
lflags |= GPIO_TRANSITORY;
346346

347+
if (flags & OF_GPIO_PULL_UP)
348+
lflags |= GPIO_PULL_UP;
349+
350+
if (flags & OF_GPIO_PULL_DOWN)
351+
lflags |= GPIO_PULL_DOWN;
352+
347353
ret = gpiod_configure_flags(desc, propname, lflags, dflags);
348354
if (ret < 0) {
349355
gpiod_put(desc);
@@ -585,6 +591,10 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
585591
*lflags |= GPIO_ACTIVE_LOW;
586592
if (xlate_flags & OF_GPIO_TRANSITORY)
587593
*lflags |= GPIO_TRANSITORY;
594+
if (xlate_flags & OF_GPIO_PULL_UP)
595+
*lflags |= GPIO_PULL_UP;
596+
if (xlate_flags & OF_GPIO_PULL_DOWN)
597+
*lflags |= GPIO_PULL_DOWN;
588598

589599
if (of_property_read_bool(np, "input"))
590600
*dflags |= GPIOD_IN;

0 commit comments

Comments
 (0)