[PATCH v2 00/12] clk: amlogic: clock controllers clean-up and factorisation

Jerome Brunet posted 12 patches 1 month, 1 week ago
drivers/clk/meson/Kconfig            |   13 +-
drivers/clk/meson/Makefile           |    1 -
drivers/clk/meson/a1-peripherals.c   |  177 ++---
drivers/clk/meson/a1-pll.c           |   52 +-
drivers/clk/meson/axg-aoclk.c        |   45 +-
drivers/clk/meson/axg.c              |  118 +--
drivers/clk/meson/c3-peripherals.c   | 1338 ++++------------------------------
drivers/clk/meson/c3-pll.c           |   49 +-
drivers/clk/meson/clk-regmap.h       |   20 -
drivers/clk/meson/g12a-aoclk.c       |   73 +-
drivers/clk/meson/g12a.c             |  206 +++---
drivers/clk/meson/gxbb-aoclk.c       |   43 +-
drivers/clk/meson/gxbb.c             |  204 +++---
drivers/clk/meson/meson-aoclk.c      |   32 +-
drivers/clk/meson/meson-aoclk.h      |    2 +-
drivers/clk/meson/meson-clkc-utils.c |   86 ++-
drivers/clk/meson/meson-clkc-utils.h |   89 +++
drivers/clk/meson/meson-eeclk.c      |   60 --
drivers/clk/meson/meson-eeclk.h      |   24 -
drivers/clk/meson/meson8-ddr.c       |   57 +-
drivers/clk/meson/meson8b.c          |  190 ++---
drivers/clk/meson/s4-peripherals.c   |  678 +++--------------
drivers/clk/meson/s4-pll.c           |   60 +-
23 files changed, 1034 insertions(+), 2583 deletions(-)
[PATCH v2 00/12] clk: amlogic: clock controllers clean-up and factorisation
Posted by Jerome Brunet 1 month, 1 week ago
The work on this patchset started with the submission of the Amlogic t7
peripheral clock controller [1]. This controller is fairly similar to
existing controllers. Once again, it redefined the peripheral clock macro,
the probe function and composite clock helpers, even if it is almost the
same as in other controllers. This code duplication trend has been going on
for too long and now is the time to properly address the problem.

There is clearly 3 parts in this patchset. These had been sent together for v1
to show why what the ugly first part is useful. I was initially planning to
split that for v2 but, given the minor changes since v1, I did not bother.

While all controllers are doing more or less the same things, tiny and
often pointless differences have emerged between the controllers. This
makes it harder to exploit SoC commonalities. The changes to realign things
up have been applied and squashed. Now it is possible to focus on
the (slightly more) interesting stuff.

First is the factorisation of the probe functions so those stop being
copy/pasted in each clock controller drivers.

Then the clean-up and factorisation for the PCLK macros, again to stop
copy/paste but also remove the silent use CLK_IGNORE_UNUSED.

Finally the introduction of macros for composite clock definitions. The
same duplication pattern as the for the PCLKs started to appear on s4, c3
and t7 composite clocks. Done properly, this could also help reduce the
verbosity of the older controllers.

With this, the c3-peripherals controller may be used as an example of what
future similar controllers should look like.

After this, there is still some house keeping to be done in the amlogic
clock drivers:
- Moving remaining reset drivers to the reset subsystem
- Proper decoupling of clk-regmap from the clock controllers
- Reduce verbosity of older controllers with the composite macros, where it
  makes sense.

[1]: https://lore.kernel.org/linux-clk/20250108094025.2664201-6-jian.hu@amlogic.com/

Changes in v2:
- Dropped applied changes
- Put regmap config on stack in patch 2
- Link to v1: https://lore.kernel.org/r/20250702-meson-clk-cleanup-24-v1-0-e163c9a1fc21@baylibre.com

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
Jerome Brunet (12):
      clk: amlogic: drop meson-clkcee
      clk: amlogic: add probe helper for mmio based controllers
      clk: amlogic: use probe helper in mmio based controllers
      clk: amlogic: aoclk: use clkc-utils syscon probe
      clk: amlogic: move PCLK definition to clkc-utils
      clk: amlogic: drop CLK_SET_RATE_PARENT from peripheral clocks
      clk: amlogic: pclk explicitly use CLK_IGNORE_UNUSED
      clk: amlogic: introduce a common pclk definition
      clk: amlogic: use the common pclk definition
      clk: amlogic: add composite clock helpers
      clk: amlogic: align s4 and c3 pwm clock descriptions
      clk: amlogic: c3-peripherals: use helper for basic composite clocks

 drivers/clk/meson/Kconfig            |   13 +-
 drivers/clk/meson/Makefile           |    1 -
 drivers/clk/meson/a1-peripherals.c   |  177 ++---
 drivers/clk/meson/a1-pll.c           |   52 +-
 drivers/clk/meson/axg-aoclk.c        |   45 +-
 drivers/clk/meson/axg.c              |  118 +--
 drivers/clk/meson/c3-peripherals.c   | 1338 ++++------------------------------
 drivers/clk/meson/c3-pll.c           |   49 +-
 drivers/clk/meson/clk-regmap.h       |   20 -
 drivers/clk/meson/g12a-aoclk.c       |   73 +-
 drivers/clk/meson/g12a.c             |  206 +++---
 drivers/clk/meson/gxbb-aoclk.c       |   43 +-
 drivers/clk/meson/gxbb.c             |  204 +++---
 drivers/clk/meson/meson-aoclk.c      |   32 +-
 drivers/clk/meson/meson-aoclk.h      |    2 +-
 drivers/clk/meson/meson-clkc-utils.c |   86 ++-
 drivers/clk/meson/meson-clkc-utils.h |   89 +++
 drivers/clk/meson/meson-eeclk.c      |   60 --
 drivers/clk/meson/meson-eeclk.h      |   24 -
 drivers/clk/meson/meson8-ddr.c       |   57 +-
 drivers/clk/meson/meson8b.c          |  190 ++---
 drivers/clk/meson/s4-peripherals.c   |  678 +++--------------
 drivers/clk/meson/s4-pll.c           |   60 +-
 23 files changed, 1034 insertions(+), 2583 deletions(-)
---
base-commit: 4c4e17f2701316e0cac16e19366056f464feded5
change-id: 20241211-meson-clk-cleanup-24-41cbe1924619

Best regards,
-- 
Jerome
Re: [PATCH v2 00/12] clk: amlogic: clock controllers clean-up and factorisation
Posted by Jerome Brunet 4 weeks, 1 day ago
Applied to clk-meson (clk-meson-next), thanks!

[01/12] clk: amlogic: drop meson-clkcee
        https://github.com/BayLibre/clk-meson/commit/e256a6602aa0
[02/12] clk: amlogic: add probe helper for mmio based controllers
        https://github.com/BayLibre/clk-meson/commit/480197ceece7
[03/12] clk: amlogic: use probe helper in mmio based controllers
        https://github.com/BayLibre/clk-meson/commit/d7c001bd76b7
[04/12] clk: amlogic: aoclk: use clkc-utils syscon probe
        https://github.com/BayLibre/clk-meson/commit/2aeeb649ead2
[05/12] clk: amlogic: move PCLK definition to clkc-utils
        https://github.com/BayLibre/clk-meson/commit/32ee5475f7e3
[06/12] clk: amlogic: drop CLK_SET_RATE_PARENT from peripheral clocks
        https://github.com/BayLibre/clk-meson/commit/cf03071b7c3f
[07/12] clk: amlogic: pclk explicitly use CLK_IGNORE_UNUSED
        https://github.com/BayLibre/clk-meson/commit/c3f369363a13
[08/12] clk: amlogic: introduce a common pclk definition
        https://github.com/BayLibre/clk-meson/commit/aaee6f3bce3f
[09/12] clk: amlogic: use the common pclk definition
        https://github.com/BayLibre/clk-meson/commit/b7358d14f176
[10/12] clk: amlogic: add composite clock helpers
        https://github.com/BayLibre/clk-meson/commit/955e18baeb93
[11/12] clk: amlogic: align s4 and c3 pwm clock descriptions
        https://github.com/BayLibre/clk-meson/commit/9bada5ff4bf7
[12/12] clk: amlogic: c3-peripherals: use helper for basic composite clocks
        https://github.com/BayLibre/clk-meson/commit/01f3a6d1d59b

Best regards,
--
Jerome