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

phy: mediatek: hdmi: mt8195: fix wrong pll calculus

The clock rate calculus in mtk_hdmi_pll_calc() was wrong when it has
been replaced by 'div_u64'.

Fix the issue by multiplying the values in the denominator instead of
dividing them.

Fixes: 45810d486bb44 ("phy: mediatek: add support for phy-mtk-hdmi-mt8195")
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
Link: https://lore.kernel.org/r/20230413-fixes-for-mt8195-hdmi-phy-v2-2-bbad62e64321@baylibre.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Guillaume Ranquet and committed by
Vinod Koul
9d9ff3d2 714dd3c2

+2 -2
+2 -2
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c
··· 271 271 * [32,24] 9bit integer, [23,0]:24bit fraction 272 272 */ 273 273 pcw = div_u64(((u64)ns_hdmipll_ck) << PCW_DECIMAL_WIDTH, 274 - da_hdmitx21_ref_ck / PLL_FBKDIV_HS3); 274 + da_hdmitx21_ref_ck * PLL_FBKDIV_HS3); 275 275 276 276 if (pcw > GENMASK_ULL(32, 0)) 277 277 return -EINVAL; ··· 288 288 posdiv2 = 1; 289 289 290 290 /* Digital clk divider, max /32 */ 291 - digital_div = div_u64((u64)ns_hdmipll_ck, posdiv1 / posdiv2 / pixel_clk); 291 + digital_div = div_u64(ns_hdmipll_ck, posdiv1 * posdiv2 * pixel_clk); 292 292 if (!(digital_div <= 32 && digital_div >= 1)) 293 293 return -EINVAL; 294 294