Skip to content

Commit fa64023

Browse files
digetxbebarino
authored andcommitted
clk: tegra: pll: Improve PLLM enable-state detection
Power Management Controller (PMC) can override the PLLM clock settings, including the enable-state. Although PMC could only act as a second level gate, meaning that PLLM needs to be enabled by the Clock and Reset Controller (CaR) anyways if we want it to be enabled. Hence, when PLLM is overridden by PMC, it needs to be enabled by CaR and ungated by PMC in order to be functional. Please note that this patch doesn't fix any known problem, and thus, it's merely a minor improvement. Link: https://lore.kernel.org/linux-arm-kernel/20191210120909.GA2703785@ulmo/T/ Signed-off-by: Dmitry Osipenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jon Hunter <[email protected]> Tested-by: Jon Hunter <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent b3a9e3b commit fa64023

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

drivers/clk/tegra/clk-pll.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,26 @@ int tegra_pll_wait_for_lock(struct tegra_clk_pll *pll)
327327
return clk_pll_wait_for_lock(pll);
328328
}
329329

330+
static bool pllm_clk_is_gated_by_pmc(struct tegra_clk_pll *pll)
331+
{
332+
u32 val = readl_relaxed(pll->pmc + PMC_PLLP_WB0_OVERRIDE);
333+
334+
return (val & PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE) &&
335+
!(val & PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE);
336+
}
337+
330338
static int clk_pll_is_enabled(struct clk_hw *hw)
331339
{
332340
struct tegra_clk_pll *pll = to_clk_pll(hw);
333341
u32 val;
334342

335-
if (pll->params->flags & TEGRA_PLLM) {
336-
val = readl_relaxed(pll->pmc + PMC_PLLP_WB0_OVERRIDE);
337-
if (val & PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE)
338-
return val & PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE ? 1 : 0;
339-
}
343+
/*
344+
* Power Management Controller (PMC) can override the PLLM clock
345+
* settings, including the enable-state. The PLLM is enabled when
346+
* PLLM's CaR state is ON and when PLLM isn't gated by PMC.
347+
*/
348+
if ((pll->params->flags & TEGRA_PLLM) && pllm_clk_is_gated_by_pmc(pll))
349+
return 0;
340350

341351
val = pll_readl_base(pll);
342352

0 commit comments

Comments
 (0)