clk: at91: clk-system: add support for parent_hw
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Thu, 15 Jun 2023 09:32:22 +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 system 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-system 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-7-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-system.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 2dd69628b7ba049811cb28466c13d75a76fbb19b..3f19e737ae4d2961e61255f56781b5b27e4566ff 100644 (file)
@@ -182,7 +182,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
 
        for (i = 0; i < ARRAY_SIZE(at91rm9200_systemck); i++) {
                hw = at91_clk_register_system(regmap, at91rm9200_systemck[i].n,
-                                             at91rm9200_systemck[i].p,
+                                             at91rm9200_systemck[i].p, NULL,
                                              at91rm9200_systemck[i].id, 0);
                if (IS_ERR(hw))
                        goto err_free;
index 7d292d0c2bfc2872a2a73278b81db1e3ef81d8fa..0799a13060ea4551477246ef657cf381014cbaae 100644 (file)
@@ -459,7 +459,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
 
        for (i = 0; i < data->num_sck; i++) {
                hw = at91_clk_register_system(regmap, data->sck[i].n,
-                                             data->sck[i].p,
+                                             data->sck[i].p, NULL,
                                              data->sck[i].id, 0);
                if (IS_ERR(hw))
                        goto err_free;
index b49415952510899b5d9d8a3b131b114c20fc4ad7..ec2f26c3a80a563135aba33c839a4b96768debdc 100644 (file)
@@ -202,7 +202,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
 
        for (i = 0; i < ARRAY_SIZE(at91sam9g45_systemck); i++) {
                hw = at91_clk_register_system(regmap, at91sam9g45_systemck[i].n,
-                                             at91sam9g45_systemck[i].p,
+                                             at91sam9g45_systemck[i].p, NULL,
                                              at91sam9g45_systemck[i].id,
                                              at91sam9g45_systemck[i].flags);
                if (IS_ERR(hw))
index 63151cd0d3b24acf50fc6a4ca4395aa21f7aa1d3..751786184ae2b35a6c7fd441af3427e3c829d68a 100644 (file)
@@ -227,7 +227,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
 
        for (i = 0; i < ARRAY_SIZE(at91sam9n12_systemck); i++) {
                hw = at91_clk_register_system(regmap, at91sam9n12_systemck[i].n,
-                                             at91sam9n12_systemck[i].p,
+                                             at91sam9n12_systemck[i].p, NULL,
                                              at91sam9n12_systemck[i].id,
                                              at91sam9n12_systemck[i].flags);
                if (IS_ERR(hw))
index 858987757b874aa9d9daa2b2de125e5dfa025129..051b2eeb9276246a69e9c8666b0f41472ef6af32 100644 (file)
@@ -159,7 +159,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
 
        for (i = 0; i < ARRAY_SIZE(at91sam9rl_systemck); i++) {
                hw = at91_clk_register_system(regmap, at91sam9rl_systemck[i].n,
-                                             at91sam9rl_systemck[i].p,
+                                             at91sam9rl_systemck[i].p, NULL,
                                              at91sam9rl_systemck[i].id, 0);
                if (IS_ERR(hw))
                        goto err_free;
index 6a971b34f7ddd6adc8df62d36d0b7bd56896fd33..e1be2c4c54be398f542c6a1121038605195daca1 100644 (file)
@@ -252,7 +252,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
 
        for (i = 0; i < ARRAY_SIZE(at91sam9x5_systemck); i++) {
                hw = at91_clk_register_system(regmap, at91sam9x5_systemck[i].n,
-                                             at91sam9x5_systemck[i].p,
+                                             at91sam9x5_systemck[i].p, NULL,
                                              at91sam9x5_systemck[i].id,
                                              at91sam9x5_systemck[i].flags);
                if (IS_ERR(hw))
@@ -263,7 +263,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
 
        if (has_lcdck) {
                hw = at91_clk_register_system(regmap, "lcdck", "masterck_div",
-                                             3, 0);
+                                             NULL, 3, 0);
                if (IS_ERR(hw))
                        goto err_free;
 
index 10193650429eb6d908cc850b31ffcefb123f5718..90eed39d07856574798cc4a56874dd61404716b4 100644 (file)
@@ -105,14 +105,15 @@ static const struct clk_ops system_ops = {
 
 struct clk_hw * __init
 at91_clk_register_system(struct regmap *regmap, const char *name,
-                        const char *parent_name, u8 id, unsigned long flags)
+                        const char *parent_name, struct clk_hw *parent_hw, u8 id,
+                        unsigned long flags)
 {
        struct clk_system *sys;
        struct clk_hw *hw;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        int ret;
 
-       if (!parent_name || id > SYSTEM_MAX_ID)
+       if (!(parent_name || parent_hw) || id > SYSTEM_MAX_ID)
                return ERR_PTR(-EINVAL);
 
        sys = kzalloc(sizeof(*sys), GFP_KERNEL);
@@ -121,7 +122,10 @@ at91_clk_register_system(struct regmap *regmap, const char *name,
 
        init.name = name;
        init.ops = &system_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 = CLK_SET_RATE_PARENT | flags;
 
index 96ce2287e13a6b1390d33b14ba9d68771edb099e..e5fcf2e0d2351a546eb656b0c8484c7772185557 100644 (file)
@@ -908,8 +908,8 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
                if (!strcmp(sysclknp->name, "ddrck"))
                        flags = CLK_IS_CRITICAL;
 
-               hw = at91_clk_register_system(regmap, name, parent_name, id,
-                                             flags);
+               hw = at91_clk_register_system(regmap, name, parent_name, NULL,
+                                             id, flags);
                if (IS_ERR(hw))
                        continue;
 
index 658bbf574af9a444268d592aa6cc95a071bb4ddc..101e005a955038d4d8609fd19a30a0f59c06074e 100644 (file)
@@ -251,7 +251,8 @@ at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,
 
 struct clk_hw * __init
 at91_clk_register_system(struct regmap *regmap, const char *name,
-                        const char *parent_name, u8 id, unsigned long flags);
+                        const char *parent_name, struct clk_hw *parent_hw,
+                        u8 id, unsigned long flags);
 
 struct clk_hw * __init
 at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
index 369123dc009ceebcd906eb62d1097603c2c223d1..505827013b462643ee85955ea422a30510d879da 100644 (file)
@@ -324,7 +324,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
 
        for (i = 0; i < ARRAY_SIZE(sam9x60_systemck); i++) {
                hw = at91_clk_register_system(regmap, sam9x60_systemck[i].n,
-                                             sam9x60_systemck[i].p,
+                                             sam9x60_systemck[i].p, NULL,
                                              sam9x60_systemck[i].id,
                                              sam9x60_systemck[i].flags);
                if (IS_ERR(hw))
index 8eda5f95d142fb29d85c38091f21b16c7d788e05..c5df06190e1c72c1c03ac7752e6609a1d4228956 100644 (file)
@@ -311,7 +311,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
 
        for (i = 0; i < ARRAY_SIZE(sama5d2_systemck); i++) {
                hw = at91_clk_register_system(regmap, sama5d2_systemck[i].n,
-                                             sama5d2_systemck[i].p,
+                                             sama5d2_systemck[i].p, NULL,
                                              sama5d2_systemck[i].id,
                                              sama5d2_systemck[i].flags);
                if (IS_ERR(hw))
index 68a540cf8edaaf418fdf030ee3059b1d92bc39fe..15fa180a3f58fecd8949ea7134a9673a2840c955 100644 (file)
@@ -231,7 +231,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)
 
        for (i = 0; i < ARRAY_SIZE(sama5d3_systemck); i++) {
                hw = at91_clk_register_system(regmap, sama5d3_systemck[i].n,
-                                             sama5d3_systemck[i].p,
+                                             sama5d3_systemck[i].p, NULL,
                                              sama5d3_systemck[i].id,
                                              sama5d3_systemck[i].flags);
                if (IS_ERR(hw))
index 9145fa18438810a79b23a2392e71092c2bf33fed..2440a34d1d67148b38f4efce50877a515b650e5c 100644 (file)
@@ -254,7 +254,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
 
        for (i = 0; i < ARRAY_SIZE(sama5d4_systemck); i++) {
                hw = at91_clk_register_system(regmap, sama5d4_systemck[i].n,
-                                             sama5d4_systemck[i].p,
+                                             sama5d4_systemck[i].p, NULL,
                                              sama5d4_systemck[i].id,
                                              sama5d4_systemck[i].flags);
                if (IS_ERR(hw))
index 22942af8dce4c4ace9d6546d6b8994f2959b2ad0..b606d642a22b6a0b66fd4cd08fc11bbf765dfbe1 100644 (file)
@@ -1067,7 +1067,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
 
        for (i = 0; i < ARRAY_SIZE(sama7g5_systemck); i++) {
                hw = at91_clk_register_system(regmap, sama7g5_systemck[i].n,
-                                             sama7g5_systemck[i].p,
+                                             sama7g5_systemck[i].p, NULL,
                                              sama7g5_systemck[i].id, 0);
                if (IS_ERR(hw))
                        goto err_free;