Skip to content

Commit bf4237a

Browse files
committed
clk: rockchip: convert rk3399 pll type to use readl_relaxed_poll_timeout
Instead of open coding the polling of the lock status, use the handy readl_relaxed_poll_timeout for this. As the pll locking is normally blazingly fast and we don't want to incur additional delays, we're not doing any sleeps similar to for example the imx clk-pllv4 and define a very safe but still short timeout of 1ms. Suggested-by: Stephen Boyd <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b3a9e3b commit bf4237a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

drivers/clk/rockchip/clk-pll.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -589,19 +589,20 @@ static const struct clk_ops rockchip_rk3066_pll_clk_ops = {
589589
static int rockchip_rk3399_pll_wait_lock(struct rockchip_clk_pll *pll)
590590
{
591591
u32 pllcon;
592-
int delay = 24000000;
592+
int ret;
593593

594-
/* poll check the lock status in rk3399 xPLLCON2 */
595-
while (delay > 0) {
596-
pllcon = readl_relaxed(pll->reg_base + RK3399_PLLCON(2));
597-
if (pllcon & RK3399_PLLCON2_LOCK_STATUS)
598-
return 0;
594+
/*
595+
* Lock time typical 250, max 500 input clock cycles @24MHz
596+
* So define a very safe maximum of 1000us, meaning 24000 cycles.
597+
*/
598+
ret = readl_relaxed_poll_timeout(pll->reg_base + RK3399_PLLCON(2),
599+
pllcon,
600+
pllcon & RK3399_PLLCON2_LOCK_STATUS,
601+
0, 1000);
602+
if (ret)
603+
pr_err("%s: timeout waiting for pll to lock\n", __func__);
599604

600-
delay--;
601-
}
602-
603-
pr_err("%s: timeout waiting for pll to lock\n", __func__);
604-
return -ETIMEDOUT;
605+
return ret;
605606
}
606607

607608
static void rockchip_rk3399_pll_get_params(struct rockchip_clk_pll *pll,

0 commit comments

Comments
 (0)