From: Heiko Stuebner <heiko@sntech.de>
To: linus.walleij@linaro.org, bgolaszewski@baylibre.com
Cc: 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
Subject: [PATCH 4/4] gpio/rockchip: fetch deferred output settings on probe
Date: Tue, 14 Sep 2021 00:49:26 +0200 [thread overview]
Message-ID: <20210913224926.1260726-5-heiko@sntech.de> (raw)
In-Reply-To: <20210913224926.1260726-1-heiko@sntech.de>
Fetch the output settings the pinctrl driver may have created
for pinctrl hogs and set the relevant pins as requested.
Fixes: 9ce9a02039de ("pinctrl/rockchip: drop the gpio related codes")
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/gpio/gpio-rockchip.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index 3335bd57761d..cf1b465db8c3 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -689,6 +689,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
struct device_node *pctlnp = of_get_parent(np);
struct pinctrl_dev *pctldev = NULL;
struct rockchip_pin_bank *bank = NULL;
+ struct rockchip_pin_output_deferred *cfg;
static int gpio;
int id, ret;
@@ -716,12 +717,33 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
if (ret)
return ret;
+ /*
+ * Prevent clashes with a deferred output setting
+ * being added right at this moment.
+ */
+ mutex_lock(&bank->deferred_lock);
+
ret = rockchip_gpiolib_register(bank);
if (ret) {
clk_disable_unprepare(bank->clk);
+ mutex_unlock(&bank->deferred_lock);
return ret;
}
+ while (!list_empty(&bank->deferred_output)) {
+ cfg = list_first_entry(&bank->deferred_output,
+ struct rockchip_pin_output_deferred, head);
+ list_del(&cfg->head);
+
+ ret = rockchip_gpio_direction_output(&bank->gpio_chip, cfg->pin, cfg->arg);
+ if (ret)
+ dev_warn(dev, "setting output pin %u to %u failed\n", cfg->pin, cfg->arg);
+
+ kfree(cfg);
+ }
+
+ mutex_unlock(&bank->deferred_lock);
+
platform_set_drvdata(pdev, bank);
dev_info(dev, "probed %pOF\n", np);
--
2.29.2
next prev parent reply other threads:[~2021-09-13 22:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 22:49 [PATCH 0/4] gpio/pinctrl-rockchip: Fixes for the recently separated gpio/pinctrl driver Heiko Stuebner
2021-09-13 22:49 ` [PATCH 1/4] gpio/rockchip: extended debounce support is only available on v2 Heiko Stuebner
2021-09-17 22:34 ` Linus Walleij
2021-09-22 9:45 ` Bartosz Golaszewski
2021-09-13 22:49 ` [PATCH 2/4] gpio/rockchip: fix get_direction value handling Heiko Stuebner
2021-09-17 23:30 ` Linus Walleij
2021-09-22 9:46 ` Bartosz Golaszewski
2021-09-13 22:49 ` [PATCH 3/4] pinctrl/rockchip: add a queue for deferred pin output settings on probe Heiko Stuebner
2021-09-17 23:35 ` Linus Walleij
2021-09-13 22:49 ` Heiko Stuebner [this message]
2021-09-17 23:38 ` [PATCH 4/4] gpio/rockchip: fetch deferred " Linus Walleij
2021-09-18 0:00 ` Heiko Stübner
2021-09-19 14:47 ` 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=20210913224926.1260726-5-heiko@sntech.de \
--to=heiko@sntech.de \
--cc=bgolaszewski@baylibre.com \
--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 \
/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