]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: rockchip: rk3188: Drop CLK_NR_CLKS usage
authorJohan Jonker <jbx6244@gmail.com>
Mon, 24 Jun 2024 11:40:03 +0000 (13:40 +0200)
committerHeiko Stuebner <heiko@sntech.de>
Thu, 27 Jun 2024 19:04:40 +0000 (21:04 +0200)
In order to get rid of CLK_NR_CLKS and be able to drop it from the
bindings, use rockchip_clk_find_max_clk_id helper to find the highest
clock id.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Link: https://lore.kernel.org/r/1cd309fa-a4d3-4283-aa47-1330a40448a7@gmail.com
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
drivers/clk/rockchip/clk-rk3188.c

index 9c8af4d1dae04fd6986e9384da3ab2d0b6a5f740..30e670c8afbaed3cd42090bbe16afc9400e14e0d 100644 (file)
@@ -757,9 +757,11 @@ static const char *const rk3188_critical_clocks[] __initconst = {
        "sclk_mac_lbtest",
 };
 
-static struct rockchip_clk_provider *__init rk3188_common_clk_init(struct device_node *np)
+static struct rockchip_clk_provider *__init rk3188_common_clk_init(struct device_node *np,
+                                                                  unsigned long soc_nr_clks)
 {
        struct rockchip_clk_provider *ctx;
+       unsigned long common_nr_clks;
        void __iomem *reg_base;
 
        reg_base = of_iomap(np, 0);
@@ -768,7 +770,9 @@ static struct rockchip_clk_provider *__init rk3188_common_clk_init(struct device
                return ERR_PTR(-ENOMEM);
        }
 
-       ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS);
+       common_nr_clks = rockchip_clk_find_max_clk_id(common_clk_branches,
+                                                     ARRAY_SIZE(common_clk_branches)) + 1;
+       ctx = rockchip_clk_init(np, reg_base, max(common_nr_clks, soc_nr_clks));
        if (IS_ERR(ctx)) {
                pr_err("%s: rockchip clk init failed\n", __func__);
                iounmap(reg_base);
@@ -789,8 +793,11 @@ static struct rockchip_clk_provider *__init rk3188_common_clk_init(struct device
 static void __init rk3066a_clk_init(struct device_node *np)
 {
        struct rockchip_clk_provider *ctx;
+       unsigned long soc_nr_clks;
 
-       ctx = rk3188_common_clk_init(np);
+       soc_nr_clks = rockchip_clk_find_max_clk_id(rk3066a_clk_branches,
+                                                  ARRAY_SIZE(rk3066a_clk_branches)) + 1;
+       ctx = rk3188_common_clk_init(np, soc_nr_clks);
        if (IS_ERR(ctx))
                return;
 
@@ -812,11 +819,14 @@ CLK_OF_DECLARE(rk3066a_cru, "rockchip,rk3066a-cru", rk3066a_clk_init);
 static void __init rk3188a_clk_init(struct device_node *np)
 {
        struct rockchip_clk_provider *ctx;
+       unsigned long soc_nr_clks;
        struct clk *clk1, *clk2;
        unsigned long rate;
        int ret;
 
-       ctx = rk3188_common_clk_init(np);
+       soc_nr_clks = rockchip_clk_find_max_clk_id(rk3188_clk_branches,
+                                                  ARRAY_SIZE(rk3188_clk_branches)) + 1;
+       ctx = rk3188_common_clk_init(np, soc_nr_clks);
        if (IS_ERR(ctx))
                return;