public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] clk: meson: Fix an issue with inaccurate hifi_pll frequency
@ 2024-09-06 10:34 Chuan Liu via B4 Relay
  2024-09-06 10:34 ` [PATCH v2 1/3] clk: meson: Support PLL with fixed fractional denominators Chuan Liu via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Chuan Liu via B4 Relay @ 2024-09-06 10:34 UTC (permalink / raw)
  To: Neil Armstrong, Jerome Brunet, Michael Turquette, Stephen Boyd,
	Kevin Hilman, Martin Blumenstingl
  Cc: linux-amlogic, linux-clk, linux-arm-kernel, linux-kernel,
	Chuan Liu

Some PLLS with fractional multipliers have fractional denominators with
fixed values, instead of the previous "(1 << pll-> frc.width)".

The hifi_pll for both C3 and S4 supports a fractional multiplier and has
a fixed fractional denominator of "100000".

Here are the results of the C3-based command tests (already defined
CLOCK_ALLOW_WRITE_DEBUGFS):
* echo 491520000 > /sys/kernel/debug/clk/hifi_pll/clk_rate
* cat /sys/kernel/debug/clk/hifi_pll/clk_rate
491520000
* echo 1 > /sys/kernel/debug/clk/hifi_pll/clk_prepare_enable
* cat /sys/kernel/debug/meson-clk-msr/clks/hifi_pll_clk
491515625       +/-15625Hz
* devmem 0xfe008100 32
0xD00304A3
* devmem 0xfe008104 32
0x00014820

Based on the register information read above, it can be obtained:
m = 0xA3 = 0d163;
n = 0x1 = 0d1
frac = 0x14820 = 0d84000
od = 0x3 = 0d3

hifi_pll calculates the output frequency:
calc_rate = xtal_rate / n * (m + (frac / frac_max)) >> od;
calc_rate = 24000000 / 1 * (163 + (84000 / 100000)) >> 3;
calc_rate = 491520000

clk_rate, msr_rate, and calc_rate all match.

The test and calculation results of S4 are consistent with those of C3,
which will not be repeated here.

Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
---
Changes in v2:
- Added frac_max to the pll parameter instead of flag.
- frac_max is added to hifi_pll for C3 and S4.
- Link to v1: https://lore.kernel.org/r/20240906-fix_clk-v1-0-2977ef0d72e7@amlogic.com

---
Chuan Liu (3):
      clk: meson: Support PLL with fixed fractional denominators
      clk: meson: c3: pll: fix frac maximum value for hifi_pll
      clk: meson: s4: pll: fix frac maximum value for hifi_pll

 drivers/clk/meson/c3-pll.c  | 1 +
 drivers/clk/meson/clk-pll.c | 8 +++++---
 drivers/clk/meson/clk-pll.h | 1 +
 drivers/clk/meson/s4-pll.c  | 1 +
 4 files changed, 8 insertions(+), 3 deletions(-)
---
base-commit: 80344f4c1a1edec507a20adca476af84ea58cd4c
change-id: 20240904-fix_clk-668f7a1a2b16

Best regards,
-- 
Chuan Liu <chuan.liu@amlogic.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-09-09  8:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 10:34 [PATCH v2 0/3] clk: meson: Fix an issue with inaccurate hifi_pll frequency Chuan Liu via B4 Relay
2024-09-06 10:34 ` [PATCH v2 1/3] clk: meson: Support PLL with fixed fractional denominators Chuan Liu via B4 Relay
2024-09-06 11:22   ` Jerome Brunet
2024-09-09  1:55     ` Chuan Liu
2024-09-09  7:40       ` Jerome Brunet
2024-09-09  8:46         ` Chuan Liu
2024-09-09  8:50           ` Jerome Brunet
2024-09-06 10:34 ` [PATCH v2 2/3] clk: meson: c3: pll: fix frac maximum value for hifi_pll Chuan Liu via B4 Relay
2024-09-06 10:34 ` [PATCH v2 3/3] clk: meson: s4: " Chuan Liu via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox