Commit 2fa9fd69 authored by Biju Das's avatar Biju Das Committed by Geert Uytterhoeven

clk: renesas: rzg2l: Add multi clock PM support

Add multi clock PM support for cpg driver.
Signed-off-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/20210626081344.5783-2-biju.das.jz@bp.renesas.comSigned-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
parent e73f0f0e
...@@ -594,42 +594,49 @@ static int rzg2l_cpg_attach_dev(struct generic_pm_domain *unused, struct device ...@@ -594,42 +594,49 @@ static int rzg2l_cpg_attach_dev(struct generic_pm_domain *unused, struct device
{ {
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct of_phandle_args clkspec; struct of_phandle_args clkspec;
bool once = true;
struct clk *clk; struct clk *clk;
int error; int error;
int i = 0; int i = 0;
while (!of_parse_phandle_with_args(np, "clocks", "#clock-cells", i, while (!of_parse_phandle_with_args(np, "clocks", "#clock-cells", i,
&clkspec)) { &clkspec)) {
if (rzg2l_cpg_is_pm_clk(&clkspec)) if (rzg2l_cpg_is_pm_clk(&clkspec)) {
goto found; if (once) {
once = false;
error = pm_clk_create(dev);
if (error) {
of_node_put(clkspec.np); of_node_put(clkspec.np);
i++; goto err;
}
} }
return 0;
found:
clk = of_clk_get_from_provider(&clkspec); clk = of_clk_get_from_provider(&clkspec);
of_node_put(clkspec.np); of_node_put(clkspec.np);
if (IS_ERR(clk)) {
if (IS_ERR(clk)) error = PTR_ERR(clk);
return PTR_ERR(clk); goto fail_destroy;
}
error = pm_clk_create(dev);
if (error)
goto fail_put;
error = pm_clk_add_clk(dev, clk); error = pm_clk_add_clk(dev, clk);
if (error) if (error) {
goto fail_destroy; dev_err(dev, "pm_clk_add_clk failed %d\n",
error);
goto fail_put;
}
} else {
of_node_put(clkspec.np);
}
i++;
}
return 0; return 0;
fail_destroy:
pm_clk_destroy(dev);
fail_put: fail_put:
clk_put(clk); clk_put(clk);
fail_destroy:
pm_clk_destroy(dev);
err:
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment