Re: [PATCH V5 11/14] soc: tegra: pmc: Add generic PM domain support
From: Kevin Hilman <khilman@baylibre.com>
Date: 2016-02-12 23:14:04
Also in:
linux-arm-kernel, linux-pm, linux-tegra
Ulf Hansson [off-list ref] writes:
On 28 January 2016 at 17:33, Jon Hunter [off-list ref] wrote:quoted
Adds generic PM support to the PMC driver where the PM domains are populated from device-tree and the PM domain consumer devices are bound to their relevant PM domains via device-tree as well. Update the tegra_powergate_sequence_power_up() API so that internally it calls the same tegra_powergate_xxx functions that are used by the tegra generic power domain code for consistency. This is based upon work by Thierry Reding [off-list ref] and Vince Hsu [off-list ref]. Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
[...]
quoted
+static void tegra_powergate_disable_clocks(struct tegra_powergate *pg) +{ + unsigned int i; + + for (i = 0; i < pg->num_clks; i++) + clk_disable_unprepare(pg->clks[i]); +} + +static int tegra_powergate_enable_clocks(struct tegra_powergate *pg) +{ + unsigned int i; + int err; + + for (i = 0; i < pg->num_clks; i++) { + err = clk_prepare_enable(pg->clks[i]); + if (err) + goto out; + } + + return 0; + +out: + while (i--) + clk_disable_unprepare(pg->clks[i]); + + return err; +}I have seen similar code around in other PM domains, dealing with enabling/disabling a *list* of clocks. Perhaps we should invent a new clock API that helps with this to prevents code duplication!?
What about the pm_clk_* API which was built for tracking clocks associated with devices for runtime PM. IOW, you could pm_clk_add(pg->pmc->dev, pg->clks[i]) and then your _enable_clocks() would become pm_clk_suspend() an dyour _disable_clocks() would become pm_clk_resume(). I might not be following the mapping between PMC and PGs though so not sure pg->pmc->dev is the right struct device, but you get the idea. Kevin