clk: at91: clk-utmi: add support for parent_hw
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Thu, 15 Jun 2023 09:32:23 +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 utmi 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-utmi 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-8-claudiu.beznea@microchip.com
drivers/clk/at91/at91sam9g45.c
drivers/clk/at91/at91sam9rl.c
drivers/clk/at91/at91sam9x5.c
drivers/clk/at91/clk-utmi.c
drivers/clk/at91/dt-compat.c
drivers/clk/at91/pmc.h
drivers/clk/at91/sama5d2.c
drivers/clk/at91/sama5d3.c
drivers/clk/at91/sama5d4.c
drivers/clk/at91/sama7g5.c

index ec2f26c3a80a563135aba33c839a4b96768debdc..f45a7b80f7d8be6ae34d4df2d98bc989f66176f5 100644 (file)
@@ -145,7 +145,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
 
        at91sam9g45_pmc->chws[PMC_PLLACK] = hw;
 
-       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
+       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index 051b2eeb9276246a69e9c8666b0f41472ef6af32..969f809e7d65aab5eeba405bbb3f3b8353d3d469 100644 (file)
@@ -109,7 +109,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
 
        at91sam9rl_pmc->chws[PMC_PLLACK] = hw;
 
-       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
+       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index e1be2c4c54be398f542c6a1121038605195daca1..3b801d12fac0d1c511b85abab8044d9dd974f0fb 100644 (file)
@@ -193,7 +193,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
 
        at91sam9x5_pmc->chws[PMC_PLLACK] = hw;
 
-       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
+       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index a22c10d9a1b964e4fbeb883a3a5d02e85f250c16..40c84f5af5e8a6dda739f1d356b74e94c575fe78 100644 (file)
@@ -144,21 +144,30 @@ static struct clk_hw * __init
 at91_clk_register_utmi_internal(struct regmap *regmap_pmc,
                                struct regmap *regmap_sfr,
                                const char *name, const char *parent_name,
+                               struct clk_hw *parent_hw,
                                const struct clk_ops *ops, unsigned long flags)
 {
        struct clk_utmi *utmi;
        struct clk_hw *hw;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        int ret;
 
+       if (!(parent_name || parent_hw))
+               return ERR_PTR(-EINVAL);
+
        utmi = kzalloc(sizeof(*utmi), GFP_KERNEL);
        if (!utmi)
                return ERR_PTR(-ENOMEM);
 
        init.name = name;
        init.ops = ops;
-       init.parent_names = parent_name ? &parent_name : NULL;
-       init.num_parents = parent_name ? 1 : 0;
+       if (parent_hw) {
+               init.parent_hws = parent_hw ? (const struct clk_hw **)&parent_hw : NULL;
+               init.num_parents = parent_hw ? 1 : 0;
+       } else {
+               init.parent_names = parent_name ? &parent_name : NULL;
+               init.num_parents = parent_name ? 1 : 0;
+       }
        init.flags = flags;
 
        utmi->hw.init = &init;
@@ -177,10 +186,11 @@ at91_clk_register_utmi_internal(struct regmap *regmap_pmc,
 
 struct clk_hw * __init
 at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr,
-                      const char *name, const char *parent_name)
+                      const char *name, const char *parent_name,
+                      struct clk_hw *parent_hw)
 {
        return at91_clk_register_utmi_internal(regmap_pmc, regmap_sfr, name,
-                       parent_name, &utmi_ops, CLK_SET_RATE_GATE);
+                       parent_name, parent_hw, &utmi_ops, CLK_SET_RATE_GATE);
 }
 
 static int clk_utmi_sama7g5_prepare(struct clk_hw *hw)
@@ -279,8 +289,8 @@ static const struct clk_ops sama7g5_utmi_ops = {
 
 struct clk_hw * __init
 at91_clk_sama7g5_register_utmi(struct regmap *regmap_pmc, const char *name,
-                              const char *parent_name)
+                              const char *parent_name, struct clk_hw *parent_hw)
 {
        return at91_clk_register_utmi_internal(regmap_pmc, NULL, name,
-                       parent_name, &sama7g5_utmi_ops, 0);
+                       parent_name, parent_hw, &sama7g5_utmi_ops, 0);
 }
index e5fcf2e0d2351a546eb656b0c8484c7772185557..a32dc2111b900e3aa12efbbdfa79ab2308f0fe75 100644 (file)
@@ -1055,7 +1055,7 @@ static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
                        regmap_sfr = NULL;
        }
 
-       hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name);
+       hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name, NULL);
        if (IS_ERR(hw))
                return;
 
index 101e005a955038d4d8609fd19a30a0f59c06074e..8e32be004843fcdf68fc1d1113e393a39650a795 100644 (file)
@@ -269,10 +269,11 @@ at91rm9200_clk_register_usb(struct regmap *regmap, const char *name,
 
 struct clk_hw * __init
 at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr,
-                      const char *name, const char *parent_name);
+                      const char *name, const char *parent_name,
+                      struct clk_hw *parent_hw);
 
 struct clk_hw * __init
 at91_clk_sama7g5_register_utmi(struct regmap *regmap, const char *name,
-                              const char *parent_name);
+                              const char *parent_name, struct clk_hw *parent_hw);
 
 #endif /* __PMC_H_ */
index c5df06190e1c72c1c03ac7752e6609a1d4228956..c16594fce90c91c1ef46f614ac72aaa08e91db44 100644 (file)
@@ -249,7 +249,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
        if (IS_ERR(regmap_sfr))
                regmap_sfr = NULL;
 
-       hw = at91_clk_register_utmi(regmap, regmap_sfr, "utmick", "mainck");
+       hw = at91_clk_register_utmi(regmap, regmap_sfr, "utmick", "mainck", NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index 15fa180a3f58fecd8949ea7134a9673a2840c955..522ce6031446411b8dec4ac463db5ac152963e1c 100644 (file)
@@ -172,7 +172,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)
 
        sama5d3_pmc->chws[PMC_PLLACK] = hw;
 
-       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
+       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index 2440a34d1d67148b38f4efce50877a515b650e5c..160c0bddb6a3be7b12877d3d832a9aa9255c1bd5 100644 (file)
@@ -187,7 +187,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
 
        sama5d4_pmc->chws[PMC_PLLACK] = hw;
 
-       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
+       hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
        if (IS_ERR(hw))
                goto err_free;
 
index b606d642a22b6a0b66fd4cd08fc11bbf765dfbe1..42f2f61cc6d16cca7076ef964868c78fccb9bd0e 100644 (file)
@@ -1035,7 +1035,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
                        sama7g5_pmc->chws[sama7g5_mckx[i].eid] = hw;
        }
 
-       hw = at91_clk_sama7g5_register_utmi(regmap, "utmick", "main_xtal");
+       hw = at91_clk_sama7g5_register_utmi(regmap, "utmick", "main_xtal", NULL);
        if (IS_ERR(hw))
                goto err_free;