arm64: allwinner: a523: Enable MCU PRCM and NPU
Subsystems (4)
Chen-Yu Tsai
maintainerv2 cover arm64: allwinner: a523: Enable MCU PRCM and NPU
From: Chen-Yu Tsai <[email protected]>
Hi folks,
This is v2 of my A523 MCU PRCM and NPU support series.
Changes since v1:
- Dropped dual divider clock rate read-back fix that is already merged
- DT binding
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
- Add NPU clk
- Move .num to after list of clks
- MCU CCU clk driver
- Added comment for "fixed" dividers in audio PLL clock
- Corrected variable names for audio PLL divider clocks
- Added comment for the reversed order of some of the DSP clock's parents when compared to the manual
- Added comments for clocks and resets only found in the BSP driver
- Corrected register offset for i2s3-asrc and bus-mcu-pwm0 clocks
- Made "r-ahb" and new "r-apb0" external bus clocks the parents of the bus gate clocks, with comments if guessed which one applies
- Moved .num_clks to after the list of clocks, making it obvious that the value needs to be added if more clocks are added to the list
- MCU CCU DT node
- Enlarged MCU PRCM register range to 0x200
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
- Link to v1
https://lore.kernel.org/all/[email protected]/
The MCU PRCM is a Power, Reset & Clock Management block that has some clock and reset controls for the MCU, DSP and some peripherals that the MCU could use.
The NPU is a Vivante IP block. It is clocked from the NPU PLL from the main clock unit, but the bus clock and reset controls lie in the MCU PRCM.
Patch 1 adds the missing NPU module clock to the main clock control unit's binding.
Patch 2 adds the binding for the MCU PRCM clock control unit
Patch 3 adds the missing NPU module clock.
Patch 4 adds support for power-of-two dividers to the sunxi-ng clk library.
Patch 5 adds a new driver for the A523 MCU PRCM CCU.
Patch 6 adds a device node for the MCU PRCM CCU.
Patch 7 adds a device node for the NPU.
The NPU was only lightly tested: the driver correctly probes and detects a model GC9000, revision 9003.
Please have a look. All patches will be merged through the sunxi tree.
Thanks
ChenYu
Chen-Yu Tsai (7):
dt-bindings: clock: sun55i-a523-ccu: Add missing NPU module clock
dt-bindings: clock: sun55i-a523-ccu: Add A523 MCU CCU clock controller
clk: sunxi-ng: sun55i-a523-ccu: Add missing NPU module clock
clk: sunxi-ng: div: support power-of-two dividers
clk: sunxi-ng: add support for the A523/T527 MCU CCU
arm64: dts: allwinner: a523: Add MCU PRCM CCU node
arm64: dts: allwinner: a523: Add NPU device node
.../clock/allwinner,sun55i-a523-ccu.yaml | 37 +- .../arm64/boot/dts/allwinner/sun55i-a523.dtsi | 39 ++ drivers/clk/sunxi-ng/Kconfig | 5 + drivers/clk/sunxi-ng/Makefile | 2 + drivers/clk/sunxi-ng/ccu-sun55i-a523-mcu.c | 469 ++++++++++++++++++ drivers/clk/sunxi-ng/ccu-sun55i-a523.c | 21 +- drivers/clk/sunxi-ng/ccu-sun55i-a523.h | 14 - drivers/clk/sunxi-ng/ccu_div.h | 18 + include/dt-bindings/clock/sun55i-a523-ccu.h | 1 + .../dt-bindings/clock/sun55i-a523-mcu-ccu.h | 54 ++ .../dt-bindings/reset/sun55i-a523-mcu-ccu.h | 30 ++ 11 files changed, 671 insertions(+), 19 deletions(-) create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523-mcu.c delete mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523.h create mode 100644 include/dt-bindings/clock/sun55i-a523-mcu-ccu.h create mode 100644 include/dt-bindings/reset/sun55i-a523-mcu-ccu.h
Signature · 1 line
2.39.5
Chen-Yu Tsai
maintainerPATCH v2 1/7 dt-bindings: clock: sun55i-a523-ccu: Add missing NPU module clock
From: Chen-Yu Tsai <[email protected]>
The main clock controller on the A523/T527 has the NPU's module clock. It was missing from the original submission, likely because that was based on the A523 user manual; the A523 is marketed without the NPU.
--- include/dt-bindings/clock/sun55i-a523-ccu.h | 1 + 1 file changed, 1 insertion(+)
include/dt-bindings/clock/sun55i-a523-ccu.h +1 -0
@@ -185,5 +185,6 @@#define CLK_FANOUT0 176#define CLK_FANOUT1 177#define CLK_FANOUT2 178 +#define CLK_NPU 179#endif /* _DT_BINDINGS_CLK_SUN55I_A523_CCU_H_ */
Signature · 1 line
2.39.5
Chen-Yu Tsai
maintainerPATCH v2 2/7 dt-bindings: clock: sun55i-a523-ccu: Add A523 MCU CCU clock controller
In reply to Chen-Yu TsaiFrom: Chen-Yu Tsai <[email protected]>
There are four clock controllers in the A523 SoC. The existing binding already covers two of them that are critical for basic operation. The remaining ones are the MCU clock controller and CPU PLL clock controller.
Add a description for the MCU CCU. This unit controls and provides clocks to the MCU (RISC-V) subsystem and peripherals meant to operate under low power conditions.
---
Changes since v1:
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
Reviewed-by not dropped since this is a minor change.
--- .../clock/allwinner,sun55i-a523-ccu.yaml | 37 ++++++++++++- .../dt-bindings/clock/sun55i-a523-mcu-ccu.h | 54 +++++++++++++++++++ .../dt-bindings/reset/sun55i-a523-mcu-ccu.h | 30 +++++++++++ 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 include/dt-bindings/clock/sun55i-a523-mcu-ccu.h create mode 100644 include/dt-bindings/reset/sun55i-a523-mcu-ccu.h
Documentation/devicetree/bindings/clock/allwinner,sun55i-a523-ccu.yaml +35 -2
@@ -19,6 +19,7 @@ properties: compatible: enum: - allwinner,sun55i-a523-ccu + - allwinner,sun55i-a523-mcu-ccu - allwinner,sun55i-a523-r-ccu reg:
@@ -26,11 +27,11 @@ properties: clocks: minItems: 4 - maxItems: 5 + maxItems: 9 clock-names: minItems: 4 - maxItems: 5 + maxItems: 9 required: - "#clock-cells"
@@ -63,6 +64,38 @@ allOf: - const: iosc - const: losc-fanout + - if: + properties: + compatible: + enum: + - allwinner,sun55i-a523-mcu-ccu + + then: + properties: + clocks: + items: + - description: High Frequency Oscillator (usually at 24MHz) + - description: Low Frequency Oscillator (usually at 32kHz) + - description: Internal Oscillator + - description: Audio PLL (4x) + - description: Peripherals PLL 0 (300 MHz output) + - description: DSP module clock + - description: MBUS clock + - description: PRCM AHB clock + - description: PRCM APB0 clock + + clock-names: + items: + - const: hosc + - const: losc + - const: iosc + - const: pll-audio0-4x + - const: pll-periph0-300m + - const: dsp + - const: mbus + - const: r-ahb + - const: r-apb0 + - if: properties: compatible:
include/dt-bindings/clock/sun55i-a523-mcu-ccu.h new file +54 -0
54 lines not on this page · raw message
include/dt-bindings/reset/sun55i-a523-mcu-ccu.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */ +/* +* Copyright (C) 2025 Chen-Yu Tsai <[email protected]> +*/ + +#ifndef _DT_BINDINGS_RST_SUN55I_A523_MCU_CCU_H_ +#define _DT_BINDINGS_RST_SUN55I_A523_MCU_CCU_H_ + +#define RST_BUS_MCU_I2S0 0 +#define RST_BUS_MCU_I2S1 1 +#define RST_BUS_MCU_I2S2 2 +#define RST_BUS_MCU_I2S3 3 +#define RST_BUS_MCU_SPDIF 4 +#define RST_BUS_MCU_DMIC 5 +#define RST_BUS_MCU_AUDIO_CODEC 6 +#define RST_BUS_MCU_DSP_MSGBOX 7 +#define RST_BUS_MCU_DSP_CFG 8 +#define RST_BUS_MCU_NPU 9 +#define RST_BUS_MCU_TIMER 10 +#define RST_BUS_MCU_DSP_DEBUG 11 +#define RST_BUS_MCU_DSP 12 +#define RST_BUS_MCU_DMA 13 +#define RST_BUS_MCU_PUBSRAM 14 +#define RST_BUS_MCU_RISCV_CFG 15 +#define RST_BUS_MCU_RISCV_DEBUG 16 +#define RST_BUS_MCU_RISCV_CORE 17 +#define RST_BUS_MCU_RISCV_MSGBOX 18 +#define RST_BUS_MCU_PWM0 19 + +#endif /* _DT_BINDINGS_RST_SUN55I_A523_MCU_CCU_H_ */
Signature · 1 line
2.39.5
Chen-Yu Tsai
maintainerPATCH v2 3/7 clk: sunxi-ng: sun55i-a523-ccu: Add missing NPU module clock
In reply to Chen-Yu TsaiFrom: Chen-Yu Tsai <[email protected]>
The main clock controller on the A523/T527 has the NPU's module clock. It was missing from the original submission, likely because that was based on the A523 user manual; the A523 is marketed without the NPU.
Also, merge the private header back into the driver code itself. The header only contains a macro containing the total number of clocks. This has to be updated every time a missing clock gets added. Having it in a separate file doesn't help the process. Instead just drop the macro, and thus the header no longer has any reason to exist.
Also move the .num value to after the list of clks to make it obvious that it should be updated when new clks are added.
---
Changes since v1:
- Move .num to after list of clks
--- drivers/clk/sunxi-ng/ccu-sun55i-a523.c | 21 ++++++++++++++++++--- drivers/clk/sunxi-ng/ccu-sun55i-a523.h | 14 -------------- 2 files changed, 18 insertions(+), 17 deletions(-) delete mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523.h
drivers/clk/sunxi-ng/ccu-sun55i-a523.c +18 -3
@@ -11,6 +11,9 @@#include <linux/module.h> #include <linux/platform_device.h> +#include <dt-bindings/clock/sun55i-a523-ccu.h> +#include <dt-bindings/reset/sun55i-a523-ccu.h> +#include "../clk.h" #include "ccu_common.h"
@@ -25,8 +28,6 @@#include "ccu_nkmp.h" #include "ccu_nm.h" -#include "ccu-sun55i-a523.h" -/* * The 24 MHz oscillator, the root of most of the clock tree. * .fw_name is the string used in the DT "clock-names" property, used to
@@ -486,6 +487,18 @@ static SUNXI_CCU_M_HW_WITH_MUX_GATE(ve_clk, "ve", ve_parents, 0x690, static SUNXI_CCU_GATE_HWS(bus_ve_clk, "bus-ve", ahb_hws, 0x69c, BIT(0), 0); +static const struct clk_hw *npu_parents[] = { + &pll_periph0_480M_clk.common.hw, + &pll_periph0_600M_clk.hw, + &pll_periph0_800M_clk.common.hw, + &pll_npu_2x_clk.hw, +}; +static SUNXI_CCU_M_HW_WITH_MUX_GATE(npu_clk, "npu", npu_parents, 0x6e0, +0 ,5 ,/* M */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + CLK_SET_RATE_PARENT); + static SUNXI_CCU_GATE_HWS(bus_dma_clk, "bus-dma", ahb_hws, 0x70c, BIT(0), 0); static SUNXI_CCU_GATE_HWS(bus_msgbox_clk, "bus-msgbox", ahb_hws, 0x71c,
@@ -1217,6 +1230,7 @@ static struct ccu_common *sun55i_a523_ccu_clks[] = { &bus_ce_sys_clk.common, &ve_clk.common, &bus_ve_clk.common, + &npu_clk.common, &bus_dma_clk.common, &bus_msgbox_clk.common, &bus_spinlock_clk.common,
@@ -1343,7 +1357,6 @@ static struct ccu_common *sun55i_a523_ccu_clks[] = { };static struct clk_hw_onecell_data sun55i_a523_hw_clks = { - .num =CLK_NUMBER , .hws = { [CLK_PLL_DDR0 ] = &pll_ddr_clk.common.hw, [CLK_PLL_PERIPH0_4X ] = &pll_periph0_4x_clk.common.hw,
@@ -1524,7 +1537,9 @@ static struct clk_hw_onecell_data sun55i_a523_hw_clks = { [CLK_FANOUT0] = &fanout0_clk.common.hw, [CLK_FANOUT1] = &fanout1_clk.common.hw, [CLK_FANOUT2] = &fanout2_clk.common.hw, + [CLK_NPU] = &npu_clk.common.hw, }, + .num = CLK_NPU + 1, };static struct ccu_reset_map sun55i_a523_ccu_resets[] = {
drivers/clk/sunxi-ng/ccu-sun55i-a523.h deleted +0 -14
@@ -1,14 +0,0 @@ -/* 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 */
Signature · 1 line
2.39.5
Re: [PATCH v2 3/7] clk: sunxi-ng: sun55i-a523-ccu: Add missing NPU module clock
Dne četrtek, 11. september 2025 ob 19:47:06 Srednjeevropski poletni čas je Chen-Yu Tsai napisal(a):
Quoted 12 lines
From: Chen-Yu Tsai <[email protected]>
The main clock controller on the A523/T527 has the NPU's module clock. It was missing from the original submission, likely because that was based on the A523 user manual; the A523 is marketed without the NPU.
Also, merge the private header back into the driver code itself. The header only contains a macro containing the total number of clocks. This has to be updated every time a missing clock gets added. Having it in a separate file doesn't help the process. Instead just drop the macro, and thus the header no longer has any reason to exist.
Quoted 4 lines
Also move the .num value to after the list of clks to make it obvious that it should be updated when new clks are added.
Signed-off-by Chen-Yu Tsai <[email protected]>
Best regards,
Jernej
Quoted 98 lines
---
Changes since v1:
- Move .num to after list of clks--- drivers/clk/sunxi-ng/ccu-sun55i-a523.c | 21 ++++++++++++++++++--- drivers/clk/sunxi-ng/ccu-sun55i-a523.h | 14 -------------- 2 files changed, 18 insertions(+), 17 deletions(-) delete mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523.hdrivers/clk/sunxi-ng/ccu-sun55i-a523.c +18
-3@@ -11,6 +11,9 @@#include <linux/module.h> #include <linux/platform_device.h> +#include <dt-bindings/clock/sun55i-a523-ccu.h> +#include <dt-bindings/reset/sun55i-a523-ccu.h> +#include "../clk.h" #include "ccu_common.h" @@ -25,8 +28,6 @@#include "ccu_nkmp.h" #include "ccu_nm.h" -#include "ccu-sun55i-a523.h" -/* * The 24 MHz oscillator, the root of most of the clock tree. * .fw_name is the string used in the DT "clock-names" property, used to @@ -486,6 +487,18 @@ static SUNXI_CCU_M_HW_WITH_MUX_GATE(ve_clk, "ve", ve_parents, 0x690, static SUNXI_CCU_GATE_HWS(bus_ve_clk, "bus-ve", ahb_hws, 0x69c, BIT(0), 0); +static const struct clk_hw *npu_parents[] = { + &pll_periph0_480M_clk.common.hw, + &pll_periph0_600M_clk.hw, + &pll_periph0_800M_clk.common.hw, + &pll_npu_2x_clk.hw, +}; +static SUNXI_CCU_M_HW_WITH_MUX_GATE(npu_clk, "npu", npu_parents, 0x6e0, +0 ,5 ,/* M */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + CLK_SET_RATE_PARENT); + static SUNXI_CCU_GATE_HWS(bus_dma_clk, "bus-dma", ahb_hws, 0x70c, BIT(0), 0); static SUNXI_CCU_GATE_HWS(bus_msgbox_clk, "bus-msgbox", ahb_hws, 0x71c,@@ -1217,6 +1230,7 @@ static struct ccu_common *sun55i_a523_ccu_clks[] = { &bus_ce_sys_clk.common, &ve_clk.common, &bus_ve_clk.common, + &npu_clk.common, &bus_dma_clk.common, &bus_msgbox_clk.common, &bus_spinlock_clk.common,@@ -1343,7 +1357,6 @@ static struct ccu_common *sun55i_a523_ccu_clks[] = { };static struct clk_hw_onecell_data sun55i_a523_hw_clks = { - .num =CLK_NUMBER , .hws = { [CLK_PLL_DDR0 ] = &pll_ddr_clk.common.hw, [CLK_PLL_PERIPH0_4X ] = &pll_periph0_4x_clk.common.hw,@@ -1524,7 +1537,9 @@ static struct clk_hw_onecell_data sun55i_a523_hw_clks = { [CLK_FANOUT0] = &fanout0_clk.common.hw, [CLK_FANOUT1] = &fanout1_clk.common.hw, [CLK_FANOUT2] = &fanout2_clk.common.hw, + [CLK_NPU] = &npu_clk.common.hw, }, + .num = CLK_NPU + 1, };static struct ccu_reset_map sun55i_a523_ccu_resets[] = {drivers/clk/sunxi-ng/ccu-sun55i-a523.h deleted +0
-14@@ -1,14 +0,0 @@ -/* 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 */
Re: [PATCH v2 3/7] clk: sunxi-ng: sun55i-a523-ccu: Add missing NPU module clock
In reply to Chen-Yu TsaiQuoted 12 lines · On Fri, 12 Sep 2025 01:47:06 +0800 Chen-Yu Tsai <[email protected]> wrote:
From: Chen-Yu Tsai <[email protected]>
The main clock controller on the A523/T527 has the NPU's module clock. It was missing from the original submission, likely because that was based on the A523 user manual; the A523 is marketed without the NPU.
Also, merge the private header back into the driver code itself. The header only contains a macro containing the total number of clocks. This has to be updated every time a missing clock gets added. Having it in a separate file doesn't help the process. Instead just drop the macro, and thus the header no longer has any reason to exist.
Quoted 4 lines
Also move the .num value to after the list of clks to make it obvious that it should be updated when new clks are added.
Signed-off-by Chen-Yu Tsai <[email protected]>
Thanks for the change!
Cheers,
Andre
Quoted 97 lines
---
Changes since v1:
- Move .num to after list of clks--- drivers/clk/sunxi-ng/ccu-sun55i-a523.c | 21 ++++++++++++++++++--- drivers/clk/sunxi-ng/ccu-sun55i-a523.h | 14 -------------- 2 files changed, 18 insertions(+), 17 deletions(-) delete mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523.hdrivers/clk/sunxi-ng/ccu-sun55i-a523.c +18
-3@@ -11,6 +11,9 @@#include <linux/module.h> #include <linux/platform_device.h> +#include <dt-bindings/clock/sun55i-a523-ccu.h> +#include <dt-bindings/reset/sun55i-a523-ccu.h> +#include "../clk.h" #include "ccu_common.h" @@ -25,8 +28,6 @@#include "ccu_nkmp.h" #include "ccu_nm.h" -#include "ccu-sun55i-a523.h" -/* * The 24 MHz oscillator, the root of most of the clock tree. * .fw_name is the string used in the DT "clock-names" property, used to @@ -486,6 +487,18 @@ static SUNXI_CCU_M_HW_WITH_MUX_GATE(ve_clk, "ve", ve_parents, 0x690, static SUNXI_CCU_GATE_HWS(bus_ve_clk, "bus-ve", ahb_hws, 0x69c, BIT(0), 0); +static const struct clk_hw *npu_parents[] = { + &pll_periph0_480M_clk.common.hw, + &pll_periph0_600M_clk.hw, + &pll_periph0_800M_clk.common.hw, + &pll_npu_2x_clk.hw, +}; +static SUNXI_CCU_M_HW_WITH_MUX_GATE(npu_clk, "npu", npu_parents, 0x6e0, +0 ,5 ,/* M */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ + CLK_SET_RATE_PARENT); + static SUNXI_CCU_GATE_HWS(bus_dma_clk, "bus-dma", ahb_hws, 0x70c, BIT(0), 0); static SUNXI_CCU_GATE_HWS(bus_msgbox_clk, "bus-msgbox", ahb_hws, 0x71c,@@ -1217,6 +1230,7 @@ static struct ccu_common *sun55i_a523_ccu_clks[] = { &bus_ce_sys_clk.common, &ve_clk.common, &bus_ve_clk.common, + &npu_clk.common, &bus_dma_clk.common, &bus_msgbox_clk.common, &bus_spinlock_clk.common,@@ -1343,7 +1357,6 @@ static struct ccu_common *sun55i_a523_ccu_clks[] = { };static struct clk_hw_onecell_data sun55i_a523_hw_clks = { - .num =CLK_NUMBER , .hws = { [CLK_PLL_DDR0 ] = &pll_ddr_clk.common.hw, [CLK_PLL_PERIPH0_4X ] = &pll_periph0_4x_clk.common.hw,@@ -1524,7 +1537,9 @@ static struct clk_hw_onecell_data sun55i_a523_hw_clks = { [CLK_FANOUT0] = &fanout0_clk.common.hw, [CLK_FANOUT1] = &fanout1_clk.common.hw, [CLK_FANOUT2] = &fanout2_clk.common.hw, + [CLK_NPU] = &npu_clk.common.hw, }, + .num = CLK_NPU + 1, };static struct ccu_reset_map sun55i_a523_ccu_resets[] = {drivers/clk/sunxi-ng/ccu-sun55i-a523.h deleted +0
-14@@ -1,14 +0,0 @@ -/* 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 */
Chen-Yu Tsai
maintainerPATCH v2 4/7 clk: sunxi-ng: div: support power-of-two dividers
In reply to Chen-Yu TsaiFrom: Chen-Yu Tsai <[email protected]>
Some clocks (for timers) on the A523 are mux-divider-gate types with the divider being values of power-of-two.
Add a macro for these types of clocks so that we can use the divider types instead of the M-P types without an M divider.
--- drivers/clk/sunxi-ng/ccu_div.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/clk/sunxi-ng/ccu_div.h +18 -0
@@ -274,6 +274,24 @@ struct ccu_div {SUNXI_CCU_M_HWS_WITH_GATE (_struct, _name, _parent, _reg, \ _mshift, _mwidth, 0, _flags) +#define SUNXI_CCU_P_DATA_WITH_MUX_GATE (_struct, _name, _parents, _reg, \ + _mshift, _mwidth, \ + _muxshift, _muxwidth, \ + _gate, _flags) \ + struct ccu_div _struct = { \ + .enable = _gate, \ + .div = _SUNXI_CCU_DIV_FLAGS(_mshift, _mwidth, \ + CLK_DIVIDER_POWER_OF_TWO), \ + .mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \ + .common = { \ + .reg = _reg, \ + .hw.init = CLK_HW_INIT_PARENTS_DATA(_name, \ + _parents, \ + &ccu_div_ops, \ + _flags), \ + }, \ + } +static inline struct ccu_div *hw_to_ccu_div (struct clk_hw *hw) {struct ccu_common *common =hw_to_ccu_common (hw);
Signature · 1 line
2.39.5
Re: [PATCH v2 4/7] clk: sunxi-ng: div: support power-of-two dividers
Dne četrtek, 11. september 2025 ob 19:47:07 Srednjeevropski poletni čas je Chen-Yu Tsai napisal(a):
Quoted 9 lines
From: Chen-Yu Tsai <[email protected]>
Some clocks (for timers) on the A523 are mux-divider-gate types with the divider being values of power-of-two.
Add a macro for these types of clocks so that we can use the divider types instead of the M-P types without an M divider.
Signed-off-by Chen-Yu Tsai <[email protected]>
Best regards,
Jernej
Quoted 34 lines
--- drivers/clk/sunxi-ng/ccu_div.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/clk/sunxi-ng/ccu_div.h +18
-0@@ -274,6 +274,24 @@ struct ccu_div {SUNXI_CCU_M_HWS_WITH_GATE (_struct, _name, _parent, _reg, \ _mshift, _mwidth, 0, _flags) +#define SUNXI_CCU_P_DATA_WITH_MUX_GATE (_struct, _name, _parents, _reg, \ + _mshift, _mwidth, \ + _muxshift, _muxwidth, \ + _gate, _flags) \ + struct ccu_div _struct = { \ + .enable = _gate, \ + .div = _SUNXI_CCU_DIV_FLAGS(_mshift, _mwidth, \ + CLK_DIVIDER_POWER_OF_TWO), \ + .mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \ + .common = { \ + .reg = _reg, \ + .hw.init = CLK_HW_INIT_PARENTS_DATA(_name, \ + _parents, \ + &ccu_div_ops, \ + _flags), \ + }, \ + } +static inline struct ccu_div *hw_to_ccu_div (struct clk_hw *hw) {struct ccu_common *common =hw_to_ccu_common (hw);
Chen-Yu Tsai
maintainerPATCH v2 5/7 clk: sunxi-ng: add support for the A523/T527 MCU CCU
In reply to Chen-Yu TsaiFrom: Chen-Yu Tsai <[email protected]>
The A523/T527 SoCs have a new MCU PRCM, which has more clocks and reset controls for the RISC-V MCU and other peripherals. There is a second audio PLL, but no bus clock dividers. The BSP driver uses the 24MHz main oscillator as the parent for all the bus clocks. But the diagram suggests busses from the other PRCM are used in this block as well.
Add a driver to support this part. Unlike the BSP driver, the SoC's main MBUS clock is chosen as the parent for the MCU MBUS clock, and the latter then serves as the parent of the MCU DMA controller's MBUS clock. The bus gate clocks also use their respective bus clocks as parents according to the system bus tree diagram. In cases where a block does not appear in that diagram, an educated guess is made.
---
Changes since v1:
- Added comment for "fixed" dividers in audio PLL clock
- Corrected variable names for audio PLL divider clocks
- Added comment for the reversed order of some of the DSP clock's parents when compared to the manual
- Added comments for clocks and resets only found in the BSP driver
- Corrected register offset for i2s3-asrc and bus-mcu-pwm0 clocks
- Made "r-ahb" and new "r-apb0" external bus clocks the parents of the bus gate clocks, with comments if guessed which one applies
- Moved .num_clks to after the list of clocks, making it obvious that the value needs to be added if more clocks are added to the list
--- drivers/clk/sunxi-ng/Kconfig | 5 + drivers/clk/sunxi-ng/Makefile | 2 + drivers/clk/sunxi-ng/ccu-sun55i-a523-mcu.c | 469 +++++++++++++++++++++ 3 files changed, 476 insertions(+) create mode 100644 drivers/clk/sunxi-ng/ccu-sun55i-a523-mcu.c
drivers/clk/sunxi-ng/Kconfig +5 -0
@@ -57,6 +57,11 @@ config SUN55I_A523_CCU default ARCH_SUNXI depends on ARM64 || COMPILE_TEST +config SUN55I_A523_MCU_CCU + tristate "Support for the Allwinner A523/T527 MCU CCU" + default ARCH_SUNXI + depends on ARM64 || COMPILE_TEST + config SUN55I_A523_R_CCU tristate "Support for the Allwinner A523/T527 PRCM CCU" default ARCH_SUNXI
drivers/clk/sunxi-ng/Makefile +2 -0
@@ -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_MCU_CCU) += sun55i-a523-mcu-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
@@ -61,6 +62,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-mcu-ccu-y += ccu-sun55i-a523-mcu.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
drivers/clk/sunxi-ng/ccu-sun55i-a523-mcu.c new file +469 -0
469 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH v2 5/7] clk: sunxi-ng: add support for the A523/T527 MCU CCU
Dne četrtek, 11. september 2025 ob 19:47:08 Srednjeevropski poletni čas je Chen-Yu Tsai napisal(a):
Quoted 16 lines
From: Chen-Yu Tsai <[email protected]>
The A523/T527 SoCs have a new MCU PRCM, which has more clocks and reset controls for the RISC-V MCU and other peripherals. There is a second audio PLL, but no bus clock dividers. The BSP driver uses the 24MHz main oscillator as the parent for all the bus clocks. But the diagram suggests busses from the other PRCM are used in this block as well.
Add a driver to support this part. Unlike the BSP driver, the SoC's main MBUS clock is chosen as the parent for the MCU MBUS clock, and the latter then serves as the parent of the MCU DMA controller's MBUS clock. The bus gate clocks also use their respective bus clocks as parents according to the system bus tree diagram. In cases where a block does not appear in that diagram, an educated guess is made.
Signed-off-by Chen-Yu Tsai <[email protected]>
Quoted 12 lines
---
Changes since v1:
- Added comment for "fixed" dividers in audio PLL clock
- Corrected variable names for audio PLL divider clocks
- Added comment for the reversed order of some of the DSP clock's parents when compared to the manual
- Added comments for clocks and resets only found in the BSP driver
- Corrected register offset for i2s3-asrc and bus-mcu-pwm0 clocks
- Made "r-ahb" and new "r-apb0" external bus clocks the parents of the bus gate clocks, with comments if guessed which one applies
- Moved .num_clks to after the list of clocks, making it obvious that the value needs to be added if more clocks are added to the list
Best regards,
Jernej
Chen-Yu Tsai
maintainerPATCH v2 6/7 arm64: dts: allwinner: a523: Add MCU PRCM CCU node
In reply to Chen-Yu TsaiFrom: Chen-Yu Tsai <[email protected]>
Add a device node for the third supported clock controller found in the A523 / T527 SoCs. This controller has clocks and resets for the RISC-V MCU, and others peripherals possibly meant to operate in low power mode driven by the MCU, such as audio interfaces, an audio DSP, and the NPU.
---
Changes since v1:
- Enlarged MCU PRCM register range to 0x200
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
--- .../arm64/boot/dts/allwinner/sun55i-a523.dtsi | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +27 -0
@@ -4,8 +4,10 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/sun6i-rtc.h> #include <dt-bindings/clock/sun55i-a523-ccu.h> +#include <dt-bindings/clock/sun55i-a523-mcu-ccu.h> #include <dt-bindings/clock/sun55i-a523-r-ccu.h> #include <dt-bindings/reset/sun55i-a523-ccu.h> +#include <dt-bindings/reset/sun55i-a523-mcu-ccu.h> #include <dt-bindings/reset/sun55i-a523-r-ccu.h> #include <dt-bindings/power/allwinner,sun55i-a523-ppu.h> #include <dt-bindings/power/allwinner,sun55i-a523-pck-600.h>
@@ -825,6 +827,31 @@ rtc: rtc@7090000 { clock-names = "bus", "hosc", "ahb"; #clock-cells = <1>; }; + + mcu_ccu: clock-controller@7102000 { + compatible = "allwinner,sun55i-a523-mcu-ccu"; + reg = <0x7102000 0x200>; + clocks = <&osc24M>, + <&rtc CLK_OSC32K>, + <&rtc CLK_IOSC>, + <&ccu CLK_PLL_AUDIO0_4X>, + <&ccu CLK_PLL_PERIPH0_300M>, + <&ccu CLK_DSP>, + <&ccu CLK_MBUS>, + <&r_ccu CLK_R_AHB>, + <&r_ccu CLK_R_APB0>; + clock-names = "hosc", + "losc", + "iosc", + "pll-audio0-4x", + "pll-periph0-300m", + "dsp", + "mbus", + "r-ahb", + "r-apb0"; + #clock-cells = <1>; + #reset-cells = <1>; + }; }; thermal-zones {
Signature · 1 line
2.39.5
Re: [PATCH v2 6/7] arm64: dts: allwinner: a523: Add MCU PRCM CCU node
Dne četrtek, 11. september 2025 ob 19:47:09 Srednjeevropski poletni čas je Chen-Yu Tsai napisal(a):
Quoted 9 lines
From: Chen-Yu Tsai <[email protected]>
Add a device node for the third supported clock controller found in the A523 / T527 SoCs. This controller has clocks and resets for the RISC-V MCU, and others peripherals possibly meant to operate in low power mode driven by the MCU, such as audio interfaces, an audio DSP, and the NPU.
Reviewed-by Andre Przywara <[email protected]>Signed-off-by Chen-Yu Tsai <[email protected]>
Best regards,
Jernej
Quoted 56 lines
---
Changes since v1:
- Enlarged MCU PRCM register range to0x200
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock--- .../arm64/boot/dts/allwinner/sun55i-a523.dtsi | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+)arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +27
-0@@ -4,8 +4,10 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/sun6i-rtc.h> #include <dt-bindings/clock/sun55i-a523-ccu.h> +#include <dt-bindings/clock/sun55i-a523-mcu-ccu.h> #include <dt-bindings/clock/sun55i-a523-r-ccu.h> #include <dt-bindings/reset/sun55i-a523-ccu.h> +#include <dt-bindings/reset/sun55i-a523-mcu-ccu.h> #include <dt-bindings/reset/sun55i-a523-r-ccu.h> #include <dt-bindings/power/allwinner,sun55i-a523-ppu.h> #include <dt-bindings/power/allwinner,sun55i-a523-pck-600.h>@@ -825,6 +827,31 @@ rtc: rtc@7090000 { clock-names = "bus", "hosc", "ahb"; #clock-cells = <1>; }; + + mcu_ccu: clock-controller@7102000 { + compatible = "allwinner,sun55i-a523-mcu-ccu"; + reg = <0x7102000 0x200>; + clocks = <&osc24M>, + <&rtc CLK_OSC32K>, + <&rtc CLK_IOSC>, + <&ccu CLK_PLL_AUDIO0_4X>, + <&ccu CLK_PLL_PERIPH0_300M>, + <&ccu CLK_DSP>, + <&ccu CLK_MBUS>, + <&r_ccu CLK_R_AHB>, + <&r_ccu CLK_R_APB0>; + clock-names = "hosc", + "losc", + "iosc", + "pll-audio0-4x", + "pll-periph0-300m", + "dsp", + "mbus", + "r-ahb", + "r-apb0"; + #clock-cells = <1>; + #reset-cells = <1>; + }; }; thermal-zones {
Chen-Yu Tsai
maintainerPATCH v2 7/7 arm64: dts: allwinner: a523: Add NPU device node
In reply to Chen-Yu TsaiFrom: Chen-Yu Tsai <[email protected]>
The Allwinner T527 SoC has an NPU built in. Based on identifiers found in the BSP, it is a Vivante IP block. After enabling it, the etnaviv driver reports it as a GC9000 revision 9003.
The standard bindings are used as everything matches directly. There is no option for DVFS at the moment. That might require some more work, perhaps on the efuse side to map speed bins.
It is unclear whether the NPU block is fused out at the hardware level or the BSP limits use of the NPU through software, as the author only has boards with the T527.
--- arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +12 -0
@@ -852,6 +852,18 @@ mcu_ccu: clock-controller@7102000 { #clock-cells = <1>; #reset-cells = <1>; }; + + npu: npu@7122000 { + compatible = "vivante,gc"; + reg = <0x07122000 0x1000>; + interrupts = <GIC_SPI 199 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mcu_ccu CLK_BUS_MCU_NPU_ACLK>, + <&ccu CLK_NPU>, + <&mcu_ccu CLK_BUS_MCU_NPU_HCLK>; + clock-names = "bus", "core", "reg"; + resets = <&mcu_ccu RST_BUS_MCU_NPU>; + power-domains = <&ppu PD_NPU>; + }; }; thermal-zones {
Signature · 1 line
2.39.5
Re: [PATCH v2 7/7] arm64: dts: allwinner: a523: Add NPU device node
Dne četrtek, 11. september 2025 ob 19:47:10 Srednjeevropski poletni čas je Chen-Yu Tsai napisal(a):
Quoted 10 lines
From: Chen-Yu Tsai <[email protected]>
The Allwinner T527 SoC has an NPU built in. Based on identifiers found in the BSP, it is a Vivante IP block. After enabling it, the etnaviv driver reports it as a GC9000 revision 9003.
The standard bindings are used as everything matches directly. There is no option for DVFS at the moment. That might require some more work, perhaps on the efuse side to map speed bins.
Quoted 6 lines
It is unclear whether the NPU block is fused out at the hardware level or the BSP limits use of the NPU through software, as the author only has boards with the T527.
Reviewed-by Andre Przywara <[email protected]>Signed-off-by Chen-Yu Tsai <[email protected]>
Best regards,
Jernej
Quoted 28 lines
--- arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +12
-0@@ -852,6 +852,18 @@ mcu_ccu: clock-controller@7102000 { #clock-cells = <1>; #reset-cells = <1>; }; + + npu: npu@7122000 { + compatible = "vivante,gc"; + reg = <0x07122000 0x1000>; + interrupts = <GIC_SPI 199 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mcu_ccu CLK_BUS_MCU_NPU_ACLK>, + <&ccu CLK_NPU>, + <&mcu_ccu CLK_BUS_MCU_NPU_HCLK>; + clock-names = "bus", "core", "reg"; + resets = <&mcu_ccu RST_BUS_MCU_NPU>; + power-domains = <&ppu PD_NPU>; + }; }; thermal-zones {
Quoted 25 lines · Chen-Yu Tsai
This is v2 of my A523 MCU PRCM and NPU support series.
Changes since v1:
- Dropped dual divider clock rate read-back fix that is already merged
- DT binding
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
- Add NPU clk
- Move .num to after list of clks
- MCU CCU clk driver
- Added comment for "fixed" dividers in audio PLL clock
- Corrected variable names for audio PLL divider clocks
- Added comment for the reversed order of some of the DSP clock's parents when compared to the manual
- Added comments for clocks and resets only found in the BSP driver
- Corrected register offset for i2s3-asrc and bus-mcu-pwm0 clocks
- Made "r-ahb" and new "r-apb0" external bus clocks the parents of the bus gate clocks, with comments if guessed which one applies
- Moved .num_clks to after the list of clocks, making it obvious that the value needs to be added if more clocks are added to the list
- MCU CCU DT node
- Enlarged MCU PRCM register range to0x200
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
- Link to v1
https://lore.kernel.org/all/[email protected]/
Quoted 1 line
[...]
Applied to sunxi/shared-dt-headers-for-6.18 in local tree, thanks!
[1/7] dt-bindings: clock: sun55i-a523-ccu: Add missing NPU module clock
commit: e9671ddd82eee96146a7359431a4e1f04ac2b076
[2/7] dt-bindings: clock: sun55i-a523-ccu: Add A523 MCU CCU clock controller
commit: 0f610e650d4e979490ccfa4c22ca29ca547f41e7[3/7] clk: sunxi-ng: sun55i-a523-ccu: Add missing NPU module clock
(no commit info)
[4/7] clk: sunxi-ng: div: support power-of-two dividers
(no commit info)
[5/7] clk: sunxi-ng: add support for the A523/T527 MCU CCU
(no commit info)
[6/7] arm64: dts: allwinner: a523: Add MCU PRCM CCU node
(no commit info)
[7/7] arm64: dts: allwinner: a523: Add NPU device node
(no commit info)
Best regards,
Signature · 1 line
Chen-Yu Tsai <[email protected]>
Quoted 25 lines · Chen-Yu Tsai
This is v2 of my A523 MCU PRCM and NPU support series.
Changes since v1:
- Dropped dual divider clock rate read-back fix that is already merged
- DT binding
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
- Add NPU clk
- Move .num to after list of clks
- MCU CCU clk driver
- Added comment for "fixed" dividers in audio PLL clock
- Corrected variable names for audio PLL divider clocks
- Added comment for the reversed order of some of the DSP clock's parents when compared to the manual
- Added comments for clocks and resets only found in the BSP driver
- Corrected register offset for i2s3-asrc and bus-mcu-pwm0 clocks
- Made "r-ahb" and new "r-apb0" external bus clocks the parents of the bus gate clocks, with comments if guessed which one applies
- Moved .num_clks to after the list of clocks, making it obvious that the value needs to be added if more clocks are added to the list
- MCU CCU DT node
- Enlarged MCU PRCM register range to0x200
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
- Link to v1
https://lore.kernel.org/all/[email protected]/
Quoted 1 line
[...]
Applied to sunxi/clk-for-6.18 in local tree, thanks!
[1/7] dt-bindings: clock: sun55i-a523-ccu: Add missing NPU module clock
commit: e9671ddd82eee96146a7359431a4e1f04ac2b076
[2/7] dt-bindings: clock: sun55i-a523-ccu: Add A523 MCU CCU clock controller
commit: 0f610e650d4e979490ccfa4c22ca29ca547f41e7
[3/7] clk: sunxi-ng: sun55i-a523-ccu: Add missing NPU module clock
commit: 828dea389683d8e1df687fbd4521d391df369437
[4/7] clk: sunxi-ng: div: support power-of-two dividers
commit: 44293edd013e5ed48060e6a8848c215fd3bf8ce3
[5/7] clk: sunxi-ng: add support for the A523/T527 MCU CCU
commit: 598e4b6713b54267acc257b3c66a269079ee4d8f[6/7] arm64: dts: allwinner: a523: Add MCU PRCM CCU node
(no commit info)
[7/7] arm64: dts: allwinner: a523: Add NPU device node
(no commit info)
Best regards,
Signature · 1 line
Chen-Yu Tsai <[email protected]>
Re: (subset) [PATCH v2 0/7] arm64: allwinner: a523: Enable MCU PRCM and NPU
In reply to Chen-Yu TsaiQuoted 29 lines · Chen-Yu Tsai
From: Chen-Yu Tsai <[email protected]>
Hi folks,
This is v2 of my A523 MCU PRCM and NPU support series.
Changes since v1:
- Dropped dual divider clock rate read-back fix that is already merged
- DT binding
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
- Add NPU clk
- Move .num to after list of clks
- MCU CCU clk driver
- Added comment for "fixed" dividers in audio PLL clock
- Corrected variable names for audio PLL divider clocks
- Added comment for the reversed order of some of the DSP clock's parents when compared to the manual
- Added comments for clocks and resets only found in the BSP driver
- Corrected register offset for i2s3-asrc and bus-mcu-pwm0 clocks
- Made "r-ahb" and new "r-apb0" external bus clocks the parents of the bus gate clocks, with comments if guessed which one applies
- Moved .num_clks to after the list of clocks, making it obvious that the value needs to be added if more clocks are added to the list
- MCU CCU DT node
- Enlarged MCU PRCM register range to0x200
- Moved "r-ahb" clock to the end of the list and added "r-apb0" clock
- Link to v1
https://lore.kernel.org/all/[email protected]/
Quoted 1 line
[...]
Applied to sunxi/dt-for-6.18 in local tree, thanks!
[6/7] arm64: dts: allwinner: a523: Add MCU PRCM CCU node
commit: edd63e54e516b54c0b7071463d6e839445efab68
[7/7] arm64: dts: allwinner: a523: Add NPU device node
commit: a1845487afd06899502714a3500b60f815d98203Best regards,
Signature · 1 line
Chen-Yu Tsai <[email protected]>