Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20200129163821.1547295-3-heiko@sntech.de

authored by

Heiko Stuebner and committed by
Heiko Stuebner
7f6ffbb8 3507df1a

+23 -3
+23 -3
drivers/clk/rockchip/clk-pll.c
··· 12 12 #include <linux/io.h> 13 13 #include <linux/delay.h> 14 14 #include <linux/clk-provider.h> 15 + #include <linux/iopoll.h> 15 16 #include <linux/regmap.h> 16 17 #include <linux/clk.h> 17 18 #include "clk.h" ··· 110 109 #define RK3036_PLLCON1_REFDIV_SHIFT 0 111 110 #define RK3036_PLLCON1_POSTDIV2_MASK 0x7 112 111 #define RK3036_PLLCON1_POSTDIV2_SHIFT 6 112 + #define RK3036_PLLCON1_LOCK_STATUS BIT(10) 113 113 #define RK3036_PLLCON1_DSMPD_MASK 0x1 114 114 #define RK3036_PLLCON1_DSMPD_SHIFT 12 115 + #define RK3036_PLLCON1_PWRDOWN BIT(13) 115 116 #define RK3036_PLLCON2_FRAC_MASK 0xffffff 116 117 #define RK3036_PLLCON2_FRAC_SHIFT 0 117 118 118 - #define RK3036_PLLCON1_PWRDOWN (1 << 13) 119 + static int rockchip_rk3036_pll_wait_lock(struct rockchip_clk_pll *pll) 120 + { 121 + u32 pllcon; 122 + int ret; 123 + 124 + /* 125 + * Lock time typical 250, max 500 input clock cycles @24MHz 126 + * So define a very safe maximum of 1000us, meaning 24000 cycles. 127 + */ 128 + ret = readl_relaxed_poll_timeout(pll->reg_base + RK3036_PLLCON(1), 129 + pllcon, 130 + pllcon & RK3036_PLLCON1_LOCK_STATUS, 131 + 0, 1000); 132 + if (ret) 133 + pr_err("%s: timeout waiting for pll to lock\n", __func__); 134 + 135 + return ret; 136 + } 119 137 120 138 static void rockchip_rk3036_pll_get_params(struct rockchip_clk_pll *pll, 121 139 struct rockchip_pll_rate_table *rate) ··· 232 212 writel_relaxed(pllcon, pll->reg_base + RK3036_PLLCON(2)); 233 213 234 214 /* wait for the pll to lock */ 235 - ret = rockchip_pll_wait_lock(pll); 215 + ret = rockchip_rk3036_pll_wait_lock(pll); 236 216 if (ret) { 237 217 pr_warn("%s: pll update unsuccessful, trying to restore old params\n", 238 218 __func__); ··· 271 251 272 252 writel(HIWORD_UPDATE(0, RK3036_PLLCON1_PWRDOWN, 0), 273 253 pll->reg_base + RK3036_PLLCON(1)); 274 - rockchip_pll_wait_lock(pll); 254 + rockchip_rk3036_pll_wait_lock(pll); 275 255 276 256 return 0; 277 257 }