Skip to content

Commit 077782e

Browse files
committed
clk: at91: clk-utmi: add support for parent_hw
Add support for parent_hw in utmi 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-utmi 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-8-claudiu.beznea@microchip.com
1 parent 1a537f6 commit 077782e

10 files changed

Lines changed: 28 additions & 17 deletions

File tree

drivers/clk/at91/at91sam9g45.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
145145

146146
at91sam9g45_pmc->chws[PMC_PLLACK] = hw;
147147

148-
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
148+
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
149149
if (IS_ERR(hw))
150150
goto err_free;
151151

drivers/clk/at91/at91sam9rl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
109109

110110
at91sam9rl_pmc->chws[PMC_PLLACK] = hw;
111111

112-
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
112+
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
113113
if (IS_ERR(hw))
114114
goto err_free;
115115

drivers/clk/at91/at91sam9x5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
193193

194194
at91sam9x5_pmc->chws[PMC_PLLACK] = hw;
195195

196-
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
196+
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
197197
if (IS_ERR(hw))
198198
goto err_free;
199199

drivers/clk/at91/clk-utmi.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,30 @@ static struct clk_hw * __init
144144
at91_clk_register_utmi_internal(struct regmap *regmap_pmc,
145145
struct regmap *regmap_sfr,
146146
const char *name, const char *parent_name,
147+
struct clk_hw *parent_hw,
147148
const struct clk_ops *ops, unsigned long flags)
148149
{
149150
struct clk_utmi *utmi;
150151
struct clk_hw *hw;
151-
struct clk_init_data init;
152+
struct clk_init_data init = {};
152153
int ret;
153154

155+
if (!(parent_name || parent_hw))
156+
return ERR_PTR(-EINVAL);
157+
154158
utmi = kzalloc(sizeof(*utmi), GFP_KERNEL);
155159
if (!utmi)
156160
return ERR_PTR(-ENOMEM);
157161

158162
init.name = name;
159163
init.ops = ops;
160-
init.parent_names = parent_name ? &parent_name : NULL;
161-
init.num_parents = parent_name ? 1 : 0;
164+
if (parent_hw) {
165+
init.parent_hws = parent_hw ? (const struct clk_hw **)&parent_hw : NULL;
166+
init.num_parents = parent_hw ? 1 : 0;
167+
} else {
168+
init.parent_names = parent_name ? &parent_name : NULL;
169+
init.num_parents = parent_name ? 1 : 0;
170+
}
162171
init.flags = flags;
163172

164173
utmi->hw.init = &init;
@@ -177,10 +186,11 @@ at91_clk_register_utmi_internal(struct regmap *regmap_pmc,
177186

178187
struct clk_hw * __init
179188
at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr,
180-
const char *name, const char *parent_name)
189+
const char *name, const char *parent_name,
190+
struct clk_hw *parent_hw)
181191
{
182192
return at91_clk_register_utmi_internal(regmap_pmc, regmap_sfr, name,
183-
parent_name, &utmi_ops, CLK_SET_RATE_GATE);
193+
parent_name, parent_hw, &utmi_ops, CLK_SET_RATE_GATE);
184194
}
185195

186196
static int clk_utmi_sama7g5_prepare(struct clk_hw *hw)
@@ -279,8 +289,8 @@ static const struct clk_ops sama7g5_utmi_ops = {
279289

280290
struct clk_hw * __init
281291
at91_clk_sama7g5_register_utmi(struct regmap *regmap_pmc, const char *name,
282-
const char *parent_name)
292+
const char *parent_name, struct clk_hw *parent_hw)
283293
{
284294
return at91_clk_register_utmi_internal(regmap_pmc, NULL, name,
285-
parent_name, &sama7g5_utmi_ops, 0);
295+
parent_name, parent_hw, &sama7g5_utmi_ops, 0);
286296
}

drivers/clk/at91/dt-compat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
10551055
regmap_sfr = NULL;
10561056
}
10571057

1058-
hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name);
1058+
hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name, NULL);
10591059
if (IS_ERR(hw))
10601060
return;
10611061

drivers/clk/at91/pmc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,11 @@ at91rm9200_clk_register_usb(struct regmap *regmap, const char *name,
269269

270270
struct clk_hw * __init
271271
at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr,
272-
const char *name, const char *parent_name);
272+
const char *name, const char *parent_name,
273+
struct clk_hw *parent_hw);
273274

274275
struct clk_hw * __init
275276
at91_clk_sama7g5_register_utmi(struct regmap *regmap, const char *name,
276-
const char *parent_name);
277+
const char *parent_name, struct clk_hw *parent_hw);
277278

278279
#endif /* __PMC_H_ */

drivers/clk/at91/sama5d2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
249249
if (IS_ERR(regmap_sfr))
250250
regmap_sfr = NULL;
251251

252-
hw = at91_clk_register_utmi(regmap, regmap_sfr, "utmick", "mainck");
252+
hw = at91_clk_register_utmi(regmap, regmap_sfr, "utmick", "mainck", NULL);
253253
if (IS_ERR(hw))
254254
goto err_free;
255255

drivers/clk/at91/sama5d3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np)
172172

173173
sama5d3_pmc->chws[PMC_PLLACK] = hw;
174174

175-
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
175+
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
176176
if (IS_ERR(hw))
177177
goto err_free;
178178

drivers/clk/at91/sama5d4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
187187

188188
sama5d4_pmc->chws[PMC_PLLACK] = hw;
189189

190-
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
190+
hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
191191
if (IS_ERR(hw))
192192
goto err_free;
193193

drivers/clk/at91/sama7g5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
10351035
sama7g5_pmc->chws[sama7g5_mckx[i].eid] = hw;
10361036
}
10371037

1038-
hw = at91_clk_sama7g5_register_utmi(regmap, "utmick", "main_xtal");
1038+
hw = at91_clk_sama7g5_register_utmi(regmap, "utmick", "main_xtal", NULL);
10391039
if (IS_ERR(hw))
10401040
goto err_free;
10411041

0 commit comments

Comments
 (0)