clk: at91: clk-sam9x60-pll: add support for parent_hw
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Thu, 15 Jun 2023 09:32:24 +0000 (12:32 +0300)
committerClaudiu Beznea <claudiu.beznea@microchip.com>
Wed, 21 Jun 2023 07:42:48 +0000 (10:42 +0300)
Add support for parent_hw in SAM9X60 PLL 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-sam9x60-pll 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-9-claudiu.beznea@microchip.com
drivers/clk/at91/clk-sam9x60-pll.c
drivers/clk/at91/pmc.h
drivers/clk/at91/sam9x60.c
drivers/clk/at91/sama7g5.c

index 0882ed01d5c27fd1a693ff5a197584fc5009736e..ff65f7b916f077f1e2c87d7677beeb722a14f25c 100644 (file)
@@ -616,7 +616,7 @@ sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock,
 {
        struct sam9x60_frac *frac;
        struct clk_hw *hw;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        unsigned long parent_rate, irqflags;
        unsigned int val;
        int ret;
@@ -629,7 +629,10 @@ sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock,
                return ERR_PTR(-ENOMEM);
 
        init.name = name;
-       init.parent_names = &parent_name;
+       if (parent_name)
+               init.parent_names = &parent_name;
+       else
+               init.parent_hws = (const struct clk_hw **)&parent_hw;
        init.num_parents = 1;
        if (flags & CLK_SET_RATE_GATE)
                init.ops = &sam9x60_frac_pll_ops;
@@ -692,14 +695,15 @@ free:
 
 struct clk_hw * __init
 sam9x60_clk_register_div_pll(struct regmap *regmap, spinlock_t *lock,
-                            const char *name, const char *parent_name, u8 id,
+                            const char *name, const char *parent_name,
+                            struct clk_hw *parent_hw, u8 id,
                             const struct clk_pll_characteristics *characteristics,
                             const struct clk_pll_layout *layout, u32 flags,
                             u32 safe_div)
 {
        struct sam9x60_div *div;
        struct clk_hw *hw;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        unsigned long irqflags;
        unsigned int val;
        int ret;
@@ -716,7 +720,10 @@ sam9x60_clk_register_div_pll(struct regmap *regmap, spinlock_t *lock,
                return ERR_PTR(-ENOMEM);
 
        init.name = name;
-       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;
        if (flags & CLK_SET_RATE_GATE)
                init.ops = &sam9x60_div_pll_ops;
index 8e32be004843fcdf68fc1d1113e393a39650a795..0f52e80bcd49a1afe249459efcee8b17d92895c7 100644 (file)
@@ -220,7 +220,8 @@ at91_clk_register_plldiv(struct regmap *regmap, const char *name,
 
 struct clk_hw * __init
 sam9x60_clk_register_div_pll(struct regmap *regmap, spinlock_t *lock,
-                            const char *name, const char *parent_name, u8 id,
+                            const char *name, const char *parent_name,
+                            struct clk_hw *parent_hw, u8 id,
                             const struct clk_pll_characteristics *characteristics,
                             const struct clk_pll_layout *layout, u32 flags,
                             u32 safe_div);
index 505827013b462643ee85955ea422a30510d879da..e309cbf3cb9a4d611aa5bce8d2fb73428d515da6 100644 (file)
@@ -246,7 +246,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
                goto err_free;
 
        hw = sam9x60_clk_register_div_pll(regmap, &pmc_pll_lock, "pllack_divck",
-                                         "pllack_fracck", 0, &plla_characteristics,
+                                         "pllack_fracck", NULL, 0, &plla_characteristics,
                                          &pll_div_layout,
                                           /*
                                            * This feeds CPU. It should not
@@ -266,7 +266,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
                goto err_free;
 
        hw = sam9x60_clk_register_div_pll(regmap, &pmc_pll_lock, "upllck_divck",
-                                         "upllck_fracck", 1, &upll_characteristics,
+                                         "upllck_fracck", NULL, 1, &upll_characteristics,
                                          &pll_div_layout,
                                          CLK_SET_RATE_GATE |
                                          CLK_SET_PARENT_GATE |
index 42f2f61cc6d16cca7076ef964868c78fccb9bd0e..3297e028c2c5483941c118f288178c49f39df6a4 100644 (file)
@@ -975,7 +975,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
                        case PLL_TYPE_DIV:
                                hw = sam9x60_clk_register_div_pll(regmap,
                                        &pmc_pll_lock, sama7g5_plls[i][j].n,
-                                       sama7g5_plls[i][j].p, i,
+                                       sama7g5_plls[i][j].p, NULL, i,
                                        sama7g5_plls[i][j].c,
                                        sama7g5_plls[i][j].l,
                                        sama7g5_plls[i][j].f,