Skip to content

Commit 171e502

Browse files
committed
clk: at91: clk-master: add support for parent_hw
Add support for parent_hw in master 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-master 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-4-claudiu.beznea@microchip.com
1 parent 00bd581 commit 171e502

14 files changed

Lines changed: 47 additions & 35 deletions

drivers/clk/at91/at91rm9200.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
140140
parent_names[2] = "pllack";
141141
parent_names[3] = "pllbck";
142142
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 4,
143-
parent_names,
143+
parent_names, NULL,
144144
&at91rm9200_master_layout,
145145
&rm9200_mck_characteristics,
146146
&rm9200_mck_lock);
147147
if (IS_ERR(hw))
148148
goto err_free;
149149

150150
hw = at91_clk_register_master_div(regmap, "masterck_div",
151-
"masterck_pres",
151+
"masterck_pres", NULL,
152152
&at91rm9200_master_layout,
153153
&rm9200_mck_characteristics,
154154
&rm9200_mck_lock, CLK_SET_RATE_GATE, 0);

drivers/clk/at91/at91sam9260.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,15 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
416416
parent_names[2] = "pllack";
417417
parent_names[3] = "pllbck";
418418
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 4,
419-
parent_names,
419+
parent_names, NULL,
420420
&at91rm9200_master_layout,
421421
data->mck_characteristics,
422422
&at91sam9260_mck_lock);
423423
if (IS_ERR(hw))
424424
goto err_free;
425425

426426
hw = at91_clk_register_master_div(regmap, "masterck_div",
427-
"masterck_pres",
427+
"masterck_pres", NULL,
428428
&at91rm9200_master_layout,
429429
data->mck_characteristics,
430430
&at91sam9260_mck_lock,

drivers/clk/at91/at91sam9g45.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
156156
parent_names[2] = "plladivck";
157157
parent_names[3] = "utmick";
158158
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 4,
159-
parent_names,
159+
parent_names, NULL,
160160
&at91rm9200_master_layout,
161161
&mck_characteristics,
162162
&at91sam9g45_mck_lock);
163163
if (IS_ERR(hw))
164164
goto err_free;
165165

166166
hw = at91_clk_register_master_div(regmap, "masterck_div",
167-
"masterck_pres",
167+
"masterck_pres", NULL,
168168
&at91rm9200_master_layout,
169169
&mck_characteristics,
170170
&at91sam9g45_mck_lock,

drivers/clk/at91/at91sam9n12.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
183183
parent_names[2] = "plladivck";
184184
parent_names[3] = "pllbck";
185185
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 4,
186-
parent_names,
186+
parent_names, NULL,
187187
&at91sam9x5_master_layout,
188188
&mck_characteristics,
189189
&at91sam9n12_mck_lock);
190190
if (IS_ERR(hw))
191191
goto err_free;
192192

193193
hw = at91_clk_register_master_div(regmap, "masterck_div",
194-
"masterck_pres",
194+
"masterck_pres", NULL,
195195
&at91sam9x5_master_layout,
196196
&mck_characteristics,
197197
&at91sam9n12_mck_lock,

drivers/clk/at91/at91sam9rl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
120120
parent_names[2] = "pllack";
121121
parent_names[3] = "utmick";
122122
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 4,
123-
parent_names,
123+
parent_names, NULL,
124124
&at91rm9200_master_layout,
125125
&sam9rl_mck_characteristics,
126126
&sam9rl_mck_lock);
127127
if (IS_ERR(hw))
128128
goto err_free;
129129

130130
hw = at91_clk_register_master_div(regmap, "masterck_div",
131-
"masterck_pres",
131+
"masterck_pres", NULL,
132132
&at91rm9200_master_layout,
133133
&sam9rl_mck_characteristics,
134134
&sam9rl_mck_lock, CLK_SET_RATE_GATE, 0);

drivers/clk/at91/at91sam9x5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
204204
parent_names[2] = "plladivck";
205205
parent_names[3] = "utmick";
206206
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 4,
207-
parent_names,
207+
parent_names, NULL,
208208
&at91sam9x5_master_layout,
209209
&mck_characteristics, &mck_lock);
210210
if (IS_ERR(hw))
211211
goto err_free;
212212

213213
hw = at91_clk_register_master_div(regmap, "masterck_div",
214-
"masterck_pres",
214+
"masterck_pres", NULL,
215215
&at91sam9x5_master_layout,
216216
&mck_characteristics, &mck_lock,
217217
CLK_SET_RATE_GATE, 0);

drivers/clk/at91/clk-master.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -473,18 +473,19 @@ static struct clk_hw * __init
473473
at91_clk_register_master_internal(struct regmap *regmap,
474474
const char *name, int num_parents,
475475
const char **parent_names,
476+
struct clk_hw **parent_hws,
476477
const struct clk_master_layout *layout,
477478
const struct clk_master_characteristics *characteristics,
478479
const struct clk_ops *ops, spinlock_t *lock, u32 flags)
479480
{
480481
struct clk_master *master;
481-
struct clk_init_data init;
482+
struct clk_init_data init = {};
482483
struct clk_hw *hw;
483484
unsigned int mckr;
484485
unsigned long irqflags;
485486
int ret;
486487

487-
if (!name || !num_parents || !parent_names || !lock)
488+
if (!name || !num_parents || !(parent_names || parent_hws) || !lock)
488489
return ERR_PTR(-EINVAL);
489490

490491
master = kzalloc(sizeof(*master), GFP_KERNEL);
@@ -493,7 +494,10 @@ at91_clk_register_master_internal(struct regmap *regmap,
493494

494495
init.name = name;
495496
init.ops = ops;
496-
init.parent_names = parent_names;
497+
if (parent_hws)
498+
init.parent_hws = (const struct clk_hw **)parent_hws;
499+
else
500+
init.parent_names = parent_names;
497501
init.num_parents = num_parents;
498502
init.flags = flags;
499503

@@ -527,12 +531,13 @@ struct clk_hw * __init
527531
at91_clk_register_master_pres(struct regmap *regmap,
528532
const char *name, int num_parents,
529533
const char **parent_names,
534+
struct clk_hw **parent_hws,
530535
const struct clk_master_layout *layout,
531536
const struct clk_master_characteristics *characteristics,
532537
spinlock_t *lock)
533538
{
534539
return at91_clk_register_master_internal(regmap, name, num_parents,
535-
parent_names, layout,
540+
parent_names, parent_hws, layout,
536541
characteristics,
537542
&master_pres_ops,
538543
lock, CLK_SET_RATE_GATE);
@@ -541,7 +546,7 @@ at91_clk_register_master_pres(struct regmap *regmap,
541546
struct clk_hw * __init
542547
at91_clk_register_master_div(struct regmap *regmap,
543548
const char *name, const char *parent_name,
544-
const struct clk_master_layout *layout,
549+
struct clk_hw *parent_hw, const struct clk_master_layout *layout,
545550
const struct clk_master_characteristics *characteristics,
546551
spinlock_t *lock, u32 flags, u32 safe_div)
547552
{
@@ -554,7 +559,8 @@ at91_clk_register_master_div(struct regmap *regmap,
554559
ops = &master_div_ops_chg;
555560

556561
hw = at91_clk_register_master_internal(regmap, name, 1,
557-
&parent_name, layout,
562+
parent_name ? &parent_name : NULL,
563+
parent_hw ? &parent_hw : NULL, layout,
558564
characteristics, ops,
559565
lock, flags);
560566

@@ -806,18 +812,19 @@ struct clk_hw * __init
806812
at91_clk_sama7g5_register_master(struct regmap *regmap,
807813
const char *name, int num_parents,
808814
const char **parent_names,
815+
struct clk_hw **parent_hws,
809816
u32 *mux_table,
810817
spinlock_t *lock, u8 id,
811818
bool critical, int chg_pid)
812819
{
813820
struct clk_master *master;
814821
struct clk_hw *hw;
815-
struct clk_init_data init;
822+
struct clk_init_data init = {};
816823
unsigned long flags;
817824
unsigned int val;
818825
int ret;
819826

820-
if (!name || !num_parents || !parent_names || !mux_table ||
827+
if (!name || !num_parents || !(parent_names || parent_hws) || !mux_table ||
821828
!lock || id > MASTER_MAX_ID)
822829
return ERR_PTR(-EINVAL);
823830

@@ -827,7 +834,10 @@ at91_clk_sama7g5_register_master(struct regmap *regmap,
827834

828835
init.name = name;
829836
init.ops = &sama7g5_master_ops;
830-
init.parent_names = parent_names;
837+
if (parent_hws)
838+
init.parent_hws = (const struct clk_hw **)parent_hws;
839+
else
840+
init.parent_names = parent_names;
831841
init.num_parents = num_parents;
832842
init.flags = CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE;
833843
if (chg_pid >= 0)

drivers/clk/at91/dt-compat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,12 @@ of_at91_clk_master_setup(struct device_node *np,
420420
return;
421421

422422
hw = at91_clk_register_master_pres(regmap, "masterck_pres", num_parents,
423-
parent_names, layout,
423+
parent_names, NULL, layout,
424424
characteristics, &mck_lock);
425425
if (IS_ERR(hw))
426426
goto out_free_characteristics;
427427

428-
hw = at91_clk_register_master_div(regmap, name, "masterck_pres",
428+
hw = at91_clk_register_master_div(regmap, name, "masterck_pres", NULL,
429429
layout, characteristics,
430430
&mck_lock, CLK_SET_RATE_GATE, 0);
431431
if (IS_ERR(hw))

drivers/clk/at91/pmc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,23 @@ at91_clk_register_sam9x5_main(struct regmap *regmap, const char *name,
177177
struct clk_hw * __init
178178
at91_clk_register_master_pres(struct regmap *regmap, const char *name,
179179
int num_parents, const char **parent_names,
180+
struct clk_hw **parent_hws,
180181
const struct clk_master_layout *layout,
181182
const struct clk_master_characteristics *characteristics,
182183
spinlock_t *lock);
183184

184185
struct clk_hw * __init
185186
at91_clk_register_master_div(struct regmap *regmap, const char *name,
186-
const char *parent_names,
187+
const char *parent_names, struct clk_hw *parent_hw,
187188
const struct clk_master_layout *layout,
188189
const struct clk_master_characteristics *characteristics,
189190
spinlock_t *lock, u32 flags, u32 safe_div);
190191

191192
struct clk_hw * __init
192193
at91_clk_sama7g5_register_master(struct regmap *regmap,
193194
const char *name, int num_parents,
194-
const char **parent_names, u32 *mux_table,
195+
const char **parent_names,
196+
struct clk_hw **parent_hws, u32 *mux_table,
195197
spinlock_t *lock, u8 id, bool critical,
196198
int chg_pid);
197199

drivers/clk/at91/sam9x60.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,13 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
280280
parent_names[1] = "mainck";
281281
parent_names[2] = "pllack_divck";
282282
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 3,
283-
parent_names, &sam9x60_master_layout,
283+
parent_names, NULL, &sam9x60_master_layout,
284284
&mck_characteristics, &mck_lock);
285285
if (IS_ERR(hw))
286286
goto err_free;
287287

288288
hw = at91_clk_register_master_div(regmap, "masterck_div",
289-
"masterck_pres", &sam9x60_master_layout,
289+
"masterck_pres", NULL, &sam9x60_master_layout,
290290
&mck_characteristics, &mck_lock,
291291
CLK_SET_RATE_GATE, 0);
292292
if (IS_ERR(hw))

0 commit comments

Comments
 (0)