Skip to content

Commit 5008604

Browse files
committed
clk: renesas: rcar-gen3: Increase Z clock accuracy
Improve accuracy in the .determine_rate() callback for Z and Z2 clocks by using rounded divisions. This is similar to the calculation of rates and multipliers in the .recalc_rate() resp. set_rate() callbacks. Sample impact for a few requested clock rates: - R-Car H3: - Z 500 MHz: 468 MHz => 515 MHz - Z2 1000 MHz: 973 MHz => 1011 MHz - R-Car M3-W: - Z 500 MHz: 422 MHz => 516 MHz - Z2 800 MHz: 750 MHz => 788 MHz Signed-off-by: Geert Uytterhoeven <[email protected]> Acked-by: Stephen Boyd <[email protected]> Reviewed-by: Yoshihiro Shimoda <[email protected]> Tested-by: Yoshihiro Shimoda <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 67a1b9b commit 5008604

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/clk/renesas/rcar-gen3-cpg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ static int cpg_z_clk_determine_rate(struct clk_hw *hw,
8383
if (max_mult < min_mult)
8484
return -EINVAL;
8585

86-
mult = div64_ul(req->rate * 32ULL, prate);
86+
mult = DIV_ROUND_CLOSEST_ULL(req->rate * 32ULL, prate);
8787
mult = clamp(mult, min_mult, max_mult);
8888

89-
req->rate = div_u64((u64)prate * mult, 32);
89+
req->rate = DIV_ROUND_CLOSEST_ULL((u64)prate * mult, 32);
9090
return 0;
9191
}
9292

0 commit comments

Comments
 (0)