clk: at91: clk-main: add support for parent_data/parent_hw
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Thu, 15 Jun 2023 09:32:17 +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_data and parent_hw in main oscillator clock drivers.
With this parent-child relations are described with pointers rather
than strings making registration a bit faster.

All the SoC based drivers that rely on clk-main 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-2-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-main.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 0b86012..83917a2 100644 (file)
@@ -108,12 +108,12 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
 
        bypass = of_property_read_bool(np, "atmel,osc-bypass");
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
                                        bypass);
        if (IS_ERR(hw))
                goto err_free;
 
-       hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc");
+       hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc", NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index b521f47..e9b5682 100644 (file)
@@ -363,12 +363,12 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
 
        bypass = of_property_read_bool(np, "atmel,osc-bypass");
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
                                        bypass);
        if (IS_ERR(hw))
                goto err_free;
 
-       hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc");
+       hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc", NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index 5099669..e25fb1b 100644 (file)
@@ -123,12 +123,12 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
 
        bypass = of_property_read_bool(np, "atmel,osc-bypass");
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
                                        bypass);
        if (IS_ERR(hw))
                goto err_free;
 
-       hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc");
+       hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc", NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index 08a10e1..35f137f 100644 (file)
@@ -147,14 +147,14 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
 
        bypass = of_property_read_bool(np, "atmel,osc-bypass");
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
                                        bypass);
        if (IS_ERR(hw))
                goto err_free;
 
        parent_names[0] = "main_rc_osc";
        parent_names[1] = "main_osc";
-       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
+       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
        if (IS_ERR(hw))
                goto err_free;
 
index 1a1b6b2..d3186dd 100644 (file)
@@ -95,7 +95,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
        if (!at91sam9rl_pmc)
                return;
 
-       hw = at91_clk_register_rm9200_main(regmap, "mainck", mainxtal_name);
+       hw = at91_clk_register_rm9200_main(regmap, "mainck", mainxtal_name, NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index 13e589c..57f41aa 100644 (file)
@@ -169,14 +169,14 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
 
        bypass = of_property_read_bool(np, "atmel,osc-bypass");
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
                                        bypass);
        if (IS_ERR(hw))
                goto err_free;
 
        parent_names[0] = "main_rc_osc";
        parent_names[1] = "main_osc";
-       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
+       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
        if (IS_ERR(hw))
                goto err_free;
 
index 8601b27..4b5f0ff 100644 (file)
@@ -152,14 +152,15 @@ struct clk_hw * __init
 at91_clk_register_main_osc(struct regmap *regmap,
                           const char *name,
                           const char *parent_name,
+                          struct clk_parent_data *parent_data,
                           bool bypass)
 {
        struct clk_main_osc *osc;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        struct clk_hw *hw;
        int ret;
 
-       if (!name || !parent_name)
+       if (!name || !(parent_name || parent_data))
                return ERR_PTR(-EINVAL);
 
        osc = kzalloc(sizeof(*osc), GFP_KERNEL);
@@ -168,7 +169,10 @@ at91_clk_register_main_osc(struct regmap *regmap,
 
        init.name = name;
        init.ops = &main_osc_ops;
-       init.parent_names = &parent_name;
+       if (parent_data)
+               init.parent_data = (const struct clk_parent_data *)parent_data;
+       else
+               init.parent_names = &parent_name;
        init.num_parents = 1;
        init.flags = CLK_IGNORE_UNUSED;
 
@@ -397,17 +401,18 @@ static const struct clk_ops rm9200_main_ops = {
 struct clk_hw * __init
 at91_clk_register_rm9200_main(struct regmap *regmap,
                              const char *name,
-                             const char *parent_name)
+                             const char *parent_name,
+                             struct clk_hw *parent_hw)
 {
        struct clk_rm9200_main *clkmain;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        struct clk_hw *hw;
        int ret;
 
        if (!name)
                return ERR_PTR(-EINVAL);
 
-       if (!parent_name)
+       if (!(parent_name || parent_hw))
                return ERR_PTR(-EINVAL);
 
        clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL);
@@ -416,7 +421,10 @@ at91_clk_register_rm9200_main(struct regmap *regmap,
 
        init.name = name;
        init.ops = &rm9200_main_ops;
-       init.parent_names = &parent_name;
+       if (parent_hw)
+               init.parent_hws = (const struct clk_hw **)&parent_hw;
+       else
+               init.parent_names = &parent_name;
        init.num_parents = 1;
        init.flags = 0;
 
@@ -543,10 +551,11 @@ struct clk_hw * __init
 at91_clk_register_sam9x5_main(struct regmap *regmap,
                              const char *name,
                              const char **parent_names,
+                             struct clk_hw **parent_hws,
                              int num_parents)
 {
        struct clk_sam9x5_main *clkmain;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        unsigned int status;
        struct clk_hw *hw;
        int ret;
@@ -554,7 +563,7 @@ at91_clk_register_sam9x5_main(struct regmap *regmap,
        if (!name)
                return ERR_PTR(-EINVAL);
 
-       if (!parent_names || !num_parents)
+       if (!(parent_hws || parent_names) || !num_parents)
                return ERR_PTR(-EINVAL);
 
        clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL);
@@ -563,7 +572,10 @@ at91_clk_register_sam9x5_main(struct regmap *regmap,
 
        init.name = name;
        init.ops = &sam9x5_main_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_PARENT_GATE;
 
index 97f67e2..ecb0beb 100644 (file)
@@ -269,7 +269,7 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
        if (IS_ERR(regmap))
                return;
 
-       hw = at91_clk_register_main_osc(regmap, name, parent_name, bypass);
+       hw = at91_clk_register_main_osc(regmap, name, parent_name, NULL, bypass);
        if (IS_ERR(hw))
                return;
 
@@ -323,7 +323,7 @@ static void __init of_at91rm9200_clk_main_setup(struct device_node *np)
        if (IS_ERR(regmap))
                return;
 
-       hw = at91_clk_register_rm9200_main(regmap, name, parent_name);
+       hw = at91_clk_register_rm9200_main(regmap, name, parent_name, NULL);
        if (IS_ERR(hw))
                return;
 
@@ -354,7 +354,7 @@ static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
 
        of_property_read_string(np, "clock-output-names", &name);
 
-       hw = at91_clk_register_sam9x5_main(regmap, name, parent_names,
+       hw = at91_clk_register_sam9x5_main(regmap, name, parent_names, NULL,
                                           num_parents);
        if (IS_ERR(hw))
                return;
index 1b3ca7d..487e44d 100644 (file)
@@ -161,14 +161,17 @@ at91_clk_register_main_rc_osc(struct regmap *regmap, const char *name,
                              u32 frequency, u32 accuracy);
 struct clk_hw * __init
 at91_clk_register_main_osc(struct regmap *regmap, const char *name,
-                          const char *parent_name, bool bypass);
+                          const char *parent_name,
+                          struct clk_parent_data *parent_data, bool bypass);
 struct clk_hw * __init
 at91_clk_register_rm9200_main(struct regmap *regmap,
                              const char *name,
-                             const char *parent_name);
+                             const char *parent_name,
+                             struct clk_hw *parent_hw);
 struct clk_hw * __init
 at91_clk_register_sam9x5_main(struct regmap *regmap, const char *name,
-                             const char **parent_names, int num_parents);
+                             const char **parent_names,
+                             struct clk_hw **parent_hws, int num_parents);
 
 struct clk_hw * __init
 at91_clk_register_master_pres(struct regmap *regmap, const char *name,
index ac070db..e2f40f1 100644 (file)
@@ -219,14 +219,14 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
        if (IS_ERR(hw))
                goto err_free;
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, 0);
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL, 0);
        if (IS_ERR(hw))
                goto err_free;
        main_osc_hw = hw;
 
        parent_names[0] = "main_rc_osc";
        parent_names[1] = "main_osc";
-       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
+       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
        if (IS_ERR(hw))
                goto err_free;
 
index c0e3e1a..2ee8f10 100644 (file)
@@ -202,14 +202,14 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
 
        bypass = of_property_read_bool(np, "atmel,osc-bypass");
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
                                        bypass);
        if (IS_ERR(hw))
                goto err_free;
 
        parent_names[0] = "main_rc_osc";
        parent_names[1] = "main_osc";
-       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
+       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
        if (IS_ERR(hw))
                goto err_free;
 
index ad6068b..88de1cc 100644 (file)
@@ -150,14 +150,14 @@ static void __init sama5d3_pmc_setup(struct device_node *np)
 
        bypass = of_property_read_bool(np, "atmel,osc-bypass");
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
                                        bypass);
        if (IS_ERR(hw))
                goto err_free;
 
        parent_names[0] = "main_rc_osc";
        parent_names[1] = "main_osc";
-       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
+       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
        if (IS_ERR(hw))
                goto err_free;
 
index e876ec9..4e6e276 100644 (file)
@@ -165,14 +165,14 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
 
        bypass = of_property_read_bool(np, "atmel,osc-bypass");
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
                                        bypass);
        if (IS_ERR(hw))
                goto err_free;
 
        parent_names[0] = "main_rc_osc";
        parent_names[1] = "main_osc";
-       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
+       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
        if (IS_ERR(hw))
                goto err_free;
 
index f135b66..42dc74d 100644 (file)
@@ -936,14 +936,14 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
 
        bypass = of_property_read_bool(np, "atmel,osc-bypass");
 
-       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
+       hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
                                        bypass);
        if (IS_ERR(hw))
                goto err_free;
 
        parent_names[0] = "main_rc_osc";
        parent_names[1] = "main_osc";
-       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
+       hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
        if (IS_ERR(hw))
                goto err_free;