Skip to contentSkip to conversation

clk: sophgo: add SG2044 clock controller support

PATCH Applied Inochi Amaoto 2 participants 21 messages Feb 26, 2025 – Mar 27, 2025

Subsystems (5)

v3 of 5 Applied Latest is v5 →

lore
Share & tools
lore

Inochi Amaoto

author maintainer
#0 lore raw

v3 cover clk: sophgo: add SG2044 clock controller support

The clock controller of SG2044 provides multiple clocks for various IPs on the SoC, including PLL, mux, div and gates. As the PLL and div have obvious changed and do not fit the framework of SG2042, a new implement is provided to handle these.

Changed from v2:
1. Applied Chen Wang' tag
2. patch 2: fix author mail infomation

Changed from v1:
1. patch 1: Applied Krzysztof's tag
2. patch 2: Fix the build warning from bot.

Inochi Amaoto (2):
dt-bindings: clock: sophgo: add clock controller for SG2044
clk: sophgo: Add clock controller support for SG2044 SoC

 .../bindings/clock/sophgo,sg2044-clk.yaml     |   40 +
 drivers/clk/sophgo/Kconfig                    |   11 +
 drivers/clk/sophgo/Makefile                   |    1 +
 drivers/clk/sophgo/clk-sg2044.c               | 2271 +++++++++++++++++
 drivers/clk/sophgo/clk-sg2044.h               |   62 +
 include/dt-bindings/clock/sophgo,sg2044-clk.h |  170 ++
 6 files changed, 2555 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml
 create mode 100644 drivers/clk/sophgo/clk-sg2044.c
 create mode 100644 drivers/clk/sophgo/clk-sg2044.h
 create mode 100644 include/dt-bindings/clock/sophgo,sg2044-clk.h

--
2.48.1

author maintainer
#1 lore raw

PATCH v3 1/2 dt-bindings: clock: sophgo: add clock controller for SG2044

The clock controller on the SG2044 provides common clock function for all IPs on the SoC. This device requires PLL clock to function normally.

Add definition for the clock controller of the SG2044 SoC.

---
 .../bindings/clock/sophgo,sg2044-clk.yaml     |  40 +++++
 include/dt-bindings/clock/sophgo,sg2044-clk.h | 170 ++++++++++++++++++
 2 files changed, 210 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml
 create mode 100644 include/dt-bindings/clock/sophgo,sg2044-clk.h
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +40 -0
new file mode 100644
index 000000000000..d55c5d32e206
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/sophgo,sg2044-clk.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sophgo SG2044 Clock Controller
+
+maintainers:
+  - Inochi Amaoto <[email protected]>
+
+properties:
+  compatible:
+    const: sophgo,sg2044-clk
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - '#clock-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@50002000 {
+      compatible = "sophgo,sg2044-clk";
+      reg = <0x50002000 0x1000>;
+      #clock-cells = <1>;
+      clocks = <&osc>;
+    };
include/dt-bindings/clock/sophgo,sg2044-clk.h new file +170 -0

170 lines not on this page · raw message

Signature · 1 line
2.48.1
maintainer
#2 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoting Inochi Amaoto (2025-02-26 15:23:18)

Quoted 6 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +0 -0
new file mode 100644
index 000000000000..d55c5d32e206

Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml line 10

Quoted 10 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +10 -0
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/sophgo,sg2044-clk.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sophgo SG2044 Clock Controller
+
+maintainers:
+  - Inochi Amaoto <[email protected]>

No description?

Quoted 19 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +19 -0
+
+properties:
+  compatible:
+    const: sophgo,sg2044-clk
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - '#clock-cells'

Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +10 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@50002000 {
+      compatible = "sophgo,sg2044-clk";
+      reg = <0x50002000 0x1000>;
+      #clock-cells = <1>;
+      clocks = <&osc>;

I think you want the syscon phandle here as another property. Doing that will cause the DT parsing logic to wait for the syscon to be probed before trying to probe this driver. It's also useful so we can see if the clock controller is overlapping withe whatever the syscon node is, or if that syscon node should just have the #clock-cells property as part of the node instead.

author maintainer
#3 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoted 11 lines · Stephen Boyd

Quoting Inochi Amaoto (2025-02-26 15:23:18)

Quoted 10 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +4 -0
new file mode 100644
index 000000000000..d55c5d32e206
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/sophgo,sg2044-clk.yaml#
Quoted 9 lines

Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml line 10

Quoted 6 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +6 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sophgo SG2044 Clock Controller
+
+maintainers:
+  - Inochi Amaoto <[email protected]>

No description?

I am not sure the things to be described. Maybe just tell the clock required and providing?

Quoted 26 lines
Quoted 26 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +26 -0
+
+properties:
+  compatible:
+    const: sophgo,sg2044-clk
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - '#clock-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@50002000 {
+      compatible = "sophgo,sg2044-clk";
Quoted 8 lines

Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml line 39

Quoted 3 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +3 -0
+      reg = <0x50002000 0x1000>;
+      #clock-cells = <1>;
+      clocks = <&osc>;

I think you want the syscon phandle here as another property. Doing that will cause the DT parsing logic to wait for the syscon to be probed before trying to probe this driver. It's also useful so we can see if the clock controller is overlapping withe whatever the syscon node is,

It sounds like a good idea. At now, it does not seem like a good idea to hidden the device dependency detail. I will add a syscon property like "sophgo,pll-syscon" to identify its pll needs a syscon handle.

Quoted 2 lines

or if that syscon node should just have the #clock-cells property as part of the node instead.

This is not match the hardware I think. The pll area is on the middle of the syscon and is hard to be separated as a subdevice of the syscon or just add "#clock-cells" to the syscon device. It is better to handle them in one device/driver. So let the clock device reference it.

Regards,
Inochi

maintainer
#4 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoting Inochi Amaoto (2025-03-11 16:31:29)

Quoted 22 lines · Stephen Boyd
Quoted 11 lines

Quoting Inochi Amaoto (2025-02-26 15:23:18)

Quoted 10 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +4 -0
new file mode 100644
index 000000000000..d55c5d32e206
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/sophgo,sg2044-clk.yaml#
Quoted 9 lines

Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml line 10

Quoted 6 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +6 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sophgo SG2044 Clock Controller
+
+maintainers:
+  - Inochi Amaoto <[email protected]>

No description?

Quoted 2 lines

I am not sure the things to be described. Maybe just tell the clock required and providing?

Sure and point to the header file with the binding numbers?

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +6 -0
+  - |
+    clock-controller@50002000 {
+      compatible = "sophgo,sg2044-clk";
+      reg = <0x50002000 0x1000>;
+      #clock-cells = <1>;
+      clocks = <&osc>;
Quoted 8 lines
Quoted 4 lines

I think you want the syscon phandle here as another property. Doing that will cause the DT parsing logic to wait for the syscon to be probed before trying to probe this driver. It's also useful so we can see if the clock controller is overlapping withe whatever the syscon node is,

It sounds like a good idea. At now, it does not seem like a good idea to hidden the device dependency detail. I will add a syscon property like "sophgo,pll-syscon" to identify its pll needs a syscon handle.

Cool.

Quoted 8 lines
Quoted 3 lines

or if that syscon node should just have the #clock-cells property as part of the node instead.

This is not match the hardware I think. The pll area is on the middle of the syscon and is hard to be separated as a subdevice of the syscon or just add "#clock-cells" to the syscon device. It is better to handle them in one device/driver. So let the clock device reference it.

This happens all the time. We don't need a syscon for that unless the registers for the pll are both inside the syscon and in the register space 0x50002000. Is that the case? This looks like you want there to be one node for clks on the system because logically that is clean, when the reality is that there is a PLL block exposed in the syscon (someone forgot to put it in the clk controller?) and a non-PLL block for the other clks.

author maintainer
#5 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoted 23 lines · Stephen Boyd

Quoting Inochi Amaoto (2025-03-11 16:31:29)

Quoted 22 lines · Stephen Boyd
Quoted 20 lines

Quoting Inochi Amaoto (2025-02-26 15:23:18)

Quoted 6 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +0 -0
new file mode 100644
index 000000000000..d55c5d32e206

Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml line 10

Quoted 10 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +10 -0
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/sophgo,sg2044-clk.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sophgo SG2044 Clock Controller
+
+maintainers:
+  - Inochi Amaoto <[email protected]>

No description?

Quoted 5 lines
Quoted 2 lines

I am not sure the things to be described. Maybe just tell the clock required and providing?

Sure and point to the header file with the binding numbers?

Good, I will add it.

Quoted 22 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml new file +6 -0
+  - |
+    clock-controller@50002000 {
+      compatible = "sophgo,sg2044-clk";
+      reg = <0x50002000 0x1000>;
+      #clock-cells = <1>;
+      clocks = <&osc>;
Quoted 8 lines
Quoted 4 lines

I think you want the syscon phandle here as another property. Doing that will cause the DT parsing logic to wait for the syscon to be probed before trying to probe this driver. It's also useful so we can see if the clock controller is overlapping withe whatever the syscon node is,

It sounds like a good idea. At now, it does not seem like a good idea to hidden the device dependency detail. I will add a syscon property like "sophgo,pll-syscon" to identify its pll needs a syscon handle.

Cool.

Quoted 4 lines
Quoted 3 lines

or if that syscon node should just have the #clock-cells property as part of the node instead.

Quoted 8 lines
Quoted 4 lines

This is not match the hardware I think. The pll area is on the middle of the syscon and is hard to be separated as a subdevice of the syscon or just add "#clock-cells" to the syscon device. It is better to handle them in one device/driver. So let the clock device reference it.

This happens all the time. We don't need a syscon for that unless the registers for the pll are both inside the syscon and in the register space 0x50002000. Is that the case?

Yes, the clock has two areas, one in the clk controller and one in the syscon, the vendor said this design is a heritage from other SoC.

Quoted 4 lines

This looks like you want there to be one node for clks on the system because logically that is clean, when the reality is that there is a PLL block exposed in the syscon (someone forgot to put it in the clk controller?) and a non-PLL block for the other clks.

That is true, I prefer to keep clean and make less mistakes. Although the PLL is exposed in the syscon, the pll need to be tight with other clocks in the space 0x50002000 (especially between the PLL and mux). In this view, it is more like a mistake made by the hardware design. And I prefer not to add a subnode for the syscon.

Regards,
Inochi

maintainer
#6 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoting Inochi Amaoto (2025-03-12 16:29:43)

Quoted 11 lines · Stephen Boyd
Quoted 10 lines

Quoting Inochi Amaoto (2025-03-11 16:31:29)

Quoted 8 lines
Quoted 3 lines

or if that syscon node should just have the #clock-cells property as part of the node instead.

This is not match the hardware I think. The pll area is on the middle of the syscon and is hard to be separated as a subdevice of the syscon or just add "#clock-cells" to the syscon device. It is better to handle them in one device/driver. So let the clock device reference it.

Quoted 6 lines
Quoted 3 lines

This happens all the time. We don't need a syscon for that unless the registers for the pll are both inside the syscon and in the register space 0x50002000. Is that the case?

Yes, the clock has two areas, one in the clk controller and one in the syscon, the vendor said this design is a heritage from other SoC.

My question is more if the PLL clk_ops need to access both the syscon register range and the clk controller register range. What part of the PLL clk_ops needs to access the clk controller at 0x50002000?

Quoted 11 lines
Quoted 5 lines

This looks like you want there to be one node for clks on the system because logically that is clean, when the reality is that there is a PLL block exposed in the syscon (someone forgot to put it in the clk controller?) and a non-PLL block for the other clks.

That is true, I prefer to keep clean and make less mistakes. Although the PLL is exposed in the syscon, the pll need to be tight with other clocks in the space 0x50002000 (especially between the PLL and mux). In this view, it is more like a mistake made by the hardware design. And I prefer not to add a subnode for the syscon.

Ok. You wouldn't add a subnode for the syscon. You would just have #clock-cells in that syscon node and register an auxiliary device to provide the PLL(s) from there. Then in drivers/clk we would have an auxiliary driver that uses a regmap or gets an iomem pointer from the parent device somehow so that we can logically put the PLL code in drivers/clk while having one node in DT for the "miscellaneous register area" where the hardware engineer had to expose the PLL control to software.

author maintainer
#7 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoted 16 lines · Stephen Boyd

Quoting Inochi Amaoto (2025-03-12 16:29:43)

Quoted 15 lines · Stephen Boyd
Quoted 13 lines

Quoting Inochi Amaoto (2025-03-11 16:31:29)

Quoted 8 lines
Quoted 3 lines

or if that syscon node should just have the #clock-cells property as part of the node instead.

This is not match the hardware I think. The pll area is on the middle of the syscon and is hard to be separated as a subdevice of the syscon or just add "#clock-cells" to the syscon device. It is better to handle them in one device/driver. So let the clock device reference it.

This happens all the time. We don't need a syscon for that unless the registers for the pll are both inside the syscon and in the register space 0x50002000. Is that the case?

Quoted 7 lines
Quoted 2 lines

Yes, the clock has two areas, one in the clk controller and one in the syscon, the vendor said this design is a heritage from other SoC.

My question is more if the PLL clk_ops need to access both the syscon register range and the clk controller register range. What part of the PLL clk_ops needs to access the clk controller at 0x50002000?

The PLL clk_ops does nothing, but there is an implicit dependency:
When the PLL change rate, the mux attached to it must switch to another source to keep the output clock stable. This is the only thing it needed.

Quoted 12 lines
Quoted 11 lines
Quoted 5 lines

This looks like you want there to be one node for clks on the system because logically that is clean, when the reality is that there is a PLL block exposed in the syscon (someone forgot to put it in the clk controller?) and a non-PLL block for the other clks.

That is true, I prefer to keep clean and make less mistakes. Although the PLL is exposed in the syscon, the pll need to be tight with other clocks in the space 0x50002000 (especially between the PLL and mux). In this view, it is more like a mistake made by the hardware design. And I prefer not to add a subnode for the syscon.

Quoted 8 lines

Ok. You wouldn't add a subnode for the syscon. You would just have #clock-cells in that syscon node and register an auxiliary device to provide the PLL(s) from there. Then in drivers/clk we would have an auxiliary driver that uses a regmap or gets an iomem pointer from the parent device somehow so that we can logically put the PLL code in drivers/clk while having one node in DT for the "miscellaneous register area" where the hardware engineer had to expose the PLL control to software.

Cool, I understand what you mean. It is a good idea, I will have a try.

Regards,
Inochi

maintainer
#8 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoting Inochi Amaoto (2025-03-12 18:08:11)

Quoted 25 lines · Stephen Boyd
Quoted 16 lines

Quoting Inochi Amaoto (2025-03-12 16:29:43)

Quoted 15 lines · Stephen Boyd
Quoted 13 lines

Quoting Inochi Amaoto (2025-03-11 16:31:29)

Quoted 8 lines
Quoted 3 lines

or if that syscon node should just have the #clock-cells property as part of the node instead.

This is not match the hardware I think. The pll area is on the middle of the syscon and is hard to be separated as a subdevice of the syscon or just add "#clock-cells" to the syscon device. It is better to handle them in one device/driver. So let the clock device reference it.

This happens all the time. We don't need a syscon for that unless the registers for the pll are both inside the syscon and in the register space 0x50002000. Is that the case?

Quoted 7 lines
Quoted 2 lines

Yes, the clock has two areas, one in the clk controller and one in the syscon, the vendor said this design is a heritage from other SoC.

My question is more if the PLL clk_ops need to access both the syscon register range and the clk controller register range. What part of the PLL clk_ops needs to access the clk controller at 0x50002000?

Quoted 4 lines

The PLL clk_ops does nothing, but there is an implicit dependency:
When the PLL change rate, the mux attached to it must switch to another source to keep the output clock stable. This is the only thing it needed.

I haven't looked at the clk_ops in detail (surprise! :) but that sounds a lot like the parent of the mux is the PLL and there's some "safe" source that is needed temporarily while the PLL is reprogrammed for a new rate. Is that right? I recall the notifier is in the driver so this sounds like that sort of design.

author maintainer
#9 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoted 31 lines · Stephen Boyd

Quoting Inochi Amaoto (2025-03-12 18:08:11)

Quoted 25 lines · Stephen Boyd
Quoted 16 lines

Quoting Inochi Amaoto (2025-03-12 16:29:43)

Quoted 15 lines · Stephen Boyd
Quoted 13 lines

Quoting Inochi Amaoto (2025-03-11 16:31:29)

Quoted 8 lines
Quoted 3 lines

or if that syscon node should just have the #clock-cells property as part of the node instead.

This is not match the hardware I think. The pll area is on the middle of the syscon and is hard to be separated as a subdevice of the syscon or just add "#clock-cells" to the syscon device. It is better to handle them in one device/driver. So let the clock device reference it.

This happens all the time. We don't need a syscon for that unless the registers for the pll are both inside the syscon and in the register space 0x50002000. Is that the case?

Quoted 7 lines
Quoted 2 lines

Yes, the clock has two areas, one in the clk controller and one in the syscon, the vendor said this design is a heritage from other SoC.

My question is more if the PLL clk_ops need to access both the syscon register range and the clk controller register range. What part of the PLL clk_ops needs to access the clk controller at 0x50002000?

Quoted 4 lines

The PLL clk_ops does nothing, but there is an implicit dependency:
When the PLL change rate, the mux attached to it must switch to another source to keep the output clock stable. This is the only thing it needed.

Quoted 5 lines

I haven't looked at the clk_ops in detail (surprise! :) but that sounds a lot like the parent of the mux is the PLL and there's some "safe" source that is needed temporarily while the PLL is reprogrammed for a new rate. Is that right? I recall the notifier is in the driver so this sounds like that sort of design.

You are right, this design is like what you say. And this design is the reason that I prefer to just reference the syscon node but not setting the syscon with "#clock-cell".

Regards,
Inochi

maintainer
#10 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoting Inochi Amaoto (2025-03-13 15:46:22)

Quoted 38 lines · Stephen Boyd
Quoted 31 lines

Quoting Inochi Amaoto (2025-03-12 18:08:11)

Quoted 25 lines · Stephen Boyd
Quoted 16 lines

Quoting Inochi Amaoto (2025-03-12 16:29:43)

Quoted 15 lines · Stephen Boyd
Quoted 13 lines

Quoting Inochi Amaoto (2025-03-11 16:31:29)

Quoted 8 lines
Quoted 3 lines

or if that syscon node should just have the #clock-cells property as part of the node instead.

This is not match the hardware I think. The pll area is on the middle of the syscon and is hard to be separated as a subdevice of the syscon or just add "#clock-cells" to the syscon device. It is better to handle them in one device/driver. So let the clock device reference it.

This happens all the time. We don't need a syscon for that unless the registers for the pll are both inside the syscon and in the register space 0x50002000. Is that the case?

Quoted 7 lines
Quoted 2 lines

Yes, the clock has two areas, one in the clk controller and one in the syscon, the vendor said this design is a heritage from other SoC.

My question is more if the PLL clk_ops need to access both the syscon register range and the clk controller register range. What part of the PLL clk_ops needs to access the clk controller at 0x50002000?

Quoted 4 lines

The PLL clk_ops does nothing, but there is an implicit dependency:
When the PLL change rate, the mux attached to it must switch to another source to keep the output clock stable. This is the only thing it needed.

Quoted 5 lines

I haven't looked at the clk_ops in detail (surprise! :) but that sounds a lot like the parent of the mux is the PLL and there's some "safe" source that is needed temporarily while the PLL is reprogrammed for a new rate. Is that right? I recall the notifier is in the driver so this sounds like that sort of design.

Quoted 4 lines

You are right, this design is like what you say. And this design is the reason that I prefer to just reference the syscon node but not setting the syscon with "#clock-cell".

I don't see why a syscon phandle is preferred over #clock-cells. This temporary parent is still a clk, right? In my opinion syscon should never be used. It signals that we lack a proper framework in the kernel to handle something. Even in the "miscellaneous" register range sort of design, we can say that this grab bag of registers is exposing resources like clks or gpios, etc. as a one off sort of thing because it was too late to change other hardware blocks.

author maintainer
#11 lore raw

Re: [PATCH v3 1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

Quoted 39 lines · Stephen Boyd

Quoting Inochi Amaoto (2025-03-13 15:46:22)

Quoted 38 lines · Stephen Boyd
Quoted 36 lines

Quoting Inochi Amaoto (2025-03-12 18:08:11)

Quoted 25 lines · Stephen Boyd
Quoted 16 lines

Quoting Inochi Amaoto (2025-03-12 16:29:43)

Quoted 15 lines · Stephen Boyd
Quoted 13 lines

Quoting Inochi Amaoto (2025-03-11 16:31:29)

Quoted 8 lines
Quoted 3 lines

or if that syscon node should just have the #clock-cells property as part of the node instead.

This is not match the hardware I think. The pll area is on the middle of the syscon and is hard to be separated as a subdevice of the syscon or just add "#clock-cells" to the syscon device. It is better to handle them in one device/driver. So let the clock device reference it.

This happens all the time. We don't need a syscon for that unless the registers for the pll are both inside the syscon and in the register space 0x50002000. Is that the case?

Quoted 7 lines
Quoted 2 lines

Yes, the clock has two areas, one in the clk controller and one in the syscon, the vendor said this design is a heritage from other SoC.

My question is more if the PLL clk_ops need to access both the syscon register range and the clk controller register range. What part of the PLL clk_ops needs to access the clk controller at 0x50002000?

Quoted 4 lines

The PLL clk_ops does nothing, but there is an implicit dependency:
When the PLL change rate, the mux attached to it must switch to another source to keep the output clock stable. This is the only thing it needed.

I haven't looked at the clk_ops in detail (surprise! :) but that sounds a lot like the parent of the mux is the PLL and there's some "safe" source that is needed temporarily while the PLL is reprogrammed for a new rate. Is that right? I recall the notifier is in the driver so this sounds like that sort of design.

Quoted 7 lines
Quoted 4 lines

You are right, this design is like what you say. And this design is the reason that I prefer to just reference the syscon node but not setting the syscon with "#clock-cell".

I don't see why a syscon phandle is preferred over #clock-cells. This temporary parent is still a clk, right?

Yeah, it is true.

Quoted 6 lines

In my opinion syscon should never be used. It signals that we lack a proper framework in the kernel to handle something. Even in the "miscellaneous" register range sort of design, we can say that this grab bag of registers is exposing resources like clks or gpios, etc. as a one off sort of thing because it was too late to change other hardware blocks.

This is right, the syscon is not very good to be added. And I found mfd framework is used in most case to provide multi-function. So I think I make a mistake in design. I will try your advice and submit a new version for it. Thanks for your kindly explanation.

Regards,
Inochi

author maintainer
#12 lore raw

PATCH v3 2/2 clk: sophgo: Add clock controller support for SG2044 SoC

In reply to Inochi Amaoto

Add clock driver and clock definition for SG2044 SoC.

---
 drivers/clk/sophgo/Kconfig      |   11 +
 drivers/clk/sophgo/Makefile     |    1 +
 drivers/clk/sophgo/clk-sg2044.c | 2271 +++++++++++++++++++++++++++++++
 drivers/clk/sophgo/clk-sg2044.h |   62 +
 4 files changed, 2345 insertions(+)
 create mode 100644 drivers/clk/sophgo/clk-sg2044.c
 create mode 100644 drivers/clk/sophgo/clk-sg2044.h
drivers/clk/sophgo/Kconfig +11 -0
index 8b1367e3a95e..6914d08caeac 100644
@@ -37,3 +37,14 @@ config CLK_SOPHGO_SG2042_RPGATE
 	  This clock IP depends on SG2042 Clock Generator because it uses
 	  clock from Clock Generator IP as input.
 	  This driver provides Gate function for RP.
+
+config CLK_SOPHGO_SG2044
+	tristate "Sophgo SG2044 clock controller support"
+	depends on ARCH_SOPHGO || COMPILE_TEST
+	select MFD_SYSCON
+	select REGMAP_MMIO
+	help
+	  This driver supports the clock controller on the Sophgo SG2044
+	  SoC. This controller requires 25M oscillator as input.
+	  This clock control provides PLL clocks and common clock function
+	  for various IPs on the SoC.
drivers/clk/sophgo/Makefile +1 -0
index 53506845a044..f61f4bf804f0 100644
@@ -9,3 +9,4 @@ clk-sophgo-cv1800-y		+= clk-cv18xx-pll.o
 obj-$(CONFIG_CLK_SOPHGO_SG2042_CLKGEN)	+= clk-sg2042-clkgen.o
 obj-$(CONFIG_CLK_SOPHGO_SG2042_PLL)	+= clk-sg2042-pll.o
 obj-$(CONFIG_CLK_SOPHGO_SG2042_RPGATE)	+= clk-sg2042-rpgate.o
+obj-$(CONFIG_CLK_SOPHGO_SG2044)		+= clk-sg2044.o
drivers/clk/sophgo/clk-sg2044.c new file +2271 -0

2,271 lines not on this page · raw message

drivers/clk/sophgo/clk-sg2044.h new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
2.48.1
maintainer
#13 lore raw

Re: [PATCH v3 2/2] clk: sophgo: Add clock controller support for SG2044 SoC

Quoting Inochi Amaoto (2025-02-26 15:23:19)

drivers/clk/sophgo/clk-sg2044.c

Quoted 5 lines
drivers/clk/sophgo/clk-sg2044.c new file +0 -0
new file mode 100644
index 000000000000..b4c15746de77

Thanks for sticking with it. Some minor nits below but otherwise this looks good to go.

Quoted 25 lines
drivers/clk/sophgo/clk-sg2044.c new file +24 -0
@@ -0,0 +1,2271 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Sophgo SG2042 clock controller Driver
+ *
+ * Copyright (C) 2025 Inochi Amaoto <[email protected]>
+ */
+
+#include <linux/array_size.h>
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/cleanup.h>
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/math64.h>
+#include <linux/mfd/syscon.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+#include "clk-sg2044.h"
+
+#include <dt-bindings/clock/sophgo,sg2044-clk.h>
+

[...]

Quoted 15 lines
drivers/clk/sophgo/clk-sg2044.c new file +15 -0
+
+static unsigned long sg2044_pll_recalc_rate(struct clk_hw *hw,
+                                           unsigned long parent_rate)
+{
+       struct sg2044_pll *pll = hw_to_sg2044_pll(hw);
+       u32 value;
+       int ret;
+
+       ret = regmap_read(pll->top_syscon,
+                         pll->syscon_offset + pll->pll.ctrl_offset + PLL_HIGH_CTRL_OFFSET,
+                         &value);
+       if (ret < 0)
+               return 0;
+
+       return sg2044_pll_calc_rate(parent_rate,

drivers/clk/sophgo/clk-sg2044.c line 173

Quoted 10 lines
drivers/clk/sophgo/clk-sg2044.c new file +10 -0
+                                   FIELD_GET(PLL_REFDIV_MASK, value),
+                                   FIELD_GET(PLL_FBDIV_MASK, value),
+                                   FIELD_GET(PLL_POSTDIV1_MASK, value),
+                                   FIELD_GET(PLL_POSTDIV2_MASK, value));
+}
+
+static bool pll_is_better_rate(unsigned long target, unsigned long now,
+                              unsigned long best)
+{
+       return (target - now) < (target - best);

Is this more like abs_diff(target, now) < abs_diff(target, best)?

drivers/clk/sophgo/clk-sg2044.c line 325

Quoted 13 lines
drivers/clk/sophgo/clk-sg2044.c new file +13 -0
+}
+
+
+static int sg2044_pll_enable(struct sg2044_pll *pll, bool en)
+{
+       if (en) {
+               if (sg2044_pll_poll_update(pll) < 0)
+                       pr_warn("%s: fail to lock pll\n", clk_hw_get_name(&pll->common.hw));
+
+               return regmap_set_bits(pll->top_syscon,
+                                      pll->syscon_offset + pll->pll.enable_offset,
+                                      BIT(pll->pll.enable_bit));
+       } else {

Drop the else please.

Quoted 6 lines
drivers/clk/sophgo/clk-sg2044.c new file +6 -0
+               return regmap_clear_bits(pll->top_syscon,
+                                        pll->syscon_offset + pll->pll.enable_offset,
+                                        BIT(pll->pll.enable_bit));
+       }
+}
+

[...]

drivers/clk/sophgo/clk-sg2044.c line 406

Quoted 6 lines
drivers/clk/sophgo/clk-sg2044.c new file +6 -0
+
+static u32 sg2044_div_get_reg_div(u32 reg, struct sg2044_div_internal *div)
+{
+       if ((reg & DIV_FACTOR_REG_SOURCE))
+               return (reg >> div->shift) & clk_div_mask(div->width);
+       else

Drop the else please.

Quoted 5 lines
drivers/clk/sophgo/clk-sg2044.c new file +5 -0
+               return div->initval == 0 ? 1 : div->initval;
+}
+
+
+

[...]

drivers/clk/sophgo/clk-sg2044.c line 805

Quoted 4 lines
drivers/clk/sophgo/clk-sg2044.c new file +4 -0
+
+static const struct clk_parent_data clk_fpll0_parent[] = {
+       { .hw = &clk_fpll0.common.hw },
+};

If the only parent is a clk_hw pointer it's preferred to use struct clk_init_data::parent_hws directly instead of clk_parent_data.

Quoted 5 lines
drivers/clk/sophgo/clk-sg2044.c new file +5 -0
+
+static const struct clk_parent_data clk_fpll1_parent[] = {
+       { .hw = &clk_fpll1.common.hw },
+};
+

[...]

drivers/clk/sophgo/clk-sg2044.c line 1241

Quoted 12 lines
drivers/clk/sophgo/clk-sg2044.c new file +12 -0
+                        CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
+                        80);
+
+static DEFINE_SG2044_DIV(CLK_DIV_PKA, clk_div_pka,
+                        clk_fpll0_parent, 0,
+                        0x0f0, 16, 8,
+                        CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
+                        2);
+
+static const struct clk_parent_data clk_mux_ddr0_parents[] = {
+       { .hw = &clk_div_ddr0_fixed.common.hw },
+       { .hw = &clk_div_ddr0_main.common.hw },

Similarly, if the only parents are clk_hw pointers we should be using struct clk_init_data::parent_hws.

Quoted 6 lines
drivers/clk/sophgo/clk-sg2044.c new file +6 -0
+};
+
+static DEFINE_SG2044_MUX(CLK_MUX_DDR0, clk_mux_ddr0,
+
+static struct sg2044_clk_common *sg2044_pll_commons[] = {
+       &clk_fpll0.common,

[...]

Quoted 6 lines
drivers/clk/sophgo/clk-sg2044.c new file +6 -0
+       &clk_mpll5.common,
+};
+
+static struct sg2044_clk_common *sg2044_div_commons[] = {
+       &clk_div_ap_sys_fixed.common,
+       &clk_div_ap_sys_main.common,

[...]

Quoted 5 lines
drivers/clk/sophgo/clk-sg2044.c new file +5 -0
+       &clk_div_pka.common,
+};
+
+static struct sg2044_clk_common *sg2044_mux_commons[] = {
+       &clk_mux_ddr0.common,

[..]

drivers/clk/sophgo/clk-sg2044.c line 2014

Quoted 3 lines
drivers/clk/sophgo/clk-sg2044.c new file +3 -0
+};
+
+static struct sg2044_clk_common *sg2044_gate_commons[] = {

Can these arrays be const?

Quoted 9 lines
drivers/clk/sophgo/clk-sg2044.c new file +1 -0
+       &clk_gate_ap_sys.common,
drivers/clk/sophgo/clk-sg2044.h new file +2 -0
new file mode 100644
index 000000000000..bb69532fdf4f
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*

drivers/clk/sophgo/clk-sg2044.h line 12

Quoted 10 lines
drivers/clk/sophgo/clk-sg2044.h new file +10 -0
+ * Copyright (C) 2024 Inochi Amaoto <[email protected]>
+ */
+
+#ifndef _CLK_SOPHGO_SG2044_H_
+#define _CLK_SOPHGO_SG2044_H_
+
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/spinlock.h>
+

Please inline the contents of this file in the one C file that uses the header.

Quoted 15 lines
drivers/clk/sophgo/clk-sg2044.h new file +15 -0
+#define PLL_LIMIT_FOUTVCO      0
+#define PLL_LIMIT_FOUT         1
+#define PLL_LIMIT_REFDIV       2
+#define PLL_LIMIT_FBDIV                3
+#define PLL_LIMIT_POSTDIV1     4
+#define PLL_LIMIT_POSTDIV2     5
+
+#define for_each_pll_limit_range(_var, _limit) \
+       for (_var = (_limit)->min; _var <= (_limit)->max; _var++)
+
+struct sg2044_clk_limit {
+       u64 min;
+       u64 max;
+};
+
author maintainer
#14 lore raw

Re: [PATCH v3 2/2] clk: sophgo: Add clock controller support for SG2044 SoC

Quoted 55 lines · Stephen Boyd

Quoting Inochi Amaoto (2025-02-26 15:23:19)

drivers/clk/sophgo/clk-sg2044.c

Quoted 5 lines
drivers/clk/sophgo/clk-sg2044.c new file +0 -0
new file mode 100644
index 000000000000..b4c15746de77

Thanks for sticking with it. Some minor nits below but otherwise this looks good to go.

Quoted 25 lines
drivers/clk/sophgo/clk-sg2044.c new file +24 -0
@@ -0,0 +1,2271 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Sophgo SG2042 clock controller Driver
+ *
+ * Copyright (C) 2025 Inochi Amaoto <[email protected]>
+ */
+
+#include <linux/array_size.h>
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/cleanup.h>
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/math64.h>
+#include <linux/mfd/syscon.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+#include "clk-sg2044.h"
+
+#include <dt-bindings/clock/sophgo,sg2044-clk.h>
+

[...]

Quoted 19 lines
drivers/clk/sophgo/clk-sg2044.c new file +19 -0
+
+static unsigned long sg2044_pll_recalc_rate(struct clk_hw *hw,
+                                           unsigned long parent_rate)
+{
+       struct sg2044_pll *pll = hw_to_sg2044_pll(hw);
+       u32 value;
+       int ret;
+
+       ret = regmap_read(pll->top_syscon,
+                         pll->syscon_offset + pll->pll.ctrl_offset + PLL_HIGH_CTRL_OFFSET,
+                         &value);
+       if (ret < 0)
+               return 0;
+
+       return sg2044_pll_calc_rate(parent_rate,
+                                   FIELD_GET(PLL_REFDIV_MASK, value),
+                                   FIELD_GET(PLL_FBDIV_MASK, value),
+                                   FIELD_GET(PLL_POSTDIV1_MASK, value),
+                                   FIELD_GET(PLL_POSTDIV2_MASK, value));
Quoted 9 lines

drivers/clk/sophgo/clk-sg2044.c line 173

Quoted 6 lines
drivers/clk/sophgo/clk-sg2044.c new file +6 -0
+}
+
+static bool pll_is_better_rate(unsigned long target, unsigned long now,
+                              unsigned long best)
+{
+       return (target - now) < (target - best);

Is this more like abs_diff(target, now) < abs_diff(target, best)?

Yeah, using abs is more better.

Quoted 38 lines

drivers/clk/sophgo/clk-sg2044.c line 325

Quoted 13 lines
drivers/clk/sophgo/clk-sg2044.c new file +13 -0
+}
+
+
+static int sg2044_pll_enable(struct sg2044_pll *pll, bool en)
+{
+       if (en) {
+               if (sg2044_pll_poll_update(pll) < 0)
+                       pr_warn("%s: fail to lock pll\n", clk_hw_get_name(&pll->common.hw));
+
+               return regmap_set_bits(pll->top_syscon,
+                                      pll->syscon_offset + pll->pll.enable_offset,
+                                      BIT(pll->pll.enable_bit));
+       } else {

Drop the else please.

Quoted 6 lines
drivers/clk/sophgo/clk-sg2044.c new file +6 -0
+               return regmap_clear_bits(pll->top_syscon,
+                                        pll->syscon_offset + pll->pll.enable_offset,
+                                        BIT(pll->pll.enable_bit));
+       }
+}
+

[...]

drivers/clk/sophgo/clk-sg2044.c line 406

Quoted 6 lines
drivers/clk/sophgo/clk-sg2044.c new file +6 -0
+
+static u32 sg2044_div_get_reg_div(u32 reg, struct sg2044_div_internal *div)
+{
+       if ((reg & DIV_FACTOR_REG_SOURCE))
+               return (reg >> div->shift) & clk_div_mask(div->width);
+       else

Drop the else please.

Quoted 5 lines
drivers/clk/sophgo/clk-sg2044.c new file +5 -0
+               return div->initval == 0 ? 1 : div->initval;
+}
+
+
+

[...]

Quoted 8 lines

drivers/clk/sophgo/clk-sg2044.c line 805

Quoted 4 lines
drivers/clk/sophgo/clk-sg2044.c new file +4 -0
+
+static const struct clk_parent_data clk_fpll0_parent[] = {
+       { .hw = &clk_fpll0.common.hw },
+};

If the only parent is a clk_hw pointer it's preferred to use struct clk_init_data::parent_hws directly instead of clk_parent_data.

This is OK for me, I will change all to parent_hws.

Quoted 42 lines
Quoted 5 lines
drivers/clk/sophgo/clk-sg2044.c new file +5 -0
+
+static const struct clk_parent_data clk_fpll1_parent[] = {
+       { .hw = &clk_fpll1.common.hw },
+};
+

[...]

drivers/clk/sophgo/clk-sg2044.c line 1241

Quoted 12 lines
drivers/clk/sophgo/clk-sg2044.c new file +12 -0
+                        CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
+                        80);
+
+static DEFINE_SG2044_DIV(CLK_DIV_PKA, clk_div_pka,
+                        clk_fpll0_parent, 0,
+                        0x0f0, 16, 8,
+                        CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
+                        2);
+
+static const struct clk_parent_data clk_mux_ddr0_parents[] = {
+       { .hw = &clk_div_ddr0_fixed.common.hw },
+       { .hw = &clk_div_ddr0_main.common.hw },

Similarly, if the only parents are clk_hw pointers we should be using struct clk_init_data::parent_hws.

Quoted 6 lines
drivers/clk/sophgo/clk-sg2044.c new file +6 -0
+};
+
+static DEFINE_SG2044_MUX(CLK_MUX_DDR0, clk_mux_ddr0,
+
+static struct sg2044_clk_common *sg2044_pll_commons[] = {
+       &clk_fpll0.common,

[...]

Quoted 6 lines
drivers/clk/sophgo/clk-sg2044.c new file +6 -0
+       &clk_mpll5.common,
+};
+
+static struct sg2044_clk_common *sg2044_div_commons[] = {
+       &clk_div_ap_sys_fixed.common,
+       &clk_div_ap_sys_main.common,

[...]

Quoted 5 lines
drivers/clk/sophgo/clk-sg2044.c new file +5 -0
+       &clk_div_pka.common,
+};
+
+static struct sg2044_clk_common *sg2044_mux_commons[] = {
+       &clk_mux_ddr0.common,

[..]

Quoted 6 lines

drivers/clk/sophgo/clk-sg2044.c line 2014

Quoted 3 lines
drivers/clk/sophgo/clk-sg2044.c new file +3 -0
+};
+
+static struct sg2044_clk_common *sg2044_gate_commons[] = {

Can these arrays be const?

It can not be, we need a non const clk_hw to register. It is defined in this structure. Although these array can be set as "struct sg2044_clk_common * const", but I think this is kind of meaningless.

Quoted 14 lines
Quoted 14 lines
drivers/clk/sophgo/clk-sg2044.c new file +1 -0
+       &clk_gate_ap_sys.common,
drivers/clk/sophgo/clk-sg2044.h new file +7 -0
new file mode 100644
index 000000000000..bb69532fdf4f
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024 Inochi Amaoto <[email protected]>
+ */
+
+#ifndef _CLK_SOPHGO_SG2044_H_
+#define _CLK_SOPHGO_SG2044_H_
Quoted 9 lines

drivers/clk/sophgo/clk-sg2044.h line 12

Quoted 5 lines
drivers/clk/sophgo/clk-sg2044.h new file +5 -0
+
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/spinlock.h>
+

Please inline the contents of this file in the one C file that uses the header.

OK, I will take it.

Quoted 15 lines
Quoted 15 lines
drivers/clk/sophgo/clk-sg2044.h new file +15 -0
+#define PLL_LIMIT_FOUTVCO      0
+#define PLL_LIMIT_FOUT         1
+#define PLL_LIMIT_REFDIV       2
+#define PLL_LIMIT_FBDIV                3
+#define PLL_LIMIT_POSTDIV1     4
+#define PLL_LIMIT_POSTDIV2     5
+
+#define for_each_pll_limit_range(_var, _limit) \
+       for (_var = (_limit)->min; _var <= (_limit)->max; _var++)
+
+struct sg2044_clk_limit {
+       u64 min;
+       u64 max;
+};
+
maintainer
#15 lore raw

Re: [PATCH v3 2/2] clk: sophgo: Add clock controller support for SG2044 SoC

Quoting Inochi Amaoto (2025-03-11 18:01:54)

Quoted 10 lines · Stephen Boyd
Quoted 9 lines

Quoting Inochi Amaoto (2025-02-26 15:23:19)

Quoted 8 lines
drivers/clk/sophgo/clk-sg2044.c new file +3 -1
new file mode 100644
index 000000000000..b4c15746de77
--- /dev/null
@@ -0,0 +1,2271 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Sophgo SG2042 clock controller Driver

[...]

Quoted 11 lines
Quoted 6 lines

drivers/clk/sophgo/clk-sg2044.c line 2014

Quoted 3 lines
drivers/clk/sophgo/clk-sg2044.c new file +3 -0
+};
+
+static struct sg2044_clk_common *sg2044_gate_commons[] = {

Can these arrays be const?

It can not be, we need a non const clk_hw to register. It is defined in this structure. Although these array can be set as "struct sg2044_clk_common * const", but I think this is kind of meaningless.

Can't the array of pointers can be const so that it lives in RO memory?

author maintainer
#16 lore raw

Re: [PATCH v3 2/2] clk: sophgo: Add clock controller support for SG2044 SoC

Quoted 19 lines · Stephen Boyd

Quoting Inochi Amaoto (2025-03-11 18:01:54)

Quoted 10 lines · Stephen Boyd
Quoted 9 lines

Quoting Inochi Amaoto (2025-02-26 15:23:19)

Quoted 8 lines
drivers/clk/sophgo/clk-sg2044.c new file +3 -1
new file mode 100644
index 000000000000..b4c15746de77
--- /dev/null
@@ -0,0 +1,2271 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Sophgo SG2042 clock controller Driver

[...]

Quoted 7 lines
Quoted 6 lines

drivers/clk/sophgo/clk-sg2044.c line 2014

Quoted 3 lines
drivers/clk/sophgo/clk-sg2044.c new file +3 -0
+};
+
+static struct sg2044_clk_common *sg2044_gate_commons[] = {

Can these arrays be const?

Quoted 6 lines
Quoted 4 lines

It can not be, we need a non const clk_hw to register. It is defined in this structure. Although these array can be set as "struct sg2044_clk_common * const", but I think this is kind of meaningless.

Can't the array of pointers can be const so that it lives in RO memory?

Yeah, it can. I forgot this can also be set as RO. It is OK for me to fix that.

Regards,
Inochi

author maintainer
#17 lore raw
In reply to Inochi Amaoto
Quoted 29 lines · Inochi Amaoto

The clock controller of SG2044 provides multiple clocks for various IPs on the SoC, including PLL, mux, div and gates. As the PLL and div have obvious changed and do not fit the framework of SG2042, a new implement is provided to handle these.

Changed from v2:
1. Applied Chen Wang' tag
2. patch 2: fix author mail infomation

Changed from v1:
1. patch 1: Applied Krzysztof's tag
2. patch 2: Fix the build warning from bot.

Inochi Amaoto (2):
dt-bindings: clock: sophgo: add clock controller for SG2044
clk: sophgo: Add clock controller support for SG2044 SoC

 .../bindings/clock/sophgo,sg2044-clk.yaml     |   40 +
 drivers/clk/sophgo/Kconfig                    |   11 +
 drivers/clk/sophgo/Makefile                   |    1 +
 drivers/clk/sophgo/clk-sg2044.c               | 2271 +++++++++++++++++
 drivers/clk/sophgo/clk-sg2044.h               |   62 +
 include/dt-bindings/clock/sophgo,sg2044-clk.h |  170 ++
 6 files changed, 2555 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/sophgo,sg2044-clk.yaml
 create mode 100644 drivers/clk/sophgo/clk-sg2044.c
 create mode 100644 drivers/clk/sophgo/clk-sg2044.h
 create mode 100644 include/dt-bindings/clock/sophgo,sg2044-clk.h
Quoted 3 lines

--
2.48.1

If there is no comments anymore, I will collect these patch and send a PR to Stephen at rc6 to see whether he will accept it.

Regards,
Inochi

author maintainer Applied
#18 lore raw
In reply to Inochi Amaoto
Quoted 10 lines · Inochi Amaoto

The clock controller of SG2044 provides multiple clocks for various IPs on the SoC, including PLL, mux, div and gates. As the PLL and div have obvious changed and do not fit the framework of SG2042, a new implement is provided to handle these.

Changed from v2:
1. Applied Chen Wang' tag
2. patch 2: fix author mail infomation

[...]

Applied to for-next, thanks!

[1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

      https://github.com/sophgo/linux/commit/0332ae22ce09ce64f5e54fc2a24ed22073dbeb9d
[2/2] clk: sophgo: Add clock controller support for SG2044 SoC
      https://github.com/sophgo/linux/commit/fcee6f2173e7f7fb39f35899faea282fd9b5ea30

Thanks,
Inochi

author maintainer
#19 lore raw
Quoted 14 lines · Inochi Amaoto
Quoted 10 lines · Inochi Amaoto

The clock controller of SG2044 provides multiple clocks for various IPs on the SoC, including PLL, mux, div and gates. As the PLL and div have obvious changed and do not fit the framework of SG2042, a new implement is provided to handle these.

Changed from v2:
1. Applied Chen Wang' tag
2. patch 2: fix author mail infomation

[...]

Applied to for-next, thanks!

Quoted 8 lines

[1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

      https://github.com/sophgo/linux/commit/0332ae22ce09ce64f5e54fc2a24ed22073dbeb9d
[2/2] clk: sophgo: Add clock controller support for SG2044 SoC
      https://github.com/sophgo/linux/commit/fcee6f2173e7f7fb39f35899faea282fd9b5ea30

Thanks,
Inochi

Please ignore this mail, this point to a wrong url.

Regards,
Inochi

author maintainer Applied
#20 lore raw
In reply to Inochi Amaoto
Quoted 10 lines · Inochi Amaoto

The clock controller of SG2044 provides multiple clocks for various IPs on the SoC, including PLL, mux, div and gates. As the PLL and div have obvious changed and do not fit the framework of SG2042, a new implement is provided to handle these.

Changed from v2:
1. Applied Chen Wang' tag
2. patch 2: fix author mail infomation

[...]

Applied to sg2044/for-next, thanks!

[1/2] dt-bindings: clock: sophgo: add clock controller for SG2044

      https://github.com/sophgo/linux/commit/c90eac0946162efb7436098f25e21f02bc483ada
[2/2] clk: sophgo: Add clock controller support for SG2044 SoC
      https://github.com/sophgo/linux/commit/135418add3878dcd44483d0f2851f6f470a85395

Thanks,
Inochi