Skip to content

Commit 7f6ffbb

Browse files
committed
clk: rockchip: convert rk3036 pll type to use internal lock status
The rk3036 pll type exposes its lock status in both its pllcon registers as well as the General Register Files. To remove one dependency convert it to the "internal" lock status, similar to how rk3399 handles it. Signed-off-by: Heiko Stuebner <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 3507df1 commit 7f6ffbb

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

drivers/clk/rockchip/clk-pll.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/io.h>
1313
#include <linux/delay.h>
1414
#include <linux/clk-provider.h>
15+
#include <linux/iopoll.h>
1516
#include <linux/regmap.h>
1617
#include <linux/clk.h>
1718
#include "clk.h"
@@ -109,12 +110,31 @@ static int rockchip_pll_wait_lock(struct rockchip_clk_pll *pll)
109110
#define RK3036_PLLCON1_REFDIV_SHIFT 0
110111
#define RK3036_PLLCON1_POSTDIV2_MASK 0x7
111112
#define RK3036_PLLCON1_POSTDIV2_SHIFT 6
113+
#define RK3036_PLLCON1_LOCK_STATUS BIT(10)
112114
#define RK3036_PLLCON1_DSMPD_MASK 0x1
113115
#define RK3036_PLLCON1_DSMPD_SHIFT 12
116+
#define RK3036_PLLCON1_PWRDOWN BIT(13)
114117
#define RK3036_PLLCON2_FRAC_MASK 0xffffff
115118
#define RK3036_PLLCON2_FRAC_SHIFT 0
116119

117-
#define RK3036_PLLCON1_PWRDOWN (1 << 13)
120+
static int rockchip_rk3036_pll_wait_lock(struct rockchip_clk_pll *pll)
121+
{
122+
u32 pllcon;
123+
int ret;
124+
125+
/*
126+
* Lock time typical 250, max 500 input clock cycles @24MHz
127+
* So define a very safe maximum of 1000us, meaning 24000 cycles.
128+
*/
129+
ret = readl_relaxed_poll_timeout(pll->reg_base + RK3036_PLLCON(1),
130+
pllcon,
131+
pllcon & RK3036_PLLCON1_LOCK_STATUS,
132+
0, 1000);
133+
if (ret)
134+
pr_err("%s: timeout waiting for pll to lock\n", __func__);
135+
136+
return ret;
137+
}
118138

119139
static void rockchip_rk3036_pll_get_params(struct rockchip_clk_pll *pll,
120140
struct rockchip_pll_rate_table *rate)
@@ -212,7 +232,7 @@ static int rockchip_rk3036_pll_set_params(struct rockchip_clk_pll *pll,
212232
writel_relaxed(pllcon, pll->reg_base + RK3036_PLLCON(2));
213233

214234
/* wait for the pll to lock */
215-
ret = rockchip_pll_wait_lock(pll);
235+
ret = rockchip_rk3036_pll_wait_lock(pll);
216236
if (ret) {
217237
pr_warn("%s: pll update unsuccessful, trying to restore old params\n",
218238
__func__);
@@ -251,7 +271,7 @@ static int rockchip_rk3036_pll_enable(struct clk_hw *hw)
251271

252272
writel(HIWORD_UPDATE(0, RK3036_PLLCON1_PWRDOWN, 0),
253273
pll->reg_base + RK3036_PLLCON(1));
254-
rockchip_pll_wait_lock(pll);
274+
rockchip_rk3036_pll_wait_lock(pll);
255275

256276
return 0;
257277
}

0 commit comments

Comments
 (0)