aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@freescale.com>2013-07-15 22:23:20 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:01:27 -0400
commitaa004ffc744f55e5886665059f469480a6fd4fb3 (patch)
tree387e73270e07be2adb5d70293c51bcc696a3f707 /arch
parenteb2e6fd0c138ca49f8abcb58e17cfd1056ea9d14 (diff)
ARM: imx: clk-pllv3: improve the timeout waiting method
There are two improvements for this commit: - Add comparing pll lock condition after while loop. It can fix potential fake timeout problem caused by the code is just scheduled out before compare the timeout, and the time of scheduling out are more than one jiffies. - Move timeout assignment more close to compare the timeout. It can reduce the possibility the code is scheduled out, and the timeout can be more precise. Signed-off-by: Peter Chen <peter.chen@freescale.com> Acked-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-imx/clk-pllv3.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/arm/mach-imx/clk-pllv3.c b/arch/arm/mach-imx/clk-pllv3.c
index d09bc3df9a7a..ee85c6c12ee8 100644
--- a/arch/arm/mach-imx/clk-pllv3.c
+++ b/arch/arm/mach-imx/clk-pllv3.c
@@ -48,7 +48,7 @@ struct clk_pllv3 {
48static int clk_pllv3_prepare(struct clk_hw *hw) 48static int clk_pllv3_prepare(struct clk_hw *hw)
49{ 49{
50 struct clk_pllv3 *pll = to_clk_pllv3(hw); 50 struct clk_pllv3 *pll = to_clk_pllv3(hw);
51 unsigned long timeout = jiffies + msecs_to_jiffies(10); 51 unsigned long timeout;
52 u32 val; 52 u32 val;
53 53
54 val = readl_relaxed(pll->base); 54 val = readl_relaxed(pll->base);
@@ -59,12 +59,19 @@ static int clk_pllv3_prepare(struct clk_hw *hw)
59 val &= ~BM_PLL_POWER; 59 val &= ~BM_PLL_POWER;
60 writel_relaxed(val, pll->base); 60 writel_relaxed(val, pll->base);
61 61
62 timeout = jiffies + msecs_to_jiffies(10);
62 /* Wait for PLL to lock */ 63 /* Wait for PLL to lock */
63 while (!(readl_relaxed(pll->base) & BM_PLL_LOCK)) 64 do {
65 if (readl_relaxed(pll->base) & BM_PLL_LOCK)
66 break;
64 if (time_after(jiffies, timeout)) 67 if (time_after(jiffies, timeout))
65 return -ETIMEDOUT; 68 break;
69 } while (1);
66 70
67 return 0; 71 if (readl_relaxed(pll->base) & BM_PLL_LOCK)
72 return 0;
73 else
74 return -ETIMEDOUT;
68} 75}
69 76
70static void clk_pllv3_unprepare(struct clk_hw *hw) 77static void clk_pllv3_unprepare(struct clk_hw *hw)