]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
clk: at91: sama7g5: move mux table macros to header file
authorVarshini Rajendran <varshini.rajendran@microchip.com>
Mon, 29 Jul 2024 07:07:53 +0000 (12:37 +0530)
committerClaudiu Beznea <claudiu.beznea@tuxon.dev>
Wed, 7 Aug 2024 16:16:47 +0000 (19:16 +0300)
Move the mux table init and fill macro function definitions from the
sama7g5 pmc driver to the pmc.h header file since they will be used
by other SoC's pmc drivers as well like sam9x7.

Signed-off-by: Varshini Rajendran <varshini.rajendran@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Link: https://lore.kernel.org/r/20240729070753.1990866-1-varshini.rajendran@microchip.com
Signed-off-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
drivers/clk/at91/pmc.h
drivers/clk/at91/sama7g5.c

index 91d1c6305d95cfb013f513c3df6440341aee7b7e..4fb29ca111f7d4272aa6df7e1518daad758f2f02 100644 (file)
@@ -121,6 +121,22 @@ struct at91_clk_pms {
 
 #define ndck(a, s) (a[s - 1].id + 1)
 #define nck(a) (a[ARRAY_SIZE(a) - 1].id + 1)
+
+#define PMC_INIT_TABLE(_table, _count)                 \
+       do {                                            \
+               u8 _i;                                  \
+               for (_i = 0; _i < (_count); _i++)       \
+                       (_table)[_i] = _i;              \
+       } while (0)
+
+#define PMC_FILL_TABLE(_to, _from, _count)             \
+       do {                                            \
+               u8 _i;                                  \
+               for (_i = 0; _i < (_count); _i++) {     \
+                       (_to)[_i] = (_from)[_i];        \
+               }                                       \
+       } while (0)
+
 struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem,
                                   unsigned int nperiph, unsigned int ngck,
                                   unsigned int npck);
index e6eb5afba93d55b0559fc2bdc26350c3317ba729..6706d1305baaa557d112f228fcdbb171b8e4778a 100644 (file)
 
 #include "pmc.h"
 
-#define SAMA7G5_INIT_TABLE(_table, _count)             \
-       do {                                            \
-               u8 _i;                                  \
-               for (_i = 0; _i < (_count); _i++)       \
-                       (_table)[_i] = _i;              \
-       } while (0)
-
-#define SAMA7G5_FILL_TABLE(_to, _from, _count)         \
-       do {                                            \
-               u8 _i;                                  \
-               for (_i = 0; _i < (_count); _i++) {     \
-                       (_to)[_i] = (_from)[_i];        \
-               }                                       \
-       } while (0)
-
 static DEFINE_SPINLOCK(pmc_pll_lock);
 static DEFINE_SPINLOCK(pmc_mck0_lock);
 static DEFINE_SPINLOCK(pmc_mckX_lock);
@@ -1119,17 +1104,17 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
                if (!mux_table)
                        goto err_free;
 
-               SAMA7G5_INIT_TABLE(mux_table, 3);
-               SAMA7G5_FILL_TABLE(&mux_table[3], sama7g5_mckx[i].ep_mux_table,
-                                  sama7g5_mckx[i].ep_count);
+               PMC_INIT_TABLE(mux_table, 3);
+               PMC_FILL_TABLE(&mux_table[3], sama7g5_mckx[i].ep_mux_table,
+                              sama7g5_mckx[i].ep_count);
                for (j = 0; j < sama7g5_mckx[i].ep_count; j++) {
                        u8 pll_id = sama7g5_mckx[i].ep[j].pll_id;
                        u8 pll_compid = sama7g5_mckx[i].ep[j].pll_compid;
 
                        tmp_parent_hws[j] = sama7g5_plls[pll_id][pll_compid].hw;
                }
-               SAMA7G5_FILL_TABLE(&parent_hws[3], tmp_parent_hws,
-                                  sama7g5_mckx[i].ep_count);
+               PMC_FILL_TABLE(&parent_hws[3], tmp_parent_hws,
+                              sama7g5_mckx[i].ep_count);
 
                hw = at91_clk_sama7g5_register_master(regmap, sama7g5_mckx[i].n,
                                   num_parents, NULL, parent_hws, mux_table,
@@ -1215,17 +1200,17 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
                if (!mux_table)
                        goto err_free;
 
-               SAMA7G5_INIT_TABLE(mux_table, 3);
-               SAMA7G5_FILL_TABLE(&mux_table[3], sama7g5_gck[i].pp_mux_table,
-                                  sama7g5_gck[i].pp_count);
+               PMC_INIT_TABLE(mux_table, 3);
+               PMC_FILL_TABLE(&mux_table[3], sama7g5_gck[i].pp_mux_table,
+                              sama7g5_gck[i].pp_count);
                for (j = 0; j < sama7g5_gck[i].pp_count; j++) {
                        u8 pll_id = sama7g5_gck[i].pp[j].pll_id;
                        u8 pll_compid = sama7g5_gck[i].pp[j].pll_compid;
 
                        tmp_parent_hws[j] = sama7g5_plls[pll_id][pll_compid].hw;
                }
-               SAMA7G5_FILL_TABLE(&parent_hws[3], tmp_parent_hws,
-                                  sama7g5_gck[i].pp_count);
+               PMC_FILL_TABLE(&parent_hws[3], tmp_parent_hws,
+                              sama7g5_gck[i].pp_count);
 
                hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
                                                 &sama7g5_pcr_layout,