Commit e2d17960 authored by Jon Hunter's avatar Jon Hunter Committed by Thierry Reding

soc/tegra: pmc: Initialise power partitions early

If CONFIG_PM_GENERIC_DOMAINS is not enabled, then power partitions
associated with a device will not be enabled automatically by the PM
core when the device is in use. To avoid situations where a device in
a power partition is to be used but the partition is not enabled,
initialise the power partitions for Tegra early in the boot process and
if CONFIG_PM_GENERIC_DOMAINS is not enabled, then power on all
partitions defined in the device-tree blob.

Note that if CONFIG_PM_GENERIC_DOMAINS is not enabled, after the
partitions are turned on, the clocks and resets used as part of the
sequence for turning on the partition are released again as they are no
longer needed by the PMC driver. Another benefit of this is that this
avoids any issues of sharing resets between the PMC driver and other
device drivers that may wish to independently control a particular
reset.
Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent c2710ac9
...@@ -834,6 +834,9 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np) ...@@ -834,6 +834,9 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np)
goto remove_clks; goto remove_clks;
} }
if (!IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS))
goto power_on_cleanup;
pm_genpd_init(&pg->genpd, NULL, off); pm_genpd_init(&pg->genpd, NULL, off);
err = of_genpd_add_provider_simple(np, &pg->genpd); err = of_genpd_add_provider_simple(np, &pg->genpd);
...@@ -847,6 +850,10 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np) ...@@ -847,6 +850,10 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np)
return; return;
power_on_cleanup:
if (off)
WARN_ON(tegra_powergate_power_up(pg, true));
remove_resets: remove_resets:
while (pg->num_resets--) while (pg->num_resets--)
reset_control_put(pg->resets[pg->num_resets]); reset_control_put(pg->resets[pg->num_resets]);
...@@ -866,11 +873,18 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np) ...@@ -866,11 +873,18 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np)
kfree(pg); kfree(pg);
} }
static void tegra_powergate_init(struct tegra_pmc *pmc) static void tegra_powergate_init(struct tegra_pmc *pmc,
struct device_node *parent)
{ {
struct device_node *np, *child; struct device_node *np, *child;
unsigned int i;
np = of_get_child_by_name(pmc->dev->of_node, "powergates"); /* Create a bitmap of the available and valid partitions */
for (i = 0; i < pmc->soc->num_powergates; i++)
if (pmc->soc->powergates[i])
set_bit(i, pmc->powergates_available);
np = of_get_child_by_name(parent, "powergates");
if (!np) if (!np)
return; return;
...@@ -1291,8 +1305,6 @@ static int tegra_pmc_probe(struct platform_device *pdev) ...@@ -1291,8 +1305,6 @@ static int tegra_pmc_probe(struct platform_device *pdev)
return err; return err;
} }
tegra_powergate_init(pmc);
mutex_lock(&pmc->powergates_lock); mutex_lock(&pmc->powergates_lock);
iounmap(pmc->base); iounmap(pmc->base);
pmc->base = base; pmc->base = base;
...@@ -1526,7 +1538,6 @@ static int __init tegra_pmc_early_init(void) ...@@ -1526,7 +1538,6 @@ static int __init tegra_pmc_early_init(void)
const struct of_device_id *match; const struct of_device_id *match;
struct device_node *np; struct device_node *np;
struct resource regs; struct resource regs;
unsigned int i;
bool invert; bool invert;
u32 value; u32 value;
...@@ -1581,10 +1592,7 @@ static int __init tegra_pmc_early_init(void) ...@@ -1581,10 +1592,7 @@ static int __init tegra_pmc_early_init(void)
if (np) { if (np) {
pmc->soc = match->data; pmc->soc = match->data;
/* Create a bit-map of the available and valid partitions */ tegra_powergate_init(pmc, np);
for (i = 0; i < pmc->soc->num_powergates; i++)
if (pmc->soc->powergates[i])
set_bit(i, pmc->powergates_available);
/* /*
* Invert the interrupt polarity if a PMC device tree node * Invert the interrupt polarity if a PMC device tree node
......
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