Commit 077782e3 authored by Claudiu Beznea's avatar Claudiu Beznea
Browse files

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: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: default avatarMaxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20230615093227.576102-8-claudiu.beznea@microchip.com
parent 1a537f62
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)

	at91sam9g45_pmc->chws[PMC_PLLACK] = hw;

	hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
	hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
	if (IS_ERR(hw))
		goto err_free;

+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)

	at91sam9rl_pmc->chws[PMC_PLLACK] = hw;

	hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
	hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
	if (IS_ERR(hw))
		goto err_free;

+1 −1
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,

	at91sam9x5_pmc->chws[PMC_PLLACK] = hw;

	hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
	hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL);
	if (IS_ERR(hw))
		goto err_free;

+17 −7
Original line number Diff line number Diff line
@@ -144,21 +144,30 @@ static struct clk_hw * __init
at91_clk_register_utmi_internal(struct regmap *regmap_pmc,
				struct regmap *regmap_sfr,
				const char *name, const char *parent_name,
				struct clk_hw *parent_hw,
				const struct clk_ops *ops, unsigned long flags)
{
	struct clk_utmi *utmi;
	struct clk_hw *hw;
	struct clk_init_data init;
	struct clk_init_data init = {};
	int ret;

	if (!(parent_name || parent_hw))
		return ERR_PTR(-EINVAL);

	utmi = kzalloc(sizeof(*utmi), GFP_KERNEL);
	if (!utmi)
		return ERR_PTR(-ENOMEM);

	init.name = name;
	init.ops = ops;
	if (parent_hw) {
		init.parent_hws = parent_hw ? (const struct clk_hw **)&parent_hw : NULL;
		init.num_parents = parent_hw ? 1 : 0;
	} else {
		init.parent_names = parent_name ? &parent_name : NULL;
		init.num_parents = parent_name ? 1 : 0;
	}
	init.flags = flags;

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

struct clk_hw * __init
at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr,
		       const char *name, const char *parent_name)
		       const char *name, const char *parent_name,
		       struct clk_hw *parent_hw)
{
	return at91_clk_register_utmi_internal(regmap_pmc, regmap_sfr, name,
			parent_name, &utmi_ops, CLK_SET_RATE_GATE);
			parent_name, parent_hw, &utmi_ops, CLK_SET_RATE_GATE);
}

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

struct clk_hw * __init
at91_clk_sama7g5_register_utmi(struct regmap *regmap_pmc, const char *name,
			       const char *parent_name)
			       const char *parent_name, struct clk_hw *parent_hw)
{
	return at91_clk_register_utmi_internal(regmap_pmc, NULL, name,
			parent_name, &sama7g5_utmi_ops, 0);
			parent_name, parent_hw, &sama7g5_utmi_ops, 0);
}
+1 −1
Original line number Diff line number Diff line
@@ -1055,7 +1055,7 @@ static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
			regmap_sfr = NULL;
	}

	hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name);
	hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name, NULL);
	if (IS_ERR(hw))
		return;

Loading