From 3621f871953d9711884bd6bbc498cfdd4187d42a Mon Sep 17 00:00:00 2001 From: Dong Aisheng Date: Thu, 7 Sep 2017 14:34:36 +0800 Subject: [PATCH] MLK-17491-33 clk: imx: clk-pfdv2: need wait lock stable for PFD Add the required wait lock stable for PLL. Fixes: 78ef764871d6 ("MLK-13441-5 ARM: imx: add new clk types") Cc: Anson Huang Reviewed-by: Bai Ping Signed-off-by: Dong Aisheng --- drivers/clk/imx/clk-pfdv2.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-pfdv2.c b/drivers/clk/imx/clk-pfdv2.c index cc8121c59bbd..b342f3c3d843 100644 --- a/drivers/clk/imx/clk-pfdv2.c +++ b/drivers/clk/imx/clk-pfdv2.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "clk.h" @@ -38,8 +39,18 @@ struct clk_pfdv2 { #define CLK_PFDV2_FRAC_MASK 0x3f +#define LOCK_TIMEOUT_US USEC_PER_MSEC + static DEFINE_SPINLOCK(pfd_lock); +static int clk_pfdv2_wait(struct clk_pfdv2 *pfd) +{ + u32 val; + + return readl_poll_timeout(pfd->reg, val, val & pfd->vld_bit, + 0, LOCK_TIMEOUT_US); +} + static int clk_pfd_enable(struct clk_hw *hw) { struct clk_pfdv2 *pfd = to_clk_pfdv2(hw); @@ -52,7 +63,7 @@ static int clk_pfd_enable(struct clk_hw *hw) writel_relaxed(val, pfd->reg); spin_unlock_irqrestore(&pfd_lock, flags); - return 0; + return clk_pfdv2_wait(pfd); } static void clk_pfd_disable(struct clk_hw *hw) -- 2.17.1