diff options
| author | Alexey Charkov <alchark@flipper.net> | 2026-07-23 19:04:24 +0400 |
|---|---|---|
| committer | Quentin Schulz <u-boot@0leil.net> | 2026-08-12 16:50:43 +0200 |
| commit | 7a3ef6c21fdb4912779132e0dd93fc59da7d6357 (patch) | |
| tree | c6e6bf60c01d99a8c26628d666890a52aa5eb995 | |
| parent | e5b3e6fd45ceff28a3cb9834809acacad82aa585 (diff) | |
| download | u-boot-7a3ef6c21fdb4912779132e0dd93fc59da7d6357.tar.gz u-boot-7a3ef6c21fdb4912779132e0dd93fc59da7d6357.zip | |
clk: rockchip: pll: fix rounding of negative k in RK3588 frac PLL
Current code uses magical constants when rounding up the magnitude of
negative fractional PLL component k. This leads to overshooting the
requested rate when the calculated fractional part has less than 0.3 in
its decimal part due to failure to round up the fractional part.
Use a proper rounding up function to avoid overshooting the requested
rate and make the calculation more readable.
Fixes: 6bfb37e70209 ("clk: rockchip: rk3588: fix up the frac pll calculation")
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Signed-off-by: Alexey Charkov <alchark@flipper.net>
Link: https://patch.msgid.link/20260723-rk3588-fracpll-v2-2-382d113f3a80@flipper.net
Signed-off-by: Quentin Schulz <u-boot@0leil.net>
| -rw-r--r-- | drivers/clk/rockchip/clk_pll.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/clk/rockchip/clk_pll.c b/drivers/clk/rockchip/clk_pll.c index d0df3b8fb49..69d2d182dcb 100644 --- a/drivers/clk/rockchip/clk_pll.c +++ b/drivers/clk/rockchip/clk_pll.c @@ -11,6 +11,7 @@ #include <asm/arch-rockchip/hardware.h> #include <div64.h> #include <linux/delay.h> +#include <linux/math64.h> static struct rockchip_pll_rate_table rockchip_auto_table; @@ -177,7 +178,10 @@ rockchip_rk3588_pll_k_get(u32 m, u32 p, u32 s, u64 fin_hz, u64 fvco) k = ffrac * 65536 / fref; if (k > 32767) { ffrac = ((m + 1) * fref) - fvco; - k = ((ffrac * 65536 * 10 / fref) + 7) / 10; + /* + * Round up to avoid overshooting requested rate for negative k + */ + k = DIV64_U64_ROUND_UP(ffrac * 65536, fref); if (k > 32767) k = 0; else |
