From: Ye Zhang <ye.zhang@rock-chips.com>
To: linus.walleij@linaro.org, brgl@bgdev.pl, heiko@sntech.de,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
mika.westerberg@linux.intel.com,
andriy.shevchenko@linux.intel.com, tao.huang@rock-chips.com,
finley.xiao@rock-chips.com, tim.chen@rock-chips.com,
elaine.zhang@rock-chips.com, Ye Zhang <ye.zhang@rock-chips.com>
Subject: [PATCH v2] gpio: rockchip: support 'clock-names' from dt nodes
Date: Fri, 23 Aug 2024 11:43:10 +0800 [thread overview]
Message-ID: <20240823034314.62305-8-ye.zhang@rock-chips.com> (raw)
In-Reply-To: <20240823034314.62305-1-ye.zhang@rock-chips.com>
Added support for retrieving clocks using 'clock-names' from dt nodes
Signed-off-by: Ye Zhang <ye.zhang@rock-chips.com>
---
drivers/gpio/gpio-rockchip.c | 42 ++++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index aff8bec79062..25ddf6a82c09 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -646,23 +646,12 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
if (!bank->irq)
return -EINVAL;
- bank->clk = of_clk_get(bank->of_node, 0);
- if (IS_ERR(bank->clk))
- return PTR_ERR(bank->clk);
-
- clk_prepare_enable(bank->clk);
id = readl(bank->reg_base + gpio_regs_v2.version_id);
/* If not gpio v2, that is default to v1. */
if (id == GPIO_TYPE_V2 || id == GPIO_TYPE_V2_1) {
bank->gpio_regs = &gpio_regs_v2;
bank->gpio_type = GPIO_TYPE_V2;
- bank->db_clk = of_clk_get(bank->of_node, 1);
- if (IS_ERR(bank->db_clk)) {
- dev_err(bank->dev, "cannot find debounce clk\n");
- clk_disable_unprepare(bank->clk);
- return -EINVAL;
- }
} else {
bank->gpio_regs = &gpio_regs_v1;
bank->gpio_type = GPIO_TYPE_V1;
@@ -722,10 +711,29 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
raw_spin_lock_init(&bank->slock);
+ bank->clk = devm_clk_get(dev, "bus");
+ if (IS_ERR(bank->clk)) {
+ bank->clk = of_clk_get(dev->of_node, 0);
+ if (IS_ERR(bank->clk)) {
+ dev_err(dev, "fail to get apb clock\n");
+ return PTR_ERR(bank->clk);
+ }
+ }
+
ret = rockchip_get_bank_data(bank);
if (ret)
return ret;
+ bank->db_clk = devm_clk_get(dev, "db");
+ if (IS_ERR(bank->db_clk)) {
+ bank->db_clk = of_clk_get(dev->of_node, 1);
+ if (IS_ERR(bank->db_clk))
+ bank->db_clk = NULL;
+ }
+
+ clk_prepare_enable(bank->clk);
+ clk_prepare_enable(bank->db_clk);
+
/*
* Prevent clashes with a deferred output setting
* being added right at this moment.
@@ -734,9 +742,8 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
ret = rockchip_gpiolib_register(bank);
if (ret) {
- clk_disable_unprepare(bank->clk);
- mutex_unlock(&bank->deferred_lock);
- return ret;
+ dev_err(bank->dev, "Failed to register gpio %d\n", ret);
+ goto err_unlock;
}
while (!list_empty(&bank->deferred_pins)) {
@@ -769,6 +776,12 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
dev_info(dev, "probed %pOF\n", np);
return 0;
+err_unlock:
+ mutex_unlock(&bank->deferred_lock);
+ clk_disable_unprepare(bank->clk);
+ clk_disable_unprepare(bank->db_clk);
+
+ return ret;
}
static void rockchip_gpio_remove(struct platform_device *pdev)
@@ -776,6 +789,7 @@ static void rockchip_gpio_remove(struct platform_device *pdev)
struct rockchip_pin_bank *bank = platform_get_drvdata(pdev);
clk_disable_unprepare(bank->clk);
+ clk_disable_unprepare(bank->db_clk);
gpiochip_remove(&bank->gpio_chip);
}
--
2.34.1
next prev parent reply other threads:[~2024-08-23 8:32 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 3:43 [PATCH v2] gpio: rockchip: Update the GPIO driver Ye Zhang
2024-08-23 3:43 ` [PATCH v2] gpio: rockchip: avoid division by zero Ye Zhang
2024-08-23 9:27 ` Heiko Stübner
2024-08-23 14:45 ` Andy Shevchenko
2024-08-23 3:43 ` [PATCH v2] gpio: rockchip: release reference to device node Ye Zhang
2024-08-23 9:28 ` Heiko Stübner
2024-08-23 10:52 ` Shawn Lin
2024-08-23 3:43 ` [PATCH v2] gpio: rockchip: resolve overflow issues Ye Zhang
2024-08-23 9:34 ` Heiko Stübner
2024-08-23 10:59 ` Shawn Lin
2024-08-23 14:49 ` Andy Shevchenko
2024-08-23 14:48 ` Andy Shevchenko
2024-08-23 3:43 ` [PATCH v2] gpio: rockchip: resolve underflow issue Ye Zhang
2024-08-23 14:51 ` Andy Shevchenko
2024-08-23 3:43 ` [PATCH v2] gpio: rockchip: fix debounce calculate Ye Zhang
2024-08-23 3:43 ` [PATCH v2] gpio: rockchip: Update debounce config function Ye Zhang
2024-08-23 3:43 ` Ye Zhang [this message]
2024-08-23 14:56 ` [PATCH v2] gpio: rockchip: support 'clock-names' from dt nodes Andy Shevchenko
2024-08-23 3:43 ` [PATCH v2] gpio: rockchip: support new version gpio Ye Zhang
2024-08-23 13:32 ` Sebastian Reichel
2024-08-23 15:05 ` Andy Shevchenko
2024-08-23 3:43 ` [PATCH v2] gpio: rockchip: Set input direction when request irq Ye Zhang
2024-08-23 14:59 ` Andy Shevchenko
2024-08-23 3:43 ` [PATCH v2] gpio: rockchip: support ACPI Ye Zhang
2024-08-23 5:27 ` Mika Westerberg
2024-08-23 7:03 ` [PATCH v2] gpio: rockchip: Update the GPIO driver Bartosz Golaszewski
2024-08-23 7:06 ` Dragan Simic
2024-08-23 15:07 ` Andy Shevchenko
2024-08-23 9:33 ` Heiko Stübner
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=20240823034314.62305-8-ye.zhang@rock-chips.com \
--to=ye.zhang@rock-chips.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=elaine.zhang@rock-chips.com \
--cc=finley.xiao@rock-chips.com \
--cc=heiko@sntech.de \
--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=mika.westerberg@linux.intel.com \
--cc=tao.huang@rock-chips.com \
--cc=tim.chen@rock-chips.com \
/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
all inboxes | Powered by JetHome®