Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: pistachio: Lock the PLL when enabled upon rate change

Currently, when the rate is changed, the driver makes sure the
PLL is enabled before doing so. This is done because the PLL
cannot be locked while disabled. Once locked, the drivers
returns the PLL to its previous enable/disable state.

This is a bit cumbersome, and can be simplified.

This commit reworks the .set_rate() functions for the integer
and fractional PLLs. Upon rate change, the PLL is now locked
only if it's already enabled.

Also, the driver locks the PLL on .enable(). This makes sure
the PLL is locked when enabled, and not locked when disabled.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

authored by

Ezequiel Garcia and committed by
Stephen Boyd
e0b7a795 4f4adfbf

+10 -18
+10 -18
drivers/clk/pistachio/clk-pll.c
··· 130 130 val &= ~PLL_FRAC_CTRL4_BYPASS; 131 131 pll_writel(pll, val, PLL_CTRL4); 132 132 133 + pll_lock(pll); 134 + 133 135 return 0; 134 136 } 135 137 ··· 157 155 { 158 156 struct pistachio_clk_pll *pll = to_pistachio_pll(hw); 159 157 struct pistachio_pll_rate_table *params; 160 - bool was_enabled; 158 + int enabled = pll_gf40lp_frac_is_enabled(hw); 161 159 u32 val; 162 160 163 161 params = pll_get_params(pll, parent_rate, rate); 164 162 if (!params) 165 163 return -EINVAL; 166 - 167 - was_enabled = pll_gf40lp_frac_is_enabled(hw); 168 - if (!was_enabled) 169 - pll_gf40lp_frac_enable(hw); 170 164 171 165 val = pll_readl(pll, PLL_CTRL1); 172 166 val &= ~((PLL_CTRL1_REFDIV_MASK << PLL_CTRL1_REFDIV_SHIFT) | ··· 182 184 (params->postdiv2 << PLL_FRAC_CTRL2_POSTDIV2_SHIFT); 183 185 pll_writel(pll, val, PLL_CTRL2); 184 186 185 - pll_lock(pll); 186 - 187 - if (!was_enabled) 188 - pll_gf40lp_frac_disable(hw); 187 + if (enabled) 188 + pll_lock(pll); 189 189 190 190 return 0; 191 191 } ··· 242 246 val &= ~PLL_INT_CTRL2_BYPASS; 243 247 pll_writel(pll, val, PLL_CTRL2); 244 248 249 + pll_lock(pll); 250 + 245 251 return 0; 246 252 } 247 253 ··· 269 271 { 270 272 struct pistachio_clk_pll *pll = to_pistachio_pll(hw); 271 273 struct pistachio_pll_rate_table *params; 272 - bool was_enabled; 274 + int enabled = pll_gf40lp_laint_is_enabled(hw); 273 275 u32 val; 274 276 275 277 params = pll_get_params(pll, parent_rate, rate); 276 278 if (!params) 277 279 return -EINVAL; 278 - 279 - was_enabled = pll_gf40lp_laint_is_enabled(hw); 280 - if (!was_enabled) 281 - pll_gf40lp_laint_enable(hw); 282 280 283 281 val = pll_readl(pll, PLL_CTRL1); 284 282 val &= ~((PLL_CTRL1_REFDIV_MASK << PLL_CTRL1_REFDIV_SHIFT) | ··· 287 293 (params->postdiv2 << PLL_INT_CTRL1_POSTDIV2_SHIFT); 288 294 pll_writel(pll, val, PLL_CTRL1); 289 295 290 - pll_lock(pll); 291 - 292 - if (!was_enabled) 293 - pll_gf40lp_laint_disable(hw); 296 + if (enabled) 297 + pll_lock(pll); 294 298 295 299 return 0; 296 300 }