* [PATCH 1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders
@ 2020-04-12 1:33 Adam Ford
2020-04-12 1:33 ` [PATCH 2/2] gpio: pca953x: Fix pca953x_gpio_set_config Adam Ford
2020-04-15 11:23 ` [PATCH 1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders Bartosz Golaszewski
0 siblings, 2 replies; 4+ messages in thread
From: Adam Ford @ 2020-04-12 1:33 UTC (permalink / raw)
To: linux-gpio
Cc: aford, Adam Ford, Linus Walleij, Bartosz Golaszewski,
Thomas Petazzoni, linux-kernel
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] gpio: pca953x: Fix pca953x_gpio_set_config
2020-04-12 1:33 [PATCH 1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders Adam Ford
@ 2020-04-12 1:33 ` Adam Ford
2020-04-15 11:23 ` Bartosz Golaszewski
2020-04-15 11:23 ` [PATCH 1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders Bartosz Golaszewski
1 sibling, 1 reply; 4+ messages in thread
From: Adam Ford @ 2020-04-12 1:33 UTC (permalink / raw)
To: linux-gpio
Cc: aford, Adam Ford, Linus Walleij, Bartosz Golaszewski,
Thomas Petazzoni, linux-kernel
pca953x_gpio_set_config is setup to support pull-up/down
bias. Currently the driver uses a variable called 'config' to
determine which options to use. Unfortunately, this is incorrect.
This patch uses function pinconf_to_config_param(config), which
converts this 'config' parameter back to pinconfig to determine
which option to use.
Fixes: 15add06841a3 ("gpio: pca953x: add ->set_config implementation")
Signed-off-by: Adam Ford <aford173@gmail.com>
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 5638b4e5355f..4269ea9a817e 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -531,7 +531,7 @@ static int pca953x_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
{
struct pca953x_chip *chip = gpiochip_get_data(gc);
- switch (config) {
+ switch (pinconf_to_config_param(config)) {
case PIN_CONFIG_BIAS_PULL_UP:
case PIN_CONFIG_BIAS_PULL_DOWN:
return pca953x_gpio_set_pull_up_down(chip, offset, config);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders
2020-04-12 1:33 [PATCH 1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders Adam Ford
2020-04-12 1:33 ` [PATCH 2/2] gpio: pca953x: Fix pca953x_gpio_set_config Adam Ford
@ 2020-04-15 11:23 ` Bartosz Golaszewski
1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2020-04-15 11:23 UTC (permalink / raw)
To: Adam Ford; +Cc: linux-gpio, aford, Linus Walleij, Thomas Petazzoni, LKML
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] gpio: pca953x: Fix pca953x_gpio_set_config
2020-04-12 1:33 ` [PATCH 2/2] gpio: pca953x: Fix pca953x_gpio_set_config Adam Ford
@ 2020-04-15 11:23 ` Bartosz Golaszewski
0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2020-04-15 11:23 UTC (permalink / raw)
To: Adam Ford; +Cc: linux-gpio, aford, Linus Walleij, Thomas Petazzoni, LKML
niedz., 12 kwi 2020 o 03:34 Adam Ford <aford173@gmail.com> napisał(a):
>
> pca953x_gpio_set_config is setup to support pull-up/down
> bias. Currently the driver uses a variable called 'config' to
> determine which options to use. Unfortunately, this is incorrect.
>
> This patch uses function pinconf_to_config_param(config), which
> converts this 'config' parameter back to pinconfig to determine
> which option to use.
>
> Fixes: 15add06841a3 ("gpio: pca953x: add ->set_config implementation")
>
> Signed-off-by: Adam Ford <aford173@gmail.com>
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 5638b4e5355f..4269ea9a817e 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -531,7 +531,7 @@ static int pca953x_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
> {
> struct pca953x_chip *chip = gpiochip_get_data(gc);
>
> - switch (config) {
> + switch (pinconf_to_config_param(config)) {
> case PIN_CONFIG_BIAS_PULL_UP:
> case PIN_CONFIG_BIAS_PULL_DOWN:
> return pca953x_gpio_set_pull_up_down(chip, offset, config);
> --
> 2.25.1
>
Patch applied for fixes, thanks!
Bart
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-15 11:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 1:33 [PATCH 1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders Adam Ford
2020-04-12 1:33 ` [PATCH 2/2] gpio: pca953x: Fix pca953x_gpio_set_config Adam Ford
2020-04-15 11:23 ` Bartosz Golaszewski
2020-04-15 11:23 ` [PATCH 1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).