Skip to content

Commit b739073

Browse files
claudiubezneageertu
authored andcommitted
clk: renesas: rzg2l-cpg: Move PM domain power on in rzg2l_cpg_pd_setup()
Move the PM domain power on in rzg2l_cpg_pd_setup(). With this the previously always-on power domains got struct generic_pm_domain::{power_on, power_off} populated (and registered with simple_qos_governor if #power-domain-cells = <1> and with pm_domain_always_on_gov if #power-domain-cells = <0>). The values for struct generic_pm_domain::{power_on, power_off} are now populated for all registered domains but used by core only for the domains that can use them (the PM domain should be non always-on and registered with simple_qos_governor). Moreover, the power on/off functions check if the mstop support is valid. The mstop is populated only by the RZ/G3S initialization code at the moment. This approach was chosen to keep the code simple and use the same code across different implementations. There should be no issues with this approach as the always on domains are registered with GENPD_FLAG_ALWAYS_ON and the PM domain core takes care of it. This approach allows doing further cleanups on the rzg2l_cpg power domain registering code that will be handled by the next commit. Signed-off-by: Claudiu Beznea <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Ulf Hansson <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 92850be commit b739073

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

drivers/clk/renesas/rzg2l-cpg.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,23 +1680,31 @@ static int rzg2l_cpg_power_off(struct generic_pm_domain *domain)
16801680
return 0;
16811681
}
16821682

1683-
static int __init rzg2l_cpg_pd_setup(struct rzg2l_cpg_pd *pd, bool always_on)
1683+
static int __init rzg2l_cpg_pd_setup(struct rzg2l_cpg_pd *pd)
16841684
{
1685+
bool always_on = !!(pd->genpd.flags & GENPD_FLAG_ALWAYS_ON);
16851686
struct dev_power_governor *governor;
1687+
int ret;
1688+
1689+
if (always_on)
1690+
governor = &pm_domain_always_on_gov;
1691+
else
1692+
governor = &simple_qos_governor;
16861693

16871694
pd->genpd.flags |= GENPD_FLAG_PM_CLK | GENPD_FLAG_ACTIVE_WAKEUP;
16881695
pd->genpd.attach_dev = rzg2l_cpg_attach_dev;
16891696
pd->genpd.detach_dev = rzg2l_cpg_detach_dev;
1690-
if (always_on) {
1691-
pd->genpd.flags |= GENPD_FLAG_ALWAYS_ON;
1692-
governor = &pm_domain_always_on_gov;
1693-
} else {
1694-
pd->genpd.power_on = rzg2l_cpg_power_on;
1695-
pd->genpd.power_off = rzg2l_cpg_power_off;
1696-
governor = &simple_qos_governor;
1697-
}
1697+
pd->genpd.power_on = rzg2l_cpg_power_on;
1698+
pd->genpd.power_off = rzg2l_cpg_power_off;
1699+
1700+
ret = pm_genpd_init(&pd->genpd, governor, !always_on);
1701+
if (ret)
1702+
return ret;
16981703

1699-
return pm_genpd_init(&pd->genpd, governor, !always_on);
1704+
if (always_on)
1705+
ret = rzg2l_cpg_power_on(&pd->genpd);
1706+
1707+
return ret;
17001708
}
17011709

17021710
static int __init rzg2l_cpg_add_clk_domain(struct rzg2l_cpg_priv *priv)
@@ -1711,8 +1719,9 @@ static int __init rzg2l_cpg_add_clk_domain(struct rzg2l_cpg_priv *priv)
17111719
return -ENOMEM;
17121720

17131721
pd->genpd.name = np->name;
1722+
pd->genpd.flags = GENPD_FLAG_ALWAYS_ON;
17141723
pd->priv = priv;
1715-
ret = rzg2l_cpg_pd_setup(pd, true);
1724+
ret = rzg2l_cpg_pd_setup(pd);
17161725
if (ret)
17171726
return ret;
17181727

@@ -1785,20 +1794,16 @@ static int __init rzg2l_cpg_add_pm_domains(struct rzg2l_cpg_priv *priv)
17851794
return -ENOMEM;
17861795

17871796
pd->genpd.name = info->pm_domains[i].name;
1797+
if (always_on)
1798+
pd->genpd.flags = GENPD_FLAG_ALWAYS_ON;
17881799
pd->conf = info->pm_domains[i].conf;
17891800
pd->id = info->pm_domains[i].id;
17901801
pd->priv = priv;
17911802

1792-
ret = rzg2l_cpg_pd_setup(pd, always_on);
1803+
ret = rzg2l_cpg_pd_setup(pd);
17931804
if (ret)
17941805
return ret;
17951806

1796-
if (always_on) {
1797-
ret = rzg2l_cpg_power_on(&pd->genpd);
1798-
if (ret)
1799-
return ret;
1800-
}
1801-
18021807
domains->domains[i] = &pd->genpd;
18031808
/* Parent should be on the very first entry of info->pm_domains[]. */
18041809
if (!i) {

0 commit comments

Comments
 (0)