Skip to content

Commit dabf72b

Browse files
bijudasgeertu
authored andcommitted
clk: renesas: rzg2l: Fix FOUTPOSTDIV clk
While computing foutpostdiv_rate, the value of params->pl5_fracin is discarded, which results in the wrong refresh rate. Fix the formula for computing foutpostdiv_rate. Fixes: 1561380 ("clk: renesas: rzg2l: Add FOUTPOSTDIV clk support") Signed-off-by: Hien Huynh <hien.huynh.px@renesas.com> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/20241024134236.315289-1-biju.das.jz@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent e200b06 commit dabf72b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/clk/renesas/rzg2l-cpg.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ static unsigned long
548548
rzg2l_cpg_get_foutpostdiv_rate(struct rzg2l_pll5_param *params,
549549
unsigned long rate)
550550
{
551-
unsigned long foutpostdiv_rate;
551+
unsigned long foutpostdiv_rate, foutvco_rate;
552552

553553
params->pl5_intin = rate / MEGA;
554554
params->pl5_fracin = div_u64(((u64)rate % MEGA) << 24, MEGA);
@@ -557,10 +557,11 @@ rzg2l_cpg_get_foutpostdiv_rate(struct rzg2l_pll5_param *params,
557557
params->pl5_postdiv2 = 1;
558558
params->pl5_spread = 0x16;
559559

560-
foutpostdiv_rate =
561-
EXTAL_FREQ_IN_MEGA_HZ * MEGA / params->pl5_refdiv *
562-
((((params->pl5_intin << 24) + params->pl5_fracin)) >> 24) /
563-
(params->pl5_postdiv1 * params->pl5_postdiv2);
560+
foutvco_rate = div_u64(mul_u32_u32(EXTAL_FREQ_IN_MEGA_HZ * MEGA,
561+
(params->pl5_intin << 24) + params->pl5_fracin),
562+
params->pl5_refdiv) >> 24;
563+
foutpostdiv_rate = DIV_ROUND_CLOSEST_ULL(foutvco_rate,
564+
params->pl5_postdiv1 * params->pl5_postdiv2);
564565

565566
return foutpostdiv_rate;
566567
}

0 commit comments

Comments
 (0)