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

soc/tegra: pmc: Fix early initialisation of PMC

During early initialisation, the available power partitions for a given
device is configured as well as the polarity of the PMC interrupt. Both
of which should only be configured if there is a valid device node for
the PMC device. This is because the soc data used for configuring the
power partitions is only available if a device node for the PMC is found
and the code to configure the interrupt polarity uses the device node
pointer directly.

Some early device-tree images may not have this device node and so fix
this by ensuring the device node pointer is valid when configuring these
items.
Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent 403db2d2
...@@ -1550,16 +1550,17 @@ static int __init tegra_pmc_early_init(void) ...@@ -1550,16 +1550,17 @@ static int __init tegra_pmc_early_init(void)
return -ENXIO; return -ENXIO;
} }
mutex_init(&pmc->powergates_lock);
if (np) {
/* Create a bit-map of the available and valid partitions */ /* Create a bit-map of the available and valid partitions */
for (i = 0; i < pmc->soc->num_powergates; i++) for (i = 0; i < pmc->soc->num_powergates; i++)
if (pmc->soc->powergates[i]) if (pmc->soc->powergates[i])
set_bit(i, pmc->powergates_available); set_bit(i, pmc->powergates_available);
mutex_init(&pmc->powergates_lock);
/* /*
* Invert the interrupt polarity if a PMC device tree node exists and * Invert the interrupt polarity if a PMC device tree node
* contains the nvidia,invert-interrupt property. * exists and contains the nvidia,invert-interrupt property.
*/ */
invert = of_property_read_bool(np, "nvidia,invert-interrupt"); invert = of_property_read_bool(np, "nvidia,invert-interrupt");
...@@ -1571,6 +1572,7 @@ static int __init tegra_pmc_early_init(void) ...@@ -1571,6 +1572,7 @@ static int __init tegra_pmc_early_init(void)
value &= ~PMC_CNTRL_INTR_POLARITY; value &= ~PMC_CNTRL_INTR_POLARITY;
tegra_pmc_writel(value, PMC_CNTRL); tegra_pmc_writel(value, PMC_CNTRL);
}
return 0; return 0;
} }
......
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