Skip to content

Commit 8c0e783

Browse files
Dinh Nguyenbebarino
authored andcommitted
clk: socfpga: stratix10: simplify parameter passing
Just pass the clock pointer structure to the various register functions. Signed-off-by: Dinh Nguyen <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent cc26ed7 commit 8c0e783

File tree

5 files changed

+57
-92
lines changed

5 files changed

+57
-92
lines changed

drivers/clk/socfpga/clk-gate-s10.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,54 +65,49 @@ static const struct clk_ops dbgclk_ops = {
6565
.get_parent = socfpga_gate_get_parent,
6666
};
6767

68-
struct clk *s10_register_gate(const char *name, const char *parent_name,
69-
const char * const *parent_names,
70-
u8 num_parents, unsigned long flags,
71-
void __iomem *regbase, unsigned long gate_reg,
72-
unsigned long gate_idx, unsigned long div_reg,
73-
unsigned long div_offset, u8 div_width,
74-
unsigned long bypass_reg, u8 bypass_shift,
75-
u8 fixed_div)
68+
struct clk *s10_register_gate(const struct stratix10_gate_clock *clks, void __iomem *regbase)
7669
{
7770
struct clk *clk;
7871
struct socfpga_gate_clk *socfpga_clk;
7972
struct clk_init_data init;
73+
const char * const *parent_names = clks->parent_names;
74+
const char *parent_name = clks->parent_name;
8075

8176
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
8277
if (!socfpga_clk)
8378
return NULL;
8479

85-
socfpga_clk->hw.reg = regbase + gate_reg;
86-
socfpga_clk->hw.bit_idx = gate_idx;
80+
socfpga_clk->hw.reg = regbase + clks->gate_reg;
81+
socfpga_clk->hw.bit_idx = clks->gate_idx;
8782

8883
gateclk_ops.enable = clk_gate_ops.enable;
8984
gateclk_ops.disable = clk_gate_ops.disable;
9085

91-
socfpga_clk->fixed_div = fixed_div;
86+
socfpga_clk->fixed_div = clks->fixed_div;
9287

93-
if (div_reg)
94-
socfpga_clk->div_reg = regbase + div_reg;
88+
if (clks->div_reg)
89+
socfpga_clk->div_reg = regbase + clks->div_reg;
9590
else
9691
socfpga_clk->div_reg = NULL;
9792

98-
socfpga_clk->width = div_width;
99-
socfpga_clk->shift = div_offset;
93+
socfpga_clk->width = clks->div_width;
94+
socfpga_clk->shift = clks->div_offset;
10095

101-
if (bypass_reg)
102-
socfpga_clk->bypass_reg = regbase + bypass_reg;
96+
if (clks->bypass_reg)
97+
socfpga_clk->bypass_reg = regbase + clks->bypass_reg;
10398
else
10499
socfpga_clk->bypass_reg = NULL;
105-
socfpga_clk->bypass_shift = bypass_shift;
100+
socfpga_clk->bypass_shift = clks->bypass_shift;
106101

107-
if (streq(name, "cs_pdbg_clk"))
102+
if (streq(clks->name, "cs_pdbg_clk"))
108103
init.ops = &dbgclk_ops;
109104
else
110105
init.ops = &gateclk_ops;
111106

112-
init.name = name;
113-
init.flags = flags;
107+
init.name = clks->name;
108+
init.flags = clks->flags;
114109

115-
init.num_parents = num_parents;
110+
init.num_parents = clks->num_parents;
116111
init.parent_names = parent_names ? parent_names : &parent_name;
117112
socfpga_clk->hw.hw.init = &init;
118113

@@ -121,6 +116,5 @@ struct clk *s10_register_gate(const char *name, const char *parent_name,
121116
kfree(socfpga_clk);
122117
return NULL;
123118
}
124-
125119
return clk;
126120
}

drivers/clk/socfpga/clk-periph-s10.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,27 @@ static const struct clk_ops peri_cnt_clk_ops = {
7373
.get_parent = clk_periclk_get_parent,
7474
};
7575

76-
struct clk *s10_register_periph(const char *name, const char *parent_name,
77-
const char * const *parent_names,
78-
u8 num_parents, unsigned long flags,
79-
void __iomem *reg, unsigned long offset)
76+
struct clk *s10_register_periph(const struct stratix10_perip_c_clock *clks,
77+
void __iomem *reg)
8078
{
8179
struct clk *clk;
8280
struct socfpga_periph_clk *periph_clk;
8381
struct clk_init_data init;
82+
const char *name = clks->name;
83+
const char *parent_name = clks->parent_name;
84+
const char * const *parent_names = clks->parent_names;
8485

8586
periph_clk = kzalloc(sizeof(*periph_clk), GFP_KERNEL);
8687
if (WARN_ON(!periph_clk))
8788
return NULL;
8889

89-
periph_clk->hw.reg = reg + offset;
90+
periph_clk->hw.reg = reg + clks->offset;
9091

9192
init.name = name;
9293
init.ops = &peri_c_clk_ops;
93-
init.flags = flags;
94+
init.flags = clks->flags;
9495

95-
init.num_parents = num_parents;
96+
init.num_parents = clks->num_parents;
9697
init.parent_names = parent_names ? parent_names : &parent_name;
9798

9899
periph_clk->hw.hw.init = &init;
@@ -105,38 +106,37 @@ struct clk *s10_register_periph(const char *name, const char *parent_name,
105106
return clk;
106107
}
107108

108-
struct clk *s10_register_cnt_periph(const char *name, const char *parent_name,
109-
const char * const *parent_names,
110-
u8 num_parents, unsigned long flags,
111-
void __iomem *regbase, unsigned long offset,
112-
u8 fixed_divider, unsigned long bypass_reg,
113-
unsigned long bypass_shift)
109+
struct clk *s10_register_cnt_periph(const struct stratix10_perip_cnt_clock *clks,
110+
void __iomem *regbase)
114111
{
115112
struct clk *clk;
116113
struct socfpga_periph_clk *periph_clk;
117114
struct clk_init_data init;
115+
const char *name = clks->name;
116+
const char *parent_name = clks->parent_name;
117+
const char * const *parent_names = clks->parent_names;
118118

119119
periph_clk = kzalloc(sizeof(*periph_clk), GFP_KERNEL);
120120
if (WARN_ON(!periph_clk))
121121
return NULL;
122122

123-
if (offset)
124-
periph_clk->hw.reg = regbase + offset;
123+
if (clks->offset)
124+
periph_clk->hw.reg = regbase + clks->offset;
125125
else
126126
periph_clk->hw.reg = NULL;
127127

128-
if (bypass_reg)
129-
periph_clk->bypass_reg = regbase + bypass_reg;
128+
if (clks->bypass_reg)
129+
periph_clk->bypass_reg = regbase + clks->bypass_reg;
130130
else
131131
periph_clk->bypass_reg = NULL;
132-
periph_clk->bypass_shift = bypass_shift;
133-
periph_clk->fixed_div = fixed_divider;
132+
periph_clk->bypass_shift = clks->bypass_shift;
133+
periph_clk->fixed_div = clks->fixed_divider;
134134

135135
init.name = name;
136136
init.ops = &peri_cnt_clk_ops;
137-
init.flags = flags;
137+
init.flags = clks->flags;
138138

139-
init.num_parents = num_parents;
139+
init.num_parents = clks->num_parents;
140140
init.parent_names = parent_names ? parent_names : &parent_name;
141141

142142
periph_clk->hw.hw.init = &init;

drivers/clk/socfpga/clk-pll-s10.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,29 +110,30 @@ static struct clk_ops clk_boot_ops = {
110110
.prepare = clk_pll_prepare,
111111
};
112112

113-
struct clk *s10_register_pll(const char *name, const char * const *parent_names,
114-
u8 num_parents, unsigned long flags,
115-
void __iomem *reg, unsigned long offset)
113+
struct clk *s10_register_pll(const struct stratix10_pll_clock *clks,
114+
void __iomem *reg)
116115
{
117116
struct clk *clk;
118117
struct socfpga_pll *pll_clk;
119118
struct clk_init_data init;
119+
const char *name = clks->name;
120+
const char * const *parent_names = clks->parent_names;
120121

121122
pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL);
122123
if (WARN_ON(!pll_clk))
123124
return NULL;
124125

125-
pll_clk->hw.reg = reg + offset;
126+
pll_clk->hw.reg = reg + clks->offset;
126127

127128
if (streq(name, SOCFPGA_BOOT_CLK))
128129
init.ops = &clk_boot_ops;
129130
else
130131
init.ops = &clk_pll_ops;
131132

132133
init.name = name;
133-
init.flags = flags;
134+
init.flags = clks->flags;
134135

135-
init.num_parents = num_parents;
136+
init.num_parents = clks->num_parents;
136137
init.parent_names = parent_names;
137138
pll_clk->hw.hw.init = &init;
138139

drivers/clk/socfpga/clk-s10.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ static int s10_clk_register_c_perip(const struct stratix10_perip_c_clock *clks,
177177
int i;
178178

179179
for (i = 0; i < nums; i++) {
180-
clk = s10_register_periph(clks[i].name, clks[i].parent_name,
181-
clks[i].parent_names, clks[i].num_parents,
182-
clks[i].flags, base, clks[i].offset);
180+
clk = s10_register_periph(&clks[i], base);
183181
if (IS_ERR(clk)) {
184182
pr_err("%s: failed to register clock %s\n",
185183
__func__, clks[i].name);
@@ -198,14 +196,7 @@ static int s10_clk_register_cnt_perip(const struct stratix10_perip_cnt_clock *cl
198196
int i;
199197

200198
for (i = 0; i < nums; i++) {
201-
clk = s10_register_cnt_periph(clks[i].name, clks[i].parent_name,
202-
clks[i].parent_names,
203-
clks[i].num_parents,
204-
clks[i].flags, base,
205-
clks[i].offset,
206-
clks[i].fixed_divider,
207-
clks[i].bypass_reg,
208-
clks[i].bypass_shift);
199+
clk = s10_register_cnt_periph(&clks[i], base);
209200
if (IS_ERR(clk)) {
210201
pr_err("%s: failed to register clock %s\n",
211202
__func__, clks[i].name);
@@ -225,16 +216,7 @@ static int s10_clk_register_gate(const struct stratix10_gate_clock *clks,
225216
int i;
226217

227218
for (i = 0; i < nums; i++) {
228-
clk = s10_register_gate(clks[i].name, clks[i].parent_name,
229-
clks[i].parent_names,
230-
clks[i].num_parents,
231-
clks[i].flags, base,
232-
clks[i].gate_reg,
233-
clks[i].gate_idx, clks[i].div_reg,
234-
clks[i].div_offset, clks[i].div_width,
235-
clks[i].bypass_reg,
236-
clks[i].bypass_shift,
237-
clks[i].fixed_div);
219+
clk = s10_register_gate(&clks[i], base);
238220
if (IS_ERR(clk)) {
239221
pr_err("%s: failed to register clock %s\n",
240222
__func__, clks[i].name);
@@ -254,10 +236,7 @@ static int s10_clk_register_pll(const struct stratix10_pll_clock *clks,
254236
int i;
255237

256238
for (i = 0; i < nums; i++) {
257-
clk = s10_register_pll(clks[i].name, clks[i].parent_names,
258-
clks[i].num_parents,
259-
clks[i].flags, base,
260-
clks[i].offset);
239+
clk = s10_register_pll(&clks[i], base);
261240
if (IS_ERR(clk)) {
262241
pr_err("%s: failed to register clock %s\n",
263242
__func__, clks[i].name);

drivers/clk/socfpga/stratix10-clk.h

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,12 @@ struct stratix10_gate_clock {
6060
u8 fixed_div;
6161
};
6262

63-
struct clk *s10_register_pll(const char *, const char *const *, u8,
64-
unsigned long, void __iomem *, unsigned long);
65-
66-
struct clk *s10_register_periph(const char *, const char *,
67-
const char * const *, u8, unsigned long,
68-
void __iomem *, unsigned long);
69-
struct clk *s10_register_cnt_periph(const char *, const char *,
70-
const char * const *, u8,
71-
unsigned long, void __iomem *,
72-
unsigned long, u8, unsigned long,
73-
unsigned long);
74-
struct clk *s10_register_gate(const char *, const char *,
75-
const char * const *, u8,
76-
unsigned long, void __iomem *,
77-
unsigned long, unsigned long,
78-
unsigned long, unsigned long, u8,
79-
unsigned long, u8, u8);
63+
struct clk *s10_register_pll(const struct stratix10_pll_clock *,
64+
void __iomem *);
65+
struct clk *s10_register_periph(const struct stratix10_perip_c_clock *,
66+
void __iomem *);
67+
struct clk *s10_register_cnt_periph(const struct stratix10_perip_cnt_clock *,
68+
void __iomem *);
69+
struct clk *s10_register_gate(const struct stratix10_gate_clock *,
70+
void __iomem *);
8071
#endif /* __STRATIX10_CLK_H */

0 commit comments

Comments
 (0)