Message ID | 20200129163821.1547295-2-heiko@sntech.de (mailing list archive) |
---|---|
State | Mainlined |
Commit | 3507df1a4615113ae6509e0f14f6546f0d1c84b4 |
Headers | show |
Series | [v3,1/3] clk: rockchip: convert rk3399 pll type to use readl_poll_timeout | expand |
Quoting Heiko Stuebner (2020-01-29 08:38:20) > From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com> > > Instead of open coding the polling of the lock status, use the > handy regmap_read_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 <sboyd@kernel.org> > Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com> > --- Reviewed-by: Stephen Boyd <sboyd@kernel.org>
diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c index 6fd52895e7b6..c7c3848d68e8 100644 --- a/drivers/clk/rockchip/clk-pll.c +++ b/drivers/clk/rockchip/clk-pll.c @@ -86,23 +86,14 @@ static int rockchip_pll_wait_lock(struct rockchip_clk_pll *pll) { struct regmap *grf = pll->ctx->grf; unsigned int val; - int delay = 24000000, ret; - - while (delay > 0) { - ret = regmap_read(grf, pll->lock_offset, &val); - if (ret) { - pr_err("%s: failed to read pll lock status: %d\n", - __func__, ret); - return ret; - } + int ret; - if (val & BIT(pll->lock_shift)) - return 0; - delay--; - } + ret = regmap_read_poll_timeout(grf, pll->lock_offset, val, + val & BIT(pll->lock_shift), 0, 1000); + if (ret) + pr_err("%s: timeout waiting for pll to lock\n", __func__); - pr_err("%s: timeout waiting for pll to lock\n", __func__); - return -ETIMEDOUT; + return ret; } /**