Skip to content

Commit dec15c9

Browse files
digetxthierryreding
authored andcommitted
clk: tegra: cclk: Add helpers for handling PLLX rate changes
CCLK should be re-parented away from PLLX if PLLX's rate is changing. The PLLP parent is a common safe CPU parent for all Tegra SoCs, thus CCLK will be re-parented to PLLP before PLLX rate-change begins and then switched back to PLLX after the rate-change completion. This patch adds helper functions which perform CCLK re-parenting, these helpers will be utilized by further patches. 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 9157abe commit dec15c9

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

drivers/clk/tegra/clk-tegra-super-cclk.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
#define SUPER_CDIV_ENB BIT(31)
2727

28+
static struct tegra_clk_super_mux *cclk_super;
29+
static bool cclk_on_pllx;
30+
2831
static u8 cclk_super_get_parent(struct clk_hw *hw)
2932
{
3033
return tegra_clk_super_ops.get_parent(hw);
@@ -115,6 +118,9 @@ struct clk *tegra_clk_register_super_cclk(const char *name,
115118
struct clk_init_data init;
116119
u32 val;
117120

121+
if (WARN_ON(cclk_super))
122+
return ERR_PTR(-EBUSY);
123+
118124
super = kzalloc(sizeof(*super), GFP_KERNEL);
119125
if (!super)
120126
return ERR_PTR(-ENOMEM);
@@ -173,6 +179,34 @@ struct clk *tegra_clk_register_super_cclk(const char *name,
173179
clk = clk_register(NULL, &super->hw);
174180
if (IS_ERR(clk))
175181
kfree(super);
182+
else
183+
cclk_super = super;
176184

177185
return clk;
178186
}
187+
188+
int tegra_cclk_pre_pllx_rate_change(void)
189+
{
190+
if (IS_ERR_OR_NULL(cclk_super))
191+
return -EINVAL;
192+
193+
if (cclk_super_get_parent(&cclk_super->hw) == PLLX_INDEX)
194+
cclk_on_pllx = true;
195+
else
196+
cclk_on_pllx = false;
197+
198+
/*
199+
* CPU needs to be temporarily re-parented away from PLLX if PLLX
200+
* changes its rate. PLLP is a safe parent for CPU on all Tegra SoCs.
201+
*/
202+
if (cclk_on_pllx)
203+
cclk_super_set_parent(&cclk_super->hw, PLLP_INDEX);
204+
205+
return 0;
206+
}
207+
208+
void tegra_cclk_post_pllx_rate_change(void)
209+
{
210+
if (cclk_on_pllx)
211+
cclk_super_set_parent(&cclk_super->hw, PLLX_INDEX);
212+
}

drivers/clk/tegra/clk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ struct clk *tegra_clk_register_super_cclk(const char *name,
771771
const char * const *parent_names, u8 num_parents,
772772
unsigned long flags, void __iomem *reg, u8 clk_super_flags,
773773
spinlock_t *lock);
774+
int tegra_cclk_pre_pllx_rate_change(void);
775+
void tegra_cclk_post_pllx_rate_change(void);
774776

775777
/**
776778
* struct tegra_sdmmc_mux - switch divider with Low Jitter inputs for SDMMC

0 commit comments

Comments
 (0)