[PATCH v2 00/15] clk: sunxi-ng: add A523 clock support

Andre Przywara
2025-02-14T12:56:04Z

Hi,

this is the second drop of the series introducing basic clock support for
the Allwinner A523 family of SoCs, comprising A523, A527, T527, H728. [1]
Since the posting of v1, a T527 user manual surfaced, so we could add
an extra clock, and confirm and clarify on some existing (guessed) ones.
This also contains some fixes to some clock definitions, which were
found either during testing or while checking for new clocks.
One big change in this series is the split of the main CCU driver into 9
patches, purely to help review. For a more detailed changelog, see below.

*************
Please note that the clock numbers changed compared to v1, so DTs from
that era cannot be used anymore with this driver: you have to update
the DTB. Just copying the binding header and recompiling the DTB should do
the trick, since the symbols stayed mostly the same, at least as far they
are used in the basic DTs we use today.
*************

The SoCs contain *four* CCU components, aside from the usual main clock
device and the PRCM clock (in the always-on-domain), there is an MCU
clock and a DSP clock. This series just adds support for the first two,
the other two don't seem to be required for the basic functionality.

The clock tree of each SoC has always been individual, even though the
main clock *types* mostly remain the same. This time we see two slight
variations: There is an MP clock without the P (shift) part, and there
is one with two dividers instead of one divider and one shift field.
The first three patches add support for these new clock types.

Patch 04/15 add the DT binding description for the main CCU, along with
all the clock numbers already defined in the binding headers.
Since the main CCU is massive, and contains a lot of detail, I decided
to split this driver up into 9 patches, simply to help review. I tried
to group them somewhat logically, although this is rather arbitrary, and
just to make each individual patch smaller. I am happy to squash them
all back into one patch once they have been reviewed, for the final
merge. The PRCM CCU is comparably small, so I kept this in one patch.

Interestingly the Allwinner BSP has switched to using the existing sunxi
CCU framework for modelling the clocks (they had their own way before), so
we could theoretically use their code. However when I started working on
this more than a year ago, their files had a GPL-3.0-only license header,
which, according to my research, makes them incompatible for mainline
inclusion. I thus started from "scratch" (adjusting the D1 driver, really).
Meanwhile they seem to have changed the license, and a quick comparison
turned up some differences, some of which seem to be bugs on their, some
on my side, probably. I hope having such a "reference" helps the mainline
code quality, as people can help the review by comparing code.

Given the level of detail required in CCU drivers, I am certain there are
many bugs in there, also many things that can be improved. But after
starring and editing this for weeks, I feel like it's time for the
community to have a look, so please help with the review, and also test.

Based on v6.14-rc1.

Cheers,
Andre

[1] https://linux-sunxi.org/A523#Family_of_sun55iw3

Changelog v1 .. v2:
- rebase onto v6.14-rc1
- split main CCU definition patch into 9 smaller patches
- rename RST_BUS_VO1_TCONLCD0 to RST_BUS_TCON_LCD2
- insert CLK_PLL_VIDEO3_xx clocks
- add clock for 2nd EMAC
- add R_SPI name (though clock definiton is still missing)
- fix ISP clock definition
- remove BSP comments from clocks now documented in the T527 manual
- add Conor's binding ACKs (with thanks!)

Andre Przywara (15):
clk: sunxi-ng: mp: Add SUNXI_CCU_P_DATA_WITH_MUX_GATE wrapper
clk: sunxi-ng: mp: introduce dual-divider clock
clk: sunxi-ng: mp: provide wrapper for setting feature flags
dt-bindings: clk: sunxi-ng: add compatible for the A523 CCU
clk: sunxi-ng: Add support for the A523/T527 CCU PLLs
clk: sunxi-ng: a523: Add support for bus clocks
clk: sunxi-ng: a523: add video mod clocks
clk: sunxi-ng: a523: add system mod clocks
clk: sunxi-ng: a523: add interface mod clocks
clk: sunxi-ng: a523: add USB mod clocks
clk: sunxi-ng: a523: remaining mod clocks
clk: sunxi-ng: a523: add bus clock gates
clk: sunxi-ng: a523: add reset lines
dt-bindings: clk: sunxi-ng: add compatible for the A523 PRCM-CCU
clk: sunxi-ng: add support for the A523/T527 PRCM CCU

.../clock/allwinner,sun4i-a10-ccu.yaml | 76 +-
drivers/clk/sunxi-ng/Kconfig | 10 +
drivers/clk/sunxi-ng/Makefile | 4 +
drivers/clk/sunxi-ng/ccu-sun55i-a523-r.c | 245 +++
drivers/clk/sunxi-ng/ccu-sun55i-a523-r.h | 14 +
drivers/clk/sunxi-ng/ccu-sun55i-a523.c | 1641 +++++++++++++++++
drivers/clk/sunxi-ng/ccu-sun55i-a523.h | 14 +
drivers/clk/sunxi-ng/ccu_common.h | 1 +
drivers/clk/sunxi-ng/ccu_mp.c | 51 +-
drivers/clk/sunxi-ng/ccu_mp.h | 39 +-
include/dt-bindings/clock/sun55i-a523-ccu.h | 190 ++
include/dt-bindings/clock/sun55i-a523-r-ccu.h | 37 +
include/dt-bindings/reset/sun55i-a523-ccu.h | 87 +
include/dt-bindings/reset/sun55i-a523-r-ccu.h | 25 +
14 files changed, 2394 insertions(+), 40 deletions(-)
create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523-r.c
create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523-r.h
create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523.c
create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523.h
create mode 100644 include/dt-bindings/clock/sun55i-a523-ccu.h
create mode 100644 include/dt-bindings/clock/sun55i-a523-r-ccu.h
create mode 100644 include/dt-bindings/reset/sun55i-a523-ccu.h
create mode 100644 include/dt-bindings/reset/sun55i-a523-r-ccu.h

--
2.46.3