Skip to content

Commit 5bf194a

Browse files
varshini-rajendranclaudiubeznea
authored andcommitted
clk: at91: sama7g5: move mux table macros to header file
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 <[email protected]> Reviewed-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Claudiu Beznea <[email protected]>
1 parent 5299f80 commit 5bf194a

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

drivers/clk/at91/pmc.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,22 @@ struct at91_clk_pms {
121121

122122
#define ndck(a, s) (a[s - 1].id + 1)
123123
#define nck(a) (a[ARRAY_SIZE(a) - 1].id + 1)
124+
125+
#define PMC_INIT_TABLE(_table, _count) \
126+
do { \
127+
u8 _i; \
128+
for (_i = 0; _i < (_count); _i++) \
129+
(_table)[_i] = _i; \
130+
} while (0)
131+
132+
#define PMC_FILL_TABLE(_to, _from, _count) \
133+
do { \
134+
u8 _i; \
135+
for (_i = 0; _i < (_count); _i++) { \
136+
(_to)[_i] = (_from)[_i]; \
137+
} \
138+
} while (0)
139+
124140
struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem,
125141
unsigned int nperiph, unsigned int ngck,
126142
unsigned int npck);

drivers/clk/at91/sama7g5.c

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@
1616

1717
#include "pmc.h"
1818

19-
#define SAMA7G5_INIT_TABLE(_table, _count) \
20-
do { \
21-
u8 _i; \
22-
for (_i = 0; _i < (_count); _i++) \
23-
(_table)[_i] = _i; \
24-
} while (0)
25-
26-
#define SAMA7G5_FILL_TABLE(_to, _from, _count) \
27-
do { \
28-
u8 _i; \
29-
for (_i = 0; _i < (_count); _i++) { \
30-
(_to)[_i] = (_from)[_i]; \
31-
} \
32-
} while (0)
33-
3419
static DEFINE_SPINLOCK(pmc_pll_lock);
3520
static DEFINE_SPINLOCK(pmc_mck0_lock);
3621
static DEFINE_SPINLOCK(pmc_mckX_lock);
@@ -1119,17 +1104,17 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
11191104
if (!mux_table)
11201105
goto err_free;
11211106

1122-
SAMA7G5_INIT_TABLE(mux_table, 3);
1123-
SAMA7G5_FILL_TABLE(&mux_table[3], sama7g5_mckx[i].ep_mux_table,
1124-
sama7g5_mckx[i].ep_count);
1107+
PMC_INIT_TABLE(mux_table, 3);
1108+
PMC_FILL_TABLE(&mux_table[3], sama7g5_mckx[i].ep_mux_table,
1109+
sama7g5_mckx[i].ep_count);
11251110
for (j = 0; j < sama7g5_mckx[i].ep_count; j++) {
11261111
u8 pll_id = sama7g5_mckx[i].ep[j].pll_id;
11271112
u8 pll_compid = sama7g5_mckx[i].ep[j].pll_compid;
11281113

11291114
tmp_parent_hws[j] = sama7g5_plls[pll_id][pll_compid].hw;
11301115
}
1131-
SAMA7G5_FILL_TABLE(&parent_hws[3], tmp_parent_hws,
1132-
sama7g5_mckx[i].ep_count);
1116+
PMC_FILL_TABLE(&parent_hws[3], tmp_parent_hws,
1117+
sama7g5_mckx[i].ep_count);
11331118

11341119
hw = at91_clk_sama7g5_register_master(regmap, sama7g5_mckx[i].n,
11351120
num_parents, NULL, parent_hws, mux_table,
@@ -1215,17 +1200,17 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
12151200
if (!mux_table)
12161201
goto err_free;
12171202

1218-
SAMA7G5_INIT_TABLE(mux_table, 3);
1219-
SAMA7G5_FILL_TABLE(&mux_table[3], sama7g5_gck[i].pp_mux_table,
1220-
sama7g5_gck[i].pp_count);
1203+
PMC_INIT_TABLE(mux_table, 3);
1204+
PMC_FILL_TABLE(&mux_table[3], sama7g5_gck[i].pp_mux_table,
1205+
sama7g5_gck[i].pp_count);
12211206
for (j = 0; j < sama7g5_gck[i].pp_count; j++) {
12221207
u8 pll_id = sama7g5_gck[i].pp[j].pll_id;
12231208
u8 pll_compid = sama7g5_gck[i].pp[j].pll_compid;
12241209

12251210
tmp_parent_hws[j] = sama7g5_plls[pll_id][pll_compid].hw;
12261211
}
1227-
SAMA7G5_FILL_TABLE(&parent_hws[3], tmp_parent_hws,
1228-
sama7g5_gck[i].pp_count);
1212+
PMC_FILL_TABLE(&parent_hws[3], tmp_parent_hws,
1213+
sama7g5_gck[i].pp_count);
12291214

12301215
hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
12311216
&sama7g5_pcr_layout,

0 commit comments

Comments
 (0)