From: Quentin Schulz <foss+kernel@0leil.net>
To: unlisted-recipients:; (no To-header on input)
Cc: linus.walleij@linaro.org, brgl@bgdev.pl, heiko@sntech.de,
jay.xu@rock-chips.com, linux-gpio@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
foss+kernel@0leil.net,
Quentin Schulz <quentin.schulz@theobroma-systems.com>,
stable@vger.kernel.org
Subject: [PATCH v2 2/2] gpio: rockchip: request GPIO mux to pinctrl when setting direction
Date: Fri, 30 Sep 2022 15:20:33 +0200 [thread overview]
Message-ID: <20220930132033.4003377-3-foss+kernel@0leil.net> (raw)
In-Reply-To: <20220930132033.4003377-1-foss+kernel@0leil.net>
From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Before the split of gpio and pinctrl sections in their own driver,
rockchip_set_mux was called in pinmux_ops.gpio_set_direction for
configuring a pin in its GPIO function.
This is essential for cases where pinctrl is "bypassed" by gpio
consumers otherwise the GPIO function is not configured for the pin and
it does not work. Such was the case for the sysfs/libgpiod userspace
GPIO handling.
Let's call pinctrl_gpio_direction_input/output when setting the
direction of a GPIO so that the pinctrl core requests from the rockchip
pinctrl driver to put the pin in its GPIO function.
Fixes: 9ce9a02039de ("pinctrl/rockchip: drop the gpio related codes")
Fixes: 936ee2675eee ("gpio/rockchip: add driver for rockchip gpio")
Cc: stable@vger.kernel.org
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
---
v2:
- added Reviewed-by,
- added missing linux/pinctrl/consumer.h header,
drivers/gpio/gpio-rockchip.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index bb50335239ac8..9c976ad7208ef 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -19,6 +19,7 @@
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_irq.h>
+#include <linux/pinctrl/consumer.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/regmap.h>
@@ -156,6 +157,12 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip,
unsigned long flags;
u32 data = input ? 0 : 1;
+
+ if (input)
+ pinctrl_gpio_direction_input(bank->pin_base + offset);
+ else
+ pinctrl_gpio_direction_output(bank->pin_base + offset);
+
raw_spin_lock_irqsave(&bank->slock, flags);
rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr);
raw_spin_unlock_irqrestore(&bank->slock, flags);
--
2.37.3
next prev parent reply other threads:[~2022-09-30 13:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 13:20 [PATCH v2 0/2] fix gpio-sysfs/libgpiod for rockchip Quentin Schulz
2022-09-30 13:20 ` [PATCH v2 1/2] pinctrl: rockchip: add pinmux_ops.gpio_set_direction callback Quentin Schulz
2022-09-30 13:20 ` Quentin Schulz [this message]
2022-10-04 7:21 ` [PATCH v2 0/2] fix gpio-sysfs/libgpiod for rockchip Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220930132033.4003377-3-foss+kernel@0leil.net \
--to=foss+kernel@0leil.net \
--cc=brgl@bgdev.pl \
--cc=heiko@sntech.de \
--cc=jay.xu@rock-chips.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=quentin.schulz@theobroma-systems.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).