Skip to contentSkip to conversation

clk: sunxi-ng: add A523 clock support

PATCH Superseded Andre Przywara 2 participants 10 messages Nov 11, 2024

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover clk: sunxi-ng: add A523 clock support

Hi,

this series introduces basic clock support for the Allwinner A523 family of SoCs (comprising A523, A527, T527). [1]
The SoC contains *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.

The remaining four patches then add the DT bindings documentation and describe all the clocks and their relationship in gory detail. I split the binding patches up, since they contain the header files naming the clocks, let me know if they should be in one patch instead.

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 about 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.

Also we only have a user manual for the A523, but its siblings introduce more clocks (HDMI, NPU, etc.). I tried to close the gaps by looking at some BSP code, and also by probing registers on actual hardware, to see which clocks implement which bits.

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.12-rc1.

Cheers,
Andre

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

Andre Przywara (7):
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
dt-bindings: clk: sunxi-ng: add compatible for the A523 PRCM-CCU
clk: sunxi-ng: Add support for the A523/T527 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        | 1628 +++++++++++++++++
 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   |  187 ++
 include/dt-bindings/clock/sun55i-a523-r-ccu.h |   36 +
 include/dt-bindings/reset/sun55i-a523-ccu.h   |   87 +
 include/dt-bindings/reset/sun55i-a523-r-ccu.h |   25 +
 14 files changed, 2377 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
Signature · 1 line
2.46.2
#1 lore raw

PATCH 1/7 clk: sunxi-ng: mp: Add SUNXI_CCU_P_DATA_WITH_MUX_GATE wrapper

The PRCM CCU in the A523 SoC contains some clocks that only feature a P (shift) factor, but no M divider.
Treat this as a special case of an MP clock: by forcing the M mask to be 0 bits wide, this always result in the M divider value to be 1.

---
 drivers/clk/sunxi-ng/ccu_mp.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/clk/sunxi-ng/ccu_mp.h +18 -0
index 6e50f3728fb5f..e235fdfde2d36 100644
@@ -71,6 +71,24 @@ struct ccu_mp {
 		}							\
 	}
 
+#define SUNXI_CCU_P_DATA_WITH_MUX_GATE(_struct, _name, _parents, _reg,	\
+				       _pshift, _pwidth,		\
+				       _muxshift, _muxwidth,		\
+				       _gate, _flags)			\
+	struct ccu_mp _struct = {					\
+		.enable	= _gate,					\
+		.m	= _SUNXI_CCU_DIV(0, 0),				\
+		.p	= _SUNXI_CCU_DIV(_pshift, _pwidth),		\
+		.mux	= _SUNXI_CCU_MUX(_muxshift, _muxwidth),		\
+		.common	= {						\
+			.reg		= _reg,				\
+			.hw.init	= CLK_HW_INIT_PARENTS_DATA(_name,    \
+								   _parents, \
+								   &ccu_mp_ops,\
+								   _flags),  \
+		}							\
+	}
+
 #define SUNXI_CCU_MP_WITH_MUX(_struct, _name, _parents, _reg,		\
 			      _mshift, _mwidth,				\
 			      _pshift, _pwidth,				\
Signature · 1 line
2.46.2
#2 lore raw

PATCH 2/7 clk: sunxi-ng: mp: introduce dual-divider clock

In reply to Andre Przywara

The Allwinner A523 SoC introduces some new MP-style mod clock, where the second "P" divider is an actual numerical divider value, and not the numbers of bits to shift (1..32 instead of 1,2,4,8).
The rest of the clock is the same as the existing MP clock, so enhance the existing code to accommodate for this.

Introduce the new CCU feature bit CCU_FEATURE_DUAL_DIV to mark an MP clock as having two dividers, and change the dividing and encoding code to differentiate the two cases.

---
 drivers/clk/sunxi-ng/ccu_common.h |  1 +
 drivers/clk/sunxi-ng/ccu_mp.c     | 51 +++++++++++++++++++++++++------
 2 files changed, 42 insertions(+), 10 deletions(-)
drivers/clk/sunxi-ng/ccu_common.h +1 -0
index 329734f8cf42b..4bb05207bb5df 100644
@@ -19,6 +19,7 @@
 #define CCU_FEATURE_SIGMA_DELTA_MOD	BIT(7)
 #define CCU_FEATURE_KEY_FIELD		BIT(8)
 #define CCU_FEATURE_CLOSEST_RATE	BIT(9)
+#define CCU_FEATURE_DUAL_DIV		BIT(10)
 
 /* MMC timing mode switch bit */
 #define CCU_MMC_NEW_TIMING_MODE		BIT(30)
drivers/clk/sunxi-ng/ccu_mp.c +41 -10

122 lines not on this page · raw message

Signature · 1 line
2.46.2
#3 lore raw

PATCH 3/7 clk: sunxi-ng: mp: provide wrapper for setting feature flags

In reply to Andre Przywara

So far our sunxi clock instantiation macros set the required flags depending on the clock type, but the new "dual divider MP clock" requires us to pass that piece of information in by the user.

Add a new wrapper macro that allows to specify a "features" field, to allow marking those dual-divider clocks accordingly.

---
 drivers/clk/sunxi-ng/ccu_mp.h | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/clk/sunxi-ng/ccu_mp.h +16 -3
index e235fdfde2d36..687bd2ec798e2 100644
@@ -100,11 +100,12 @@ struct ccu_mp {
 				   _muxshift, _muxwidth,		\
 				   0, _flags)
 
-#define SUNXI_CCU_MP_DATA_WITH_MUX_GATE(_struct, _name, _parents, _reg,	\
+#define SUNXI_CCU_MP_DATA_WITH_MUX_GATE_FEAT(_struct, _name, _parents, _reg, \
 					_mshift, _mwidth,		\
 					_pshift, _pwidth,		\
 					_muxshift, _muxwidth,		\
-					_gate, _flags)			\
+					_gate, _flags,			\
+					_features)			\
 	struct ccu_mp _struct = {					\
 		.enable	= _gate,					\
 		.m	= _SUNXI_CCU_DIV(_mshift, _mwidth),		\
@@ -112,13 +113,25 @@ struct ccu_mp {
 		.mux	= _SUNXI_CCU_MUX(_muxshift, _muxwidth),		\
 		.common	= {						\
 			.reg		= _reg,				\
+			.features	= _features,			\
 			.hw.init	= CLK_HW_INIT_PARENTS_DATA(_name, \
 								   _parents, \
-								   &ccu_mp_ops, \
+								   &ccu_mp_ops,\
 								   _flags), \
 		}							\
 	}
 
+#define SUNXI_CCU_MP_DATA_WITH_MUX_GATE(_struct, _name, _parents, _reg,	\
+					_mshift, _mwidth,		\
+					_pshift, _pwidth,		\
+					_muxshift, _muxwidth,		\
+					_gate, _flags)			\
+	SUNXI_CCU_MP_DATA_WITH_MUX_GATE_FEAT(_struct, _name, _parents,	\
+					     _reg, _mshift, _mwidth,	\
+					     _pshift, _pwidth,		\
+					     _muxshift, _muxwidth,	\
+					     _gate, _flags, 0)
+
 #define SUNXI_CCU_MP_DATA_WITH_MUX(_struct, _name, _parents, _reg,	\
 				   _mshift, _mwidth,			\
 				   _pshift, _pwidth,			\
Signature · 1 line
2.46.2
#4 lore raw

PATCH 4/7 dt-bindings: clk: sunxi-ng: add compatible for the A523 CCU

In reply to Andre Przywara

The Allwinner A523/T527 SoCs have four CCUs, this adds the binding for the main CCU.

Add the new compatible string, along with the required input clock lists.
Also add the DT binding headers, listing all the clocks with their ID numbers.

---
 .../clock/allwinner,sun4i-a10-ccu.yaml        |   2 +
 include/dt-bindings/clock/sun55i-a523-ccu.h   | 187 ++++++++++++++++++
 include/dt-bindings/reset/sun55i-a523-ccu.h   |  87 ++++++++
 3 files changed, 276 insertions(+)
 create mode 100644 include/dt-bindings/clock/sun55i-a523-ccu.h
 create mode 100644 include/dt-bindings/reset/sun55i-a523-ccu.h
Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml +2 -0
index 1690b9d99c3d4..451a18de1b6c1 100644
@@ -45,6 +45,7 @@ properties:
       - allwinner,sun50i-h6-r-ccu
       - allwinner,sun50i-h616-ccu
       - allwinner,sun50i-h616-r-ccu
+      - allwinner,sun55i-a523-ccu
       - allwinner,suniv-f1c100s-ccu
       - nextthing,gr8-ccu
 
@@ -106,6 +107,7 @@ else:
           - allwinner,sun50i-a100-ccu
           - allwinner,sun50i-h6-ccu
           - allwinner,sun50i-h616-ccu
+          - allwinner,sun55i-a523-ccu
 
   then:
     properties:
include/dt-bindings/clock/sun55i-a523-ccu.h new file +187 -0

187 lines not on this page · raw message

include/dt-bindings/reset/sun55i-a523-ccu.h new file +87 -0

87 lines not on this page · raw message

Signature · 1 line
2.46.2
#6 lore raw

PATCH 5/7 dt-bindings: clk: sunxi-ng: add compatible for the A523 PRCM-CCU

In reply to Andre Przywara

The Allwinner A523/T527 SoCs have four CCUs, this adds the binding for the PRCM R_CCU.

Add the new compatible string, along with the required input clock lists. There is now an extra input clock (PLL_AUDIO), so add this to the list of allowed clocks and required it for the A523 PRCM CCU. Also add the DT binding headers, listing all the clocks with their ID numbers.

---
 .../clock/allwinner,sun4i-a10-ccu.yaml        | 76 ++++++++++++-------
 include/dt-bindings/clock/sun55i-a523-r-ccu.h | 36 +++++++++
 include/dt-bindings/reset/sun55i-a523-r-ccu.h | 25 ++++++
 3 files changed, 109 insertions(+), 28 deletions(-)
 create mode 100644 include/dt-bindings/clock/sun55i-a523-r-ccu.h
 create mode 100644 include/dt-bindings/reset/sun55i-a523-r-ccu.h
Documentation/devicetree/bindings/clock/allwinner,sun4i-a10-ccu.yaml +48 -28
index 451a18de1b6c1..791dc333be74d 100644
@@ -46,6 +46,7 @@ properties:
       - allwinner,sun50i-h616-ccu
       - allwinner,sun50i-h616-r-ccu
       - allwinner,sun55i-a523-ccu
+      - allwinner,sun55i-a523-r-ccu
       - allwinner,suniv-f1c100s-ccu
       - nextthing,gr8-ccu
 
@@ -59,6 +60,7 @@ properties:
       - description: Low Frequency Oscillator (usually at 32kHz)
       - description: Internal Oscillator
       - description: Peripherals PLL
+      - description: Audio PLL
 
   clock-names:
     minItems: 2
@@ -67,6 +69,7 @@ properties:
       - const: losc
       - const: iosc
       - const: pll-periph
+      - const: pll-audio
 
 required:
   - "#clock-cells"
@@ -80,54 +83,71 @@ if:
   properties:
     compatible:
       enum:
-        - allwinner,sun8i-a83t-r-ccu
-        - allwinner,sun8i-h3-r-ccu
-        - allwinner,sun20i-d1-r-ccu
-        - allwinner,sun50i-a64-r-ccu
-        - allwinner,sun50i-a100-r-ccu
-        - allwinner,sun50i-h6-r-ccu
-        - allwinner,sun50i-h616-r-ccu
+        - allwinner,sun55i-a523-r-ccu
 
 then:
   properties:
     clocks:
-      minItems: 4
-      maxItems: 4
+      minItems: 5
+      maxItems: 5
 
     clock-names:
-      minItems: 4
-      maxItems: 4
+      minItems: 5
+      maxItems: 5
 
 else:
   if:
     properties:
       compatible:
         enum:
-          - allwinner,sun20i-d1-ccu
-          - allwinner,sun50i-a100-ccu
-          - allwinner,sun50i-h6-ccu
-          - allwinner,sun50i-h616-ccu
-          - allwinner,sun55i-a523-ccu
+          - allwinner,sun8i-a83t-r-ccu
+          - allwinner,sun8i-h3-r-ccu
+          - allwinner,sun20i-d1-r-ccu
+          - allwinner,sun50i-a64-r-ccu
+          - allwinner,sun50i-a100-r-ccu
+          - allwinner,sun50i-h6-r-ccu
+          - allwinner,sun50i-h616-r-ccu
 
   then:
     properties:
       clocks:
-        minItems: 3
-        maxItems: 3
+        minItems: 4
+        maxItems: 4
 
       clock-names:
-        minItems: 3
-        maxItems: 3
+        minItems: 4
+        maxItems: 4
 
   else:
-    properties:
-      clocks:
-        minItems: 2
-        maxItems: 2
-
-      clock-names:
-        minItems: 2
-        maxItems: 2
+    if:
+      properties:
+        compatible:
+          enum:
+            - allwinner,sun20i-d1-ccu
+            - allwinner,sun50i-a100-ccu
+            - allwinner,sun50i-h6-ccu
+            - allwinner,sun50i-h616-ccu
+            - allwinner,sun55i-a523-ccu
+
+    then:
+      properties:
+        clocks:
+          minItems: 3
+          maxItems: 3
+
+        clock-names:
+          minItems: 3
+          maxItems: 3
+
+    else:
+      properties:
+        clocks:
+          minItems: 2
+          maxItems: 2
+
+        clock-names:
+          minItems: 2
+          maxItems: 2
 
 additionalProperties: false
 
include/dt-bindings/clock/sun55i-a523-r-ccu.h new file +36 -0
new file mode 100644
index 0000000000000..b738054f1576b
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
+/*
+ * Copyright (C) 2024 Arm Ltd.
+ */
+
+#ifndef _DT_BINDINGS_CLK_SUN55I_A523_R_CCU_H_
+#define _DT_BINDINGS_CLK_SUN55I_A523_R_CCU_H_
+
+#define CLK_R_AHB		0
+#define CLK_R_APB0		1
+#define CLK_R_APB1		2
+#define CLK_R_TIMER0		3
+#define CLK_R_TIMER1		4
+#define CLK_R_TIMER2		5
+#define CLK_BUS_R_TIMER		6
+#define CLK_BUS_R_TWD		7
+#define CLK_R_PWMCTRL		8
+#define CLK_BUS_R_PWMCTRL	9
+#define CLK_BUS_R_SPI		10
+#define CLK_BUS_R_SPINLOCK	11
+#define CLK_BUS_R_MSGBOX	12
+#define CLK_BUS_R_UART0		13
+#define CLK_BUS_R_UART1		14
+#define CLK_BUS_R_I2C0		15
+#define CLK_BUS_R_I2C1		16
+#define CLK_BUS_R_I2C2		17
+#define CLK_BUS_R_PPU0		18
+#define CLK_BUS_R_PPU1		19
+#define CLK_BUS_R_CPU_BIST	20
+#define CLK_R_IR_RX		21
+#define CLK_BUS_R_IR_RX		22
+#define CLK_BUS_R_DMA		23
+#define CLK_BUS_R_RTC		24
+#define CLK_BUS_R_CPUCFG	25
+
+#endif /* _DT_BINDINGS_CLK_SUN55I_A523_R_CCU_H_ */
include/dt-bindings/reset/sun55i-a523-r-ccu.h new file +25 -0
new file mode 100644
index 0000000000000..dd6fbb372e190
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
+/*
+ * Copyright (C) 2024 Arm Ltd.
+ */
+
+#ifndef _DT_BINDINGS_RST_SUN55I_A523_R_CCU_H_
+#define _DT_BINDINGS_RST_SUN55I_A523_R_CCU_H_
+
+#define RST_BUS_R_TIMER		0
+#define RST_BUS_R_TWD		1
+#define RST_BUS_R_PWMCTRL	2
+#define RST_BUS_R_SPI		3
+#define RST_BUS_R_SPINLOCK	4
+#define RST_BUS_R_MSGBOX	5
+#define RST_BUS_R_UART0		6
+#define RST_BUS_R_UART1		7
+#define RST_BUS_R_I2C0		8
+#define RST_BUS_R_I2C1		9
+#define RST_BUS_R_I2C2		10
+#define RST_BUS_R_PPU1		11
+#define RST_BUS_R_IR_RX		12
+#define RST_BUS_R_RTC		13
+#define RST_BUS_R_CPUCFG	14
+
+#endif /* _DT_BINDINGS_RST_SUN55I_A523_R_CCU_H_ */
Signature · 1 line
2.46.2
#8 lore raw

PATCH 6/7 clk: sunxi-ng: Add support for the A523/T527 CCU

In reply to Andre Przywara

Add the clocks of the main CCU of the Allwinner A523 and T527 SoCs. The A523 clocks were modelled after the manual, and double checked by writing all 1's into the respective register, to spot all implemented bits. The T527 is a superset of the A523, and there does not seem to be a separate T527 manual available. Information was gathered from the BSP, by probing registers, and by looking at other recent SoCs.

The PLL and mod clocks for the two CPU clusters and the DSU are part of a separate CCU, also most audio clocks are collected in a DSP CCU, so both of these clock groups are missing from this driver.

---
 drivers/clk/sunxi-ng/Kconfig           |    5 +
 drivers/clk/sunxi-ng/Makefile          |    2 +
 drivers/clk/sunxi-ng/ccu-sun55i-a523.c | 1628 ++++++++++++++++++++++++
 drivers/clk/sunxi-ng/ccu-sun55i-a523.h |   14 +
 drivers/clk/sunxi-ng/ccu_mp.h          |   14 +-
 5 files changed, 1657 insertions(+), 6 deletions(-)
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523.c
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523.h
drivers/clk/sunxi-ng/Kconfig +5 -0
index b547198a2c654..04efbda847cf9 100644
@@ -52,6 +52,11 @@ config SUN50I_H6_R_CCU
 	default y
 	depends on ARM64 || COMPILE_TEST
 
+config SUN55I_A523_CCU
+	tristate "Support for the Allwinner A523/T527 CCU"
+	default y
+	depends on ARM64 || COMPILE_TEST
+
 config SUN4I_A10_CCU
 	tristate "Support for the Allwinner A10/A20 CCU"
 	default y
drivers/clk/sunxi-ng/Makefile +2 -0
index 6b3ae2b620db6..01a887f7824bb 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_SUN50I_A100_R_CCU)	+= sun50i-a100-r-ccu.o
 obj-$(CONFIG_SUN50I_H6_CCU)	+= sun50i-h6-ccu.o
 obj-$(CONFIG_SUN50I_H6_R_CCU)	+= sun50i-h6-r-ccu.o
 obj-$(CONFIG_SUN50I_H616_CCU)	+= sun50i-h616-ccu.o
+obj-$(CONFIG_SUN55I_A523_CCU)	+= sun55i-a523-ccu.o
 obj-$(CONFIG_SUN4I_A10_CCU)	+= sun4i-a10-ccu.o
 obj-$(CONFIG_SUN5I_CCU)		+= sun5i-ccu.o
 obj-$(CONFIG_SUN6I_A31_CCU)	+= sun6i-a31-ccu.o
@@ -58,6 +59,7 @@ sun50i-a100-r-ccu-y		+= ccu-sun50i-a100-r.o
 sun50i-h6-ccu-y			+= ccu-sun50i-h6.o
 sun50i-h6-r-ccu-y		+= ccu-sun50i-h6-r.o
 sun50i-h616-ccu-y		+= ccu-sun50i-h616.o
+sun55i-a523-ccu-y		+= ccu-sun55i-a523.o
 sun4i-a10-ccu-y			+= ccu-sun4i-a10.o
 sun5i-ccu-y			+= ccu-sun5i.o
 sun6i-a31-ccu-y			+= ccu-sun6i-a31.o
drivers/clk/sunxi-ng/ccu-sun55i-a523.c new file +1628 -0

1,628 lines not on this page · raw message

drivers/clk/sunxi-ng/ccu-sun55i-a523.h new file +14 -0
new file mode 100644
index 0000000000000..fc8dd42f1b47b
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2024 Arm Ltd.
+ */
+
+#ifndef _CCU_SUN55I_A523_H
+#define _CCU_SUN55I_A523_H
+
+#include <dt-bindings/clock/sun55i-a523-ccu.h>
+#include <dt-bindings/reset/sun55i-a523-ccu.h>
+
+#define CLK_NUMBER	(CLK_FANOUT2 + 1)
+
+#endif /* _CCU_SUN55I_A523_H */
drivers/clk/sunxi-ng/ccu_mp.h +8 -6
index 687bd2ec798e2..5311835a4db60 100644
@@ -100,20 +100,22 @@ struct ccu_mp {
 				   _muxshift, _muxwidth,		\
 				   0, _flags)
 
-#define SUNXI_CCU_MP_DATA_WITH_MUX_GATE_FEAT(_struct, _name, _parents, _reg, \
+#define SUNXI_CCU_MP_MUX_GATE_POSTDIV_FEAT(_struct, _name, _parents, _reg, \
 					_mshift, _mwidth,		\
 					_pshift, _pwidth,		\
 					_muxshift, _muxwidth,		\
-					_gate, _flags,			\
-					_features)			\
+					_gate, _postdiv,		\
+					_flags, _features)		\
 	struct ccu_mp _struct = {					\
 		.enable	= _gate,					\
 		.m	= _SUNXI_CCU_DIV(_mshift, _mwidth),		\
 		.p	= _SUNXI_CCU_DIV(_pshift, _pwidth),		\
 		.mux	= _SUNXI_CCU_MUX(_muxshift, _muxwidth),		\
+		.fixed_post_div = _postdiv,				\
 		.common	= {						\
 			.reg		= _reg,				\
-			.features	= _features,			\
+			.features	= CCU_FEATURE_FIXED_POSTDIV |	\
+						_features,		\
 			.hw.init	= CLK_HW_INIT_PARENTS_DATA(_name, \
 								   _parents, \
 								   &ccu_mp_ops,\
@@ -126,11 +128,11 @@ struct ccu_mp {
 					_pshift, _pwidth,		\
 					_muxshift, _muxwidth,		\
 					_gate, _flags)			\
-	SUNXI_CCU_MP_DATA_WITH_MUX_GATE_FEAT(_struct, _name, _parents,	\
+	SUNXI_CCU_MP_MUX_GATE_POSTDIV_FEAT(_struct, _name, _parents,	\
 					     _reg, _mshift, _mwidth,	\
 					     _pshift, _pwidth,		\
 					     _muxshift, _muxwidth,	\
-					     _gate, _flags, 0)
+					     _gate, 1, _flags, 0)
 
 #define SUNXI_CCU_MP_DATA_WITH_MUX(_struct, _name, _parents, _reg,	\
 				   _mshift, _mwidth,			\
Signature · 1 line
2.46.2
#9 lore raw

PATCH 7/7 clk: sunxi-ng: add support for the A523/T527 PRCM CCU

In reply to Andre Przywara

The A523/T527 SoCs have clock/reset controls in the PRCM part, like many previous SoCs. For a change, the whole PRCM is documented in the A523 manual, including the system bus tree, so we can describe all those clocks correctly based on that. There layout seems to be derived from the H6 and H616 PRCM CCUs, though there are more clocks, and many clocks have subtly changed.

Describe all the mod and gate clocks, including the three bus clocks (R_AHB, R_APB0, and R_APB1).

---
 drivers/clk/sunxi-ng/Kconfig             |   5 +
 drivers/clk/sunxi-ng/Makefile            |   2 +
 drivers/clk/sunxi-ng/ccu-sun55i-a523-r.c | 245 +++++++++++++++++++++++
 drivers/clk/sunxi-ng/ccu-sun55i-a523-r.h |  14 ++
 4 files changed, 266 insertions(+)
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523-r.c
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523-r.h
drivers/clk/sunxi-ng/Kconfig +5 -0
index 04efbda847cf9..5830a9d87bf25 100644
@@ -57,6 +57,11 @@ config SUN55I_A523_CCU
 	default y
 	depends on ARM64 || COMPILE_TEST
 
+config SUN55I_A523_R_CCU
+	tristate "Support for the Allwinner A523/T527 PRCM CCU"
+	default y
+	depends on ARM64 || COMPILE_TEST
+
 config SUN4I_A10_CCU
 	tristate "Support for the Allwinner A10/A20 CCU"
 	default y
drivers/clk/sunxi-ng/Makefile +2 -0
index 01a887f7824bb..82e471036de69 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_SUN50I_H6_CCU)	+= sun50i-h6-ccu.o
 obj-$(CONFIG_SUN50I_H6_R_CCU)	+= sun50i-h6-r-ccu.o
 obj-$(CONFIG_SUN50I_H616_CCU)	+= sun50i-h616-ccu.o
 obj-$(CONFIG_SUN55I_A523_CCU)	+= sun55i-a523-ccu.o
+obj-$(CONFIG_SUN55I_A523_R_CCU)	+= sun55i-a523-r-ccu.o
 obj-$(CONFIG_SUN4I_A10_CCU)	+= sun4i-a10-ccu.o
 obj-$(CONFIG_SUN5I_CCU)		+= sun5i-ccu.o
 obj-$(CONFIG_SUN6I_A31_CCU)	+= sun6i-a31-ccu.o
@@ -60,6 +61,7 @@ sun50i-h6-ccu-y			+= ccu-sun50i-h6.o
 sun50i-h6-r-ccu-y		+= ccu-sun50i-h6-r.o
 sun50i-h616-ccu-y		+= ccu-sun50i-h616.o
 sun55i-a523-ccu-y		+= ccu-sun55i-a523.o
+sun55i-a523-r-ccu-y		+= ccu-sun55i-a523-r.o
 sun4i-a10-ccu-y			+= ccu-sun4i-a10.o
 sun5i-ccu-y			+= ccu-sun5i.o
 sun6i-a31-ccu-y			+= ccu-sun6i-a31.o
drivers/clk/sunxi-ng/ccu-sun55i-a523-r.c new file +245 -0

245 lines not on this page · raw message

drivers/clk/sunxi-ng/ccu-sun55i-a523-r.h new file +14 -0
new file mode 100644
index 0000000000000..d50f46ac4f3fe
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2024 Arm Ltd.
+ */
+
+#ifndef _CCU_SUN55I_A523_R_H
+#define _CCU_SUN55I_A523_R_H
+
+#include <dt-bindings/clock/sun55i-a523-r-ccu.h>
+#include <dt-bindings/reset/sun55i-a523-r-ccu.h>
+
+#define CLK_NUMBER	(CLK_BUS_R_CPUCFG + 1)
+
+#endif /* _CCU_SUN55I_A523_R_H */
Signature · 1 line
2.46.2
Acked-by on v1 4/7
#5 lore raw

Re: [PATCH 4/7] dt-bindings: clk: sunxi-ng: add compatible for the A523 CCU

In reply to Andre Przywara
Quoted 9 lines · Andre Przywara

The Allwinner A523/T527 SoCs have four CCUs, this adds the binding for the main CCU.

Add the new compatible string, along with the required input clock lists.
Also add the DT binding headers, listing all the clocks with their ID numbers.

Acked-by on v1 5/7
#7 lore raw

Re: [PATCH 5/7] dt-bindings: clk: sunxi-ng: add compatible for the A523 PRCM-CCU

In reply to Andre Przywara
Quoted 10 lines · Andre Przywara

The Allwinner A523/T527 SoCs have four CCUs, this adds the binding for the PRCM R_CCU.

Add the new compatible string, along with the required input clock lists. There is now an extra input clock (PLL_AUDIO), so add this to the list of allowed clocks and required it for the A523 PRCM CCU. Also add the DT binding headers, listing all the clocks with their ID numbers.