[PATCH RFC v3 0/5] ZTE zx297520v3 clock bindings and driver

Stefan Dösinger posted 5 patches 1 week, 3 days ago
.../bindings/clock/zte,zx297520v3-lspclk.yaml      |  119 +++
.../bindings/clock/zte,zx297520v3-topclk.yaml      |   95 ++
MAINTAINERS                                        |    3 +
arch/arm/boot/dts/zte/zx297520v3.dtsi              |   55 +-
drivers/clk/Kconfig                                |    1 +
drivers/clk/Makefile                               |    1 +
drivers/clk/zte/Kconfig                            |   18 +
drivers/clk/zte/Makefile                           |    5 +
drivers/clk/zte/clk-zx297520v3.c                   | 1003 ++++++++++++++++++++
drivers/clk/zte/pll.c                              |  450 +++++++++
drivers/clk/zte/pll.h                              |   23 +
include/dt-bindings/clock/zte,zx297520v3-clk.h     |  179 ++++
12 files changed, 1944 insertions(+), 8 deletions(-)
[PATCH RFC v3 0/5] ZTE zx297520v3 clock bindings and driver
Posted by Stefan Dösinger 1 week, 3 days ago
Hi,

I am sending version 3 of my zx297520v3 clock patch. The major change is 
that I have merged the top and matrix clocks into one device because 
the interface between them is unclear in the hardware.

There are still a few open questions though:

1) The clk-reset interaction: Both clocks and resets are in the same IO 
space, sometimes in the same registers. I see a number of clk drivers 
that register a reset control. I noticed Yu-Chun Lin's RTD1625 clock 
submission added an aux device and placed the reset code in 
drivers/reset instead. Is there a preference for either way or any 
guideline of which way to use in which circumstances?

2) Unused clocks: I looked at recently introduced clk drivers 
(mediatek,mt8196-clock.h, sun55i-a523-mcu-ccu.h) and they do add all a 
lot of clocks that do not have an active consumer - which in a way means 
unused ABI. Please let me know if you prefer to add clocks one by one as 
their consumers are added.

That said, there are a lot of clocks that I want to define for the sole 
purpose of shutting them off. The boot loader leaves pretty much every 
device enabled, including proprietary timers that I don't even plan to 
write a driver for. Registering their clocks in the kernel will allow 
the kernel to shut them off, so they aren't entirely unused.

3) I took some naming from the old zx2967 code. In particular, each 
device has two clocks: "WCLK" for the device operation and "PCLK" for 
register access. Are there more standard names for them? Likewise I took 
some device names from ZTE's downstream sources and I am open to better 
suggestions.

My impression so far is that "PCLK" is fairly common. There is no agreed 
name name prefix/suffix for the other clock. If anything, just nothing. 
(i.e. "UART0_PCLK" and "UART0"). On prefix vs suffix, (PCLK_UART0 vs 
UART0_PCLK) the existing drivers seem to be all over the place.

4) I took care to test unbinding and rebinding my clock driver to the 
hardware and also tested building it as a module - but in practise, the 
board will be pretty useless without the clock driver and I have to jump 
through some hoops to even test it. Should I even bother, or just set 
suppress_bind_attrs = true and make the config a boolean?

Wrt clock name strings vs struct clk / clk_hw pointers for parents: 
Using string names seems like the only viable choice in practise.

I think the list of clocks in my driver is fairly complete; It is 
certainly a lot better than what the downstream ZTE drivers have. I 
deduced a lot of it by trial and error. I am sure there are some clocks 
missing that will need to be added to the binding later. Afaiu adding 
clocks is not an issue, but removing or reordering them is an ABI break.

Signed-off-by: Stefan Dösinger <stefandoesinger@gmail.com>
---
v2: Fix build issues introduced by checkpatch.pl fixes that I didn't 
spot earlier.

Changes in v3:
Model top and matrix clocks as one device
Add PLL driver
Fixed a few issues found by Sashiko: register lock, some missing devm_, 
error handling

---
Stefan Dösinger (5):
      dt-bindings: clk: zte: Add zx297520v3 top clock and reset bindings.
      dt-bindings: clk: zte: Add zx297520v3 LSP clock and reset bindings.
      clk: zte: Introduce a driver for zx297520v3 top clocks and resets.
      clk: zte: Introduce a driver for zx297520v3 LSP clocks and resets.
      ARM: dts: zte: Declare a zx297520v3 clock device nodes

 .../bindings/clock/zte,zx297520v3-lspclk.yaml      |  119 +++
 .../bindings/clock/zte,zx297520v3-topclk.yaml      |   95 ++
 MAINTAINERS                                        |    3 +
 arch/arm/boot/dts/zte/zx297520v3.dtsi              |   55 +-
 drivers/clk/Kconfig                                |    1 +
 drivers/clk/Makefile                               |    1 +
 drivers/clk/zte/Kconfig                            |   18 +
 drivers/clk/zte/Makefile                           |    5 +
 drivers/clk/zte/clk-zx297520v3.c                   | 1003 ++++++++++++++++++++
 drivers/clk/zte/pll.c                              |  450 +++++++++
 drivers/clk/zte/pll.h                              |   23 +
 include/dt-bindings/clock/zte,zx297520v3-clk.h     |  179 ++++
 12 files changed, 1944 insertions(+), 8 deletions(-)
---
base-commit: c1ecb239fa3456529a32255359fc78b69eb9d847
change-id: 20260510-zx29clk-2e4d39e3128c

Best regards,
-- 
Stefan Dösinger <stefandoesinger@gmail.com>

Re: [PATCH RFC v3 0/5] ZTE zx297520v3 clock bindings and driver
Posted by Philipp Zabel 5 days, 4 hours ago
On Fr, 2026-05-29 at 00:52 +0300, Stefan Dösinger wrote:
> Hi,
> 
> I am sending version 3 of my zx297520v3 clock patch. The major change is 
> that I have merged the top and matrix clocks into one device because 
> the interface between them is unclear in the hardware.
> 
> There are still a few open questions though:
> 
> 1) The clk-reset interaction: Both clocks and resets are in the same IO 
> space, sometimes in the same registers. I see a number of clk drivers 
> that register a reset control. I noticed Yu-Chun Lin's RTD1625 clock 
> submission added an aux device and placed the reset code in 
> drivers/reset instead. Is there a preference for either way or any 
> guideline of which way to use in which circumstances?

When there is no interaction required when operating the clk/reset
bits, I prefer the reset driver sitting in drivers/reset as an aux
device, especially when register access can be abstracted via a shared
regmap. Some of the reset drivers under drivers/clk just predate the
aux bus.


regards
Philipp
Re: [PATCH RFC v3 0/5] ZTE zx297520v3 clock bindings and driver
Posted by Stefan Dösinger 4 days, 16 hours ago
Hi Philipp,

Am Mittwoch, 3. Juni 2026, 11:50:14 Ostafrikanische Zeit schrieben Sie:
> When there is no interaction required when operating the clk/reset
> bits, I prefer the reset driver sitting in drivers/reset as an aux
> device, especially when register access can be abstracted via a shared
> regmap. Some of the reset drivers under drivers/clk just predate the
> aux bus.

There are two interactions:

The register lock because all LSP and at least one TOP register contains both 
clocks and resets.

Shared register definition: in the case of the LSP clocks breaking up the 
composite definition would sacrifice readability.

Neither of them are insurmountable and I can certainly arrange a separation if 
asked to - but my preference is to keep them together.
Re: [PATCH RFC v3 0/5] ZTE zx297520v3 clock bindings and driver
Posted by Philipp Zabel 3 days, 22 hours ago
Hi Stefan,

On Mi, 2026-06-03 at 23:49 +0300, Stefan Dösinger wrote:
> Hi Philipp,
> 
> Am Mittwoch, 3. Juni 2026, 11:50:14 Ostafrikanische Zeit schrieben Sie:
> > When there is no interaction required when operating the clk/reset
> > bits, I prefer the reset driver sitting in drivers/reset as an aux
> > device, especially when register access can be abstracted via a shared
> > regmap. Some of the reset drivers under drivers/clk just predate the
> > aux bus.
> 
> There are two interactions:
> 
> The register lock because all LSP and at least one TOP register contains both 
> clocks and resets.

That could be solved with regmap.

> Shared register definition: in the case of the LSP clocks breaking up the 
> composite definition would sacrifice readability.

That is a matter of perspective.

I had a harder time validating that the resets[] array is properly
initialized from the two different composite arrays because of the
unordered reset_ids, and some remaining resets[] being filled via code.

It would be much simpler if you split the reset definitions out into a
single, separate, const array, indexed by reset id. In fact,
I would suggest this even if you don't intend to move the reset code.

> Neither of them are insurmountable and I can certainly arrange a separation if 
> asked to - but my preference is to keep them together.

I'll leave this up to the clock maintainers.

regards
Philipp