Skip to content

Commit c2f2ca0

Browse files
committed
clk: at91: clk-peripheral: add support for parent_hw
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
1 parent 171e502 commit c2f2ca0

14 files changed

Lines changed: 34 additions & 23 deletions

drivers/clk/at91/at91rm9200.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
193193
for (i = 0; i < ARRAY_SIZE(at91rm9200_periphck); i++) {
194194
hw = at91_clk_register_peripheral(regmap,
195195
at91rm9200_periphck[i].n,
196-
"masterck_div",
196+
"masterck_div", NULL,
197197
at91rm9200_periphck[i].id);
198198
if (IS_ERR(hw))
199199
goto err_free;

drivers/clk/at91/at91sam9260.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
470470
for (i = 0; i < data->num_pck; i++) {
471471
hw = at91_clk_register_peripheral(regmap,
472472
data->pck[i].n,
473-
"masterck_div",
473+
"masterck_div", NULL,
474474
data->pck[i].id);
475475
if (IS_ERR(hw))
476476
goto err_free;

drivers/clk/at91/at91sam9g45.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
214214
for (i = 0; i < ARRAY_SIZE(at91sam9g45_periphck); i++) {
215215
hw = at91_clk_register_peripheral(regmap,
216216
at91sam9g45_periphck[i].n,
217-
"masterck_div",
217+
"masterck_div", NULL,
218218
at91sam9g45_periphck[i].id);
219219
if (IS_ERR(hw))
220220
goto err_free;

drivers/clk/at91/at91sam9n12.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
240240
hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
241241
&at91sam9n12_pcr_layout,
242242
at91sam9n12_periphck[i].n,
243-
"masterck_div",
243+
"masterck_div", NULL,
244244
at91sam9n12_periphck[i].id,
245245
&range, INT_MIN, 0);
246246
if (IS_ERR(hw))

drivers/clk/at91/at91sam9rl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
170170
for (i = 0; i < ARRAY_SIZE(at91sam9rl_periphck); i++) {
171171
hw = at91_clk_register_peripheral(regmap,
172172
at91sam9rl_periphck[i].n,
173-
"masterck_div",
173+
"masterck_div", NULL,
174174
at91sam9rl_periphck[i].id);
175175
if (IS_ERR(hw))
176176
goto err_free;

drivers/clk/at91/at91sam9x5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
274274
hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
275275
&at91sam9x5_pcr_layout,
276276
at91sam9x5_periphck[i].n,
277-
"masterck_div",
277+
"masterck_div", NULL,
278278
at91sam9x5_periphck[i].id,
279279
&range, INT_MIN, 0);
280280
if (IS_ERR(hw))
@@ -287,7 +287,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
287287
hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
288288
&at91sam9x5_pcr_layout,
289289
extra_pcks[i].n,
290-
"masterck_div",
290+
"masterck_div", NULL,
291291
extra_pcks[i].id,
292292
&range, INT_MIN, 0);
293293
if (IS_ERR(hw))

drivers/clk/at91/clk-peripheral.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ static const struct clk_ops peripheral_ops = {
9797

9898
struct clk_hw * __init
9999
at91_clk_register_peripheral(struct regmap *regmap, const char *name,
100-
const char *parent_name, u32 id)
100+
const char *parent_name, struct clk_hw *parent_hw,
101+
u32 id)
101102
{
102103
struct clk_peripheral *periph;
103-
struct clk_init_data init;
104+
struct clk_init_data init = {};
104105
struct clk_hw *hw;
105106
int ret;
106107

107-
if (!name || !parent_name || id > PERIPHERAL_ID_MAX)
108+
if (!name || !(parent_name || parent_hw) || id > PERIPHERAL_ID_MAX)
108109
return ERR_PTR(-EINVAL);
109110

110111
periph = kzalloc(sizeof(*periph), GFP_KERNEL);
@@ -113,7 +114,10 @@ at91_clk_register_peripheral(struct regmap *regmap, const char *name,
113114

114115
init.name = name;
115116
init.ops = &peripheral_ops;
116-
init.parent_names = &parent_name;
117+
if (parent_hw)
118+
init.parent_hws = (const struct clk_hw **)&parent_hw;
119+
else
120+
init.parent_names = &parent_name;
117121
init.num_parents = 1;
118122
init.flags = 0;
119123

@@ -444,23 +448,27 @@ struct clk_hw * __init
444448
at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
445449
const struct clk_pcr_layout *layout,
446450
const char *name, const char *parent_name,
451+
struct clk_hw *parent_hw,
447452
u32 id, const struct clk_range *range,
448453
int chg_pid, unsigned long flags)
449454
{
450455
struct clk_sam9x5_peripheral *periph;
451-
struct clk_init_data init;
456+
struct clk_init_data init = {};
452457
struct clk_hw *hw;
453458
int ret;
454459

455-
if (!name || !parent_name)
460+
if (!name || !(parent_name || parent_hw))
456461
return ERR_PTR(-EINVAL);
457462

458463
periph = kzalloc(sizeof(*periph), GFP_KERNEL);
459464
if (!periph)
460465
return ERR_PTR(-ENOMEM);
461466

462467
init.name = name;
463-
init.parent_names = &parent_name;
468+
if (parent_hw)
469+
init.parent_hws = (const struct clk_hw **)&parent_hw;
470+
else
471+
init.parent_names = &parent_name;
464472
init.num_parents = 1;
465473
init.flags = flags;
466474
if (chg_pid < 0) {

drivers/clk/at91/dt-compat.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
490490

491491
if (type == PERIPHERAL_AT91RM9200) {
492492
hw = at91_clk_register_peripheral(regmap, name,
493-
parent_name, id);
493+
parent_name, NULL, id);
494494
} else {
495495
struct clk_range range = CLK_RANGE(0, 0);
496496
unsigned long flags = 0;
@@ -512,6 +512,7 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
512512
&dt_pcr_layout,
513513
name,
514514
parent_name,
515+
NULL,
515516
id, &range,
516517
INT_MIN,
517518
flags);

drivers/clk/at91/pmc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,13 @@ at91_clk_sama7g5_register_master(struct regmap *regmap,
199199

200200
struct clk_hw * __init
201201
at91_clk_register_peripheral(struct regmap *regmap, const char *name,
202-
const char *parent_name, u32 id);
202+
const char *parent_name, struct clk_hw *parent_hw,
203+
u32 id);
203204
struct clk_hw * __init
204205
at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
205206
const struct clk_pcr_layout *layout,
206207
const char *name, const char *parent_name,
208+
struct clk_hw *parent_hw,
207209
u32 id, const struct clk_range *range,
208210
int chg_pid, unsigned long flags);
209211

drivers/clk/at91/sam9x60.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
337337
hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
338338
&sam9x60_pcr_layout,
339339
sam9x60_periphck[i].n,
340-
"masterck_div",
340+
"masterck_div", NULL,
341341
sam9x60_periphck[i].id,
342342
&range, INT_MIN,
343343
sam9x60_periphck[i].flags);

0 commit comments

Comments
 (0)