Skip to content

Commit b5105e3

Browse files
committed
clk: at91: clk-main: add support for parent_data/parent_hw
Add support for parent_data and parent_hw in main oscillator clock drivers. With this parent-child relations are described with pointers rather than strings making registration a bit faster. All the SoC based drivers that rely on clk-main 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-2-claudiu.beznea@microchip.com
1 parent 9a7b010 commit b5105e3

14 files changed

Lines changed: 52 additions & 37 deletions

drivers/clk/at91/at91rm9200.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
108108

109109
bypass = of_property_read_bool(np, "atmel,osc-bypass");
110110

111-
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
111+
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
112112
bypass);
113113
if (IS_ERR(hw))
114114
goto err_free;
115115

116-
hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc");
116+
hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc", NULL);
117117
if (IS_ERR(hw))
118118
goto err_free;
119119

drivers/clk/at91/at91sam9260.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,12 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
363363

364364
bypass = of_property_read_bool(np, "atmel,osc-bypass");
365365

366-
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
366+
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
367367
bypass);
368368
if (IS_ERR(hw))
369369
goto err_free;
370370

371-
hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc");
371+
hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc", NULL);
372372
if (IS_ERR(hw))
373373
goto err_free;
374374

drivers/clk/at91/at91sam9g45.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
123123

124124
bypass = of_property_read_bool(np, "atmel,osc-bypass");
125125

126-
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
126+
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
127127
bypass);
128128
if (IS_ERR(hw))
129129
goto err_free;
130130

131-
hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc");
131+
hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc", NULL);
132132
if (IS_ERR(hw))
133133
goto err_free;
134134

drivers/clk/at91/at91sam9n12.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
147147

148148
bypass = of_property_read_bool(np, "atmel,osc-bypass");
149149

150-
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
150+
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
151151
bypass);
152152
if (IS_ERR(hw))
153153
goto err_free;
154154

155155
parent_names[0] = "main_rc_osc";
156156
parent_names[1] = "main_osc";
157-
hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
157+
hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
158158
if (IS_ERR(hw))
159159
goto err_free;
160160

drivers/clk/at91/at91sam9rl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
9595
if (!at91sam9rl_pmc)
9696
return;
9797

98-
hw = at91_clk_register_rm9200_main(regmap, "mainck", mainxtal_name);
98+
hw = at91_clk_register_rm9200_main(regmap, "mainck", mainxtal_name, NULL);
9999
if (IS_ERR(hw))
100100
goto err_free;
101101

drivers/clk/at91/at91sam9x5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
169169

170170
bypass = of_property_read_bool(np, "atmel,osc-bypass");
171171

172-
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
172+
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
173173
bypass);
174174
if (IS_ERR(hw))
175175
goto err_free;
176176

177177
parent_names[0] = "main_rc_osc";
178178
parent_names[1] = "main_osc";
179-
hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
179+
hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
180180
if (IS_ERR(hw))
181181
goto err_free;
182182

drivers/clk/at91/clk-main.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,15 @@ struct clk_hw * __init
152152
at91_clk_register_main_osc(struct regmap *regmap,
153153
const char *name,
154154
const char *parent_name,
155+
struct clk_parent_data *parent_data,
155156
bool bypass)
156157
{
157158
struct clk_main_osc *osc;
158-
struct clk_init_data init;
159+
struct clk_init_data init = {};
159160
struct clk_hw *hw;
160161
int ret;
161162

162-
if (!name || !parent_name)
163+
if (!name || !(parent_name || parent_data))
163164
return ERR_PTR(-EINVAL);
164165

165166
osc = kzalloc(sizeof(*osc), GFP_KERNEL);
@@ -168,7 +169,10 @@ at91_clk_register_main_osc(struct regmap *regmap,
168169

169170
init.name = name;
170171
init.ops = &main_osc_ops;
171-
init.parent_names = &parent_name;
172+
if (parent_data)
173+
init.parent_data = (const struct clk_parent_data *)parent_data;
174+
else
175+
init.parent_names = &parent_name;
172176
init.num_parents = 1;
173177
init.flags = CLK_IGNORE_UNUSED;
174178

@@ -397,17 +401,18 @@ static const struct clk_ops rm9200_main_ops = {
397401
struct clk_hw * __init
398402
at91_clk_register_rm9200_main(struct regmap *regmap,
399403
const char *name,
400-
const char *parent_name)
404+
const char *parent_name,
405+
struct clk_hw *parent_hw)
401406
{
402407
struct clk_rm9200_main *clkmain;
403-
struct clk_init_data init;
408+
struct clk_init_data init = {};
404409
struct clk_hw *hw;
405410
int ret;
406411

407412
if (!name)
408413
return ERR_PTR(-EINVAL);
409414

410-
if (!parent_name)
415+
if (!(parent_name || parent_hw))
411416
return ERR_PTR(-EINVAL);
412417

413418
clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL);
@@ -416,7 +421,10 @@ at91_clk_register_rm9200_main(struct regmap *regmap,
416421

417422
init.name = name;
418423
init.ops = &rm9200_main_ops;
419-
init.parent_names = &parent_name;
424+
if (parent_hw)
425+
init.parent_hws = (const struct clk_hw **)&parent_hw;
426+
else
427+
init.parent_names = &parent_name;
420428
init.num_parents = 1;
421429
init.flags = 0;
422430

@@ -543,18 +551,19 @@ struct clk_hw * __init
543551
at91_clk_register_sam9x5_main(struct regmap *regmap,
544552
const char *name,
545553
const char **parent_names,
554+
struct clk_hw **parent_hws,
546555
int num_parents)
547556
{
548557
struct clk_sam9x5_main *clkmain;
549-
struct clk_init_data init;
558+
struct clk_init_data init = {};
550559
unsigned int status;
551560
struct clk_hw *hw;
552561
int ret;
553562

554563
if (!name)
555564
return ERR_PTR(-EINVAL);
556565

557-
if (!parent_names || !num_parents)
566+
if (!(parent_hws || parent_names) || !num_parents)
558567
return ERR_PTR(-EINVAL);
559568

560569
clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL);
@@ -563,7 +572,10 @@ at91_clk_register_sam9x5_main(struct regmap *regmap,
563572

564573
init.name = name;
565574
init.ops = &sam9x5_main_ops;
566-
init.parent_names = parent_names;
575+
if (parent_hws)
576+
init.parent_hws = (const struct clk_hw **)parent_hws;
577+
else
578+
init.parent_names = parent_names;
567579
init.num_parents = num_parents;
568580
init.flags = CLK_SET_PARENT_GATE;
569581

drivers/clk/at91/dt-compat.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
269269
if (IS_ERR(regmap))
270270
return;
271271

272-
hw = at91_clk_register_main_osc(regmap, name, parent_name, bypass);
272+
hw = at91_clk_register_main_osc(regmap, name, parent_name, NULL, bypass);
273273
if (IS_ERR(hw))
274274
return;
275275

@@ -323,7 +323,7 @@ static void __init of_at91rm9200_clk_main_setup(struct device_node *np)
323323
if (IS_ERR(regmap))
324324
return;
325325

326-
hw = at91_clk_register_rm9200_main(regmap, name, parent_name);
326+
hw = at91_clk_register_rm9200_main(regmap, name, parent_name, NULL);
327327
if (IS_ERR(hw))
328328
return;
329329

@@ -354,7 +354,7 @@ static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
354354

355355
of_property_read_string(np, "clock-output-names", &name);
356356

357-
hw = at91_clk_register_sam9x5_main(regmap, name, parent_names,
357+
hw = at91_clk_register_sam9x5_main(regmap, name, parent_names, NULL,
358358
num_parents);
359359
if (IS_ERR(hw))
360360
return;

drivers/clk/at91/pmc.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,17 @@ at91_clk_register_main_rc_osc(struct regmap *regmap, const char *name,
161161
u32 frequency, u32 accuracy);
162162
struct clk_hw * __init
163163
at91_clk_register_main_osc(struct regmap *regmap, const char *name,
164-
const char *parent_name, bool bypass);
164+
const char *parent_name,
165+
struct clk_parent_data *parent_data, bool bypass);
165166
struct clk_hw * __init
166167
at91_clk_register_rm9200_main(struct regmap *regmap,
167168
const char *name,
168-
const char *parent_name);
169+
const char *parent_name,
170+
struct clk_hw *parent_hw);
169171
struct clk_hw * __init
170172
at91_clk_register_sam9x5_main(struct regmap *regmap, const char *name,
171-
const char **parent_names, int num_parents);
173+
const char **parent_names,
174+
struct clk_hw **parent_hws, int num_parents);
172175

173176
struct clk_hw * __init
174177
at91_clk_register_master_pres(struct regmap *regmap, const char *name,

drivers/clk/at91/sam9x60.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
219219
if (IS_ERR(hw))
220220
goto err_free;
221221

222-
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, 0);
222+
hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL, 0);
223223
if (IS_ERR(hw))
224224
goto err_free;
225225
main_osc_hw = hw;
226226

227227
parent_names[0] = "main_rc_osc";
228228
parent_names[1] = "main_osc";
229-
hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
229+
hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, NULL, 2);
230230
if (IS_ERR(hw))
231231
goto err_free;
232232

0 commit comments

Comments
 (0)