* [PATCH] clk: rockchip: rk3588: fix CLK_NR_CLKS usage
@ 2024-04-02 9:19 Sascha Hauer
2024-04-02 9:22 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2024-04-02 9:19 UTC (permalink / raw)
To: Barebox List
barebox adoption of Linux commit 2dc66a5ab2c6:
| clk: rockchip: rk3588: fix CLK_NR_CLKS usage
|
| CLK_NR_CLKS is not part of the DT bindings and needs to be removed
| from it, just like it recently happened for other platforms. This
| takes care of it by introducing a new function identifying the
| maximum used clock ID at runtime.
|
| Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| Link: https://lore.kernel.org/r/20240126182919.48402-2-sebastian.reichel@collabora.com
| Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/clk/rockchip/clk-rk3588.c | 5 ++++-
drivers/clk/rockchip/clk.c | 17 +++++++++++++++++
drivers/clk/rockchip/clk.h | 2 ++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/rockchip/clk-rk3588.c b/drivers/clk/rockchip/clk-rk3588.c
index 8b5c68debe..68565a188c 100644
--- a/drivers/clk/rockchip/clk-rk3588.c
+++ b/drivers/clk/rockchip/clk-rk3588.c
@@ -2451,15 +2451,18 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
static void __init rk3588_clk_init(struct device_node *np)
{
struct rockchip_clk_provider *ctx;
+ unsigned long clk_nr_clks;
void __iomem *reg_base;
+ clk_nr_clks = rockchip_clk_find_max_clk_id(rk3588_clk_branches,
+ ARRAY_SIZE(rk3588_clk_branches)) + 1;
reg_base = of_iomap(np, 0);
if (!reg_base) {
pr_err("%s: could not map cru region\n", __func__);
return;
}
- ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
+ ctx = rockchip_clk_init(np, reg_base, clk_nr_clks);
if (IS_ERR(ctx)) {
pr_err("%s: rockchip clk init failed\n", __func__);
return;
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index aca107a45d..aedb02a8d3 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -395,6 +395,23 @@ void rockchip_clk_register_plls(struct rockchip_clk_provider *ctx,
}
EXPORT_SYMBOL_GPL(rockchip_clk_register_plls);
+unsigned long rockchip_clk_find_max_clk_id(struct rockchip_clk_branch *list,
+ unsigned int nr_clk)
+{
+ unsigned long max = 0;
+ unsigned int idx;
+
+ for (idx = 0; idx < nr_clk; idx++, list++) {
+ if (list->id > max)
+ max = list->id;
+ if (list->child && list->child->id > max)
+ max = list->id;
+ }
+
+ return max;
+}
+EXPORT_SYMBOL_GPL(rockchip_clk_find_max_clk_id);
+
void rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,
struct rockchip_clk_branch *list,
unsigned int nr_clk)
diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h
index df819c61f1..a451229326 100644
--- a/drivers/clk/rockchip/clk.h
+++ b/drivers/clk/rockchip/clk.h
@@ -888,6 +888,8 @@ void rockchip_clk_of_add_provider(struct device_node *np,
struct rockchip_clk_provider *ctx);
void rockchip_clk_add_lookup(struct rockchip_clk_provider *ctx,
struct clk *clk, unsigned int id);
+unsigned long rockchip_clk_find_max_clk_id(struct rockchip_clk_branch *list,
+ unsigned int nr_clk);
void rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,
struct rockchip_clk_branch *list,
unsigned int nr_clk);
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: rockchip: rk3588: fix CLK_NR_CLKS usage
2024-04-02 9:19 [PATCH] clk: rockchip: rk3588: fix CLK_NR_CLKS usage Sascha Hauer
@ 2024-04-02 9:22 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-04-02 9:22 UTC (permalink / raw)
To: Barebox List, Sascha Hauer
On Tue, 02 Apr 2024 11:19:26 +0200, Sascha Hauer wrote:
> barebox adoption of Linux commit 2dc66a5ab2c6:
>
> | clk: rockchip: rk3588: fix CLK_NR_CLKS usage
> |
> | CLK_NR_CLKS is not part of the DT bindings and needs to be removed
> | from it, just like it recently happened for other platforms. This
> | takes care of it by introducing a new function identifying the
> | maximum used clock ID at runtime.
> |
> | Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> | Link: https://lore.kernel.org/r/20240126182919.48402-2-sebastian.reichel@collabora.com
> | Signed-off-by: Heiko Stuebner <heiko@sntech.de>
>
> [...]
Applied, thanks!
[1/1] clk: rockchip: rk3588: fix CLK_NR_CLKS usage
https://git.pengutronix.de/cgit/barebox/commit/?id=966c042f806f (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-02 9:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02 9:19 [PATCH] clk: rockchip: rk3588: fix CLK_NR_CLKS usage Sascha Hauer
2024-04-02 9:22 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox