Skip to content

Commit 9157abe

Browse files
digetxthierryreding
authored andcommitted
clk: tegra: pll: Add pre/post rate-change hooks
There is a need to temporarily re-parent CCLK away from PLLX if PLLX's rate is about to change. The newly introduced PLL pre/post rate-change hooks allow to handle such case. Acked-by: Peter De Schrijver <[email protected]> Tested-by: Peter Geis <[email protected]> Tested-by: Marcel Ziswiler <[email protected]> Tested-by: Jasper Korten <[email protected]> Tested-by: David Heidelberg <[email protected]> Tested-by: Nicolas Chauvet <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 1641567 commit 9157abe

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

drivers/clk/tegra/clk-pll.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,19 @@ static int _program_pll(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg,
744744

745745
state = clk_pll_is_enabled(hw);
746746

747+
if (state && pll->params->pre_rate_change) {
748+
ret = pll->params->pre_rate_change();
749+
if (WARN_ON(ret))
750+
return ret;
751+
}
752+
747753
_get_pll_mnp(pll, &old_cfg);
748754

749755
if (state && pll->params->defaults_set && pll->params->dyn_ramp &&
750756
(cfg->m == old_cfg.m) && (cfg->p == old_cfg.p)) {
751757
ret = pll->params->dyn_ramp(pll, cfg);
752758
if (!ret)
753-
return 0;
759+
goto done;
754760
}
755761

756762
if (state) {
@@ -772,6 +778,10 @@ static int _program_pll(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg,
772778
pll_clk_start_ss(pll);
773779
}
774780

781+
done:
782+
if (state && pll->params->post_rate_change)
783+
pll->params->post_rate_change();
784+
775785
return ret;
776786
}
777787

drivers/clk/tegra/clk.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ struct tegra_clk_pll;
266266
* disabled.
267267
* @dyn_ramp: Callback which can be used to define a custom
268268
* dynamic ramp function for a given PLL.
269+
* @pre_rate_change: Callback which is invoked just before changing
270+
* PLL's rate.
271+
* @post_rate_change: Callback which is invoked right after changing
272+
* PLL's rate.
269273
*
270274
* Flags:
271275
* TEGRA_PLL_USE_LOCK - This flag indicated to use lock bits for
@@ -342,6 +346,8 @@ struct tegra_clk_pll_params {
342346
void (*set_defaults)(struct tegra_clk_pll *pll);
343347
int (*dyn_ramp)(struct tegra_clk_pll *pll,
344348
struct tegra_clk_pll_freq_table *cfg);
349+
int (*pre_rate_change)(void);
350+
void (*post_rate_change)(void);
345351
};
346352

347353
#define TEGRA_PLL_USE_LOCK BIT(0)

0 commit comments

Comments
 (0)