clk: at91: clk-programmable: add support for parent_hw
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Thu, 15 Jun 2023 09:32:21 +0000 (12:32 +0300)
committerClaudiu Beznea <claudiu.beznea@microchip.com>
Wed, 21 Jun 2023 07:42:47 +0000 (10:42 +0300)
Add support for parent_hw in programmable clock driver.
With this parent-child relation is described with pointers rather
than strings making registration a bit faster.

All the SoC based drivers that rely on clk-programmable were adapted
to the new API change. The switch itself for SoCs will be done
in subsequent patches.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20230615093227.576102-6-claudiu.beznea@microchip.com
14 files changed:
drivers/clk/at91/at91rm9200.c
drivers/clk/at91/at91sam9260.c
drivers/clk/at91/at91sam9g45.c
drivers/clk/at91/at91sam9n12.c
drivers/clk/at91/at91sam9rl.c
drivers/clk/at91/at91sam9x5.c
drivers/clk/at91/clk-programmable.c
drivers/clk/at91/dt-compat.c
drivers/clk/at91/pmc.h
drivers/clk/at91/sam9x60.c
drivers/clk/at91/sama5d2.c
drivers/clk/at91/sama5d3.c
drivers/clk/at91/sama5d4.c
drivers/clk/at91/sama7g5.c

index 9eaf544..2dd6962 100644 (file)
@@ -171,7 +171,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 4, i,
+                                                   parent_names, NULL, 4, i,
                                                    &at91rm9200_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index b124a8d..7d292d0 100644 (file)
@@ -448,7 +448,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 4, i,
+                                                   parent_names, NULL, 4, i,
                                                    &at91rm9200_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index be968b4..b494159 100644 (file)
@@ -191,7 +191,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 5, i,
+                                                   parent_names, NULL, 5, i,
                                                    &at91sam9g45_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index 8441eae..63151cd 100644 (file)
@@ -216,7 +216,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 5, i,
+                                                   parent_names, NULL, 5, i,
                                                    &at91sam9x5_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index 94a6b48..8589877 100644 (file)
@@ -148,7 +148,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 5, i,
+                                                   parent_names, NULL, 5, i,
                                                    &at91rm9200_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index 15fbbcf..6a971b3 100644 (file)
@@ -241,7 +241,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 5, i,
+                                                   parent_names, NULL, 5, i,
                                                    &at91sam9x5_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index 6c4b259..1195fb4 100644 (file)
@@ -215,16 +215,16 @@ static const struct clk_ops programmable_ops = {
 struct clk_hw * __init
 at91_clk_register_programmable(struct regmap *regmap,
                               const char *name, const char **parent_names,
-                              u8 num_parents, u8 id,
+                              struct clk_hw **parent_hws, u8 num_parents, u8 id,
                               const struct clk_programmable_layout *layout,
                               u32 *mux_table)
 {
        struct clk_programmable *prog;
        struct clk_hw *hw;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        int ret;
 
-       if (id > PROG_ID_MAX)
+       if (id > PROG_ID_MAX || !(parent_names || parent_hws))
                return ERR_PTR(-EINVAL);
 
        prog = kzalloc(sizeof(*prog), GFP_KERNEL);
@@ -233,7 +233,10 @@ at91_clk_register_programmable(struct regmap *regmap,
 
        init.name = name;
        init.ops = &programmable_ops;
-       init.parent_names = parent_names;
+       if (parent_hws)
+               init.parent_hws = (const struct clk_hw **)parent_hws;
+       else
+               init.parent_names = parent_names;
        init.num_parents = num_parents;
        init.flags = CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE;
 
index 8995e1c..96ce228 100644 (file)
@@ -770,7 +770,7 @@ of_at91_clk_prog_setup(struct device_node *np,
                        name = progclknp->name;
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, num_parents,
+                                                   parent_names, NULL, num_parents,
                                                    id, layout, mux_table);
                if (IS_ERR(hw))
                        continue;
index 6866e81..658bbf5 100644 (file)
@@ -234,7 +234,8 @@ sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock,
 
 struct clk_hw * __init
 at91_clk_register_programmable(struct regmap *regmap, const char *name,
-                              const char **parent_names, u8 num_parents, u8 id,
+                              const char **parent_names, struct clk_hw **parent_hws,
+                              u8 num_parents, u8 id,
                               const struct clk_programmable_layout *layout,
                               u32 *mux_table);
 
index 71fa8cb..369123d 100644 (file)
@@ -313,7 +313,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 6, i,
+                                                   parent_names, NULL, 6, i,
                                                    &sam9x60_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index 944e1fe..8eda5f9 100644 (file)
@@ -300,7 +300,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 6, i,
+                                                   parent_names, NULL, 6, i,
                                                    &sama5d2_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index f61bef0..68a540c 100644 (file)
@@ -220,7 +220,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 5, i,
+                                                   parent_names, NULL, 5, i,
                                                    &at91sam9x5_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index f0bf209..9145fa1 100644 (file)
@@ -243,7 +243,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name,
-                                                   parent_names, 5, i,
+                                                   parent_names, NULL, 5, i,
                                                    &at91sam9x5_programmable_layout,
                                                    NULL);
                if (IS_ERR(hw))
index c913c1c..22942af 100644 (file)
@@ -1056,7 +1056,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
                snprintf(name, sizeof(name), "prog%d", i);
 
                hw = at91_clk_register_programmable(regmap, name, parent_names,
-                                                   9, i,
+                                                   NULL, 9, i,
                                                    &programmable_layout,
                                                    sama7g5_prog_mux_table);
                if (IS_ERR(hw))