clk: at91: clk-generated: add support for parent_hw
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Thu, 15 Jun 2023 09:32:18 +0000 (12:32 +0300)
committerClaudiu Beznea <claudiu.beznea@microchip.com>
Wed, 21 Jun 2023 07:42:45 +0000 (10:42 +0300)
Add support for parent_hw in generic clock drivers.
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-generated 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-3-claudiu.beznea@microchip.com
drivers/clk/at91/clk-generated.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/sama7g5.c

index 943ea67bf135fb486d96feae259b32ee45f7743e..4b4edeecc88971531d05c8338d005b7a66a9600e 100644 (file)
@@ -319,22 +319,29 @@ struct clk_hw * __init
 at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
                            const struct clk_pcr_layout *layout,
                            const char *name, const char **parent_names,
+                           struct clk_hw **parent_hws,
                            u32 *mux_table, u8 num_parents, u8 id,
                            const struct clk_range *range,
                            int chg_pid)
 {
        struct clk_generated *gck;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        struct clk_hw *hw;
        int ret;
 
+       if (!(parent_names || parent_hws))
+               return ERR_PTR(-ENOMEM);
+
        gck = kzalloc(sizeof(*gck), GFP_KERNEL);
        if (!gck)
                return ERR_PTR(-ENOMEM);
 
        init.name = name;
        init.ops = &generated_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;
        if (chg_pid >= 0)
index ecb0bebb8a7d9c2e27b3b117a729a437fab5e909..e5a56aaff96d82c5cb1a9c8778c6836c8d83ce33 100644 (file)
@@ -171,7 +171,7 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np)
 
                hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
                                                 &dt_pcr_layout, name,
-                                                parent_names, NULL,
+                                                parent_names, NULL, NULL,
                                                 num_parents, id, &range,
                                                 chg_pid);
                if (IS_ERR(hw))
index 487e44deeca0b64918f50b3fd94b752c4d8f07fa..e947c78a82d08f7076a1c469f6047403147782cb 100644 (file)
@@ -144,7 +144,8 @@ struct clk_hw * __init
 at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
                            const struct clk_pcr_layout *layout,
                            const char *name, const char **parent_names,
-                           u32 *mux_table, u8 num_parents, u8 id,
+                           struct clk_hw **parent_hws, u32 *mux_table,
+                           u8 num_parents, u8 id,
                            const struct clk_range *range, int chg_pid);
 
 struct clk_hw * __init
index e2f40f167c0891bb61af1dbe26fb53e174e70716..dcc8f81421806fb23d7675758f6e334c77379025 100644 (file)
@@ -351,7 +351,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
                hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
                                                 &sam9x60_pcr_layout,
                                                 sam9x60_gck[i].n,
-                                                parent_names, NULL, 6,
+                                                parent_names, NULL, NULL, 6,
                                                 sam9x60_gck[i].id,
                                                 &sam9x60_gck[i].r, INT_MIN);
                if (IS_ERR(hw))
index 2ee8f10d3b034346afb7cb466272d480ddfa3707..18695c9c9beb1923b1969f302d15056267a1f984 100644 (file)
@@ -358,7 +358,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
                hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
                                                 &sama5d2_pcr_layout,
                                                 sama5d2_gck[i].n,
-                                                parent_names, NULL, 6,
+                                                parent_names, NULL, NULL, 6,
                                                 sama5d2_gck[i].id,
                                                 &sama5d2_gck[i].r,
                                                 sama5d2_gck[i].chg_pid);
index 42dc74dbfc28a35933e04ffecb6f75c81b723774..e754c127b2b805bfd08375405a4994fa5086a352 100644 (file)
@@ -1111,7 +1111,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
                hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
                                                 &sama7g5_pcr_layout,
                                                 sama7g5_gck[i].n,
-                                                parent_names, mux_table,
+                                                parent_names, NULL, mux_table,
                                                 num_parents,
                                                 sama7g5_gck[i].id,
                                                 &sama7g5_gck[i].r,