clk: at91: clk-peripheral: add support for parent_hw
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Thu, 15 Jun 2023 09:32:20 +0000 (12:32 +0300)
committerClaudiu Beznea <claudiu.beznea@microchip.com>
Wed, 21 Jun 2023 07:42:46 +0000 (10:42 +0300)
Add support for parent_hw in peripheral 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-peripheral 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-5-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-peripheral.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 259e314ef40fcf9d08d3e115b563761591baa213..9eaf54418b7e47ae1cf55e35ad157f4c84a6277f 100644 (file)
@@ -193,7 +193,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
        for (i = 0; i < ARRAY_SIZE(at91rm9200_periphck); i++) {
                hw = at91_clk_register_peripheral(regmap,
                                                  at91rm9200_periphck[i].n,
-                                                 "masterck_div",
+                                                 "masterck_div", NULL,
                                                  at91rm9200_periphck[i].id);
                if (IS_ERR(hw))
                        goto err_free;
index f9bf65c77c9bd7df7b06006194c5ba665d321fa8..b124a8da58c7a73245dfb8751fabe9b295f1d075 100644 (file)
@@ -470,7 +470,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
        for (i = 0; i < data->num_pck; i++) {
                hw = at91_clk_register_peripheral(regmap,
                                                  data->pck[i].n,
-                                                 "masterck_div",
+                                                 "masterck_div", NULL,
                                                  data->pck[i].id);
                if (IS_ERR(hw))
                        goto err_free;
index c9313a7b32eac341b1e393c515bf03db170013bd..be968b428ed7e72a59cdc8ca31da498d119e3d7f 100644 (file)
@@ -214,7 +214,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
        for (i = 0; i < ARRAY_SIZE(at91sam9g45_periphck); i++) {
                hw = at91_clk_register_peripheral(regmap,
                                                  at91sam9g45_periphck[i].n,
-                                                 "masterck_div",
+                                                 "masterck_div", NULL,
                                                  at91sam9g45_periphck[i].id);
                if (IS_ERR(hw))
                        goto err_free;
index 608410bef1204162dbee288de302dd2090673c51..8441eae0daaa56980ce9c0bbbc26499943f7868a 100644 (file)
@@ -240,7 +240,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                         &at91sam9n12_pcr_layout,
                                                         at91sam9n12_periphck[i].n,
-                                                        "masterck_div",
+                                                        "masterck_div", NULL,
                                                         at91sam9n12_periphck[i].id,
                                                         &range, INT_MIN, 0);
                if (IS_ERR(hw))
index 90911cbd969029aa9ca3a56622340a02d706fb2f..94a6b48352ceef4c897c9a6c92681b24f9180b9b 100644 (file)
@@ -170,7 +170,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
        for (i = 0; i < ARRAY_SIZE(at91sam9rl_periphck); i++) {
                hw = at91_clk_register_peripheral(regmap,
                                                  at91sam9rl_periphck[i].n,
-                                                 "masterck_div",
+                                                 "masterck_div", NULL,
                                                  at91sam9rl_periphck[i].id);
                if (IS_ERR(hw))
                        goto err_free;
index 63097cdd4809bd4ff0af7742b4a7a9993cebf7ee..15fbbcf535bcb4bbc19f5b98cc175f19f0be6a60 100644 (file)
@@ -274,7 +274,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                         &at91sam9x5_pcr_layout,
                                                         at91sam9x5_periphck[i].n,
-                                                        "masterck_div",
+                                                        "masterck_div", NULL,
                                                         at91sam9x5_periphck[i].id,
                                                         &range, INT_MIN, 0);
                if (IS_ERR(hw))
@@ -287,7 +287,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                         &at91sam9x5_pcr_layout,
                                                         extra_pcks[i].n,
-                                                        "masterck_div",
+                                                        "masterck_div", NULL,
                                                         extra_pcks[i].id,
                                                         &range, INT_MIN, 0);
                if (IS_ERR(hw))
index 93ea685e27f679dd4067579236c0c8660ee34e68..c173a44c800aa8cc6970c266995f4a60b0a38554 100644 (file)
@@ -97,14 +97,15 @@ static const struct clk_ops peripheral_ops = {
 
 struct clk_hw * __init
 at91_clk_register_peripheral(struct regmap *regmap, const char *name,
-                            const char *parent_name, u32 id)
+                            const char *parent_name, struct clk_hw *parent_hw,
+                            u32 id)
 {
        struct clk_peripheral *periph;
-       struct clk_init_data init;
+       struct clk_init_data init = {};
        struct clk_hw *hw;
        int ret;
 
-       if (!name || !parent_name || id > PERIPHERAL_ID_MAX)
+       if (!name || !(parent_name || parent_hw) || id > PERIPHERAL_ID_MAX)
                return ERR_PTR(-EINVAL);
 
        periph = kzalloc(sizeof(*periph), GFP_KERNEL);
@@ -113,7 +114,10 @@ at91_clk_register_peripheral(struct regmap *regmap, const char *name,
 
        init.name = name;
        init.ops = &peripheral_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;
 
@@ -444,15 +448,16 @@ struct clk_hw * __init
 at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
                                    const struct clk_pcr_layout *layout,
                                    const char *name, const char *parent_name,
+                                   struct clk_hw *parent_hw,
                                    u32 id, const struct clk_range *range,
                                    int chg_pid, unsigned long flags)
 {
        struct clk_sam9x5_peripheral *periph;
-       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_hw))
                return ERR_PTR(-EINVAL);
 
        periph = kzalloc(sizeof(*periph), GFP_KERNEL);
@@ -460,7 +465,10 @@ at91_clk_register_sam9x5_peripheral(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;
        init.flags = flags;
        if (chg_pid < 0) {
index 4a024bb973124a32969bbb178a3052e7030332c8..8995e1cc73c6212736d632592a284c26f5087d1b 100644 (file)
@@ -490,7 +490,7 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
 
                if (type == PERIPHERAL_AT91RM9200) {
                        hw = at91_clk_register_peripheral(regmap, name,
-                                                         parent_name, id);
+                                                         parent_name, NULL, id);
                } else {
                        struct clk_range range = CLK_RANGE(0, 0);
                        unsigned long flags = 0;
@@ -512,6 +512,7 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
                                                                 &dt_pcr_layout,
                                                                 name,
                                                                 parent_name,
+                                                                NULL,
                                                                 id, &range,
                                                                 INT_MIN,
                                                                 flags);
index c09abb8ff8fef1f1e3ce9b31f4411be6e5c44f66..6866e810352b9ca919bbb19360451ffce64fd162 100644 (file)
@@ -199,11 +199,13 @@ at91_clk_sama7g5_register_master(struct regmap *regmap,
 
 struct clk_hw * __init
 at91_clk_register_peripheral(struct regmap *regmap, const char *name,
-                            const char *parent_name, u32 id);
+                            const char *parent_name, struct clk_hw *parent_hw,
+                            u32 id);
 struct clk_hw * __init
 at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
                                    const struct clk_pcr_layout *layout,
                                    const char *name, const char *parent_name,
+                                   struct clk_hw *parent_hw,
                                    u32 id, const struct clk_range *range,
                                    int chg_pid, unsigned long flags);
 
index 3ff1eb3bee816acddf3dc010531bb74d1146e3a1..71fa8cb86a9d267fb121cbbcad132e193dd7a15c 100644 (file)
@@ -337,7 +337,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                         &sam9x60_pcr_layout,
                                                         sam9x60_periphck[i].n,
-                                                        "masterck_div",
+                                                        "masterck_div", NULL,
                                                         sam9x60_periphck[i].id,
                                                         &range, INT_MIN,
                                                         sam9x60_periphck[i].flags);
index c47d43a7e95be38eb448f4725ab457f8fd96c782..944e1fec8ad2b0db145f96b865a740d8a523b551 100644 (file)
@@ -324,7 +324,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                         &sama5d2_pcr_layout,
                                                         sama5d2_periphck[i].n,
-                                                        "masterck_div",
+                                                        "masterck_div", NULL,
                                                         sama5d2_periphck[i].id,
                                                         &range, INT_MIN,
                                                         sama5d2_periphck[i].flags);
@@ -338,7 +338,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                         &sama5d2_pcr_layout,
                                                         sama5d2_periph32ck[i].n,
-                                                        "h32mxck",
+                                                        "h32mxck", NULL,
                                                         sama5d2_periph32ck[i].id,
                                                         &sama5d2_periph32ck[i].r,
                                                         INT_MIN, 0);
index d605a540b30f57aab6b9b6b5087e4bbffb0838df..f61bef0838c9b064566bf9d4d23aea88e46a75fa 100644 (file)
@@ -244,7 +244,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                         &sama5d3_pcr_layout,
                                                         sama5d3_periphck[i].n,
-                                                        "masterck_div",
+                                                        "masterck_div", NULL,
                                                         sama5d3_periphck[i].id,
                                                         &sama5d3_periphck[i].r,
                                                         INT_MIN,
index 21a61840d5f30158d66a63cbd1601c636821777d..f0bf2096f66658998c42a17089e015399dc35f17 100644 (file)
@@ -267,7 +267,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                         &sama5d4_pcr_layout,
                                                         sama5d4_periphck[i].n,
-                                                        "masterck_div",
+                                                        "masterck_div", NULL,
                                                         sama5d4_periphck[i].id,
                                                         &range, INT_MIN,
                                                         sama5d4_periphck[i].flags);
@@ -281,7 +281,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                         &sama5d4_pcr_layout,
                                                         sama5d4_periph32ck[i].n,
-                                                        "h32mxck",
+                                                        "h32mxck", NULL,
                                                         sama5d4_periph32ck[i].id,
                                                         &range, INT_MIN, 0);
                if (IS_ERR(hw))
index 989d66f5370e069feb3c25fdeb6c995fe97a5011..c913c1c7a9f9d20b34edea7b094c6329f2080ba5 100644 (file)
@@ -1079,7 +1079,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
                hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
                                                &sama7g5_pcr_layout,
                                                sama7g5_periphck[i].n,
-                                               sama7g5_periphck[i].p,
+                                               sama7g5_periphck[i].p, NULL,
                                                sama7g5_periphck[i].id,
                                                &sama7g5_periphck[i].r,
                                                sama7g5_periphck[i].chgp ? 0 :