Skip to content

Commit d4c83ac

Browse files
rockosovjbrun3t
authored andcommitted
clk: meson: add 'NOINIT_ENABLED' flag to eliminate init for enabled PLL
When dealing with certain PLLs, it is necessary to avoid modifying them if they have already been initialized by lower levels. For instance, in the A1 SoC Family, the sys_pll is enabled as the parent for the cpuclk, and it cannot be disabled during the initialization sequence. Therefore, initialization phase must be skipped. Signed-off-by: Dmitry Rokosov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jerome Brunet <[email protected]>
1 parent f06ac3e commit d4c83ac

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

drivers/clk/meson/clk-pll.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,35 @@ static int meson_clk_pll_wait_lock(struct clk_hw *hw)
289289
return -ETIMEDOUT;
290290
}
291291

292+
static int meson_clk_pll_is_enabled(struct clk_hw *hw)
293+
{
294+
struct clk_regmap *clk = to_clk_regmap(hw);
295+
struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
296+
297+
if (MESON_PARM_APPLICABLE(&pll->rst) &&
298+
meson_parm_read(clk->map, &pll->rst))
299+
return 0;
300+
301+
if (!meson_parm_read(clk->map, &pll->en) ||
302+
!meson_parm_read(clk->map, &pll->l))
303+
return 0;
304+
305+
return 1;
306+
}
307+
292308
static int meson_clk_pll_init(struct clk_hw *hw)
293309
{
294310
struct clk_regmap *clk = to_clk_regmap(hw);
295311
struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
296312

313+
/*
314+
* Keep the clock running, which was already initialized and enabled
315+
* from the bootloader stage, to avoid any glitches.
316+
*/
317+
if ((pll->flags & CLK_MESON_PLL_NOINIT_ENABLED) &&
318+
meson_clk_pll_is_enabled(hw))
319+
return 0;
320+
297321
if (pll->init_count) {
298322
if (MESON_PARM_APPLICABLE(&pll->rst))
299323
meson_parm_write(clk->map, &pll->rst, 1);
@@ -308,22 +332,6 @@ static int meson_clk_pll_init(struct clk_hw *hw)
308332
return 0;
309333
}
310334

311-
static int meson_clk_pll_is_enabled(struct clk_hw *hw)
312-
{
313-
struct clk_regmap *clk = to_clk_regmap(hw);
314-
struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
315-
316-
if (MESON_PARM_APPLICABLE(&pll->rst) &&
317-
meson_parm_read(clk->map, &pll->rst))
318-
return 0;
319-
320-
if (!meson_parm_read(clk->map, &pll->en) ||
321-
!meson_parm_read(clk->map, &pll->l))
322-
return 0;
323-
324-
return 1;
325-
}
326-
327335
static int meson_clk_pcie_pll_enable(struct clk_hw *hw)
328336
{
329337
int retries = 10;

drivers/clk/meson/clk-pll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct pll_mult_range {
2828
}
2929

3030
#define CLK_MESON_PLL_ROUND_CLOSEST BIT(0)
31+
#define CLK_MESON_PLL_NOINIT_ENABLED BIT(1)
3132

3233
struct meson_clk_pll_data {
3334
struct parm en;

0 commit comments

Comments
 (0)