Skip to contentSkip to conversation

clk: sophgo: add SG2044 clock controller support

PATCH Superseded Inochi Amaoto 3 participants 5 messages Dec 9, 2024 – Dec 16, 2024

Subsystems (5)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Inochi Amaoto

author maintainer
#0 lore raw

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.

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               | 2275 +++++++++++++++++
 drivers/clk/sophgo/clk-sg2044.h               |   62 +
 include/dt-bindings/clock/sophgo,sg2044-clk.h |  170 ++
 6 files changed, 2559 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.47.1

author maintainer
#1 lore raw

PATCH 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.47.1
Reviewed-by on v1 1/2
#2 lore raw

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

Quoted 6 lines · Inochi Amaoto

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.

Quoted 7 lines
---
 .../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

Best regards,
Krzysztof

author maintainer
#3 lore raw

PATCH 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 | 2275 +++++++++++++++++++++++++++++++
 drivers/clk/sophgo/clk-sg2044.h |   62 +
 4 files changed, 2349 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 +2275 -0

2,275 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.47.1
#4 lore raw

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

kernel test robot noticed the following build warnings:

Hi Inochi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on sophgo/for-next]
[also build test WARNING on sophgo/fixes clk/clk-next robh/for-next linus/master v6.13-rc2 next-20241209] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Inochi-Amaoto/dt-bindings-clock-sophgo-add-clock-controller-for-SG2044/20241209-162418
base:   https://github.com/sophgo/linux.git for-next
patch link:    https://lore.kernel.org/r/20241209082132.752775-3-inochiama%40gmail.com
patch subject: [PATCH 2/2] clk: sophgo: Add clock controller support for SG2044 SoC
config: parisc-randconfig-r053-20241210 (https://download.01.org/0day-ci/archive/20241210/[email protected]/config)
compiler: hppa-linux-gcc (GCC) 14.2.0

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]/

cocci warnings: (new ones prefixed by >>)

>> drivers/clk/sophgo/clk-sg2044.c:133:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead.
>> drivers/clk/sophgo/clk-sg2044.c:149:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.

vim +133 drivers/clk/sophgo/clk-sg2044.c

126
127 static unsigned long sg2044_pll_calc_vco_rate(unsigned long parent_rate,
128 unsigned long refdiv,
129 unsigned long fbdiv)
130 {
131 u64 numerator = parent_rate * fbdiv;
132

 > 133		do_div(numerator, refdiv);
   134	
   135		return numerator;
   136	}
   137	
   138	static unsigned long sg2044_pll_calc_rate(unsigned long parent_rate,
   139						  unsigned long refdiv,
   140						  unsigned long fbdiv,
   141						  unsigned long postdiv1,
   142						  unsigned long postdiv2)
   143	{
   144		u64 numerator, denominator;
   145	
   146		numerator = parent_rate * fbdiv;
   147		denominator = refdiv * (postdiv1 + 1) * (postdiv2 + 1);
   148	
 > 149		do_div(numerator, denominator);

150
151 return numerator;
152 }
153

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