Skip to content

Commit 9558b51

Browse files
Anson-HuangShawn Guo
authored andcommitted
clk: imx: clk-pllv3: Use readl_relaxed_poll_timeout() for PLL lock wait
Use readl_relaxed_poll_timeout() for PLL lock wait which can simplify the code a lot. Signed-off-by: Anson Huang <[email protected]> Reviewed-by: Abel Vesa <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Signed-off-by: Shawn Guo <[email protected]>
1 parent 23aadcb commit 9558b51

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

drivers/clk/imx/clk-pllv3.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/clk-provider.h>
88
#include <linux/delay.h>
99
#include <linux/io.h>
10+
#include <linux/iopoll.h>
1011
#include <linux/slab.h>
1112
#include <linux/jiffies.h>
1213
#include <linux/err.h>
@@ -25,6 +26,8 @@
2526
#define IMX7_ENET_PLL_POWER (0x1 << 5)
2627
#define IMX7_DDR_PLL_POWER (0x1 << 20)
2728

29+
#define PLL_LOCK_TIMEOUT 10000
30+
2831
/**
2932
* struct clk_pllv3 - IMX PLL clock version 3
3033
* @clk_hw: clock source
@@ -53,23 +56,14 @@ struct clk_pllv3 {
5356

5457
static int clk_pllv3_wait_lock(struct clk_pllv3 *pll)
5558
{
56-
unsigned long timeout = jiffies + msecs_to_jiffies(10);
5759
u32 val = readl_relaxed(pll->base) & pll->power_bit;
5860

5961
/* No need to wait for lock when pll is not powered up */
6062
if ((pll->powerup_set && !val) || (!pll->powerup_set && val))
6163
return 0;
6264

63-
/* Wait for PLL to lock */
64-
do {
65-
if (readl_relaxed(pll->base) & BM_PLL_LOCK)
66-
break;
67-
if (time_after(jiffies, timeout))
68-
break;
69-
usleep_range(50, 500);
70-
} while (1);
71-
72-
return readl_relaxed(pll->base) & BM_PLL_LOCK ? 0 : -ETIMEDOUT;
65+
return readl_relaxed_poll_timeout(pll->base, val, val & BM_PLL_LOCK,
66+
500, PLL_LOCK_TIMEOUT);
7367
}
7468

7569
static int clk_pllv3_prepare(struct clk_hw *hw)

0 commit comments

Comments
 (0)