Re: [PATCH v2 3/3] scsi: ufs: mediatek: round scalable clock bounds to clk_round_rate()

From: Peter Wang

Date: Fri Nov 27 2026 - 02:11:31 EST


On Fri, 2026-11-27 at 09:14 +0800, Ilia Snezhkov wrote:
> Hi Peter,
>
> It is not a missing hardware calibration — it comes directly from the
> fractional-N PLL PCW quantization against the 26 MHz reference
> crystal
> (clk26m).
>
> On MT6789, msdcpll has pcwbits = 22 and pcwibits = 8 (14 fractional
> bits, 2^14 = 16384), with VCO range 1500..3800 MHz, and
> ufs_sel_max_src
> is msdcpll_d2 (msdcpll / 2). To target msdcpll = 384 MHz (msdcpll_d2
> =
> 192 MHz) at postdiv = 4, VCO = 1536 MHz, so the required multiplier
> is:
>
>   1536 / 26 = 768 / 13 = 59 + 1/13
>
> Because 1/13 is a non-terminating binary fraction, no integer PCW
> value
> can represent 384 MHz exactly in 14 fractional bits:
>
>   pcw = 0xec4ec (967916) -> vco = 1535999512 Hz -> msdcpll =
> 383999878 Hz -> msdcpll_d2 = 191999939 Hz (-61 Hz)
>   pcw = 0xec4ed (967917) -> vco = 1536001099 Hz -> msdcpll =
> 384000275 Hz -> msdcpll_d2 = 192000137 Hz (+137 Hz)
>
> (With postdiv = 8, VCO = 3072 MHz = 26 MHz * (118 + 2/13), the
> closest
> PCW values give 191999939 Hz and 192000038 Hz — still never exactly
> 192000000 Hz.)
>
> So the CCF __mtk_pll_recalc_rate() / clk_round_rate() result for
> msdcpll_d2 is deterministically 191999939 Hz, which never matches a
> nominal 192000000 Hz entry in freq-table-hz under
> ufshcd_devfreq_target()'s
> exact `freq == clki->max_freq` check.
>
> Best regards,
> Ilia

Thank you for your detailed explanation.
Reviewed-by: Peter Wang <peter.wang@xxxxxxxxxxxx>