Skip to contentSkip to conversation

Cirrus Logic CS2600 clock device

PATCH Superseded Paul Handrigan 3 participants 6 messages Dec 30, 2024 – Jan 1, 2025

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Cirrus Logic CS2600 clock device

This patch set provides Common Clock Framework support for the latest Cirrus Logic clocking device, the CS2600.

This device has two input clocks and three output clocks. One of the input clocks, the REFCLK, can be a constant reference clock input, a crystal reference input, or not available and use the internal clock. The second input is the CLK_IN digital clock input.

The three clock outputs are CLK_OUT, BCLK_OUT, and FSYNC_OUT.

v2 changes:
- Remove | from after "discription" in DT binding.
- Remove discription from "clocks" in DT binding.
- Change ref_clk to xti
- Clarify auxiliary clock pin
- Change DT example to not have "reg" for the bus
- Change DT example to change i2c@0 to i2c
- Remove "OUTPUT" from the clock ouputs in the dt binding include file.
- Remove AUX_OUT defines
- Use do_div when dividing u64 by a u32
- Include the dt bindings include file
- Use the includes from the dt bindings include file aux output.
- Move of_device_id and i2c_device_id tables next to i2c_driver struct.

v3 changes:
- Changed clock-names in device tree to an emum since the both clocks are not always required.
- Changed cirrus,aux-output-source to a string input.
- Added cirrus,clock-mode as a string input.
- Fixed ordering in DT example.
- Removed dt-bindings .h file.
- Add in_range to allow for acceptable ranges for clock rates.

v4 changes:
- Change DT discription to add more detial.
- Move reg property to keep consistant with the required list.
- Add enum to string DT inputs and change the input values to lower case.
- Change unevauatedProperties to additionalProperties
- Reove black line.

Paul Handrigan (2):
dt-binding: clock: cs2600: Add support for the CS2600
clk: cs2600: Add Fractional-N clock driver

 .../bindings/clock/cirrus,cs2600.yaml         |   89 ++
 drivers/clk/Kconfig                           |    9 +
 drivers/clk/Makefile                          |    2 +
 drivers/clk/clk-cs2600.c                      | 1177 +++++++++++++++++
 drivers/clk/clk-cs2600.h                      |  173 +++
 5 files changed, 1450 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml
 create mode 100644 drivers/clk/clk-cs2600.c
 create mode 100644 drivers/clk/clk-cs2600.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/2 dt-binding: clock: cs2600: Add support for the CS2600

Add device tree support for the Cirrus Logic CS2600 clock device.

---
 .../bindings/clock/cirrus,cs2600.yaml         | 99 +++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +99 -0
new file mode 100644
index 000000000000..c6f216e45791
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/cirrus,cs2600.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cirrus Logic Fractional-N Clock Synthesizer & Clock Multiplier
+
+maintainers:
+  - Paul Handrigan <[email protected]>
+  - [email protected]>
+
+description:
+  The CS2600 is a system-clocking device that enables frequency synthesis and
+  clock generation from a stable timing reference clock. The device can
+  generate low-jitter clocks from a noisy clock reference at frequencies
+  as low as 50 Hz. The device has two potental clock inputs (xti and clk_in)
+  where xti can either be a crystal or a constant refclk and the clk_in. The
+  device can have either xti, clk_in, or both as a clock input depending on
+  the usecase. It also has three possible outputs CLK_OUT, BCLK_OUT, and
+  FSYNC_OUT.
+
+properties:
+  compatible:
+    enum:
+      - cirrus,cs2600
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      enum:
+        - xti
+        - clk_in
+    minItems: 1
+    maxItems: 2
+
+  '#clock-cells':
+    const: 1
+
+  vdd-supply:
+    description: Power Supply
+
+  clock-output-names:
+    maxItems: 3
+    description: Names for CLK_OUT, BCLK_OUT and FSYNC_OUT clocks.
+
+  cirrus,aux-output-source:
+    description:
+      Specifies the function of the auxiliary output pin with "phase_unlock"
+      to indicate the input and output clocks are not in phase, "freq_unlock"
+      to indicate the PLL is unlocked, and "no_clkin" to indicate the clock on
+      the clk_in pin is not present.
+    $ref: /schemas/types.yaml#/definitions/string
+    enum:
+      - phase_unock # Sets output pin to indicate PHASE_UNLOCK
+      - freq_unlock # Sets output pin to indicate FREQ_UNLOCK
+      - no_clkin # Sets output pin to indicate NO_CLKIN
+
+  cirrus,clock-mode:
+    description:
+      Sets the device into smart mode whith "smart_mode" and sets the device
+      into smart mode that only outputs a clock when clk_in starts with
+      "smart_clkin_only_mode".
+    $ref: /schemas/types.yaml#/definitions/string
+    enum:
+      - smart_mode
+      - smart_clkin_only_mode
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      clock-controller@2c {
+        compatible = "cirrus,cs2600";
+        reg = <0x2c>;
+        #clock-cells = <1>;
+        clocks = <&xtl_clk>, <&sync_clock>;
+        clock-names = "xti", "clk_in";
+        clock-output-names = "audio_clk_out", "audio_bclk", "audio_lrclk";
+        cirrus,aux-output-source = "freq_unlock";
+        vdd-supply = <&vreg>;
+      };
+    };
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v4 1/2] dt-binding: clock: cs2600: Add support for the CS2600

Quoted 4 lines · Paul Handrigan

Add device tree support for the Cirrus Logic CS2600 clock device.

I was wondering why this is not picked up by my filters... now I now:
wrong subject prefix. It's dt-bindings.

Quoted 33 lines
---
 .../bindings/clock/cirrus,cs2600.yaml         | 99 +++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +22 -0
new file mode 100644
index 000000000000..c6f216e45791
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/cirrus,cs2600.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cirrus Logic Fractional-N Clock Synthesizer & Clock Multiplier
+
+maintainers:
+  - Paul Handrigan <[email protected]>
+  - [email protected]>
+
+description:
+  The CS2600 is a system-clocking device that enables frequency synthesis and
+  clock generation from a stable timing reference clock. The device can
+  generate low-jitter clocks from a noisy clock reference at frequencies
+  as low as 50 Hz. The device has two potental clock inputs (xti and clk_in)
+  where xti can either be a crystal or a constant refclk and the clk_in. The
+  device can have either xti, clk_in, or both as a clock input depending on
+  the usecase. It also has three possible outputs CLK_OUT, BCLK_OUT, and
+  FSYNC_OUT.
+

Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml line 32

Quoted 10 lines
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +10 -0
+properties:
+  compatible:
+    enum:
+      - cirrus,cs2600
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 2

This does not match clock-names. Missing minItems. I already commented on this last time. Implement all comments I asked for.

Quoted 20 lines
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +20 -0
+
+  clock-names:
+    items:
+      enum:
+        - xti
+        - clk_in
+    minItems: 1
+    maxItems: 2
+
+  '#clock-cells':
+    const: 1
+
+  vdd-supply:
+    description: Power Supply
+
+  clock-output-names:
+    maxItems: 3
+    description: Names for CLK_OUT, BCLK_OUT and FSYNC_OUT clocks.
+
+  cirrus,aux-output-source:

Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml line 62

Quoted 10 lines
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +10 -0
+    description:
+      Specifies the function of the auxiliary output pin with "phase_unlock"
+      to indicate the input and output clocks are not in phase, "freq_unlock"
+      to indicate the PLL is unlocked, and "no_clkin" to indicate the clock on
+      the clk_in pin is not present.
+    $ref: /schemas/types.yaml#/definitions/string
+    enum:
+      - phase_unock # Sets output pin to indicate PHASE_UNLOCK
+      - freq_unlock # Sets output pin to indicate FREQ_UNLOCK
+      - no_clkin # Sets output pin to indicate NO_CLKIN

Drop comments, you just repeated the value. If you want to add comment, say something different than the value is saying.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v4 1/2] dt-binding: clock: cs2600: Add support for the CS2600

Quoted 3 lines · Krzysztof Kozlowski

I was wondering why this is not picked up by my filters... now I now:
wrong subject prefix. It's dt-bindings.

Ack

Quoted 4 lines
Quoted 1 line

+ maxItems: 2

This does not match clock-names. Missing minItems. I already commented on this last time. Implement all comments I asked for.

Sorry, I misunderstood. I will add in minItems as well.

Quoted 4 lines

Drop comments, you just repeated the value. If you want to add comment, say something different than the value is saying.

Ack

Quoted 1 line

Regards,
Paul

#4 lore raw

PATCH v4 2/2 clk: cs2600: Add Fractional-N clock driver

In reply to Paul Handrigan

Add support for the CS2600 Fractional-N Clock Synthesizer and Multiplier driver.

---
 drivers/clk/Kconfig      |    9 +
 drivers/clk/Makefile     |    1 +
 drivers/clk/clk-cs2600.c | 1177 ++++++++++++++++++++++++++++++++++++++
 drivers/clk/clk-cs2600.h |  173 ++++++
 4 files changed, 1360 insertions(+)
 create mode 100644 drivers/clk/clk-cs2600.c
 create mode 100644 drivers/clk/clk-cs2600.h
drivers/clk/Kconfig +9 -0
index 713573b6c86c..6b279ebf9c80 100644
@@ -209,6 +209,15 @@ config COMMON_CLK_CS2000_CP
 	help
 	  If you say yes here you get support for the CS2000 clock multiplier.
 
+config COMMON_CLK_CS2600
+	tristate "Clock driver for CS2600 Fractional-N Clock Synthesizer & Clock Multiplier"
+	depends on I2C
+	depends on OF
+	select REGMAP_I2C
+	help
+	  If you say yes here you get support for the CS2600 clock synthesizer
+	  and multiplier.
+
 config COMMON_CLK_EN7523
 	bool "Clock driver for Airoha EN7523 SoC system clocks"
 	depends on OF
drivers/clk/Makefile +1 -0
index bf4bd45adc3a..5d5264432613 100644
@@ -53,6 +53,7 @@ obj-$(CONFIG_COMMON_CLK_CDCE706)	+= clk-cdce706.o
 obj-$(CONFIG_COMMON_CLK_CDCE925)	+= clk-cdce925.o
 obj-$(CONFIG_ARCH_CLPS711X)		+= clk-clps711x.o
 obj-$(CONFIG_COMMON_CLK_CS2000_CP)	+= clk-cs2000-cp.o
+obj-$(CONFIG_COMMON_CLK_CS2600)		+= clk-cs2600.o
 obj-$(CONFIG_COMMON_CLK_EP93XX)		+= clk-ep93xx.o
 obj-$(CONFIG_ARCH_SPARX5)		+= clk-sparx5.o
 obj-$(CONFIG_COMMON_CLK_EN7523)		+= clk-en7523.o
drivers/clk/clk-cs2600.c new file +1177 -0

1,177 lines not on this page · raw message

drivers/clk/clk-cs2600.h new file +173 -0

173 lines not on this page · raw message

Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH v4 2/2] clk: cs2600: Add Fractional-N clock driver

kernel test robot noticed the following build warnings:

Hi Paul,

kernel test robot noticed the following build warnings:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on linus/master v6.13-rc5 next-20241220] [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/Paul-Handrigan/dt-binding-clock-cs2600-Add-support-for-the-CS2600/20241231-061424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
patch link:    https://lore.kernel.org/r/20241230221246.3927158-3-paulha%40opensource.cirrus.com
patch subject: [PATCH v4 2/2] clk: cs2600: Add Fractional-N clock driver
config: um-randconfig-r061-20250101 (https://download.01.org/0day-ci/archive/20250101/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.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/clk-cs2600.c:300:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead.

drivers/clk/clk-cs2600.c:272:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead.

vim +300 drivers/clk/clk-cs2600.c

277
278 static int cs2600_set_multi_ratio(struct cs2600 *cs2600, unsigned long rate,
279 unsigned long parent_rate,
280 unsigned int *ratio)
281 {
282 struct regmap *regmap = cs2600->regmap;
283 u64 product = (u64)rate;
284
285 if ((rate / parent_rate) > CS2600_PLL_MULTIPLY_MAX) {
286 dev_err(cs2600->dev, "Ratio is too large %lu\n",
287 rate / parent_rate);
288 return -EINVAL;
289 }
290
291 if ((rate / parent_rate) > CS2600_HI_RES_MAX) {
292 regmap_clear_bits(regmap, CS2600_PLL_CFG3, CS2600_RATIO_CFG);
293 product <<= CS2600_20_12_SHIFT;
294
295 } else {
296 regmap_set_bits(regmap, CS2600_PLL_CFG3, CS2600_RATIO_CFG);
297 product <<= CS2600_12_20_SHIFT;
298 }
299

 > 300		do_div(product, parent_rate);

301 *ratio = product;
302
303 return 0;
304 }
305

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