Commit 8efc9b19 authored by Ulf Hansson's avatar Ulf Hansson
Browse files

soc/tegra: pmc: Opt-out from genpd's common ->sync_state() support



Tegra implements its own specific ->sync_state() callback for the genpd
providers. Let's set the GENPD_FLAG_NO_SYNC_STATE to inform genpd about it.

Moreover, let's call of_genpd_sync_state() to make sure genpd tries to
power off unused PM domains.

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Tested-by: Hiago De Franco <hiago.franco@toradex.com> # Colibri iMX8X
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> # TI AM62A,Xilinx ZynqMP ZCU106
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250701114733.636510-10-ulf.hansson@linaro.org
parent c8c19622
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -418,7 +418,6 @@ struct tegra_pmc_soc {
 * @irq: chip implementation for the IRQ domain
 * @clk_nb: pclk clock changes handler
 * @core_domain_state_synced: flag marking the core domain's state as synced
 * @core_domain_registered: flag marking the core domain as registered
 * @wake_type_level_map: Bitmap indicating level type for non-dual edge wakes
 * @wake_type_dual_edge_map: Bitmap indicating if a wake is dual-edge or not
 * @wake_sw_status_map: Bitmap to hold raw status of wakes without mask
@@ -462,7 +461,6 @@ struct tegra_pmc {
	struct notifier_block clk_nb;

	bool core_domain_state_synced;
	bool core_domain_registered;

	unsigned long *wake_type_level_map;
	unsigned long *wake_type_dual_edge_map;
@@ -1297,6 +1295,7 @@ static int tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np)

	pg->id = id;
	pg->genpd.name = np->name;
	pg->genpd.flags = GENPD_FLAG_NO_SYNC_STATE;
	pg->genpd.power_off = tegra_genpd_power_off;
	pg->genpd.power_on = tegra_genpd_power_on;
	pg->pmc = pmc;
@@ -1406,6 +1405,7 @@ static int tegra_pmc_core_pd_add(struct tegra_pmc *pmc, struct device_node *np)
		return -ENOMEM;

	genpd->name = "core";
	genpd->flags = GENPD_FLAG_NO_SYNC_STATE;
	genpd->set_performance_state = tegra_pmc_core_pd_set_performance_state;

	err = devm_pm_opp_set_regulators(pmc->dev, rname);
@@ -1425,8 +1425,6 @@ static int tegra_pmc_core_pd_add(struct tegra_pmc *pmc, struct device_node *np)
		goto remove_genpd;
	}

	pmc->core_domain_registered = true;

	return 0;

remove_genpd:
@@ -4263,8 +4261,25 @@ static const struct of_device_id tegra_pmc_match[] = {

static void tegra_pmc_sync_state(struct device *dev)
{
	struct device_node *np, *child;
	int err;

	np = of_get_child_by_name(dev->of_node, "powergates");
	if (!np)
		return;

	for_each_child_of_node(np, child)
		of_genpd_sync_state(child);

	of_node_put(np);

	np = of_get_child_by_name(dev->of_node, "core-domain");
	if (!np)
		return;

	of_genpd_sync_state(np);
	of_node_put(np);

	/*
	 * Newer device-trees have power domains, but we need to prepare all
	 * device drivers with runtime PM and OPP support first, otherwise
@@ -4278,9 +4293,6 @@ static void tegra_pmc_sync_state(struct device *dev)
	 * no dependencies that will block the state syncing. We shouldn't
	 * mark the domain as synced in this case.
	 */
	if (!pmc->core_domain_registered)
		return;

	pmc->core_domain_state_synced = true;

	/* this is a no-op if core regulator isn't used */