linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v1 0/2] pinctrl-meson: two small improvements
@ 2020-04-11 17:03 Martin Blumenstingl
  2020-04-11 17:03 ` [PATCH RFC v1 1/2] pinctrl: meson: implement the gpio_chip get_direction callback Martin Blumenstingl
  2020-04-11 17:03 ` [PATCH RFC v1 2/2] pinctrl: meson: wire up the gpio_chip's set_config callback Martin Blumenstingl
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2020-04-11 17:03 UTC (permalink / raw)
  To: linus.walleij, linux-gpio, linux-amlogic
  Cc: Martin Blumenstingl, linux-kernel, linux-arm-kernel, jbrunet

While playing with audio output on Meson8b I found out that the
vendor kernel uses a custom version of the GPIO_PULL_UP flag. I
suspect that we will need this for audio support on Meson8b and/or
Meson8m2 but I don't see it hurt other platforms.

Also while comparing the register bits with the GPIO direction (of
GPIOs exported to sysfs) I sometimes had a mismatch. This also wires
up gpio_chip.get_direction to have sysfs and the actual registers in
sync.


Martin Blumenstingl (2):
  pinctrl: meson: implement the gpio_chip get_direction callback
  pinctrl: meson: wire up the gpio_chip's set_config callback

 drivers/pinctrl/meson/pinctrl-meson.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

-- 
2.26.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH RFC v1 1/2] pinctrl: meson: implement the gpio_chip get_direction callback
  2020-04-11 17:03 [PATCH RFC v1 0/2] pinctrl-meson: two small improvements Martin Blumenstingl
@ 2020-04-11 17:03 ` Martin Blumenstingl
  2020-04-11 17:03 ` [PATCH RFC v1 2/2] pinctrl: meson: wire up the gpio_chip's set_config callback Martin Blumenstingl
  1 sibling, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2020-04-11 17:03 UTC (permalink / raw)
  To: linus.walleij, linux-gpio, linux-amlogic
  Cc: Martin Blumenstingl, linux-kernel, linux-arm-kernel, jbrunet

Implement the get_direction callback so we read the direction from the
actual GPIO controller register. This is recommended by the gpio_chip
kernel doc.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/pinctrl/meson/pinctrl-meson.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index bbc919bef2bf..291f3078e7c7 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -549,6 +549,18 @@ static const struct pinconf_ops meson_pinconf_ops = {
 	.is_generic		= true,
 };
 
+static int meson_gpio_get_direction(struct gpio_chip *chip, unsigned gpio)
+{
+	struct meson_pinctrl *pc = gpiochip_get_data(chip);
+	int ret;
+
+	ret = meson_pinconf_get_output(pc, gpio);
+	if (ret < 0)
+		return ret;
+
+	return ret ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
+}
+
 static int meson_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
 {
 	return meson_pinconf_set_output(gpiochip_get_data(chip), gpio, false);
@@ -591,6 +603,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc)
 	pc->chip.parent = pc->dev;
 	pc->chip.request = gpiochip_generic_request;
 	pc->chip.free = gpiochip_generic_free;
+	pc->chip.get_direction = meson_gpio_get_direction;
 	pc->chip.direction_input = meson_gpio_direction_input;
 	pc->chip.direction_output = meson_gpio_direction_output;
 	pc->chip.get = meson_gpio_get;
-- 
2.26.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH RFC v1 2/2] pinctrl: meson: wire up the gpio_chip's set_config callback
  2020-04-11 17:03 [PATCH RFC v1 0/2] pinctrl-meson: two small improvements Martin Blumenstingl
  2020-04-11 17:03 ` [PATCH RFC v1 1/2] pinctrl: meson: implement the gpio_chip get_direction callback Martin Blumenstingl
@ 2020-04-11 17:03 ` Martin Blumenstingl
  2020-04-11 17:23   ` Jerome Brunet
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Blumenstingl @ 2020-04-11 17:03 UTC (permalink / raw)
  To: linus.walleij, linux-gpio, linux-amlogic
  Cc: Martin Blumenstingl, linux-kernel, linux-arm-kernel, jbrunet

Use gpiochip_generic_config for the gpio_chip's set_config callback so
GPIO flags like GPIO_PULL_UP or GPIO_PULL_DOWN can be used in the board
.dts descriptions.
This is required for some Meson8m2 boards where GPIO_BSD_EN provides the
"MUTE" signal and requires enabling the internal pull-up resistor.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/pinctrl/meson/pinctrl-meson.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 291f3078e7c7..079f8ee8d353 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -603,6 +603,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc)
 	pc->chip.parent = pc->dev;
 	pc->chip.request = gpiochip_generic_request;
 	pc->chip.free = gpiochip_generic_free;
+	pc->chip.set_config = gpiochip_generic_config;
 	pc->chip.get_direction = meson_gpio_get_direction;
 	pc->chip.direction_input = meson_gpio_direction_input;
 	pc->chip.direction_output = meson_gpio_direction_output;
-- 
2.26.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH RFC v1 2/2] pinctrl: meson: wire up the gpio_chip's set_config callback
  2020-04-11 17:03 ` [PATCH RFC v1 2/2] pinctrl: meson: wire up the gpio_chip's set_config callback Martin Blumenstingl
@ 2020-04-11 17:23   ` Jerome Brunet
  2020-04-11 20:53     ` Martin Blumenstingl
  0 siblings, 1 reply; 6+ messages in thread
From: Jerome Brunet @ 2020-04-11 17:23 UTC (permalink / raw)
  To: Martin Blumenstingl, linus.walleij, linux-gpio, linux-amlogic
  Cc: linux-kernel, linux-arm-kernel


On Sat 11 Apr 2020 at 19:03, Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

> Use gpiochip_generic_config for the gpio_chip's set_config callback so
> GPIO flags like GPIO_PULL_UP or GPIO_PULL_DOWN can be used in the board
> .dts descriptions.
> This is required for some Meson8m2 boards where GPIO_BSD_EN provides the
> "MUTE" signal and requires enabling the internal pull-up resistor.

I think your addition makes sense but, FYI, there is another solution to
your problem that should already work as it is.

If the platform requires a pull-up, you could set the pinconf 'bias-pull-up'
property in dt in the pinctrl definition passed to the device using the gpio.

There is an example of that in meson-gx-libretech-pc.dtsi with the phy
irq pin.

>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
>  drivers/pinctrl/meson/pinctrl-meson.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
> index 291f3078e7c7..079f8ee8d353 100644
> --- a/drivers/pinctrl/meson/pinctrl-meson.c
> +++ b/drivers/pinctrl/meson/pinctrl-meson.c
> @@ -603,6 +603,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc)
>  	pc->chip.parent = pc->dev;
>  	pc->chip.request = gpiochip_generic_request;
>  	pc->chip.free = gpiochip_generic_free;
> +	pc->chip.set_config = gpiochip_generic_config;
>  	pc->chip.get_direction = meson_gpio_get_direction;
>  	pc->chip.direction_input = meson_gpio_direction_input;
>  	pc->chip.direction_output = meson_gpio_direction_output;


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH RFC v1 2/2] pinctrl: meson: wire up the gpio_chip's set_config callback
  2020-04-11 17:23   ` Jerome Brunet
@ 2020-04-11 20:53     ` Martin Blumenstingl
  2020-04-11 22:34       ` Jerome Brunet
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Blumenstingl @ 2020-04-11 20:53 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: linux-gpio, linus.walleij, linux-kernel, linux-arm-kernel, linux-amlogic

Hi Jerome,

On Sat, Apr 11, 2020 at 7:23 PM Jerome Brunet <jbrunet@baylibre.com> wrote:
>
>
> On Sat 11 Apr 2020 at 19:03, Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:
>
> > Use gpiochip_generic_config for the gpio_chip's set_config callback so
> > GPIO flags like GPIO_PULL_UP or GPIO_PULL_DOWN can be used in the board
> > .dts descriptions.
> > This is required for some Meson8m2 boards where GPIO_BSD_EN provides the
> > "MUTE" signal and requires enabling the internal pull-up resistor.
>
> I think your addition makes sense but, FYI, there is another solution to
> your problem that should already work as it is.
>
> If the platform requires a pull-up, you could set the pinconf 'bias-pull-up'
> property in dt in the pinctrl definition passed to the device using the gpio.
Thank you for this hint.
personally I find GPIO_PULL_UP is easier to write when I'm passing a
GPIO descriptor anyways.

> There is an example of that in meson-gx-libretech-pc.dtsi with the phy
> irq pin.
I'm still hoping that pinctrl-meson will gain interrupt support one
day, then the driver will (hopefully) take care of that :-)


Martin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH RFC v1 2/2] pinctrl: meson: wire up the gpio_chip's set_config callback
  2020-04-11 20:53     ` Martin Blumenstingl
@ 2020-04-11 22:34       ` Jerome Brunet
  0 siblings, 0 replies; 6+ messages in thread
From: Jerome Brunet @ 2020-04-11 22:34 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: linux-gpio, linus.walleij, linux-kernel, linux-arm-kernel, linux-amlogic


On Sat 11 Apr 2020 at 22:53, Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

>
>> There is an example of that in meson-gx-libretech-pc.dtsi with the phy
>> irq pin.
> I'm still hoping that pinctrl-meson will gain interrupt support one
> day, then the driver will (hopefully) take care of that :-)

I don't see why it should. If the meson gpio driver was able to provide
an irq related to gpio, I don't think it should do more than that.

In most case the gpio will be an input, yes, but nothing says it must.

>
>
> Martin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-11 22:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11 17:03 [PATCH RFC v1 0/2] pinctrl-meson: two small improvements Martin Blumenstingl
2020-04-11 17:03 ` [PATCH RFC v1 1/2] pinctrl: meson: implement the gpio_chip get_direction callback Martin Blumenstingl
2020-04-11 17:03 ` [PATCH RFC v1 2/2] pinctrl: meson: wire up the gpio_chip's set_config callback Martin Blumenstingl
2020-04-11 17:23   ` Jerome Brunet
2020-04-11 20:53     ` Martin Blumenstingl
2020-04-11 22:34       ` Jerome Brunet

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).