Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC RFT v3 00/13] clk: meson: Refactor PLL pre-divider as a divider clock
@ 2026-12-01  8:56 Jian Hu via B4 Relay
  2026-12-01  8:56 ` [PATCH RFC RFT v3 01/13] clk: divider: Add CLK_DIVIDER_INVALID_ZERO flag Jian Hu via B4 Relay
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: Jian Hu via B4 Relay @ 2026-12-01  8:56 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Neil Armstrong,
	Jerome Brunet, Kevin Hilman, Martin Blumenstingl, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Carlo Caione, linux-clk, linux-kernel, linux-amlogic,
	linux-arm-kernel, devicetree, Jian Hu

This series refactors the Meson PLL driver to remove the dedicated
PLL pre-divider (N) parameter from the PLL implementation and model it
as a separate divider clock.

Currently, the Meson PLL driver models the PLL pre-divider using a
dedicated n field in struct meson_clk_pll_data. This makes the
pre-divider part of the PLL-specific implementation, although the
Common Clock Framework already provides a generic divider clock.

The pre-divider is not intended to be dynamically adjusted. Each PLL
has a fixed N value as part of its configuration. Most PLLs use N = 1,
while a few special cases use N = 3 to satisfy their PLL input frequency
constraints. Modeling the pre-divider as a separate divider clock
removes PLL-specific handling and simplifies the PLL driver.

The series updates the Amlogic SoC clock drivers to use standalone
pre-divider clocks, with the PLL DCO taking the pre-divider clock as
its parent instead of the input clock directly. It also adds the
required clock IDs.

Some Amlogic PLL pre-dividers read as zero after reset, which
does not produce a usable clock. The existing divider implementation
reports the parent rate for a zero divisor, potentially hiding this
invalid state. In addition, when the requested pre-divider rate equals
the parent rate, the divider must be configured with a divisor of 1.
The zero value read from the register after reset must not prevent the
divider from being configured correctly.

To address these issues, the series introduces
CLK_DIVIDER_INVALID_ZERO, allowing dividers with an invalid zero
value to report a rate of zero instead of incorrectly reporting the
parent rate.

The common clock framework gained CLK_DIVIDER_INVALID_ZERO (BIT(9)),
so the divider flags no longer fit in the u8 field of struct
clk_regmap_div_data.

Widen the divider flags to u16.

Tested on: T7, C3, S4, AXG, GXL, SM1 and A1.

Signed-off-by: Jian Hu <jian.hu@amlogic.com>
---
Changes in v3:
- Rebase to clk-amlogic.
- return -EINVAL when divisor equals 0 in divider_ro_determine_rate().
- Separate patch for widen the divider flags.
- Split the SoC changes for prediv clock.
- Add CLK_DIVIDER_ONE_BASED for RO prediv.
- Drop CLK_SET_RATE_PARENT for hdmi clock.
- Update the comment for prediv table.
- Add CLK_GET_RATE_NOCACHE for pcie prediv clock.
- Rework meson_clk_pll_determine_rate().
- Described with a pll_mult_range for contiguous table.
- Covert the table to const unsigned int * array.
- Link to v2: https://lore.kernel.org/r/20261029-meson_refactor_n-v2-0-ff4ac74e527b@amlogic.com

Changes in v2:
- Add CLK_DIVIDER_INVALID_ZERO.
- Add all SoCs prediv clock index.
- Support table for pll m.
- Fix the `determine` logic: when `best_parent_rate` equals 0,
recalculate a new `parent_rate`.
- Add all SoCs pll prediv clocks.
- Link to v1: https://lore.kernel.org/r/20260923-meson_refactor_n-v1-0-3a8ce27121a2@amlogic.com

---
Jian Hu (13):
      clk: divider: Add CLK_DIVIDER_INVALID_ZERO flag
      clk: meson: clk-regmap: Widen the divider flags to 16 bits
      dt-bindings: clock: amlogic: Add PLL pre-divider clock IDs
      clk: meson: axg: Model the PLL pre-divider as a divider clock
      clk: meson: a1: Model the PLL pre-divider as a divider clock
      clk: meson: c3: Model the PLL pre-divider as a divider clock
      clk: meson: gxbb: Model the PLL pre-divider as a divider clock
      clk: meson: g12a: Model the PLL pre-divider as a divider clock
      clk: meson: meson8: Model the PLL pre-divider as a divider clock
      clk: meson: s4: Model the PLL pre-divider as a divider clock
      clk: meson: s7: Model the PLL pre-divider as a divider clock
      clk: meson: t7: Model the PLL pre-divider as a divider clock
      clk: meson: pll: Remove the dedicated n parameter

 drivers/clk/clk-divider.c                       |   5 +
 drivers/clk/meson/a1-pll.c                      |  69 ++++--
 drivers/clk/meson/axg.c                         | 210 +++++++++++-------
 drivers/clk/meson/c3-pll.c                      |  97 ++++++--
 drivers/clk/meson/clk-pll.c                     | 241 +++++++++++---------
 drivers/clk/meson/clk-pll.h                     |  14 +-
 drivers/clk/meson/clk-regmap.h                  |   2 +-
 drivers/clk/meson/g12a.c                        | 282 ++++++++++++++++++------
 drivers/clk/meson/gxbb.c                        | 260 +++++++++++++---------
 drivers/clk/meson/meson8-ddr.c                  |  33 ++-
 drivers/clk/meson/meson8b.c                     | 209 +++++++++++-------
 drivers/clk/meson/s4-pll.c                      | 130 ++++++++---
 drivers/clk/meson/s7-pll.c                      |  33 ++-
 drivers/clk/meson/t7-pll.c                      | 192 ++++++++++++----
 include/dt-bindings/clock/amlogic,a1-pll-clkc.h |   3 +
 include/dt-bindings/clock/amlogic,c3-pll-clkc.h |   3 +
 include/dt-bindings/clock/amlogic,s4-pll-clkc.h |   4 +
 include/dt-bindings/clock/amlogic,s7-pll-clkc.h |   1 +
 include/dt-bindings/clock/amlogic,t7-pll-clkc.h |   6 +
 include/dt-bindings/clock/axg-clkc.h            |   5 +
 include/dt-bindings/clock/g12a-clkc.h           |   8 +
 include/dt-bindings/clock/gxbb-clkc.h           |   4 +
 include/dt-bindings/clock/meson8-ddr-clkc.h     |   1 +
 include/dt-bindings/clock/meson8b-clkc.h        |   4 +
 include/linux/clk-provider.h                    |   3 +
 25 files changed, 1259 insertions(+), 560 deletions(-)
---
base-commit: 48275f2f75fd2a45a15f5fad2c8a2201ac465826
change-id: 20261126-meson_refactor_n-f6076ce11a53

Best regards,
-- 
Jian Hu <jian.hu@amlogic.com>




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

end of thread, other threads:[~2026-12-01 11:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  8:56 [PATCH RFC RFT v3 00/13] clk: meson: Refactor PLL pre-divider as a divider clock Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 01/13] clk: divider: Add CLK_DIVIDER_INVALID_ZERO flag Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 02/13] clk: meson: clk-regmap: Widen the divider flags to 16 bits Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 03/13] dt-bindings: clock: amlogic: Add PLL pre-divider clock IDs Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 04/13] clk: meson: axg: Model the PLL pre-divider as a divider clock Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 05/13] clk: meson: a1: " Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 06/13] clk: meson: c3: " Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 07/13] clk: meson: gxbb: " Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 08/13] clk: meson: g12a: " Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 09/13] clk: meson: meson8: " Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 10/13] clk: meson: s4: " Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 11/13] clk: meson: s7: " Jian Hu via B4 Relay
2026-12-01 11:37   ` Carlo Caione
2026-12-01  8:56 ` [PATCH RFC RFT v3 12/13] clk: meson: t7: " Jian Hu via B4 Relay
2026-12-01  8:56 ` [PATCH RFC RFT v3 13/13] clk: meson: pll: Remove the dedicated n parameter Jian Hu 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