Skip to contentSkip to conversation

clk: amlogic: Introduce A9 PLL and CCU driver support

PATCH NAK Chuan Liu 5 participants 31 messages Feb 9 – Apr 15

Subsystems (4)
lore
Share & tools
lore

Chuan Liu

author
#0 lore raw

cover clk: amlogic: Introduce A9 PLL and CCU driver support

This patch adds driver support for Phase-Locked Loop (PLL) controllers and Clock Control Units (CCUs) in A9 SoC family.

In the A9 SoC architecture, PLLs and clock control units are implemented as standardized hardware instances to reduce unnecessary differentiation across individual units.

All A9 PLLs and CCUs are exposed as device tree nodes, providing an accurate representation of the SoC's internal clock hardware structure.

These drivers are designed for reuse in subsequent SoC generations, guaranteeing code inheritance and maximizing reusability.

Makefile rules compile A9 PLL and CCU drivers into clk-amlogic.o (see drivers/clk/amlogic/Makefile), simplifying deployment and enhancing load efficiency (single insmod for kernel module).

Since the foundational A9 DTS hasn't been upstreamed yet, I'm temporarily pushing the PLL/CCU DTS files to github for driver comprehension [1]. These patches will be included in a later release after the base A9 DTS is merged.

[1] https://github.com/torvalds/linux/commit/d6a82e4cce675fa5146c5f638c2a926c1c8cb1d9

---
Chuan Liu (13):
dt-bindings: clock: Add Amlogic A9 standardized model clock control units
dt-bindings: clock: Add Amlogic A9 PLL controllers
dt-bindings: clock: Add Amlogic A9 misc clock control units
clk: amlogic: Add basic clock driver
clk: amlogic: Add composite clock driver
clk: amlogic: Add noglitch clock driver
clk: amlogic: Add duandiv clock driver
clk: amlogic: Add PLL driver
clk: amlogic: Add DT-based clock registration functions
clk: amlogic: Add A9 standardized model clock control units driver
clk: amlogic: Add A9 PLL controllers driver
clk: amlogic: Add A9 misc clock control units driver
clk: amlogic: Add support for building as combined kernel module

 .../bindings/clock/amlogic,a9-misc-ccu.yaml        | 523 +++++++++++
 .../bindings/clock/amlogic,a9-model-ccu.yaml       | 435 +++++++++
 .../devicetree/bindings/clock/amlogic,a9-pll.yaml  | 134 +++
 drivers/clk/Kconfig                                |   1 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/amlogic/Kconfig                        |  52 ++
 drivers/clk/amlogic/Makefile                       |  23 +
 drivers/clk/amlogic/a9-misc-ccu.c                  | 970 +++++++++++++++++++++
 drivers/clk/amlogic/a9-model-ccu.c                 | 475 ++++++++++
 drivers/clk/amlogic/a9-pll.c                       | 156 ++++
 drivers/clk/amlogic/clk-basic.c                    | 219 +++++
 drivers/clk/amlogic/clk-basic.h                    |  39 +
 drivers/clk/amlogic/clk-composite.c                | 280 ++++++
 drivers/clk/amlogic/clk-composite.h                |  20 +
 drivers/clk/amlogic/clk-dualdiv.c                  | 365 ++++++++
 drivers/clk/amlogic/clk-dualdiv.h                  |  27 +
 drivers/clk/amlogic/clk-module.c                   |  42 +
 drivers/clk/amlogic/clk-module.h                   |  53 ++
 drivers/clk/amlogic/clk-noglitch.c                 | 584 +++++++++++++
 drivers/clk/amlogic/clk-noglitch.h                 |  29 +
 drivers/clk/amlogic/clk-pll.c                      | 701 +++++++++++++++
 drivers/clk/amlogic/clk-pll.h                      |  43 +
 drivers/clk/amlogic/clk.c                          | 464 ++++++++++
 drivers/clk/amlogic/clk.h                          |  56 ++
 include/dt-bindings/clock/amlogic,a9-misc-ccu.h    |  53 ++
 25 files changed, 5745 insertions(+)

---
base-commit: 4d310797262f0ddf129e76c2aad2b950adaf1fda
change-id: 20260130-a9_clock_driver-ddd90357848c

Best regards,

Signature · 1 line
Chuan Liu <[email protected]>
author
#1 lore raw

PATCH 1/13 dt-bindings: clock: Add Amlogic A9 standardized model clock control units

Add dt-binding documentation for standardized model clock control units in A9 SoC family.

---
 .../bindings/clock/amlogic,a9-model-ccu.yaml       | 435 +++++++++++++++++++++
 1 file changed, 435 insertions(+)
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +435 -0
new file mode 100644
index 000000000000..56c5cbe1b246
@@ -0,0 +1,435 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/amlogic,a9-model-ccu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic A9 Family Standardized Model Clock Control Unit
+
+maintainers:
+  - Chuan Liu <[email protected]>
+
+description:
+  The clock tree within the A9 is composed of numerous instances of these
+  standardized model CCU (Clock Control Units).
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - const: amlogic,a9-composite-ccu
+        description: Supports clock source selection, frequency division, and
+                     clock gating.
+      - items:
+          - const: amlogic,a9-composite-ccu-mult
+        description: Some modules have multiple input clocks and contain
+                     multiple composite-ccus internally.
+      - items:
+          - const: amlogic,a9-noglitch-ccu
+        description: Provides the same functionality as composite-ccu but
+                     includes glitch suppression during frequency transitions.
+      - items:
+          - const: amlogic,a9-noglitch-ccu-mult
+        description: Some modules have multiple input clocks and contain
+                     multiple noglitch-ccus internally.
+      - items:
+          - const: amlogic,a9-sysbus-ccu
+        description: Consists of multiple gating arrays, commonly used for
+                     Amlogic's sys_clk and axi_clk.
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    minItems: 1
+    maxItems: 16
+
+  clock-names:
+    minItems: 1
+    maxItems: 16
+
+  clock-output-names:
+    minItems: 1
+    # The sysbus-ccu of A9 supports up to 128 gates
+    maxItems: 128
+
+  '#clock-cells':
+    description:
+      The clock controller of a module may contain one or more CCU(s). When a
+      clock controller has multiple CCUs, an index is required to specify a
+      particular CCU within the clock controller.
+    oneOf:
+      - const: 0
+        description: Single clock output, no specifier needed
+      - const: 1
+        description: Multiple clocks, index selects specific output
+
+  amlogic,clock-max-frequency:
+    description: |
+      Each clock's maximum output frequency is constrained during hardware
+      design to ensure proper timing requirements for the clock network. If the
+      clock frequency configured exceeds this design limit, it can lead to
+      abnormal behavior in modules relying on that clock and may even cause
+      cross-talk that affects other modules.
+
+      In the driver, this property is parsed, and interface functions from the
+      CCF are called to enforce the clock's maximum frequency, preventing
+      potential issues caused by excessive clock frequency configurations.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+  amlogic,reg-layout:
+    description:
+      These standardized model CCUs require register configuration for their
+      clock functions. This property node describes the register layout
+      parameters for each model's CCU.
+    $ref: /schemas/types.yaml#/definitions/uint32-matrix
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          anyOf:
+            - contains:
+                const: amlogic,a9-composite-ccu
+            - contains:
+                const: amlogic,a9-noglitch-ccu
+    then:
+      properties:
+        '#clock-cells':
+          const: 0
+        clock-output-names:
+          minItems: 1
+          maxItems: 1
+    else:
+      properties:
+        '#clock-cells':
+          const: 1
+        clock-output-names:
+          minItems: 2
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-composite-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+            - description: input clock source 4 (optional)
+            - description: input clock source 5 (optional)
+            - description: input clock source 6 (optional)
+            - description: input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains three register layout parameters:
+              * register offset
+              * bit offset
+              * divider effective bit width
+      required:
+        - amlogic,reg-layout
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-composite-ccu-mult
+    then:
+      properties:
+        clocks:
+          description:
+            Some clock controllers contain two composite-ccus (labeled
+            composite_a and composite_b). In certain controllers, composite_a
+            and composite_b share a common clock source, while in others they
+            have independent clock sources.
+          minItems: 1
+          items:
+            - description: composite_a/b's input clock source 0
+            - description: composite_a/b's input clock source 1 (optional)
+            - description: composite_a/b's input clock source 2 (optional)
+            - description: composite_a/b's input clock source 3 (optional)
+            - description: composite_a/b's input clock source 4 (optional)
+            - description: composite_a/b's input clock source 5 (optional)
+            - description: composite_a/b's input clock source 6 (optional)
+            - description: composite_a/b's input clock source 7 (optional)
+            - description: composite_b's input clock source 0 (optional)
+            - description: composite_b's input clock source 1 (optional)
+            - description: composite_b's input clock source 2 (optional)
+            - description: composite_b's input clock source 3 (optional)
+            - description: composite_b's input clock source 4 (optional)
+            - description: composite_b's input clock source 5 (optional)
+            - description: composite_b's input clock source 6 (optional)
+            - description: composite_b's input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+            - const: bclkin0
+            - const: bclkin1
+            - const: bclkin2
+            - const: bclkin3
+            - const: bclkin4
+            - const: bclkin5
+            - const: bclkin6
+            - const: bclkin7
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains three register layout parameters:
+              * register offset
+              * bit offset
+              * divider effective bit width
+      required:
+        - amlogic,reg-layout
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-noglitch-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+            - description: input clock source 4 (optional)
+            - description: input clock source 5 (optional)
+            - description: input clock source 6 (optional)
+            - description: input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+      required:
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-noglitch-ccu-mult
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+            - description: input clock source 4 (optional)
+            - description: input clock source 5 (optional)
+            - description: input clock source 6 (optional)
+            - description: input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains one register layout parameters:
+              * register offset
+      required:
+        - amlogic,reg-layout
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-sysbus-ccu
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+          description: input clock of sysbus-ccu
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains two register layout parameters:
+              * register offset
+              * bit offset
+      required:
+        - amlogic,reg-layout
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-output-names
+  - "#clock-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    clk_dummy: clock-dummy {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <0>;
+        clock-output-names = "dummy";
+        status = "disabled";
+    };
+
+    apb {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        clock-controller@350 {
+            compatible = "amlogic,a9-composite-ccu";
+            reg = <0x0 0x350 0x0 0x4>;
+            #clock-cells = <0>;
+            amlogic,clock-max-frequency = <50000000>;
+            amlogic,reg-layout = <0x0 0  7>;
+            clock-output-names = "sar_adc";
+            clocks = <&xtal_24m>,
+                     <&scmi_clk 17>;
+            clock-names = "clkin0", "clkin1";
+        };
+
+        clock-controller@290 {
+            compatible = "amlogic,a9-composite-ccu-mult";
+            reg = <0x0 0x290 0x0 0x8>;
+            #clock-cells = <1>;
+            amlogic,clock-max-frequency = <250000000>,
+                                          <250000000>,
+                                          <1200000000>;
+            amlogic,reg-layout = <0x0 0  7>,
+                                 <0x0 16 7>,
+                                 <0x4 0  7>;
+            clock-output-names = "sd_emmc_a",
+                                 "sd_emmc_b",
+                                 "sd_emmc_c";
+            clocks = <&xtal_24m>,
+                     <&scmi_clk 6>,
+                     <&scmi_clk 10>;
+            clock-names = "clkin0",
+                          "clkin1",
+                          "clkin2";
+        };
+
+        clock-controller@378 {
+            compatible = "amlogic,a9-composite-ccu-mult";
+            reg = <0x0 0x378 0x0 0x4>;
+            #clock-cells = <1>;
+            amlogic,clock-max-frequency = <500000000>,
+                                          <667000000>;
+            amlogic,reg-layout = <0x0 0  7>,
+                                 <0x0 16 7>;
+            clock-output-names = "dptx_apb2",
+                                 "dptx_aud";
+            clocks = <&xtal_24m>,
+                     <&scmi_clk 17>,
+                     <&scmi_clk 12>,
+                     <&scmi_clk 14>,
+                     <&clk_dummy>,
+                     <&clk_dummy>,
+                     <&clk_dummy>,
+                     <&clk_dummy>,
+                     <&xtal_24m>, /* composite-ccu_b's clock source 0 */
+                     <&scmi_clk 17>, /* composite-ccu_b's clock source 1 */
+                     <&scmi_clk 10>, /* composite-ccu_b's clock source 2 */
+                     <&scmi_clk 12>; /* composite-ccu_b's clock source 3 */
+            clock-names = "clkin0",
+                          "clkin1",
+                          "clkin2",
+                          "clkin3",
+                          "clkin4",
+                          "clkin5",
+                          "clkin6",
+                          "clkin7",
+                          "bclkin0",
+                          "bclkin1",
+                          "bclkin2",
+                          "bclkin3";
+        };
+
+        clock-controller@420 {
+            compatible = "amlogic,a9-noglitch-ccu";
+            reg = <0x0 0x420 0x0 0x4>;
+            #clock-cells = <0>;
+            amlogic,clock-max-frequency = <800000000>;
+            clock-output-names = "dspa";
+            clocks = <&xtal_24m>,
+                     <&scmi_clk 8>,
+                     <&scmi_clk 10>;
+            clock-names = "clkin0",
+                          "clkin1",
+                          "clkin2";
+        };
+
+        clock-controller@400 {
+            compatible = "amlogic,a9-noglitch-ccu-mult";
+            reg = <0x0 0x400 0x0 0x8>;
+            #clock-cells = <1>;
+            /*
+             * If only one maximum frequency is specified, it is shared by all
+             * clocks under the current device node.
+             */
+            amlogic,clock-max-frequency = <1000000000>;
+            amlogic,reg-layout = <0x0>,
+                                 <0x4>;
+            clock-output-names = "mali",
+                                 "mali_stack";
+            clocks = <&xtal_24m>,
+                     <&scmi_clk 23>,
+                     <&scmi_clk 6>;
+            clock-names = "clkin0",
+                          "clkin1",
+                          "clkin2";
+        };
+
+        clock-sysbus@230 {
+            compatible = "amlogic,a9-sysbus-ccu";
+            reg = <0x0 0x230 0x0 0x10>;
+            #clock-cells = <1>;
+            amlogic,reg-layout = <0 0>,
+                                 <0 1>,
+                                 <0 3>;
+            clock-output-names = "sys_am_axi",
+                                 "sys_dos",
+                                 "sys_mipi_dsi";
+            clocks = <&scmi_clk 17>;
+        };
+    };
Signature · 1 line
2.42.0
#2 lore raw

Re: [PATCH 01/13] dt-bindings: clock: Add Amlogic A9 standardized model clock control units

Quoted 9 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Add dt-binding documentation for standardized model clock control units in A9 SoC family.

---
 .../bindings/clock/amlogic,a9-model-ccu.yaml       | 435 +++++++++++++++++++++
 1 file changed, 435 insertions(+)

Brief review, you still have to read basic guidelines to not repeat the basic mistakes.

Quoted 17 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
new file mode 100644
index 000000000000..56c5cbe1b246
@@ -0,0 +1,435 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/amlogic,a9-model-ccu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic A9 Family Standardized Model Clock Control Unit
+
+maintainers:

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 20

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+  - Chuan Liu <[email protected]>
+
+description:
+  The clock tree within the A9 is composed of numerous instances of these
+  standardized model CCU (Clock Control Units).
+
+properties:
+  compatible:
+    oneOf:
+      - items:

Drop

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +3 -0
+          - const: amlogic,a9-composite-ccu
+        description: Supports clock source selection, frequency division, and
+                     clock gating.

This is just one big enum. You can add comments if you insist...

Quoted 28 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +28 -0
+      - items:
+          - const: amlogic,a9-composite-ccu-mult
+        description: Some modules have multiple input clocks and contain
+                     multiple composite-ccus internally.
+      - items:
+          - const: amlogic,a9-noglitch-ccu
+        description: Provides the same functionality as composite-ccu but
+                     includes glitch suppression during frequency transitions.
+      - items:
+          - const: amlogic,a9-noglitch-ccu-mult
+        description: Some modules have multiple input clocks and contain
+                     multiple noglitch-ccus internally.
+      - items:
+          - const: amlogic,a9-sysbus-ccu
+        description: Consists of multiple gating arrays, commonly used for
+                     Amlogic's sys_clk and axi_clk.
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    minItems: 1
+    maxItems: 16
+
+  clock-names:
+    minItems: 1
+    maxItems: 16
+

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 61

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+  clock-output-names:
+    minItems: 1
+    # The sysbus-ccu of A9 supports up to 128 gates
+    maxItems: 128
+
+  '#clock-cells':
+    description:
+      The clock controller of a module may contain one or more CCU(s). When a
+      clock controller has multiple CCUs, an index is required to specify a
+      particular CCU within the clock controller.

Drop

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 66

Quoted 5 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +5 -0
+    oneOf:
+      - const: 0
+        description: Single clock output, no specifier needed
+      - const: 1
+        description: Multiple clocks, index selects specific output

Drop all descriptions. That's enum. Do not explain usu how DT works.

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 68

Quoted 2 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +2 -0
+
+  amlogic,clock-max-frequency:

Drop property. So many wrong things here... First, start from basic guidelines like talks or docs in kernel and understand the suffixes.

Second not a DT property.

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 76

Quoted 8 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +8 -0
+    description: |
+      Each clock's maximum output frequency is constrained during hardware
+      design to ensure proper timing requirements for the clock network. If the
+      clock frequency configured exceeds this design limit, it can lead to
+      abnormal behavior in modules relying on that clock and may even cause
+      cross-talk that affects other modules.
+
+      In the driver, this property is parsed, and interface functions from the

Why would we care about driver?

This is binding, we talk about hardware.

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 81

Quoted 5 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +5 -0
+      CCF are called to enforce the clock's maximum frequency, preventing
+      potential issues caused by excessive clock frequency configurations.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+  amlogic,reg-layout:

No, drop. Compatible defines it.

Quoted 159 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +159 -0
+    description:
+      These standardized model CCUs require register configuration for their
+      clock functions. This property node describes the register layout
+      parameters for each model's CCU.
+    $ref: /schemas/types.yaml#/definitions/uint32-matrix
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          anyOf:
+            - contains:
+                const: amlogic,a9-composite-ccu
+            - contains:
+                const: amlogic,a9-noglitch-ccu
+    then:
+      properties:
+        '#clock-cells':
+          const: 0
+        clock-output-names:
+          minItems: 1
+          maxItems: 1
+    else:
+      properties:
+        '#clock-cells':
+          const: 1
+        clock-output-names:
+          minItems: 2
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-composite-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+            - description: input clock source 4 (optional)
+            - description: input clock source 5 (optional)
+            - description: input clock source 6 (optional)
+            - description: input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains three register layout parameters:
+              * register offset
+              * bit offset
+              * divider effective bit width
+      required:
+        - amlogic,reg-layout
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-composite-ccu-mult
+    then:
+      properties:
+        clocks:
+          description:
+            Some clock controllers contain two composite-ccus (labeled
+            composite_a and composite_b). In certain controllers, composite_a
+            and composite_b share a common clock source, while in others they
+            have independent clock sources.
+          minItems: 1
+          items:
+            - description: composite_a/b's input clock source 0
+            - description: composite_a/b's input clock source 1 (optional)
+            - description: composite_a/b's input clock source 2 (optional)
+            - description: composite_a/b's input clock source 3 (optional)
+            - description: composite_a/b's input clock source 4 (optional)
+            - description: composite_a/b's input clock source 5 (optional)
+            - description: composite_a/b's input clock source 6 (optional)
+            - description: composite_a/b's input clock source 7 (optional)
+            - description: composite_b's input clock source 0 (optional)
+            - description: composite_b's input clock source 1 (optional)
+            - description: composite_b's input clock source 2 (optional)
+            - description: composite_b's input clock source 3 (optional)
+            - description: composite_b's input clock source 4 (optional)
+            - description: composite_b's input clock source 5 (optional)
+            - description: composite_b's input clock source 6 (optional)
+            - description: composite_b's input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+            - const: bclkin0
+            - const: bclkin1
+            - const: bclkin2
+            - const: bclkin3
+            - const: bclkin4
+            - const: bclkin5
+            - const: bclkin6
+            - const: bclkin7
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains three register layout parameters:
+              * register offset
+              * bit offset
+              * divider effective bit width
+      required:
+        - amlogic,reg-layout
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-noglitch-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+            - description: input clock source 4 (optional)
+            - description: input clock source 5 (optional)
+            - description: input clock source 6 (optional)
+            - description: input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+      required:
+        - clock-names

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 250

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-noglitch-ccu-mult
+    then:
+      properties:
+        clocks:
+          minItems: 1

Why?

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 122

Quoted 3 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +3 -0
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)

Drop optional. Don't repeat constraints in free form text.

Quoted 25 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +25 -0
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+            - description: input clock source 4 (optional)
+            - description: input clock source 5 (optional)
+            - description: input clock source 6 (optional)
+            - description: input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains one register layout parameters:
+              * register offset
+      required:
+        - amlogic,reg-layout
+        - clock-names
+

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 288

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-sysbus-ccu
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+          description: input clock of sysbus-ccu

list the items with description instead.

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 295

Quoted 7 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +7 -0
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains two register layout parameters:
+              * register offset
+              * bit offset
+      required:
+        - amlogic,reg-layout

This is huge and amount of ifs is clearly suggesting you combined way too much into one file.

Quoted 9 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +9 -0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-output-names
+  - "#clock-cells"
+
+additionalProperties: false

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 314

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+
+examples:
+  - |
+    clk_dummy: clock-dummy {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <0>;
+        clock-output-names = "dummy";
+        status = "disabled";
+    };

Not relevant, drop entire node.

Quoted 26 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +26 -0
+
+    apb {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        clock-controller@350 {
+            compatible = "amlogic,a9-composite-ccu";
+            reg = <0x0 0x350 0x0 0x4>;
+            #clock-cells = <0>;
+            amlogic,clock-max-frequency = <50000000>;
+            amlogic,reg-layout = <0x0 0  7>;
+            clock-output-names = "sar_adc";
+            clocks = <&xtal_24m>,
+                     <&scmi_clk 17>;
+            clock-names = "clkin0", "clkin1";
+        };
+
+        clock-controller@290 {
+            compatible = "amlogic,a9-composite-ccu-mult";
+            reg = <0x0 0x290 0x0 0x8>;
+            #clock-cells = <1>;
+            amlogic,clock-max-frequency = <250000000>,
+                                          <250000000>,
+                                          <1200000000>;
+            amlogic,reg-layout = <0x0 0  7>,
+                                 <0x0 16 7>,
+                                 <0x4 0  7>;

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 350

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+            clock-output-names = "sd_emmc_a",
+                                 "sd_emmc_b",
+                                 "sd_emmc_c";
+            clocks = <&xtal_24m>,
+                     <&scmi_clk 6>,
+                     <&scmi_clk 10>;
+            clock-names = "clkin0",
+                          "clkin1",
+                          "clkin2";
+        };

One or two are enough. Drop the rest.

Quoted 1 line

Best regards,
Krzysztof

author
#3 lore raw

Re: [PATCH 01/13] dt-bindings: clock: Add Amlogic A9 standardized model clock control units

Hi Krzysztof,
Thanks for review.

Quoted 46 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 9 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Add dt-binding documentation for standardized model clock control units in A9 SoC family.

---
  .../bindings/clock/amlogic,a9-model-ccu.yaml       | 435 +++++++++++++++++++++
  1 file changed, 435 insertions(+)

Brief review, you still have to read basic guidelines to not repeat the basic mistakes.

Quoted 17 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
new file mode 100644
index 000000000000..56c5cbe1b246
@@ -0,0 +1,435 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/amlogic,a9-model-ccu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic A9 Family Standardized Model Clock Control Unit
+
+maintainers:

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 20

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+  - Chuan Liu <[email protected]>
+
+description:
+  The clock tree within the A9 is composed of numerous instances of these
+  standardized model CCU (Clock Control Units).
+
+properties:
+  compatible:
+    oneOf:
+      - items:

Drop

Quoted 5 lines

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 23

Quoted 3 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +3 -0
+          - const: amlogic,a9-composite-ccu
+        description: Supports clock source selection, frequency division, and
+                     clock gating.

This is just one big enum. You can add comments if you insist...

Thanks for pointing out. I'll refer to this approach for future comments if necessary:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/clock/samsung,exynos5433-clock.yaml?h=v7.0-rc7#n26

Quoted 51 lines
Quoted 30 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +28 -0
+      - items:
+          - const: amlogic,a9-composite-ccu-mult
+        description: Some modules have multiple input clocks and contain
+                     multiple composite-ccus internally.
+      - items:
+          - const: amlogic,a9-noglitch-ccu
+        description: Provides the same functionality as composite-ccu but
+                     includes glitch suppression during frequency transitions.
+      - items:
+          - const: amlogic,a9-noglitch-ccu-mult
+        description: Some modules have multiple input clocks and contain
+                     multiple noglitch-ccus internally.
+      - items:
+          - const: amlogic,a9-sysbus-ccu
+        description: Consists of multiple gating arrays, commonly used for
+                     Amlogic's sys_clk and axi_clk.
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    minItems: 1
+    maxItems: 16
+
+  clock-names:
+    minItems: 1
+    maxItems: 16
+

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 61

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+  clock-output-names:
+    minItems: 1
+    # The sysbus-ccu of A9 supports up to 128 gates
+    maxItems: 128
+
+  '#clock-cells':
+    description:
+      The clock controller of a module may contain one or more CCU(s). When a
+      clock controller has multiple CCUs, an index is required to specify a
+      particular CCU within the clock controller.

Drop

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 66

Quoted 5 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +5 -0
+    oneOf:
+      - const: 0
+        description: Single clock output, no specifier needed
+      - const: 1
+        description: Multiple clocks, index selects specific output

Drop all descriptions. That's enum. Do not explain usu how DT works.

Quoted 8 lines

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 68

Quoted 2 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +2 -0
+
+  amlogic,clock-max-frequency:

Drop property. So many wrong things here... First, start from basic guidelines like talks or docs in kernel and understand the suffixes.

Second not a DT property.

Thanks for pointing out. Martin also helped me explain the reasons in detail. Thanks again.

Quoted 29 lines

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 76

Quoted 8 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +8 -0
+    description: |
+      Each clock's maximum output frequency is constrained during hardware
+      design to ensure proper timing requirements for the clock network. If the
+      clock frequency configured exceeds this design limit, it can lead to
+      abnormal behavior in modules relying on that clock and may even cause
+      cross-talk that affects other modules.
+
+      In the driver, this property is parsed, and interface functions from the

Why would we care about driver?

This is binding, we talk about hardware.

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 81

Quoted 5 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +5 -0
+      CCF are called to enforce the clock's maximum frequency, preventing
+      potential issues caused by excessive clock frequency configurations.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+  amlogic,reg-layout:

No, drop. Compatible defines it.

Quoted 7 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +7 -0
+    description:
+      These standardized model CCUs require register configuration for their
+      clock functions. This property node describes the register layout
+      parameters for each model's CCU.
+    $ref: /schemas/types.yaml#/definitions/uint32-matrix
+
+allOf:

[...]

Quoted 11 lines

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 250

Quoted 9 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +9 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-noglitch-ccu-mult
+    then:
+      properties:
+        clocks:
+          minItems: 1

Why?

noglitch-ccu processes the input clock and outputs it, so it needs to have at least one input clock.

Quoted 53 lines

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 122

Quoted 4 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +3 -0
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)

Drop optional. Don't repeat constraints in free form text.

Quoted 25 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +25 -0
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+            - description: input clock source 4 (optional)
+            - description: input clock source 5 (optional)
+            - description: input clock source 6 (optional)
+            - description: input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains one register layout parameters:
+              * register offset
+      required:
+        - amlogic,reg-layout
+        - clock-names
+

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 288

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-sysbus-ccu
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+          description: input clock of sysbus-ccu

list the items with description instead.

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 295

Quoted 7 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +7 -0
+        amlogic,reg-layout:
+          description: |
+            composite-ccu contains two register layout parameters:
+              * register offset
+              * bit offset
+      required:
+        - amlogic,reg-layout
Quoted 3 lines

This is huge and amount of ifs is clearly suggesting you combined way too much into one file.

I'll try to split large blocks of if statements like this into separate .yaml files. Thanks for your suggestion.

Quoted 53 lines
Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +9 -0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-output-names
+  - "#clock-cells"
+
+additionalProperties: false

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 314

Quoted 10 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+
+examples:
+  - |
+    clk_dummy: clock-dummy {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <0>;
+        clock-output-names = "dummy";
+        status = "disabled";
+    };

Not relevant, drop entire node.

Quoted 30 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +30 -0
+
+    apb {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        clock-controller@350 {
+            compatible = "amlogic,a9-composite-ccu";
+            reg = <0x0 0x350 0x0 0x4>;
+            #clock-cells = <0>;
+            amlogic,clock-max-frequency = <50000000>;
+            amlogic,reg-layout = <0x0 0  7>;
+            clock-output-names = "sar_adc";
+            clocks = <&xtal_24m>,
+                     <&scmi_clk 17>;
+            clock-names = "clkin0", "clkin1";
+        };
+
+        clock-controller@290 {
+            compatible = "amlogic,a9-composite-ccu-mult";
+            reg = <0x0 0x290 0x0 0x8>;
+            #clock-cells = <1>;
+            amlogic,clock-max-frequency = <250000000>,
+                                          <250000000>,
+                                          <1200000000>;
+            amlogic,reg-layout = <0x0 0  7>,
+                                 <0x0 16 7>,
+                                 <0x4 0  7>;
+            clock-output-names = "sd_emmc_a",
+                                 "sd_emmc_b",
+                                 "sd_emmc_c";
+            clocks = <&xtal_24m>,
Quoted 9 lines

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 350

Quoted 6 lines
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +6 -0
+                     <&scmi_clk 6>,
+                     <&scmi_clk 10>;
+            clock-names = "clkin0",
+                          "clkin1",
+                          "clkin2";
+        };

One or two are enough. Drop the rest.

I have no objections to the comments here or the earlier ones I haven't replied to. To avoid taking up more of your time, I didn't reply one by one here. Thanks again.

Quoted 5 lines
Quoted 1 line

Best regards,
Krzysztof

Signature · 2 lines
Best regards,
Chuan
#4 lore raw

Re: [PATCH 01/13] dt-bindings: clock: Add Amlogic A9 standardized model clock control units

In reply to Chuan Liu

Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml line 313

Quoted 10 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:
Documentation/devicetree/bindings/clock/amlogic,a9-model-ccu.yaml new file +10 -0
+additionalProperties: false
+
+examples:
+  - |
+    clk_dummy: clock-dummy {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <0>;
+        clock-output-names = "dummy";
+        status = "disabled";

Eee, nope. Please review this internally so you won't be making such trivial mistakes.

Best regards,
Krzysztof

author
#5 lore raw

PATCH 2/13 dt-bindings: clock: Add Amlogic A9 PLL controllers

In reply to Chuan Liu

Add dt-binding documentation for PLL controllers used in A9 SoC family.

---
 .../devicetree/bindings/clock/amlogic,a9-pll.yaml  | 134 +++++++++++++++++++++
 1 file changed, 134 insertions(+)
Documentation/devicetree/bindings/clock/amlogic,a9-pll.yaml new file +134 -0
new file mode 100644
index 000000000000..26655716f040
@@ -0,0 +1,134 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/amlogic,a9-pll.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic A9 Family PLL Controllers
+
+maintainers:
+  - Chuan Liu <[email protected]>
+
+description: |
+  PLLs generate high-frequency clocks by frequency multiplication, feeding them
+  into the clock tree where they can be configured as operational clocks for
+  various system modules.
+
+  A diagram of the A9 PLL is as follows:
+         +------------------------------------------------------+
+         |      +-------+      +-----+                          |
+    osc-------->| div N |----->|     |   +-----+                |
+         |      +-------+      |     |   |     |                |
+         |                     |     |   | VCO |   +--------+   |
+         |                     |     |-->|  /  |-->| div OD |------>pll_out
+         |                     |     |   | DCO |   +--------+   |
+         |      +----------+   |     |   |     |                |
+         |  +-->| M & frac |-->|     |   +-----+                |
+         |  |   +----------+   +-----+      |                   |
+         |  |                               |                   |
+         |  +-------------------------------+                   |
+         +------------------------------------------------------+
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - const: amlogic,a9-int-pll
+        description: Integer multiplier PLL
+      - items:
+          - const: amlogic,a9-frac-pll
+        description: Fractional multiplier PLL
+      - items:
+          - const: amlogic,a9-frac-step-pll
+        description: Fractional PLL with integer step granularity
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+    description: input clock of pll
+
+  clock-output-names:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 0
+
+  amlogic,clock-max-frequency:
+    description: |
+      Each clock's maximum output frequency is constrained during hardware
+      design to ensure proper timing requirements for the clock network. If the
+      clock frequency configured exceeds this design limit, it can lead to
+      abnormal behavior in modules relying on that clock and may even cause
+      cross-talk that affects other modules.
+
+      In the driver, this property is parsed, and interface functions from the
+      CCF are called to enforce the clock's maximum frequency, preventing
+      potential issues caused by excessive clock frequency configurations.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+  amlogic,clock-init-regs:
+    description:
+      Certain CCUs and PLLs require initialization through dedicated registers
+      before becoming operational. This initialization configures internal clock
+      drive characteristics, divider parameters, and PLL internal circuitry.
+    $ref: /schemas/types.yaml#/definitions/uint32-matrix
+    items:
+      items:
+        - description: The register offset address
+        - description: The value to be written to the register
+        - description: The delay after the register write (unit is us)
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-output-names
+  - "#clock-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    apb {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        clock-mclk_pll@8330 {
+            compatible = "amlogic,a9-int-pll";
+            reg = <0x0 0x8330 0x0 0xc>;
+            #clock-cells = <0>;
+            amlogic,clock-init-regs = <0x4  0x00402000 0>,
+                                      <0x8  0x60000100 0>;
+            amlogic,clock-max-frequency = <2800000000>;
+            clock-output-names = "mclk_pll";
+            clocks = <&xtal_24m>;
+        };
+
+        clock-gp0_pll@8200 {
+            compatible = "amlogic,a9-frac-pll";
+            reg = <0x0 0x8200 0x0 0x10>;
+            #clock-cells = <0>;
+            amlogic,clock-init-regs = <0x0  0x08010000 0>,
+                                      <0x4  0x11480000 0>,
+                                      <0x8  0x1219b010 0>,
+                                      <0xc  0x00008010 0>;
+            amlogic,clock-max-frequency = <2800000000>;
+            clock-output-names = "gp0_pll";
+            clocks = <&xtal_24m>;
+        };
+
+        clock-hifi_pll@8280 {
+            compatible = "amlogic,a9-frac-step-pll";
+            reg = <0x0 0x8280 0x0 0x10>;
+            #clock-cells = <0>;
+            amlogic,clock-init-regs = <0x0  0x08010000 0>,
+                                      <0x4  0x11480000 0>,
+                                      <0x8  0x1219b010 0>,
+                                      <0xc  0x00008010 0>;
+            amlogic,clock-max-frequency = <2800000000>;
+            clock-output-names = "hifi_pll";
+            clocks = <&xtal_24m>;
+        };
+    };
Signature · 1 line
2.42.0
author
#6 lore raw

PATCH 3/13 dt-bindings: clock: Add Amlogic A9 misc clock control units

In reply to Chuan Liu

Add dt-binding documentation for various miscellaneous peripheral clock control units in A9 SoC family.

---
 .../bindings/clock/amlogic,a9-misc-ccu.yaml        | 523 +++++++++++++++++++++
 include/dt-bindings/clock/amlogic,a9-misc-ccu.h    |  53 +++
 2 files changed, 576 insertions(+)
Documentation/devicetree/bindings/clock/amlogic,a9-misc-ccu.yaml new file +523 -0
new file mode 100644
index 000000000000..cce209f75a6e
@@ -0,0 +1,523 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2026 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/amlogic,a9-misc-ccu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic A9 Family Misc Clock Control Unit
+
+maintainers:
+  - Chuan Liu <[email protected]>
+
+description: |
+  The misc-ccu contains clock control units which are built from dedicated,
+  non-universal model clock controllers, such as the sc-ccu for smart card and
+  the ts-ccu for temperature sensor.
+
+  The clock IDs of the subclocks of these CCUs are defined in
+  "include/dt-bindings/clock/amlogic,a9-misc-ccu.h".
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - const: amlogic,a9-sc-ccu
+        description: Clock control unit of smart card
+      - items:
+          - const: amlogic,a9-ts-ccu
+        description: Clock control unit of temperature sensor(s)
+      - items:
+          - const: amlogic,a9-genout-ccu
+        description: Clock control unit that generates clock output to pin(s)
+      - items:
+          - const: amlogic,a9-clk12_24m-ccu
+        description: Clock control unit that generates clock output 12MHz or
+                     24MHz to pin(s)
+      - items:
+          - const: amlogic,a9-vapb_ge2d-ccu
+        description: Clock control unit for vapb and ge2d
+      - items:
+          - const: amlogic,a9-di-ccu
+        description: Clock control unit of de-interlace
+      - items:
+          - const: amlogic,a9-eth-ccu
+        description: Clock control unit of ethernet
+      - items:
+          - const: amlogic,a9-mclk-ccu
+        description: Clock control unit that provides the clock to the external
+                     camera sensor
+      - items:
+          - const: amlogic,a9-dualdivmux-ccu
+        description: Clock control unit using dual divider channel toggling for
+                     fractional division
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    minItems: 1
+    maxItems: 32
+
+  clock-names:
+    minItems: 1
+    maxItems: 32
+
+  clock-output-names:
+    minItems: 1
+    maxItems: 8
+
+  '#clock-cells':
+    description:
+      The clock controller of a module may contain one or more child clock(s).
+      When a clock controller has multiple child clocks, an index is required
+      to specify a particular clock within the clock controller.
+    oneOf:
+      - const: 0
+        description: Single clock output, no specifier needed
+      - const: 1
+        description: Multiple clocks, index selects specific output
+
+  amlogic,clock-max-frequency:
+    description: |
+      Each clock's maximum output frequency is constrained during hardware
+      design to ensure proper timing requirements for the clock network. If the
+      clock frequency configured exceeds this design limit, it can lead to
+      abnormal behavior in modules relying on that clock and may even cause
+      cross-talk that affects other modules.
+
+      In the driver, this property is parsed, and interface functions from the
+      CCF are called to enforce the clock's maximum frequency, preventing
+      potential issues caused by excessive clock frequency configurations.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+  amlogic,clock-init-regs:
+    description:
+      Certain CCUs and PLLs require initialization through dedicated registers
+      before becoming operational. This initialization configures internal clock
+      drive characteristics, divider parameters, and PLL internal circuitry.
+    $ref: /schemas/types.yaml#/definitions/uint32-matrix
+    items:
+      items:
+        - description: The register offset address
+        - description: The value to be written to the register
+        - description: The delay after the register write (unit is us)
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-sc-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+        clock-output-names:
+
+          items:
+            - description: preprocessing clock
+            - description: divider clock
+      required:
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-ts-ccu
+    then:
+      properties:
+        clocks:
+          description: input clock of ts-ccu
+        clock-output-names:
+          items:
+            - description: divider clock
+            - description: gate clock
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-genout-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+            - description: input clock source 4 (optional)
+            - description: input clock source 5 (optional)
+            - description: input clock source 6 (optional)
+            - description: input clock source 7 (optional)
+            - description: input clock source 8 (optional)
+            - description: input clock source 9 (optional)
+            - description: input clock source 10 (optional)
+            - description: input clock source 11 (optional)
+            - description: input clock source 12 (optional)
+            - description: input clock source 13 (optional)
+            - description: input clock source 14 (optional)
+            - description: input clock source 15 (optional)
+            - description: input clock source 16 (optional)
+            - description: input clock source 17 (optional)
+            - description: input clock source 18 (optional)
+            - description: input clock source 19 (optional)
+            - description: input clock source 20 (optional)
+            - description: input clock source 21 (optional)
+            - description: input clock source 22 (optional)
+            - description: input clock source 23 (optional)
+            - description: input clock source 24 (optional)
+            - description: input clock source 25 (optional)
+            - description: input clock source 26 (optional)
+            - description: input clock source 27 (optional)
+            - description: input clock source 28 (optional)
+            - description: input clock source 29 (optional)
+            - description: input clock source 30 (optional)
+            - description: input clock source 31 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+            - const: clkin8
+            - const: clkin9
+            - const: clkin10
+            - const: clkin11
+            - const: clkin12
+            - const: clkin13
+            - const: clkin14
+            - const: clkin15
+            - const: clkin16
+            - const: clkin17
+            - const: clkin18
+            - const: clkin19
+            - const: clkin20
+            - const: clkin21
+            - const: clkin22
+            - const: clkin23
+            - const: clkin24
+            - const: clkin25
+            - const: clkin26
+            - const: clkin27
+            - const: clkin28
+            - const: clkin29
+            - const: clkin30
+            - const: clkin31
+        clock-output-names:
+          items:
+            - description: multiplexer clock
+            - description: divider clock
+            - description: gate clock
+      required:
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-clk12_24m-ccu
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+          description: 24m-xtal clock
+        clock-output-names:
+          items:
+            - description: input gate clock
+            - description: divider clock
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-vapb_ge2d-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+            - description: input clock source 4 (optional)
+            - description: input clock source 5 (optional)
+            - description: input clock source 6 (optional)
+            - description: input clock source 7 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+        clock-output-names:
+          items:
+            - description: vapb clock
+            - description: ge2d clock
+      required:
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-di-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: input clock source 0
+            - description: input clock source 1 (optional)
+            - description: input clock source 2 (optional)
+            - description: input clock source 3 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+        clock-output-names:
+          items:
+            - description: preprocessing clock
+            - description: divider clock
+            - description: gate clock
+      required:
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-eth-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 2
+          items:
+            - description: eth_125m input clock
+            - description: rmii input clock source 0
+            - description: rmii input clock source 1 (optional)
+            - description: rmii input clock source 2 (optional)
+            - description: rmii input clock source 3 (optional)
+            - description: rmii input clock source 4 (optional)
+            - description: rmii input clock source 5 (optional)
+            - description: rmii input clock source 6 (optional)
+            - description: rmii input clock source 7 (optional)
+        clock-names:
+          minItems: 2
+          items:
+            - const: clk125m
+            - const: clkin0
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+            - const: clkin4
+            - const: clkin5
+            - const: clkin6
+            - const: clkin7
+        clock-output-names:
+          items:
+            - description: eth_125m clock
+            - description: eth_rmii clock
+      required:
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-mclk-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 1
+          items:
+            - description: mclk0/1 predivider clock source
+            - description: mclk0/1 clock source 1 (optional)
+            - description: mclk0/1 clock source 2 (optional)
+            - description: mclk0/1 clock source 3 (optional)
+        clock-names:
+          minItems: 1
+          items:
+            - const: divin
+            - const: clkin1
+            - const: clkin2
+            - const: clkin3
+        clock-output-names:
+          items:
+            - description: mclk0 pre-divider clock
+            - description: mclk0 multiplexer clock
+            - description: mclk0 divider clock
+            - description: mclk0 gate clock
+            - description: mclk1 pre-divider clock
+            - description: mclk1 multiplexer clock
+            - description: mclk1 divider clock
+            - description: mclk1 gate clock
+      required:
+        - amlogic,clock-init-regs
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,a9-dualdivmux-ccu
+    then:
+      properties:
+        clocks:
+          minItems: 2
+          items:
+            - description: input clock of dualdiv
+            - description: mux clock source 0
+            - description: mux clock source 1 (optional)
+            - description: mux clock source 2 (optional)
+            - description: mux clock source 3 (optional)
+        clock-names:
+          minItems: 2
+          items:
+            - const: divin
+            - const: mux0
+            - const: mux1
+            - const: mux2
+            - const: mux3
+        clock-output-names:
+          items:
+            - description: dualdiv clock
+            - description: multiplexer clock
+      required:
+        - clock-names
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-output-names
+  - "#clock-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    apb {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        clock-sc@370 {
+            compatible = "amlogic,a9-sc-ccu";
+            reg = <0x0 0x370 0x0 0x4>;
+            #clock-cells = <1>;
+            clock-output-names = "sc_pre",
+                                 "sc";
+            clocks = <&scmi_clk 6>,
+                     <&scmi_clk 9>,
+                     <&scmi_clk 14>,
+                     <&xtal_24m>;
+            clock-names = "clkin0",
+                          "clkin1",
+                          "clkin2",
+                          "clkin3";
+        };
+
+        clock-ts@3a0 {
+            compatible = "amlogic,a9-ts-ccu";
+            reg = <0x0 0x3a0 0x0 0x4>;
+            #clock-cells = <1>;
+            clock-output-names = "ts_div",
+                                 "ts";
+            clocks = <&xtal_24m>;
+        };
+
+        clock-eth@3a4 {
+            compatible = "amlogic,a9-eth-ccu";
+            reg = <0x0 0x3a4 0x0 0x4>;
+            #clock-cells = <1>;
+            clock-output-names = "eth_125m",
+                                 "eth_rmii";
+            clocks = <&clk_eth_125m_div>,
+                     <&scmi_clk 6>;
+            clock-names = "clk125m",
+                          "clkin0";
+        };
+
+        clock-mclk@833c {
+            compatible = "amlogic,a9-mclk-ccu";
+            reg = <0x0 0x833c 0x0 0x8>;
+            #clock-cells = <1>;
+            amlogic,clock-init-regs = <0x0  0x04000400 0>,
+                                      <0x4  0x96169616 0>;
+            clock-output-names = "mclk0_pre_div",
+                                 "mclk0_sel",
+                                 "mclk0_div",
+                                 "mclk0",
+                                 "mclk1_pre_div",
+                                 "mclk1_sel",
+                                 "mclk1_div",
+                                 "mclk1";
+            clocks = <&mclk_pll>,
+                     <&xtal_24m>,
+                     <&scmi_clk 4>;
+            clock-names = "divin",
+                          "clkin1",
+                          "clkin2";
+        };
+    };
+
+    aobus {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        clkc_ao_cecb: clock-ao_cecb@38 {
+            compatible = "amlogic,a9-dualdivmux-ccu";
+            reg = <0x0 0x38 0x0 0x8>;
+            #clock-cells = <1>;
+
+            clock-output-names = "ao_cecb_dualdiv",
+                                 "ao_cecb";
+            clocks = <&xtal>,
+                     <&clkc_ao_cecb 0>,
+                     <&clkc_rtc 1>;
+            clock-names = "divin",
+                          "mux0",
+                          "mux1";
+        };
+
+        clkc_rtc: clock-rtc@8014c {
+            compatible = "amlogic,a9-dualdivmux-ccu";
+            reg = <0x0 0x8014c 0x0 0x8>;
+            #clock-cells = <1>;
+            clock-output-names = "rtc_dualdiv",
+                                 "rtc";
+            clocks = <&xtal>,
+                     <&xtal>,
+                     <&clkc_rtc 0>;
+            clock-names = "divin",
+                          "mux0",
+                          "mux1";
+        };
+    };
include/dt-bindings/clock/amlogic,a9-misc-ccu.h new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.42.0
#7 lore raw

Re: [PATCH 03/13] dt-bindings: clock: Add Amlogic A9 misc clock control units

Documentation/devicetree/bindings/clock/amlogic,a9-misc-ccu.yaml line 81

Quoted 13 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:
Documentation/devicetree/bindings/clock/amlogic,a9-misc-ccu.yaml new file +13 -0
+
+  '#clock-cells':
+    description:
+      The clock controller of a module may contain one or more child clock(s).
+      When a clock controller has multiple child clocks, an index is required
+      to specify a particular clock within the clock controller.
+    oneOf:
+      - const: 0
+        description: Single clock output, no specifier needed
+      - const: 1
+        description: Multiple clocks, index selects specific output
+
+  amlogic,clock-max-frequency:

No

Documentation/devicetree/bindings/clock/amlogic,a9-misc-ccu.yaml line 94

Quoted 13 lines
Documentation/devicetree/bindings/clock/amlogic,a9-misc-ccu.yaml new file +13 -0
+    description: |
+      Each clock's maximum output frequency is constrained during hardware
+      design to ensure proper timing requirements for the clock network. If the
+      clock frequency configured exceeds this design limit, it can lead to
+      abnormal behavior in modules relying on that clock and may even cause
+      cross-talk that affects other modules.
+
+      In the driver, this property is parsed, and interface functions from the
+      CCF are called to enforce the clock's maximum frequency, preventing
+      potential issues caused by excessive clock frequency configurations.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+  amlogic,clock-init-regs:

NAK

...

include/dt-bindings/clock/amlogic,a9-misc-ccu.h line 1

Quoted 7 lines
include/dt-bindings/clock/amlogic,a9-misc-ccu.h new file +1 -0
new file mode 100644
index 000000000000..102aff8d68e4
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */

Use the same license as in binding doc.

Best regards,
Krzysztof

author
#8 lore raw

PATCH 4/13 clk: amlogic: Add basic clock driver

In reply to Chuan Liu

Implement core clock driver for Amlogic SoC platforms, supporting fundamental clock types: mux (multiplexer), div (divider), and gate. The Amlogic clock architecture heavily utilizes these basic building blocks throughout its clock tree.

Features included:
- clk_ops implementations for all basic clock types
- Debugfs interface with two diagnostic nodes:
* clk_type: displays clock type identifier
* clk_available_rates: shows configurable frequency ranges

---
 drivers/clk/Kconfig             |   1 +
 drivers/clk/Makefile            |   1 +
 drivers/clk/amlogic/Kconfig     |  12 +++
 drivers/clk/amlogic/Makefile    |   6 ++
 drivers/clk/amlogic/clk-basic.c | 219 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/amlogic/clk-basic.h |  39 +++++++
 drivers/clk/amlogic/clk.c       | 142 ++++++++++++++++++++++++++
 drivers/clk/amlogic/clk.h       |  38 +++++++
 8 files changed, 458 insertions(+)
drivers/clk/Kconfig +1 -0
index 3a1611008e48..57c13348e7a5 100644
@@ -512,6 +512,7 @@ config COMMON_CLK_RPMI
 	  the RISC-V platform management interface (RPMI) specification.
 
 source "drivers/clk/actions/Kconfig"
+source "drivers/clk/amlogic/Kconfig"
 source "drivers/clk/analogbits/Kconfig"
 source "drivers/clk/baikal-t1/Kconfig"
 source "drivers/clk/bcm/Kconfig"
drivers/clk/Makefile +1 -0
index 61ec08404442..c667f22aa414 100644
@@ -113,6 +113,7 @@ obj-$(CONFIG_COMMON_CLK_XGENE)		+= clk-xgene.o
 
 # please keep this section sorted lexicographically by directory path name
 obj-y					+= actions/
+obj-$(CONFIG_ARCH_MESON)		+= amlogic/
 obj-y					+= analogbits/
 obj-$(CONFIG_COMMON_CLK_AT91)		+= at91/
 obj-$(CONFIG_ARCH_ARTPEC)		+= axis/
drivers/clk/amlogic/Kconfig new file +12 -0
new file mode 100644
index 000000000000..216fe98a413b
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR MIT)
+
+config COMMON_CLK_AMLOGIC
+	tristate "Amlogic Common Clock"
+	depends on ARCH_MESON || COMPILE_TEST
+	depends on OF
+	default ARCH_MESON
+	select REGMAP
+	help
+	  This driver provides the basic clock infrastructure for Amlogic SoCs,
+	  offering read and write interfaces for various clock control units.
+	  Select Y if your target SoC needs clock driver support.
drivers/clk/amlogic/Makefile new file +6 -0
new file mode 100644
index 000000000000..bd9dd5b78b23
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR MIT)
+
+obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-amlogic.o
+
+clk-amlogic-y += clk.o
+clk-amlogic-y += clk-basic.o
drivers/clk/amlogic/clk-basic.c new file +219 -0

219 lines not on this page · raw message

drivers/clk/amlogic/clk-basic.h new file +39 -0
new file mode 100644
index 000000000000..fb2133fa239b
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
+/*
+ * Copyright (c) 2026 Amlogic, Inc. All rights reserved
+ */
+
+#ifndef __AML_CLK_BASIC_H
+#define __AML_CLK_BASIC_H
+
+#include <linux/clk-provider.h>
+
+struct aml_clk_mux_data {
+	unsigned int	reg_offset;
+	u32		*table;
+	u32		mask;
+	u8		shift;
+	u8		flags;
+};
+
+struct aml_clk_divider_data {
+	unsigned int	reg_offset;
+	u8		shift;
+	u8		width;
+	u16		flags;
+	struct clk_div_table	*table;
+};
+
+struct aml_clk_gate_data {
+	unsigned int	reg_offset;
+	u8		bit_idx;
+	u8		flags;
+};
+
+extern const struct clk_ops aml_clk_gate_ops;
+extern const struct clk_ops aml_clk_divider_ops;
+extern const struct clk_ops aml_clk_divider_ro_ops;
+extern const struct clk_ops aml_clk_mux_ops;
+extern const struct clk_ops aml_clk_mux_ro_ops;
+
+#endif /* __AML_CLK_BASIC_H */
drivers/clk/amlogic/clk.c new file +142 -0

142 lines not on this page · raw message

drivers/clk/amlogic/clk.h new file +38 -0
new file mode 100644
index 000000000000..ec0547c1354a
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
+/*
+ * Copyright (c) 2026 Amlogic, Inc. All rights reserved
+ */
+
+#ifndef __AML_CLK_H
+#define __AML_CLK_H
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+enum aml_clk_type {
+	AML_CLKTYPE_MUX		= 1,
+	AML_CLKTYPE_DIV		= 2,
+	AML_CLKTYPE_GATE	= 3,
+};
+
+struct aml_clk {
+	struct clk_hw	hw;
+	enum aml_clk_type type;
+	struct regmap	*map;
+	void		*data;
+};
+
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+
+extern const struct file_operations aml_clk_type_fops;
+extern const struct file_operations aml_clk_div_available_rates_fops;
+#endif /* CONFIG_DEBUG_FS */
+
+static inline struct aml_clk *to_aml_clk(struct clk_hw *hw)
+{
+	return container_of(hw, struct aml_clk, hw);
+}
+
+#endif /* __AML_CLK_H */
Signature · 1 line
2.42.0
#9 lore raw

Re: [PATCH 04/13] clk: amlogic: Add basic clock driver

Quoted 3 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Implement core clock driver for Amlogic SoC platforms, supporting

So how did all existing Amlogic SoC platforms work so far without basic clock driver? Really, how?

You are suppose to grow existing code, not add your completely new "basic" driver just because you have it that way in downstream.

Best regards,
Krzysztof

author
#10 lore raw

Re: [PATCH 04/13] clk: amlogic: Add basic clock driver

Hi Krzysztof (& ALL),
Thanks for review.

Quoted 5 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 2 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Quoted 8 lines
Quoted 1 line

Implement core clock driver for Amlogic SoC platforms, supporting

So how did all existing Amlogic SoC platforms work so far without basic clock driver? Really, how?

You are suppose to grow existing code, not add your completely new "basic" driver just because you have it that way in downstream.

Firstly, apologies for the delayed response. I had intended to consolidate the V1 review feedback and come back with a clearer plan for V2 changes. In the meantime, Martin has provided many detailed and valuable suggestions - much appreciated.

The original goal of optimizing the HW based on A9 and introducing a new clock driver is to reduce unnecessary complexity in the driver. On A9, we optimized the Clock/PLL controller HW to simplify driver performance, complexity, memory footprint, and reusability. Improvements on the HW side can also help drive corresponding enhancements in the driver:
- Performance: Encapsulates sub-clock functions, reducing call paths
- Complexity: Standardized register bits eliminate a large number of
bit definitions (~1/3 of original code is defined register bit [1])
- Memory: Object-oriented design avoids copy/paste for repeated clocks
- Reusability: Same controller works across SoCs without driver
changes (or with minimal changes)

The old meson driver required compromises to unify legacy controller characteristics and driver styles. On A9, we want a fresh start.

Quoted 2 lines

Best regards,
Krzysztof

Signature · 2 lines
Best regards,
Chuan
maintainer
#11 lore raw

Re: [PATCH 04/13] clk: amlogic: Add basic clock driver

Quoted 32 lines · Chuan Liu

Hi Krzysztof (& ALL),
Thanks for review.

Quoted 10 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 3 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Implement core clock driver for Amlogic SoC platforms, supporting

So how did all existing Amlogic SoC platforms work so far without basic clock driver? Really, how?
You are suppose to grow existing code, not add your completely new "basic" driver just because you have it that way in downstream.

Firstly, apologies for the delayed response. I had intended to consolidate the V1 review feedback and come back with a clearer plan for V2 changes. In the meantime, Martin has provided many detailed and valuable suggestions - much appreciated.

The original goal of optimizing the HW based on A9 and introducing a new clock driver is to reduce unnecessary complexity in the driver. On A9, we optimized the Clock/PLL controller HW to simplify driver performance, complexity, memory footprint, and reusability. Improvements on the HW side can also help drive corresponding enhancements in the driver:
- Performance: Encapsulates sub-clock functions, reducing call paths
- Complexity: Standardized register bits eliminate a large number of
bit definitions (~1/3 of original code is defined register bit [1])
- Memory: Object-oriented design avoids copy/paste for repeated clocks
- Reusability: Same controller works across SoCs without driver
changes (or with minimal changes)

Quoted 2 lines

The old meson driver required compromises to unify legacy controller characteristics and driver styles. On A9, we want a fresh start.

I thought I was clear on the cover letter, apparently not.

*This is not going to happen*

You've provided no technical justification for such "a fresh start".

There no reason for A9 HW to be supported by different drivers than the rest of the Amlogic SoC when it is quite clear it can fit with the current drivers.

At lot of work by a lot of different people has gone into stabilizing and maintaing the current driver. That's valuable too. If you are not happy with current level of "performance" then make your case with actual numbers and submit changes against the current drivers, making improvement available to all supported SoCs. That's how upstream works.

Quoted 3 lines
Quoted 3 lines

Best regards,
Krzysztof

Signature · 1 line
Jerome
author
#12 lore raw

Re: [PATCH 04/13] clk: amlogic: Add basic clock driver

Hi Jerome,

Quoted 49 lines · Jerome Brunet

[ EXTERNAL EMAIL ]

Quoted 32 lines · Chuan Liu

Hi Krzysztof (& ALL),
Thanks for review.

Quoted 10 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 3 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Implement core clock driver for Amlogic SoC platforms, supporting

So how did all existing Amlogic SoC platforms work so far without basic clock driver? Really, how?
You are suppose to grow existing code, not add your completely new "basic" driver just because you have it that way in downstream.

Firstly, apologies for the delayed response. I had intended to consolidate the V1 review feedback and come back with a clearer plan for V2 changes. In the meantime, Martin has provided many detailed and valuable suggestions - much appreciated.

The original goal of optimizing the HW based on A9 and introducing a new clock driver is to reduce unnecessary complexity in the driver. On A9, we optimized the Clock/PLL controller HW to simplify driver performance, complexity, memory footprint, and reusability. Improvements on the HW side can also help drive corresponding enhancements in the driver:
- Performance: Encapsulates sub-clock functions, reducing call paths
- Complexity: Standardized register bits eliminate a large number of
bit definitions (~1/3 of original code is defined register bit [1])
- Memory: Object-oriented design avoids copy/paste for repeated clocks
- Reusability: Same controller works across SoCs without driver
changes (or with minimal changes)

Quoted 2 lines

The old meson driver required compromises to unify legacy controller characteristics and driver styles. On A9, we want a fresh start.

I thought I was clear on the cover letter, apparently not.

*This is not going to happen*

You've provided no technical justification for such "a fresh start".

There no reason for A9 HW to be supported by different drivers than the rest of the Amlogic SoC when it is quite clear it can fit with the current drivers.

Quoted 5 lines

At lot of work by a lot of different people has gone into stabilizing and maintaing the current driver. That's valuable too. If you are not happy with current level of "performance" then make your case with actual numbers and submit changes against the current drivers, making improvement available to all supported SoCs. That's how upstream works.

The new driver is intended to reduce unnecessary complexity, making it easier to support future SoC clock drivers while also lowering the review effort required for adding such support. It is important for us to have the foundational clock drivers supported upstream as soon as possible, so that other dependent drivers can proceed with their enablement.

In addition, the A9 clock driver abstracts clocks as fully functional "CCU" units. In previous SoCs, clocks were modeled as discrete components such as mux/divider/gate. Changing the abstraction model in existing drivers would likely require modifying clkids in the DT bindings, which introduces a risk of breaking the ABI.

I respect and truly appreciate your contributions to the Amlogic upstream ecosystem. Based on previous problems and current dilemmas, we hope the A9 approach can bring meaningful improvements.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

Best regards,
Krzysztof

--
Jerome

Signature · 2 lines
Best regards,
Chuan
#13 lore raw

Re: [PATCH 04/13] clk: amlogic: Add basic clock driver

In reply to Chuan Liu
Quoted 18 lines · Chuan Liu

Hi Krzysztof (& ALL),
Thanks for review.

Quoted 5 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 2 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Quoted 8 lines
Quoted 1 line

Implement core clock driver for Amlogic SoC platforms, supporting

So how did all existing Amlogic SoC platforms work so far without basic clock driver? Really, how?

You are suppose to grow existing code, not add your completely new "basic" driver just because you have it that way in downstream.

Quoted 7 lines

Firstly, apologies for the delayed response. I had intended to consolidate the V1 review feedback and come back with a clearer plan for V2 changes. In the meantime, Martin has provided many detailed and valuable suggestions - much appreciated.

The original goal of optimizing the HW based on A9 and introducing a new clock driver is to reduce unnecessary complexity in the driver. On A9,

Nah, you just don't care about upstream and it is easier for you to duplicate new code.

Quoted 7 lines

we optimized the Clock/PLL controller HW to simplify driver performance, complexity, memory footprint, and reusability. Improvements on the HW side can also help drive corresponding enhancements in the driver:
- Performance: Encapsulates sub-clock functions, reducing call paths
- Complexity: Standardized register bits eliminate a large number of
bit definitions (~1/3 of original code is defined register bit [1])
- Memory: Object-oriented design avoids copy/paste for repeated clocks

Object oriented design? Sorry, what?

Quoted 5 lines

- Reusability: Same controller works across SoCs without driver
changes (or with minimal changes)

The old meson driver required compromises to unify legacy controller characteristics and driver styles. On A9, we want a fresh start.

And maintainers don't want that. We expressed this many times already. Not only in this thread - that's one of the most known feedbacks.

Best regards,
Krzysztof

author
#14 lore raw

Re: [PATCH 04/13] clk: amlogic: Add basic clock driver

Hi Krzysztof,

Quoted 26 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 23 lines · Chuan Liu

Hi Krzysztof (& ALL),
Thanks for review.

Quoted 5 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 2 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Quoted 8 lines
Quoted 1 line

Implement core clock driver for Amlogic SoC platforms, supporting

So how did all existing Amlogic SoC platforms work so far without basic clock driver? Really, how?

You are suppose to grow existing code, not add your completely new "basic" driver just because you have it that way in downstream.

Firstly, apologies for the delayed response. I had intended to consolidate the V1 review feedback and come back with a clearer plan for V2 changes. In the meantime, Martin has provided many detailed and valuable suggestions - much appreciated.

Quoted 5 lines
Quoted 2 lines

The original goal of optimizing the HW based on A9 and introducing a new clock driver is to reduce unnecessary complexity in the driver. On A9,

Nah, you just don't care about upstream and it is easier for you to duplicate new code.

Regarding the "duplicate new code": the ops implemented in clk-basic.c are indeed based on the CCF components (clk-mux, clk-divider, clk-gate), with the following enhancements:
- Register access via regmap (meson clock driver looks like this)
- Additional debug nodes to support Amlogic clock automated test
tools (in conjunction with clk-measure to verify hardware functionality of each clock)
- Clock context save/restore support for STD/STR

Other drivers mainly focus on adapting to A9-specific hardware optimizations, as well as improving and refactoring the existing meson drivers.

Quoted 10 lines
Quoted 8 lines

we optimized the Clock/PLL controller HW to simplify driver performance, complexity, memory footprint, and reusability. Improvements on the HW side can also help drive corresponding enhancements in the driver:
- Performance: Encapsulates sub-clock functions, reducing call paths
- Complexity: Standardized register bits eliminate a large number of
bit definitions (~1/3 of original code is defined register bit [1])
- Memory: Object-oriented design avoids copy/paste for repeated clocks

Object oriented design? Sorry, what?

In the new driver, clocks are modeled as the SoC CCU itself. For example, pwm_a/b/c... and emmc_a/b/c use the same CCU, represented as a "composite-ccu". We instantiate the CCU once, rather than redefining clocks for each module.

Quoted 9 lines
Quoted 6 lines

- Reusability: Same controller works across SoCs without driver
changes (or with minimal changes)

The old meson driver required compromises to unify legacy controller characteristics and driver styles. On A9, we want a fresh start.

And maintainers don't want that. We expressed this many times already. Not only in this thread - that's one of the most known feedbacks.

Thanks for the clarification.

Quoted 3 lines

Best regards,
Krzysztof

Signature · 2 lines
Best regards,
Chuan
#15 lore raw

Re: [PATCH 04/13] clk: amlogic: Add basic clock driver

Quoted 36 lines · Chuan Liu

Hi Krzysztof,

Quoted 26 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 23 lines · Chuan Liu

Hi Krzysztof (& ALL),
Thanks for review.

Quoted 5 lines · Krzysztof Kozlowski

[ EXTERNAL EMAIL ]

Quoted 2 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Quoted 8 lines
Quoted 1 line

Implement core clock driver for Amlogic SoC platforms, supporting

So how did all existing Amlogic SoC platforms work so far without basic clock driver? Really, how?

You are suppose to grow existing code, not add your completely new "basic" driver just because you have it that way in downstream.

Firstly, apologies for the delayed response. I had intended to consolidate the V1 review feedback and come back with a clearer plan for V2 changes. In the meantime, Martin has provided many detailed and valuable suggestions - much appreciated.

Quoted 5 lines
Quoted 2 lines

The original goal of optimizing the HW based on A9 and introducing a new clock driver is to reduce unnecessary complexity in the driver. On A9,

Nah, you just don't care about upstream and it is easier for you to duplicate new code.

Quoted 8 lines

Regarding the "duplicate new code": the ops implemented in clk-basic.c are indeed based on the CCF components (clk-mux, clk-divider, clk-gate), with the following enhancements:
- Register access via regmap (meson clock driver looks like this)
- Additional debug nodes to support Amlogic clock automated test
tools (in conjunction with clk-measure to verify hardware functionality of each clock)
- Clock context save/restore support for STD/STR

Add all of these to existing drivers and stop pushing your downstream approach. You received feedback already more than once from more than one person. No means no. You are waiting one week with a reply and then again pushing against feedback with ridiculous arguments of "objective design" or "optimizing".

That pushing after receiving clear "no" means you value downstream or vendor or corporate rules more than what community wants and that's short way to get permanently PLONK-ed on all your submissions.

NAK

Best regards,
Krzysztof

author
#16 lore raw

PATCH 5/13 clk: amlogic: Add composite clock driver

In reply to Chuan Liu

Implement clk_ops support for Amlogic composite clocks. Composite clocks are commonly used clock control units in Amlogic SoCs that integrate multiplexer, divider, and gate functionality into a single block.

---
 drivers/clk/amlogic/Makefile        |   1 +
 drivers/clk/amlogic/clk-composite.c | 280 ++++++++++++++++++++++++++++++++++++
 drivers/clk/amlogic/clk-composite.h |  20 +++
 drivers/clk/amlogic/clk.c           |   7 +
 drivers/clk/amlogic/clk.h           |   1 +
 5 files changed, 309 insertions(+)
drivers/clk/amlogic/Makefile +1 -0
index bd9dd5b78b23..58a5e7bc8993 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-amlogic.o
 
 clk-amlogic-y += clk.o
 clk-amlogic-y += clk-basic.o
+clk-amlogic-y += clk-composite.o
drivers/clk/amlogic/clk-composite.c new file +280 -0

280 lines not on this page · raw message

drivers/clk/amlogic/clk-composite.h new file +20 -0
new file mode 100644
index 000000000000..6a356d697b78
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
+/*
+ * Copyright (c) 2026 Amlogic, Inc. All rights reserved
+ */
+
+#ifndef __AML_CLK_COMPOSITE_H
+#define __AML_CLK_COMPOSITE_H
+
+#include <linux/clk-provider.h>
+
+struct aml_clk_composite_data {
+	unsigned int	reg_offset;
+	u8		bit_offset;
+	u8		div_width;
+	u32		*table;
+};
+
+extern const struct clk_ops aml_clk_composite_ops;
+
+#endif /* __AML_CLK_COMPOSITE_H */
drivers/clk/amlogic/clk.c +7 -0
index 03ccfa78c511..e71dcb6b46b7 100644
@@ -10,6 +10,7 @@
 
 #include "clk.h"
 #include "clk-basic.h"
+#include "clk-composite.h"
 
 static const struct {
 	unsigned int type;
@@ -19,6 +20,7 @@ static const struct {
 	ENTRY(AML_CLKTYPE_MUX),
 	ENTRY(AML_CLKTYPE_DIV),
 	ENTRY(AML_CLKTYPE_GATE),
+	ENTRY(AML_CLKTYPE_COMPOSITE),
 #undef ENTRY
 };
 
@@ -95,6 +97,11 @@ static int aml_clk_div_available_rates_show(struct seq_file *s, void *data)
 			div_flags = div->flags;
 			div_width = div->width;
 		}
+	} else if (clk->type == AML_CLKTYPE_COMPOSITE) {
+		struct aml_clk_composite_data *composite = clk->data;
+
+		div_val = (1 << composite->div_width) - 1;
+		div_width = composite->div_width;
 	} else {
 		pr_err("%s: Unsupported clock type\n", clk_hw_get_name(hw));
 		return -EINVAL;
drivers/clk/amlogic/clk.h +1 -0
index ec0547c1354a..e5fe85c2969f 100644
@@ -14,6 +14,7 @@ enum aml_clk_type {
 	AML_CLKTYPE_MUX		= 1,
 	AML_CLKTYPE_DIV		= 2,
 	AML_CLKTYPE_GATE	= 3,
+	AML_CLKTYPE_COMPOSITE	= 4,
 };
 
 struct aml_clk {
Signature · 1 line
2.42.0
#17 lore raw

Re: [PATCH 05/13] clk: amlogic: Add composite clock driver

Quoted 6 lines · On 09/02/2026 06:48, Chuan Liu via B4 Relay wrote:

From: Chuan Liu <[email protected]>

Implement clk_ops support for Amlogic composite clocks. Composite clocks are commonly used clock control units in Amlogic SoCs that integrate multiplexer, divider, and gate functionality into a single block.

Quoted 7 lines
---
 drivers/clk/amlogic/Makefile        |   1 +
 drivers/clk/amlogic/clk-composite.c | 280 ++++++++++++++++++++++++++++++++++++
 drivers/clk/amlogic/clk-composite.h |  20 +++
 drivers/clk/amlogic/clk.c           |   7 +
 drivers/clk/amlogic/clk.h           |   1 +

Why did you duplicate the directory? It's already there under name meson. That's your vendor.

Best regards,
Krzysztof

author
#18 lore raw

PATCH 6/13 clk: amlogic: Add noglitch clock driver

In reply to Chuan Liu

Implement clk_ops support for Amlogic noglitch clocks. The noglitch clock consists of two Amlogic composite clocks and a noglitch multiplexer. It ensures output clock continuity through ping-pong switching between the two composite clocks, with the noglitch mux suppressing glitches during clock transitions.

Amlogic noglitch clocks are used for modules requiring high clock quality, such as GPU, video codecs, and other sensitive peripherals.

---
 drivers/clk/amlogic/Makefile       |   1 +
 drivers/clk/amlogic/clk-noglitch.c | 584 +++++++++++++++++++++++++++++++++++++
 drivers/clk/amlogic/clk-noglitch.h |  29 ++
 drivers/clk/amlogic/clk.c          |   5 +
 drivers/clk/amlogic/clk.h          |   1 +
 5 files changed, 620 insertions(+)
drivers/clk/amlogic/Makefile +1 -0
index 58a5e7bc8993..72cd2525e078 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-amlogic.o
 clk-amlogic-y += clk.o
 clk-amlogic-y += clk-basic.o
 clk-amlogic-y += clk-composite.o
+clk-amlogic-y += clk-noglitch.o
drivers/clk/amlogic/clk-noglitch.c new file +584 -0

584 lines not on this page · raw message

drivers/clk/amlogic/clk-noglitch.h new file +29 -0
new file mode 100644
index 000000000000..3b8408afd77a
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
+/*
+ * Copyright (c) 2026 Amlogic, Inc. All rights reserved
+ */
+
+#ifndef __AML_CLK_NOGLITCH_H
+#define __AML_CLK_NOGLITCH_H
+
+#include <linux/clk-provider.h>
+
+/*
+ * NOTE: Currently, the divider of the AM no-glitch clock uses a fixed 7-bit
+ * register field width.
+ *
+ * To better consolidate the code, the implementation for calculating
+ * "clk_available_rates" for divider, composite, and no-glitch clocks has been
+ * unified into a single function (in clk.c). Therefore, this macro is defined
+ * here for use by the related functions.
+ */
+#define CLK_NOGLITCH_DIV_WIDTH		7
+
+struct aml_clk_noglitch_data {
+	unsigned int	reg_offset;
+	u32		*table;
+};
+
+extern const struct clk_ops aml_clk_noglitch_ops;
+
+#endif /* __AML_CLK_NOGLITCH_H */
drivers/clk/amlogic/clk.c +5 -0
index e71dcb6b46b7..12e9596668d2 100644
@@ -11,6 +11,7 @@
 #include "clk.h"
 #include "clk-basic.h"
 #include "clk-composite.h"
+#include "clk-noglitch.h"
 
 static const struct {
 	unsigned int type;
@@ -21,6 +22,7 @@ static const struct {
 	ENTRY(AML_CLKTYPE_DIV),
 	ENTRY(AML_CLKTYPE_GATE),
 	ENTRY(AML_CLKTYPE_COMPOSITE),
+	ENTRY(AML_CLKTYPE_NOGLITCH),
 #undef ENTRY
 };
 
@@ -102,6 +104,9 @@ static int aml_clk_div_available_rates_show(struct seq_file *s, void *data)
 
 		div_val = (1 << composite->div_width) - 1;
 		div_width = composite->div_width;
+	} else if (clk->type == AML_CLKTYPE_NOGLITCH) {
+		div_val = (1 << CLK_NOGLITCH_DIV_WIDTH) - 1;
+		div_width = CLK_NOGLITCH_DIV_WIDTH;
 	} else {
 		pr_err("%s: Unsupported clock type\n", clk_hw_get_name(hw));
 		return -EINVAL;
drivers/clk/amlogic/clk.h +1 -0
index e5fe85c2969f..14045fa109c0 100644
@@ -15,6 +15,7 @@ enum aml_clk_type {
 	AML_CLKTYPE_DIV		= 2,
 	AML_CLKTYPE_GATE	= 3,
 	AML_CLKTYPE_COMPOSITE	= 4,
+	AML_CLKTYPE_NOGLITCH	= 5,
 };
 
 struct aml_clk {
Signature · 1 line
2.42.0
#19 lore raw

Re: [PATCH 06/13] clk: amlogic: Add noglitch clock driver

Hi Chuan Liu,

On Mon, Feb 9, 2026 at 6:49 AM Chuan Liu via B4 Relay <[email protected]> wrote:
[...]

Quoted 6 lines

+ * To prevent glitches from propagating to clk_out and affecting the normal
+ * operation of glitch-sensitive modules, the no-glitch clock must be configured
+ * following the specified sequence:
+ * - When the clock gate is disabled: configure it as a normal composite clock
+ * (any glitches generated will be blocked by the gate and will not
+ * propagate to clk_out).

This part is easy and makes sense.

Quoted 7 lines

+ * - When the clock gate is enabled: configure it according to the following
+ * sequence to suppress glitches:
+ * - Configure and enable the idle composite clock path of the
+ * noglitch_mux with the target frequency/parent clock.
+ * - Switch the noglitch_mux to the channel prepared in the previous step.
+ * - Disable the clock of the original noglitch_mux channel.
+ */

From a previous discussion it seems that in reality things need to be handled more carefully as you previously mentioned that CLK_SET_RATE_GATE is not good enough (the description above is what CLK_SET_RATE_GATE already achieves).
For the more careful handling Jerome suggested using the clock protection logic: [0]
You wanted to try it out at some point: [1]
Is the verdict that Jerome's suggestion did not work? Can you please share some details as to why it doesn't work.

Best regards,
Martin

[0] https://lore.kernel.org/linux-amlogic/[email protected]/
[1] https://lore.kernel.org/linux-amlogic/[email protected]/

author
#20 lore raw

Re: [PATCH 06/13] clk: amlogic: Add noglitch clock driver

Hi Martin,
Thanks for review.

Quoted 22 lines · Martin Blumenstingl

[ EXTERNAL EMAIL ]

Hi Chuan Liu,

On Mon, Feb 9, 2026 at 6:49 AM Chuan Liu via B4 Relay <[email protected]> wrote:
[...]

Quoted 6 lines

+ * To prevent glitches from propagating to clk_out and affecting the normal
+ * operation of glitch-sensitive modules, the no-glitch clock must be configured
+ * following the specified sequence:
+ * - When the clock gate is disabled: configure it as a normal composite clock
+ * (any glitches generated will be blocked by the gate and will not
+ * propagate to clk_out).

This part is easy and makes sense.

Quoted 7 lines

+ * - When the clock gate is enabled: configure it according to the following
+ * sequence to suppress glitches:
+ * - Configure and enable the idle composite clock path of the
+ * noglitch_mux with the target frequency/parent clock.
+ * - Switch the noglitch_mux to the channel prepared in the previous step.
+ * - Disable the clock of the original noglitch_mux channel.
+ */

Quoted 10 lines

From a previous discussion it seems that in reality things need to be
handled more carefully as you previously mentioned that CLK_SET_RATE_GATE is not good enough (the description above is what CLK_SET_RATE_GATE already achieves).
For the more careful handling Jerome suggested using the clock protection logic: [0]
You wanted to try it out at some point: [1]
Is the verdict that Jerome's suggestion did not work? Can you please share some details as to why it doesn't work.

In the actual use case, this switching operation completes within the nanosecond range (with a minimum clock frequency of 24 MHz in typical scenarios), which is why no issues were observed on our previous SoCs.

Thank you for the reminder, to be on the safe side, I will introduce some explicit hardware delays in the future revision.

Quoted 7 lines

Best regards,
Martin

[0] https://lore.kernel.org/linux-amlogic/[email protected]/
[1] https://lore.kernel.org/linux-amlogic/[email protected]/

Signature · 2 lines
Best regards,
Chuan
author
#21 lore raw

PATCH 7/13 clk: amlogic: Add duandiv clock driver

In reply to Chuan Liu

Implement clk_ops support for Amlogic dualdiv clocks. The dualdiv clock comprises two independent divider channels with counters. It achieves fractional division functionality by alternating between the two divided clocks.

Amlogic dualdiv clocks are used for modules requiring fractional division without concern for clock phase or duty cycle, commonly generating 32.768KHz from a 24MHz crystal input for RTC applications.

---
 drivers/clk/amlogic/Makefile      |   1 +
 drivers/clk/amlogic/clk-dualdiv.c | 365 ++++++++++++++++++++++++++++++++++++++
 drivers/clk/amlogic/clk-dualdiv.h |  27 +++
 drivers/clk/amlogic/clk.c         |   1 +
 drivers/clk/amlogic/clk.h         |   1 +
 5 files changed, 395 insertions(+)
drivers/clk/amlogic/Makefile +1 -0
index 72cd2525e078..bc2b22b4d3c9 100644
@@ -5,4 +5,5 @@ obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-amlogic.o
 clk-amlogic-y += clk.o
 clk-amlogic-y += clk-basic.o
 clk-amlogic-y += clk-composite.o
+clk-amlogic-y += clk-dualdiv.o
 clk-amlogic-y += clk-noglitch.o
drivers/clk/amlogic/clk-dualdiv.c new file +365 -0

365 lines not on this page · raw message

drivers/clk/amlogic/clk-dualdiv.h new file +27 -0
new file mode 100644
index 000000000000..fbbae6686afd
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
+/*
+ * Copyright (c) 2026 Amlogic, Inc. All rights reserved
+ */
+
+#ifndef __AML_CLK_DUALDIV_H
+#define __AML_CLK_DUALDIV_H
+
+#include <linux/clk-provider.h>
+
+struct aml_clk_dualdiv_param {
+	unsigned int div_mode;
+	unsigned int n0;
+	unsigned int m0;
+	unsigned int n1;
+	unsigned int m1;
+};
+
+struct aml_clk_dualdiv_data {
+	unsigned int			reg_offset;
+	struct	aml_clk_dualdiv_param	*table;
+	unsigned int			table_count;
+};
+
+extern const struct clk_ops aml_clk_dualdiv_ops;
+
+#endif /* __AML_CLK_DUALDIV_MUX_H */
drivers/clk/amlogic/clk.c +1 -0
index 12e9596668d2..5431aa320dfa 100644
@@ -23,6 +23,7 @@ static const struct {
 	ENTRY(AML_CLKTYPE_GATE),
 	ENTRY(AML_CLKTYPE_COMPOSITE),
 	ENTRY(AML_CLKTYPE_NOGLITCH),
+	ENTRY(AML_CLKTYPE_DUALDIV),
 #undef ENTRY
 };
 
drivers/clk/amlogic/clk.h +1 -0
index 14045fa109c0..c1d58a08e407 100644
@@ -16,6 +16,7 @@ enum aml_clk_type {
 	AML_CLKTYPE_GATE	= 3,
 	AML_CLKTYPE_COMPOSITE	= 4,
 	AML_CLKTYPE_NOGLITCH	= 5,
+	AML_CLKTYPE_DUALDIV	= 6,
 };
 
 struct aml_clk {
Signature · 1 line
2.42.0
author
#22 lore raw

PATCH 8/13 clk: amlogic: Add PLL driver

In reply to Chuan Liu

Implement clk_ops support for Amlogic PLL.

---
 drivers/clk/amlogic/Makefile  |   1 +
 drivers/clk/amlogic/clk-pll.c | 701 ++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/amlogic/clk-pll.h |  43 +++
 drivers/clk/amlogic/clk.c     |   1 +
 drivers/clk/amlogic/clk.h     |   1 +
 5 files changed, 747 insertions(+)
drivers/clk/amlogic/Makefile +1 -0
index bc2b22b4d3c9..6956592c41c8 100644
@@ -7,3 +7,4 @@ clk-amlogic-y += clk-basic.o
 clk-amlogic-y += clk-composite.o
 clk-amlogic-y += clk-dualdiv.o
 clk-amlogic-y += clk-noglitch.o
+clk-amlogic-y += clk-pll.o
drivers/clk/amlogic/clk-pll.c new file +701 -0

701 lines not on this page · raw message

drivers/clk/amlogic/clk-pll.h new file +43 -0

43 lines not on this page · raw message

drivers/clk/amlogic/clk.c +1 -0
index 5431aa320dfa..2558c3f48242 100644
@@ -24,6 +24,7 @@ static const struct {
 	ENTRY(AML_CLKTYPE_COMPOSITE),
 	ENTRY(AML_CLKTYPE_NOGLITCH),
 	ENTRY(AML_CLKTYPE_DUALDIV),
+	ENTRY(AML_CLKTYPE_PLL),
 #undef ENTRY
 };
 
drivers/clk/amlogic/clk.h +1 -0
index c1d58a08e407..b62045aedfbf 100644
@@ -17,6 +17,7 @@ enum aml_clk_type {
 	AML_CLKTYPE_COMPOSITE	= 4,
 	AML_CLKTYPE_NOGLITCH	= 5,
 	AML_CLKTYPE_DUALDIV	= 6,
+	AML_CLKTYPE_PLL		= 7,
 };
 
 struct aml_clk {
Signature · 1 line
2.42.0
#23 lore raw

Re: [PATCH 08/13] clk: amlogic: Add PLL driver

kernel test robot noticed the following build errors:

Hi Chuan,

kernel test robot noticed the following build errors:

[auto build test ERROR on 4d310797262f0ddf129e76c2aad2b950adaf1fda]

url:    https://github.com/intel-lab-lkp/linux/commits/Chuan-Liu-via-B4-Relay/dt-bindings-clock-Add-Amlogic-A9-standardized-model-clock-control-units/20260209-135334
base:   4d310797262f0ddf129e76c2aad2b950adaf1fda
patch link:    https://lore.kernel.org/r/20260209-a9_clock_driver-v1-8-a9198dc03d2a%40amlogic.com
patch subject: [PATCH 08/13] clk: amlogic: Add PLL driver
config: arm-randconfig-003-20260209 (https://download.01.org/0day-ci/archive/20260209/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260209/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

arm-linux-gnueabi-ld: drivers/clk/amlogic/clk-pll.o: in function `aml_pll_available_rates_show':

>> drivers/clk/amlogic/clk-pll.c:554: undefined reference to `__aeabi_uldivmod'
>> arm-linux-gnueabi-ld: drivers/clk/amlogic/clk-pll.c:567: undefined reference to `__aeabi_uldivmod'
>> arm-linux-gnueabi-ld: drivers/clk/amlogic/clk-pll.c:554: undefined reference to `__aeabi_uldivmod'

vim +554 drivers/clk/amlogic/clk-pll.c

536
537 static int aml_pll_get_best_rate(unsigned long rate, unsigned long step_rate,
538 u64 min_vco_rate, u64 max_vco_rate,
539 u8 od_max, enum round_type round,
540 unsigned long *out_rate)
541 {
542 int i;
543 u64 vco_rate;
544 unsigned long now_rate, best_rate = 0;
545
546 for (i = 0; i <= od_max; i++) {
547 vco_rate = rate << i;
548 if (vco_rate < min_vco_rate)
549 continue;
550
551 if (vco_rate > max_vco_rate)
552 break;
553

 > 554			if (vco_rate % step_rate == 0) {
   555				best_rate = rate;
   556	
   557				break;
   558			}
   559	
   560			if (round == ROUND_DOWN) {
   561				vco_rate = vco_rate - (vco_rate % step_rate);
   562				now_rate = vco_rate >> i;
   563				if ((rate - now_rate) < (rate - best_rate))
   564					best_rate = now_rate;
   565			} else {
   566				vco_rate = vco_rate + step_rate;
 > 567				vco_rate = vco_rate - (vco_rate % step_rate);

568 now_rate = vco_rate >> i;
569 if ((now_rate - rate) < (best_rate - rate))
570 best_rate = now_rate;
571 }
572 }
573
574 if (!best_rate)
575 return -EINVAL;
576
577 *out_rate = best_rate;
578
579 return 0;
580 }
581

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#24 lore raw

Re: [PATCH 08/13] clk: amlogic: Add PLL driver

In reply to Chuan Liu
kernel test robot noticed the following build errors:

Hi Chuan,

kernel test robot noticed the following build errors:

[auto build test ERROR on 4d310797262f0ddf129e76c2aad2b950adaf1fda]

url:    https://github.com/intel-lab-lkp/linux/commits/Chuan-Liu-via-B4-Relay/dt-bindings-clock-Add-Amlogic-A9-standardized-model-clock-control-units/20260209-135334
base:   4d310797262f0ddf129e76c2aad2b950adaf1fda
patch link:    https://lore.kernel.org/r/20260209-a9_clock_driver-v1-8-a9198dc03d2a%40amlogic.com
patch subject: [PATCH 08/13] clk: amlogic: Add PLL driver
config: arm-randconfig-004-20260209 (https://download.01.org/0day-ci/archive/20260210/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260210/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

arm-linux-gnueabi-ld: drivers/clk/amlogic/clk-pll.o: in function `aml_pll_get_rate_range':

>> drivers/clk/amlogic/clk-pll.c:554:(.text+0x700): undefined reference to `__aeabi_uldivmod'
>> arm-linux-gnueabi-ld: drivers/clk/amlogic/clk-pll.c:567:(.text+0x728): undefined reference to `__aeabi_uldivmod'

arm-linux-gnueabi-ld: drivers/clk/amlogic/clk-pll.c:554:(.text+0x814): undefined reference to `__aeabi_uldivmod'

vim +554 drivers/clk/amlogic/clk-pll.c

536
537 static int aml_pll_get_best_rate(unsigned long rate, unsigned long step_rate,
538 u64 min_vco_rate, u64 max_vco_rate,
539 u8 od_max, enum round_type round,
540 unsigned long *out_rate)
541 {
542 int i;
543 u64 vco_rate;
544 unsigned long now_rate, best_rate = 0;
545
546 for (i = 0; i <= od_max; i++) {
547 vco_rate = rate << i;
548 if (vco_rate < min_vco_rate)
549 continue;
550
551 if (vco_rate > max_vco_rate)
552 break;
553

 > 554			if (vco_rate % step_rate == 0) {
   555				best_rate = rate;
   556	
   557				break;
   558			}
   559	
   560			if (round == ROUND_DOWN) {
   561				vco_rate = vco_rate - (vco_rate % step_rate);
   562				now_rate = vco_rate >> i;
   563				if ((rate - now_rate) < (rate - best_rate))
   564					best_rate = now_rate;
   565			} else {
   566				vco_rate = vco_rate + step_rate;
 > 567				vco_rate = vco_rate - (vco_rate % step_rate);

568 now_rate = vco_rate >> i;
569 if ((now_rate - rate) < (best_rate - rate))
570 best_rate = now_rate;
571 }
572 }
573
574 if (!best_rate)
575 return -EINVAL;
576
577 *out_rate = best_rate;
578
579 return 0;
580 }
581

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author
#25 lore raw

PATCH 9/13 clk: amlogic: Add DT-based clock registration functions

In reply to Chuan Liu

Amlogic clock controllers require hardware information description in device tree. This patch provides functions for parsing clock configuration from DT and performing clock registration after obtaining clock details.

---
 drivers/clk/amlogic/clk.c | 310 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/clk/amlogic/clk.h |  14 +++
 2 files changed, 323 insertions(+), 1 deletion(-)
drivers/clk/amlogic/clk.c +309 -1
index 2558c3f48242..f3327c8414be 100644
@@ -3,12 +3,15 @@
  * Copyright (c) 2026 Amlogic, Inc. All rights reserved
  */
 
+#include <linux/clk.h>
 #include <linux/module.h>
+#include <linux/of_clk.h>
+
+#include "clk.h"
 
 #ifdef CONFIG_DEBUG_FS
 #include <linux/err.h>
 
-#include "clk.h"
 #include "clk-basic.h"
 #include "clk-composite.h"
 #include "clk-noglitch.h"
@@ -150,6 +153,311 @@ const struct file_operations aml_clk_div_available_rates_fops = {
 EXPORT_SYMBOL_NS_GPL(aml_clk_div_available_rates_fops, "CLK_AMLOGIC");
 #endif /* CONFIG_DEBUG_FS */
 
+struct regmap *aml_clk_regmap_init(struct platform_device *pdev)
+{
+	void __iomem *base;
+	struct resource *res;
+	struct regmap_config clkc_regmap_config = {
+		.reg_bits	= 32,
+		.val_bits	= 32,
+		.reg_stride	= 4,
+	};
+
+	base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+	if (IS_ERR(base))
+		return NULL;
+
+	clkc_regmap_config.max_register = resource_size(res) - 4;
+	if (!clkc_regmap_config.max_register)
+		clkc_regmap_config.max_register_is_0 = true;
+
+	return devm_regmap_init_mmio(&pdev->dev, base, &clkc_regmap_config);
+}
+EXPORT_SYMBOL_NS_GPL(aml_clk_regmap_init, "CLK_AMLOGIC");
+
+static inline int of_aml_clk_get_init_reg_count(struct device_node *np)
+{
+	return of_property_count_elems_of_size(np, "amlogic,clock-init-regs",
+					       sizeof(struct reg_sequence));
+}
+
+static inline int of_aml_clk_get_init_reg(struct device_node *np, int reg_count,
+					  struct reg_sequence *init_regs)
+{
+	return of_property_read_u32_array(np, "amlogic,clock-init-regs",
+					  (u32 *)init_regs,
+					  3 * reg_count);
+}
+
+int of_aml_clk_regs_init(struct device *dev)
+{
+	struct device_node *dev_np = dev_of_node(dev);
+	struct regmap *regmap = dev_get_regmap(dev, NULL);
+	int ret, reg_count;
+	struct reg_sequence *init_regs;
+
+	ret = of_aml_clk_get_init_reg_count(dev_np);
+	if (ret < 0)
+		return 0;
+
+	reg_count = ret;
+	init_regs = devm_kcalloc(dev, reg_count, sizeof(*init_regs),
+				 GFP_KERNEL);
+	if (!init_regs)
+		return -ENOMEM;
+
+	ret = of_aml_clk_get_init_reg(dev_np, reg_count, init_regs);
+	if (ret)
+		goto fail;
+
+	ret = regmap_multi_reg_write(regmap, init_regs, reg_count);
+
+fail:
+	devm_kfree(dev, init_regs);
+
+	return ret;
+}
+EXPORT_SYMBOL_NS_GPL(of_aml_clk_regs_init, "CLK_AMLOGIC");
+
+u32 of_aml_clk_get_count(struct device_node *np)
+{
+	/*
+	 * NOTE: Each clock under a clock device node must define the
+	 * "clock-output-names" property, so this property is used here to
+	 * determine how many clocks are contained in the current clock device
+	 * node.
+	 */
+	int ret = of_property_count_strings(np, "clock-output-names");
+
+	if (ret < 0)
+		return 0;
+
+	return ret;
+}
+EXPORT_SYMBOL_NS_GPL(of_aml_clk_get_count, "CLK_AMLOGIC");
+
+const char *of_aml_clk_get_name_index(struct device_node *np, u32 index)
+{
+	const char *name;
+
+	if (of_property_read_string_index(np, "clock-output-names", index,
+					  &name)) {
+		pr_err("<%pOFn>: Invalid clock-output-names, index = %d\n",
+		       np, index);
+		return NULL;
+	}
+
+	return name;
+}
+EXPORT_SYMBOL_NS_GPL(of_aml_clk_get_name_index, "CLK_AMLOGIC");
+
+static bool of_aml_clk_is_dummy_index(struct device_node *np, int index)
+{
+	struct of_phandle_args clk_args;
+	u32 rate;
+	int ret = of_parse_phandle_with_args(np, "clocks", "#clock-cells",
+					     index, &clk_args);
+
+	if (ret < 0)
+		return true;
+
+	/*
+	 * If the device node description specified by clk_args indicates a
+	 * fixed clock with a frequency of 0, the device is considered a dummy
+	 * clock device.
+	 */
+	if (of_device_is_compatible(clk_args.np, "fixed-clock") &&
+	    !of_property_read_u32(clk_args.np, "clock-frequency", &rate) &&
+	    rate == 0)
+		return true;
+
+	return false;
+}
+
+int of_aml_clk_get_parent_num(struct device *dev, int start_index, int end_index)
+{
+	struct device_node *np = dev_of_node(dev);
+	unsigned int pcnt = of_clk_get_parent_count(np);
+	int i, real_pcnt = 0;
+
+	if (end_index < 0 || end_index >= pcnt)
+		/* Get the number of all "clocks" for the current device node */
+		end_index = pcnt - 1;
+
+	if (start_index > end_index ||
+	    start_index > pcnt)
+		return -EINVAL;
+
+	for (i = start_index; i <= end_index; i++) {
+		if (of_aml_clk_is_dummy_index(np, i))
+			continue;
+
+		real_pcnt++;
+	}
+
+	return real_pcnt;
+}
+EXPORT_SYMBOL_NS_GPL(of_aml_clk_get_parent_num, "CLK_AMLOGIC");
+
+static struct clk_hw *of_aml_clk_get_hw(struct device_node *np,
+					struct clk_hw **dev_hws, int index)
+{
+	struct of_phandle_args out_args;
+	struct clk *clk;
+	struct clk_hw *clk_hw;
+	int ret;
+
+	ret = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index,
+					 &out_args);
+	if (ret)
+		return ERR_PTR(ret);
+
+	if (out_args.np == np) {
+		if (!dev_hws)
+			return ERR_PTR(-EFAULT);
+
+		/*
+		 * If a parent clock comes from the device node itself, the
+		 * corresponding clk_hw can be found using the
+		 * "out_args.args[0]" (clock index).
+		 */
+		clk_hw = dev_hws[out_args.args[0]];
+	} else {
+		clk = of_clk_get_from_provider(&out_args);
+		if (IS_ERR(clk)) {
+			if (PTR_ERR(clk) != -EPROBE_DEFER)
+				pr_warn("clk: couldn't get clock for %pOF\n",
+					out_args.np);
+
+			return ERR_CAST(clk);
+		}
+
+		clk_hw = __clk_get_hw(clk);
+		clk_put(clk);
+	}
+
+	return clk_hw;
+}
+
+int of_aml_clk_get_parent_data(struct device *dev, struct clk_hw **dev_hws,
+			       int start_index, int end_index,
+			       struct clk_parent_data *out_pdatas,
+			       u8 *out_num_parents)
+{
+	struct device_node *np = dev_of_node(dev);
+	unsigned int pcnt = of_clk_get_parent_count(np);
+	int i, real_pcnt;
+
+	if (end_index < 0 || end_index >= pcnt)
+		/* Get the number of all "clocks" for the current device node */
+		end_index = pcnt - 1;
+
+	if (start_index > end_index || start_index > pcnt)
+		return -EINVAL;
+
+	for (i = start_index, real_pcnt = 0; i <= end_index; i++) {
+		if (of_aml_clk_is_dummy_index(np, i))
+			continue;
+
+		out_pdatas[real_pcnt].hw = of_aml_clk_get_hw(np, dev_hws, i);
+		if (IS_ERR(out_pdatas[real_pcnt].hw))
+			return PTR_ERR(out_pdatas[real_pcnt].hw);
+
+		real_pcnt++;
+	}
+
+	if (out_num_parents)
+		*out_num_parents = real_pcnt;
+
+	return 0;
+}
+EXPORT_SYMBOL_NS_GPL(of_aml_clk_get_parent_data, "CLK_AMLOGIC");
+
+u32 *of_aml_clk_get_parent_table(struct device *dev, int start_index,
+				 int end_index)
+{
+	struct device_node *np = dev_of_node(dev);
+	bool has_ptab = false;
+	u32 *ptab;
+	unsigned int pcnt = of_clk_get_parent_count(np);
+	int i, real_pcnt, ptab_i;
+
+	real_pcnt = of_aml_clk_get_parent_num(dev, start_index, end_index);
+	if (real_pcnt < 0)
+		return ERR_PTR(-EINVAL);
+	else if (!real_pcnt) /* no parent clock */
+		return NULL;
+
+	if (end_index < 0 || end_index >= pcnt)
+		end_index = pcnt - 1;
+
+	for (i = start_index, ptab_i = 0; i <= end_index; i++) {
+		/* dummy clock exist and ptab needs to be defined */
+		if (of_aml_clk_is_dummy_index(np, i)) {
+			has_ptab = true;
+			break;
+		}
+	}
+	if (!has_ptab)
+		return NULL;
+
+	ptab = devm_kcalloc(dev, real_pcnt, sizeof(*ptab), GFP_KERNEL);
+	if (!ptab)
+		return ERR_PTR(-ENOMEM);
+
+	for (i = start_index, ptab_i = 0; i <= end_index; i++) {
+		if (!of_aml_clk_is_dummy_index(np, i))
+			ptab[ptab_i++] = i - start_index;
+	}
+
+	return ptab;
+}
+EXPORT_SYMBOL_NS_GPL(of_aml_clk_get_parent_table, "CLK_AMLOGIC");
+
+static int of_aml_clk_get_max_rate(struct device_node *np, u32 index,
+			    unsigned long *out_max_rate)
+{
+	int count = of_property_count_u32_elems(np,
+						"amlogic,clock-max-frequency");
+
+	if (count < 0)
+		return count;
+	else if (count == 1)
+		/*
+		 * If the property "amlogic,clock-max-frequency" under the
+		 * current device node defines only a single value, that value
+		 * specifies the maximum frequency limit for all clocks under
+		 * this device node.
+		 */
+		index = 0;
+
+	return of_property_read_u32_index(np, "amlogic,clock-max-frequency",
+					  index, (u32 *)out_max_rate);
+}
+
+int of_aml_clk_register(struct device *dev, struct clk_hw *hw, int clkid)
+{
+	struct device_node *np = dev_of_node(dev);
+	unsigned long max_rate;
+	int ret;
+
+	ret = devm_clk_hw_register(dev, hw);
+	if (ret)
+		return ret;
+
+	ret = of_aml_clk_get_max_rate(np, clkid, &max_rate);
+	if (ret) {
+		if (ret != -EINVAL)
+			return ret;
+	} else {
+		if (max_rate)
+			clk_hw_set_rate_range(hw, 0, max_rate);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_NS_GPL(of_aml_clk_register, "CLK_AMLOGIC");
+
 MODULE_DESCRIPTION("Amlogic Common Clock Driver");
 MODULE_AUTHOR("Chuan Liu <[email protected]>");
 MODULE_LICENSE("GPL");
drivers/clk/amlogic/clk.h +14 -0
index b62045aedfbf..3cfe2e650ed4 100644
@@ -39,4 +39,18 @@ static inline struct aml_clk *to_aml_clk(struct clk_hw *hw)
 	return container_of(hw, struct aml_clk, hw);
 }
 
+struct regmap *aml_clk_regmap_init(struct platform_device *pdev);
+int of_aml_clk_regs_init(struct device *dev);
+u32 of_aml_clk_get_count(struct device_node *np);
+const char *of_aml_clk_get_name_index(struct device_node *np, u32 index);
+int of_aml_clk_get_parent_num(struct device *dev, int start_index,
+			      int end_index);
+int of_aml_clk_get_parent_data(struct device *dev, struct clk_hw **dev_hws,
+			       int start_index, int end_index,
+			       struct clk_parent_data *out_pdatas,
+			       u8 *out_num_parents);
+u32 *of_aml_clk_get_parent_table(struct device *dev, int start_index,
+				 int end_index);
+int of_aml_clk_register(struct device *dev, struct clk_hw *hw, int clkid);
+
 #endif /* __AML_CLK_H */
Signature · 1 line
2.42.0
author
#26 lore raw

PATCH 10/13 clk: amlogic: Add A9 standardized model clock control units driver

In reply to Chuan Liu

Add support for Amlogic standardized model clock control units on A9 SoC family. The standardized models include:
- composite-ccu
- noglitch-ccu
- sysbus-ccu

---
 drivers/clk/amlogic/Kconfig        |  19 ++
 drivers/clk/amlogic/Makefile       |   3 +
 drivers/clk/amlogic/a9-model-ccu.c | 465 +++++++++++++++++++++++++++++++++++++
 3 files changed, 487 insertions(+)
drivers/clk/amlogic/Kconfig +19 -0
index 216fe98a413b..6e954c9388dc 100644
@@ -10,3 +10,22 @@ config COMMON_CLK_AMLOGIC
 	  This driver provides the basic clock infrastructure for Amlogic SoCs,
 	  offering read and write interfaces for various clock control units.
 	  Select Y if your target SoC needs clock driver support.
+
+config COMMON_CLK_AMLOGIC_MODEL
+	tristate "Amlogic Standardized Model Clock Control Units"
+	depends on COMMON_CLK_AMLOGIC
+	help
+	  Supports standardized model clock control units commonly used in Amlogic
+	  SoC clock trees, such as composite-ccu, noglitch-ccu, and sysbus-ccu.
+	  Most peripheral clock controllers in Amlogic SoCs are composed of
+	  these models. Select Y if the current SoC contains these clock control
+	  unit models.
+
+config COMMON_CLK_AMLOGIC_A9
+	tristate "Amlogic A9 Family Clock Controller"
+	depends on COMMON_CLK_AMLOGIC
+	default COMMON_CLK_AMLOGIC
+	select COMMON_CLK_AMLOGIC_MODEL
+	help
+	  Support for the clock controller present on the Amlogic A9 family
+	  SoCs. Select Y if A9 family SoC needs to support clock controller.
drivers/clk/amlogic/Makefile +3 -0
index 6956592c41c8..ef3fb57cae9f 100644
@@ -8,3 +8,6 @@ clk-amlogic-y += clk-composite.o
 clk-amlogic-y += clk-dualdiv.o
 clk-amlogic-y += clk-noglitch.o
 clk-amlogic-y += clk-pll.o
+ifneq ($(CONFIG_COMMON_CLK_AMLOGIC_MODEL),)
+clk-amlogic-y += a9-model-ccu.o
+endif
drivers/clk/amlogic/a9-model-ccu.c new file +465 -0

465 lines not on this page · raw message

Signature · 1 line
2.42.0
author
#27 lore raw

PATCH 11/13 clk: amlogic: Add A9 PLL controllers driver

In reply to Chuan Liu

Add PLL controllers driver for the Amlogic A9 SoC family.

---
 drivers/clk/amlogic/Kconfig  |  10 +++
 drivers/clk/amlogic/Makefile |   4 ++
 drivers/clk/amlogic/a9-pll.c | 146 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+)
drivers/clk/amlogic/Kconfig +10 -0
index 6e954c9388dc..3177a02ecbd5 100644
@@ -21,11 +21,21 @@ config COMMON_CLK_AMLOGIC_MODEL
 	  these models. Select Y if the current SoC contains these clock control
 	  unit models.
 
+config COMMON_CLK_AMLOGIC_PLL
+	tristate "Amlogic PLL Controller"
+	depends on COMMON_CLK_AMLOGIC
+	help
+	  Supports PLL controller used in Amlogic SoCs. The PLL supports dynamic
+	  configuration of output clock frequency, enabling flexible frequency
+	  settings to provide clocks for other modules. Select Y if the current
+	  SoC contains PLLs.
+
 config COMMON_CLK_AMLOGIC_A9
 	tristate "Amlogic A9 Family Clock Controller"
 	depends on COMMON_CLK_AMLOGIC
 	default COMMON_CLK_AMLOGIC
 	select COMMON_CLK_AMLOGIC_MODEL
+	select COMMON_CLK_AMLOGIC_PLL
 	help
 	  Support for the clock controller present on the Amlogic A9 family
 	  SoCs. Select Y if A9 family SoC needs to support clock controller.
drivers/clk/amlogic/Makefile +4 -0
index ef3fb57cae9f..74bf84dbd5a8 100644
@@ -11,3 +11,7 @@ clk-amlogic-y += clk-pll.o
 ifneq ($(CONFIG_COMMON_CLK_AMLOGIC_MODEL),)
 clk-amlogic-y += a9-model-ccu.o
 endif
+
+ifneq ($(CONFIG_COMMON_CLK_AMLOGIC_PLL),)
+clk-amlogic-y += a9-pll.o
+endif
drivers/clk/amlogic/a9-pll.c new file +146 -0

146 lines not on this page · raw message

Signature · 1 line
2.42.0
author
#28 lore raw

PATCH 12/13 clk: amlogic: Add A9 misc clock control units driver

In reply to Chuan Liu

Add support for Amlogic miscellaneous clock control units on A9 SoC family. Certain peripheral clocks do not utilize the standardized models due to specific requirements. These specialized clock control units are handled in this driver, including:
- sc-ccu
- ts-ccu
- genout-ccu
- clk12_24m-ccu
- vapb_ge2d-ccu
- di-ccu
- eth-ccu
- dualdivmux-ccu
- mclk-ccu

These clock control units contain multiple sub-clocks. The clock IDs for each sub-clock are defined in /bindings/clock/amlogic,a9-misc-ccu.h.

---
 drivers/clk/amlogic/Kconfig       |  10 +
 drivers/clk/amlogic/Makefile      |   5 +
 drivers/clk/amlogic/a9-misc-ccu.c | 960 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 975 insertions(+)
drivers/clk/amlogic/Kconfig +10 -0
index 3177a02ecbd5..502aca5332bc 100644
@@ -11,6 +11,15 @@ config COMMON_CLK_AMLOGIC
 	  offering read and write interfaces for various clock control units.
 	  Select Y if your target SoC needs clock driver support.
 
+config COMMON_CLK_AMLOGIC_MISC
+	tristate "Amlogic Misc Clock Control Units"
+	depends on COMMON_CLK_AMLOGIC
+	help
+	  Supports non-standard module clock control units in Amlogic SoC clock
+	  trees, such as sc-ccu (for smart card controller) and ts-ccu (for
+	  temperature sensor). Select Y if the current SoC contains these module
+	  clock control units.
+
 config COMMON_CLK_AMLOGIC_MODEL
 	tristate "Amlogic Standardized Model Clock Control Units"
 	depends on COMMON_CLK_AMLOGIC
@@ -34,6 +43,7 @@ config COMMON_CLK_AMLOGIC_A9
 	tristate "Amlogic A9 Family Clock Controller"
 	depends on COMMON_CLK_AMLOGIC
 	default COMMON_CLK_AMLOGIC
+	select COMMON_CLK_AMLOGIC_MISC
 	select COMMON_CLK_AMLOGIC_MODEL
 	select COMMON_CLK_AMLOGIC_PLL
 	help
drivers/clk/amlogic/Makefile +5 -0
index 74bf84dbd5a8..b174dce61ae9 100644
@@ -8,6 +8,11 @@ clk-amlogic-y += clk-composite.o
 clk-amlogic-y += clk-dualdiv.o
 clk-amlogic-y += clk-noglitch.o
 clk-amlogic-y += clk-pll.o
+
+ifneq ($(CONFIG_COMMON_CLK_AMLOGIC_MISC),)
+clk-amlogic-y += a9-misc-ccu.o
+endif
+
 ifneq ($(CONFIG_COMMON_CLK_AMLOGIC_MODEL),)
 clk-amlogic-y += a9-model-ccu.o
 endif
drivers/clk/amlogic/a9-misc-ccu.c new file +960 -0

960 lines not on this page · raw message

Signature · 1 line
2.42.0
author
#29 lore raw

PATCH 13/13 clk: amlogic: Add support for building as combined kernel module

In reply to Chuan Liu

Some use cases require clock drivers to be built as kernel modules and loaded using insmod after system initialization. This patch combines multiple clock drivers into a single module to reduce system call overhead caused by multiple insmod invocations during boot process.

---
 drivers/clk/amlogic/Kconfig        | 17 ++++++------
 drivers/clk/amlogic/Makefile       |  1 +
 drivers/clk/amlogic/a9-misc-ccu.c  | 12 ++++++++-
 drivers/clk/amlogic/a9-model-ccu.c | 12 ++++++++-
 drivers/clk/amlogic/a9-pll.c       | 12 ++++++++-
 drivers/clk/amlogic/clk-module.c   | 42 ++++++++++++++++++++++++++++++
 drivers/clk/amlogic/clk-module.h   | 53 ++++++++++++++++++++++++++++++++++++++
 7 files changed, 138 insertions(+), 11 deletions(-)
drivers/clk/amlogic/Kconfig +9 -8
index 502aca5332bc..1b60725b80d8 100644
@@ -9,7 +9,7 @@ config COMMON_CLK_AMLOGIC
 	help
 	  This driver provides the basic clock infrastructure for Amlogic SoCs,
 	  offering read and write interfaces for various clock control units.
-	  Select Y if your target SoC needs clock driver support.
+	  Select M or Y if your target SoC needs clock driver support.
 
 config COMMON_CLK_AMLOGIC_MISC
 	tristate "Amlogic Misc Clock Control Units"
@@ -17,8 +17,8 @@ config COMMON_CLK_AMLOGIC_MISC
 	help
 	  Supports non-standard module clock control units in Amlogic SoC clock
 	  trees, such as sc-ccu (for smart card controller) and ts-ccu (for
-	  temperature sensor). Select Y if the current SoC contains these module
-	  clock control units.
+	  temperature sensor). Select M or Y if the current SoC contains these
+	  module clock control units.
 
 config COMMON_CLK_AMLOGIC_MODEL
 	tristate "Amlogic Standardized Model Clock Control Units"
@@ -27,8 +27,8 @@ config COMMON_CLK_AMLOGIC_MODEL
 	  Supports standardized model clock control units commonly used in Amlogic
 	  SoC clock trees, such as composite-ccu, noglitch-ccu, and sysbus-ccu.
 	  Most peripheral clock controllers in Amlogic SoCs are composed of
-	  these models. Select Y if the current SoC contains these clock control
-	  unit models.
+	  these models. Select M or Y if the current SoC contains these clock
+	  control unit models.
 
 config COMMON_CLK_AMLOGIC_PLL
 	tristate "Amlogic PLL Controller"
@@ -36,8 +36,8 @@ config COMMON_CLK_AMLOGIC_PLL
 	help
 	  Supports PLL controller used in Amlogic SoCs. The PLL supports dynamic
 	  configuration of output clock frequency, enabling flexible frequency
-	  settings to provide clocks for other modules. Select Y if the current
-	  SoC contains PLLs.
+	  settings to provide clocks for other modules. Select M or Y if the
+	  current SoC contains PLLs.
 
 config COMMON_CLK_AMLOGIC_A9
 	tristate "Amlogic A9 Family Clock Controller"
@@ -48,4 +48,5 @@ config COMMON_CLK_AMLOGIC_A9
 	select COMMON_CLK_AMLOGIC_PLL
 	help
 	  Support for the clock controller present on the Amlogic A9 family
-	  SoCs. Select Y if A9 family SoC needs to support clock controller.
+	  SoCs. Select M or Y if A9 family SoC needs to support clock
+	  controller.
drivers/clk/amlogic/Makefile +1 -0
index b174dce61ae9..2778d3859a5e 100644
@@ -8,6 +8,7 @@ clk-amlogic-y += clk-composite.o
 clk-amlogic-y += clk-dualdiv.o
 clk-amlogic-y += clk-noglitch.o
 clk-amlogic-y += clk-pll.o
+clk-amlogic-y += clk-module.o
 
 ifneq ($(CONFIG_COMMON_CLK_AMLOGIC_MISC),)
 clk-amlogic-y += a9-misc-ccu.o
drivers/clk/amlogic/a9-misc-ccu.c +11 -1
index db130d84ccdd..6fd2c9ae3cd0 100644
@@ -10,6 +10,7 @@
 #include "clk-basic.h"
 #include "clk-composite.h"
 #include "clk-dualdiv.h"
+#include "clk-module.h"
 #include "clk-noglitch.h"
 #include "clk-pll.h"
 
@@ -952,7 +953,16 @@ static struct platform_driver of_aml_clk_misc_driver = {
 		.of_match_table = of_aml_clk_misc_match_table,
 	},
 };
-module_platform_driver(of_aml_clk_misc_driver);
+
+int __init aml_clk_misc_driver_init(void)
+{
+	return platform_driver_register(&of_aml_clk_misc_driver);
+}
+
+void __exit aml_clk_misc_driver_exit(void)
+{
+	platform_driver_unregister(&of_aml_clk_misc_driver);
+}
 
 MODULE_DESCRIPTION("Amlogic A9 Misc Clock Control Units Driver");
 MODULE_AUTHOR("Chuan Liu <[email protected]>");
drivers/clk/amlogic/a9-model-ccu.c +11 -1
index 5d5bf1538f73..58babd42aca3 100644
@@ -9,6 +9,7 @@
 #include "clk.h"
 #include "clk-basic.h"
 #include "clk-composite.h"
+#include "clk-module.h"
 #include "clk-noglitch.h"
 
 /*
@@ -457,7 +458,16 @@ static struct platform_driver of_aml_clk_model_driver = {
 		.of_match_table = of_aml_clk_model_match_table,
 	},
 };
-module_platform_driver(of_aml_clk_model_driver);
+
+int __init aml_clk_model_driver_init(void)
+{
+	return platform_driver_register(&of_aml_clk_model_driver);
+}
+
+void __exit aml_clk_model_driver_exit(void)
+{
+	platform_driver_unregister(&of_aml_clk_model_driver);
+}
 
 MODULE_DESCRIPTION("Amlogic A9 Standardized Model Clock Control Units Driver");
 MODULE_AUTHOR("Chuan Liu <[email protected]>");
drivers/clk/amlogic/a9-pll.c +11 -1
index c4c695caa8ed..fe2a77382509 100644
@@ -7,6 +7,7 @@
 #include <linux/module.h>
 
 #include "clk.h"
+#include "clk-module.h"
 #include "clk-pll.h"
 
 static const struct aml_pll_data a9_mclk_pll_data = {
@@ -138,7 +139,16 @@ static struct platform_driver of_aml_clk_pll_driver = {
 		.of_match_table = of_aml_clk_pll_match_table,
 	},
 };
-module_platform_driver(of_aml_clk_pll_driver);
+
+int __init aml_pll_driver_init(void)
+{
+	return platform_driver_register(&of_aml_clk_pll_driver);
+}
+
+void __exit aml_pll_driver_exit(void)
+{
+	platform_driver_unregister(&of_aml_clk_pll_driver);
+}
 
 MODULE_DESCRIPTION("Amlogic A9 PLL Controllers Driver");
 MODULE_AUTHOR("Chuan Liu <[email protected]>");
drivers/clk/amlogic/clk-module.c new file +42 -0

42 lines not on this page · raw message

drivers/clk/amlogic/clk-module.h new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.42.0
maintainer
#30 lore raw
In reply to Chuan Liu
Quoted 13 lines · On lun. 09 févr. 2026 at 13:48, Chuan Liu via B4 Relay…

This patch adds driver support for Phase-Locked Loop (PLL) controllers and Clock Control Units (CCUs) in A9 SoC family.

In the A9 SoC architecture, PLLs and clock control units are implemented as standardized hardware instances to reduce unnecessary differentiation across individual units.

All A9 PLLs and CCUs are exposed as device tree nodes, providing an accurate representation of the SoC's internal clock hardware structure.

These drivers are designed for reuse in subsequent SoC generations, guaranteeing code inheritance and maximizing reusability.

Quoted 8 lines

Makefile rules compile A9 PLL and CCU drivers into clk-amlogic.o (see drivers/clk/amlogic/Makefile), simplifying deployment and enhancing load efficiency (single insmod for kernel module).

Since the foundational A9 DTS hasn't been upstreamed yet, I'm temporarily pushing the PLL/CCU DTS files to github for driver comprehension [1]. These patches will be included in a later release after the base A9 DTS is merged.

Creating a new vendor directory and re-inventing supported driver without an explanation, coding style, build problems ... the list goes on. You've outdone yourself !

So NACK.

Chuan has been warned numerous times about his submission to the kernel mailing lists, without a noticeable effect. I can only suggest other reviewers do not waste their time reviewing this.

Quoted 51 lines

[1] https://github.com/torvalds/linux/commit/d6a82e4cce675fa5146c5f638c2a926c1c8cb1d9

---
Chuan Liu (13):
dt-bindings: clock: Add Amlogic A9 standardized model clock control units
dt-bindings: clock: Add Amlogic A9 PLL controllers
dt-bindings: clock: Add Amlogic A9 misc clock control units
clk: amlogic: Add basic clock driver
clk: amlogic: Add composite clock driver
clk: amlogic: Add noglitch clock driver
clk: amlogic: Add duandiv clock driver
clk: amlogic: Add PLL driver
clk: amlogic: Add DT-based clock registration functions
clk: amlogic: Add A9 standardized model clock control units driver
clk: amlogic: Add A9 PLL controllers driver
clk: amlogic: Add A9 misc clock control units driver
clk: amlogic: Add support for building as combined kernel module

 .../bindings/clock/amlogic,a9-misc-ccu.yaml        | 523 +++++++++++
 .../bindings/clock/amlogic,a9-model-ccu.yaml       | 435 +++++++++
 .../devicetree/bindings/clock/amlogic,a9-pll.yaml  | 134 +++
 drivers/clk/Kconfig                                |   1 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/amlogic/Kconfig                        |  52 ++
 drivers/clk/amlogic/Makefile                       |  23 +
 drivers/clk/amlogic/a9-misc-ccu.c                  | 970 +++++++++++++++++++++
 drivers/clk/amlogic/a9-model-ccu.c                 | 475 ++++++++++
 drivers/clk/amlogic/a9-pll.c                       | 156 ++++
 drivers/clk/amlogic/clk-basic.c                    | 219 +++++
 drivers/clk/amlogic/clk-basic.h                    |  39 +
 drivers/clk/amlogic/clk-composite.c                | 280 ++++++
 drivers/clk/amlogic/clk-composite.h                |  20 +
 drivers/clk/amlogic/clk-dualdiv.c                  | 365 ++++++++
 drivers/clk/amlogic/clk-dualdiv.h                  |  27 +
 drivers/clk/amlogic/clk-module.c                   |  42 +
 drivers/clk/amlogic/clk-module.h                   |  53 ++
 drivers/clk/amlogic/clk-noglitch.c                 | 584 +++++++++++++
 drivers/clk/amlogic/clk-noglitch.h                 |  29 +
 drivers/clk/amlogic/clk-pll.c                      | 701 +++++++++++++++
 drivers/clk/amlogic/clk-pll.h                      |  43 +
 drivers/clk/amlogic/clk.c                          | 464 ++++++++++
 drivers/clk/amlogic/clk.h                          |  56 ++
 include/dt-bindings/clock/amlogic,a9-misc-ccu.h    |  53 ++
 25 files changed, 5745 insertions(+)

---
base-commit: 4d310797262f0ddf129e76c2aad2b950adaf1fda
change-id: 20260130-a9_clock_driver-ddd90357848c

Best regards,

Signature · 1 line
Jerome