Skip to contentSkip to conversation

Cirrus Logic CS2600 clock device

PATCH Superseded Paul Handrigan 4 participants 17 messages Dec 19, 2024 – Dec 21, 2024

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 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.

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

 .../bindings/clock/cirrus,cs2600.yaml         |   81 ++
 drivers/clk/Kconfig                           |    9 +
 drivers/clk/Makefile                          |    1 +
 drivers/clk/clk-cs2600.c                      | 1158 +++++++++++++++++
 drivers/clk/clk-cs2600.h                      |  173 +++
 include/dt-bindings/clock/cirrus,cs2600.h     |   24 +
 6 files changed, 1446 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
 create mode 100644 include/dt-bindings/clock/cirrus,cs2600.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 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         | 81 +++++++++++++++++++
 include/dt-bindings/clock/cirrus,cs2600.h     | 24 ++++++
 2 files changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml
 create mode 100644 include/dt-bindings/clock/cirrus,cs2600.h
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +81 -0
new file mode 100644
index 000000000000..f49f720addf1
@@ -0,0 +1,81 @@
+# 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.
+
+properties:
+  compatible:
+    enum:
+      - cirrus,cs2600
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: xti
+      - const: clk_in
+
+  '#clock-cells':
+    const: 1
+
+  reg:
+    maxItems: 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
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum:
+      - 0 # CS2600_AUX_OUTPUT_FREQ_UNLOCK: Frequency unlock notification
+      - 1 # CS2600_AUX_OUTPUT_PHASE_UNLOCK: Phase unlock notification
+      - 2 # CS2600_AUX_OUTPUT_NO_CLKIN: CLK_IN is not available
+    default: 0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/cirrus,cs2600.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      clock-controller@2c {
+        #clock-cells = <1>;
+        compatible = "cirrus,cs2600";
+        reg = <0x2c>;
+        clocks = <&xtl_clk>, <&sync_clock>;
+        clock-names = "xti", "clk_in";
+        clock-output-names = "audio_clk_out", "audio_bclk", "audio_lrclk";
+        vdd-supply = <&vreg>;
+      };
+    };
include/dt-bindings/clock/cirrus,cs2600.h new file +24 -0
new file mode 100644
index 000000000000..86065f94a2b2
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+/*
+ * Copyright (c) 2024 Cirrus Logic, Inc. and
+ *		      Cirrus Logic International Simiconductor Ltd.
+ *
+ * Author: Paul Handrigan <[email protected]>
+ *
+ */
+
+#ifndef _DT_BINDINGS_CLK_CIRRUS_CS2600_H
+#define _DT_BINDINGS_CLK_CIRRUS_CS2600_H
+
+/* CS2600 Clocks  */
+#define CS2600_PLL      0 /* Internal clock */
+#define CS2600_CLK		1
+#define CS2600_BCLK		2
+#define CS2600_FSYNC	3
+
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2
+
+#endif
Signature · 1 line
2.34.1
#2 lore raw

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

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

Quoted 12 lines · Paul Handrigan
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +12 -0
+  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
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum:
+      - 0 # CS2600_AUX_OUTPUT_FREQ_UNLOCK: Frequency unlock notification
+      - 1 # CS2600_AUX_OUTPUT_PHASE_UNLOCK: Phase unlock notification
+      - 2 # CS2600_AUX_OUTPUT_NO_CLKIN: CLK_IN is not available

I still do not understand how "clk_in", which is required, could be not available. To me it contradicts itself, but maybe just description is a bit incomplete.

Anyway, why this cannot be simple string?

Quoted 11 lines
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +11 -0
+    default: 0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+
+unevaluatedProperties: false
+

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

Quoted 10 lines
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +10 -0
+examples:
+  - |
+    #include <dt-bindings/clock/cirrus,cs2600.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      clock-controller@2c {
+        #clock-cells = <1>;

Use order from DTS coding style.

Quoted 26 lines
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +8 -0
+        compatible = "cirrus,cs2600";
+        reg = <0x2c>;
+        clocks = <&xtl_clk>, <&sync_clock>;
+        clock-names = "xti", "clk_in";
+        clock-output-names = "audio_clk_out", "audio_bclk", "audio_lrclk";
+        vdd-supply = <&vreg>;
+      };
+    };
include/dt-bindings/clock/cirrus,cs2600.h new file +12 -0
new file mode 100644
index 000000000000..86065f94a2b2
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+/*
+ * Copyright (c) 2024 Cirrus Logic, Inc. and
+ *		      Cirrus Logic International Simiconductor Ltd.
+ *
+ * Author: Paul Handrigan <[email protected]>
+ *
+ */
+
+#ifndef _DT_BINDINGS_CLK_CIRRUS_CS2600_H
+#define _DT_BINDINGS_CLK_CIRRUS_CS2600_H
+

include/dt-bindings/clock/cirrus,cs2600.h line 22

Quoted 10 lines
include/dt-bindings/clock/cirrus,cs2600.h new file +10 -0
+/* CS2600 Clocks  */
+#define CS2600_PLL      0 /* Internal clock */
+#define CS2600_CLK		1
+#define CS2600_BCLK		2
+#define CS2600_FSYNC	3
+
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2

I still don't see why these three are supposed to be bindings. Drop them.

Best regards,
Krzysztof

#3 lore raw

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

Quoted 14 lines · Krzysztof Kozlowski

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

Quoted 12 lines · Paul Handrigan
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +12 -0
+  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
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum:
+      - 0 # CS2600_AUX_OUTPUT_FREQ_UNLOCK: Frequency unlock notification
+      - 1 # CS2600_AUX_OUTPUT_PHASE_UNLOCK: Phase unlock notification
+      - 2 # CS2600_AUX_OUTPUT_NO_CLKIN: CLK_IN is not available
Quoted 3 lines

I still do not understand how "clk_in", which is required, could be not available. To me it contradicts itself, but maybe just description is a bit incomplete.

I think yeah the description perhaps needs to make this more clear this is setting an error output pin, ie. the pin goes high for the linked error condition.

Quoted 7 lines

include/dt-bindings/clock/cirrus,cs2600.h line 22

Quoted 4 lines
include/dt-bindings/clock/cirrus,cs2600.h new file +4 -0
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2

I still don't see why these three are supposed to be bindings. Drop them.

In a binding one would presumably do:

cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

Apologies but I don't quite understand what you mean by the values are not used in the binding? The driver reads the property and sets the pin to have the appropriate function. Admittedly one could drop the defines and then DTS would just have to do:

cirrus,aux-output-source = <0>;

But that feels a bit less helpful when reading the binding.

Thanks,
Charles

#4 lore raw

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

Quoted 31 lines · Charles Keepax
Quoted 14 lines · Krzysztof Kozlowski

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

Quoted 12 lines · Paul Handrigan
Documentation/devicetree/bindings/clock/cirrus,cs2600.yaml new file +12 -0
+  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
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum:
+      - 0 # CS2600_AUX_OUTPUT_FREQ_UNLOCK: Frequency unlock notification
+      - 1 # CS2600_AUX_OUTPUT_PHASE_UNLOCK: Phase unlock notification
+      - 2 # CS2600_AUX_OUTPUT_NO_CLKIN: CLK_IN is not available
Quoted 3 lines

I still do not understand how "clk_in", which is required, could be not available. To me it contradicts itself, but maybe just description is a bit incomplete.

I think yeah the description perhaps needs to make this more clear this is setting an error output pin, ie. the pin goes high for the linked error condition.

Quoted 7 lines

include/dt-bindings/clock/cirrus,cs2600.h line 22

Quoted 4 lines
include/dt-bindings/clock/cirrus,cs2600.h new file +4 -0
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2

I still don't see why these three are supposed to be bindings. Drop them.

Quoted 6 lines

In a binding one would presumably do:

cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

Apologies but I don't quite understand what you mean by the values are not used in the binding? The driver reads the property and sets

There is no user of these defines, so not a binding.

Quoted 1 line

the pin to have the appropriate function. Admittedly one could drop

It's not a proof that this is a binding.

Quoted 5 lines

the defines and then DTS would just have to do:

cirrus,aux-output-source = <0>;

But that feels a bit less helpful when reading the binding.

Binding and being helpful are two different things. This to be the binding, it has to be used as a binding, so some translation layer between driver and DTS. It must have an user in DTS. I keep repeating this over and over...

Best regards,
Krzysztof

#5 lore raw

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

Quoted 26 lines · Krzysztof Kozlowski
Quoted 10 lines · Charles Keepax
Quoted 8 lines · Krzysztof Kozlowski

include/dt-bindings/clock/cirrus,cs2600.h line 22

Quoted 4 lines · Paul Handrigan
include/dt-bindings/clock/cirrus,cs2600.h new file +4 -0
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2

I still don't see why these three are supposed to be bindings. Drop them.

Quoted 6 lines

In a binding one would presumably do:

cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

Apologies but I don't quite understand what you mean by the values are not used in the binding? The driver reads the property and sets

There is no user of these defines, so not a binding.

Quoted 1 line

the pin to have the appropriate function. Admittedly one could drop

It's not a proof that this is a binding.

Quoted 2 lines

the defines and then DTS would just have to do:

Quoted 9 lines
Quoted 3 lines

cirrus,aux-output-source = <0>;

But that feels a bit less helpful when reading the binding.

Binding and being helpful are two different things. This to be the binding, it has to be used as a binding, so some translation layer between driver and DTS. It must have an user in DTS. I keep repeating this over and over...

Apologies, but I not sure I totally follow this, and apologies if you have already explained this are there some docs I can look at?

I think you are saying because these defines merely represent the valid values for a device tree property and are not translated into different values you can't put defines for them in the binding header?

So this would not be allowed:

  #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 0

  cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

  device_property_read_u32(dev, "cirrus,aux-output-source", &val);
  regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

But this would be fine:

  #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 1

  cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

  device_property_read_u32(dev, "cirrus,aux-output-source", &val);
  switch (val) {
  case CS2600_AUX_OUTPUT_FREQ_UNLOCK:
    regmap_write(regmap, CS2600_OUTPUT_CFG2, 0);
  }

And this would also be fine?

  cirrus,aux-output-source = <0>;

  device_property_read_u32(dev, "cirrus,aux-output-source", &val);
  regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

Thanks,
Charles

#6 lore raw

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

Quoted 67 lines · Charles Keepax
Quoted 26 lines · Krzysztof Kozlowski
Quoted 10 lines · Charles Keepax
Quoted 8 lines · Krzysztof Kozlowski

include/dt-bindings/clock/cirrus,cs2600.h line 22

Quoted 4 lines · Paul Handrigan
include/dt-bindings/clock/cirrus,cs2600.h new file +4 -0
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2

I still don't see why these three are supposed to be bindings. Drop them.

Quoted 6 lines

In a binding one would presumably do:

cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

Apologies but I don't quite understand what you mean by the values are not used in the binding? The driver reads the property and sets

There is no user of these defines, so not a binding.

Quoted 1 line

the pin to have the appropriate function. Admittedly one could drop

It's not a proof that this is a binding.

Quoted 2 lines

the defines and then DTS would just have to do:

Quoted 9 lines
Quoted 3 lines

cirrus,aux-output-source = <0>;

But that feels a bit less helpful when reading the binding.

Binding and being helpful are two different things. This to be the binding, it has to be used as a binding, so some translation layer between driver and DTS. It must have an user in DTS. I keep repeating this over and over...

Apologies, but I not sure I totally follow this, and apologies if you have already explained this are there some docs I can look at?

I think you are saying because these defines merely represent the valid values for a device tree property and are not translated into different values you can't put defines for them in the binding header?

So this would not be allowed:

  #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 0

  cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

  device_property_read_u32(dev, "cirrus,aux-output-source", &val);
  regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

But this would be fine:

  #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 1

  cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

  device_property_read_u32(dev, "cirrus,aux-output-source", &val);
  switch (val) {
  case CS2600_AUX_OUTPUT_FREQ_UNLOCK:
    regmap_write(regmap, CS2600_OUTPUT_CFG2, 0);
  }
Quoted 7 lines

And this would also be fine?

  cirrus,aux-output-source = <0>;

  device_property_read_u32(dev, "cirrus,aux-output-source", &val);
  regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

Yes. If you want to use in DTS user-readable values, then use string.

Best regards,
Krzysztof

#7 lore raw

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

Quoted 68 lines · Krzysztof Kozlowski
Quoted 67 lines · Charles Keepax
Quoted 26 lines · Krzysztof Kozlowski
Quoted 10 lines · Charles Keepax
Quoted 8 lines · Krzysztof Kozlowski

include/dt-bindings/clock/cirrus,cs2600.h line 22

Quoted 4 lines · Paul Handrigan
include/dt-bindings/clock/cirrus,cs2600.h new file +4 -0
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2

I still don't see why these three are supposed to be bindings. Drop them.

Quoted 6 lines

In a binding one would presumably do:

cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

Apologies but I don't quite understand what you mean by the values are not used in the binding? The driver reads the property and sets

There is no user of these defines, so not a binding.

Quoted 1 line

the pin to have the appropriate function. Admittedly one could drop

It's not a proof that this is a binding.

Quoted 2 lines

the defines and then DTS would just have to do:

Quoted 9 lines
Quoted 3 lines

cirrus,aux-output-source = <0>;

But that feels a bit less helpful when reading the binding.

Binding and being helpful are two different things. This to be the binding, it has to be used as a binding, so some translation layer between driver and DTS. It must have an user in DTS. I keep repeating this over and over...

Apologies, but I not sure I totally follow this, and apologies if you have already explained this are there some docs I can look at?

I think you are saying because these defines merely represent the valid values for a device tree property and are not translated into different values you can't put defines for them in the binding header?

So this would not be allowed:

   #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 0

   cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

   device_property_read_u32(dev, "cirrus,aux-output-source", &val);
   regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

But this would be fine:

   #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 1

   cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

   device_property_read_u32(dev, "cirrus,aux-output-source", &val);
   switch (val) {
   case CS2600_AUX_OUTPUT_FREQ_UNLOCK:
     regmap_write(regmap, CS2600_OUTPUT_CFG2, 0);
   }
Quoted 9 lines
Quoted 7 lines

And this would also be fine?

   cirrus,aux-output-source = <0>;

   device_property_read_u32(dev, "cirrus,aux-output-source", &val);
   regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

Yes. If you want to use in DTS user-readable values, then use string.

I don't understand this. Why should we have to use a string value for something that only needs a simple integer value? Why can't we define constants with meaningful names?

Quoted 2 lines

Best regards,
Krzysztof

#8 lore raw

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

Quoted 76 lines · Richard Fitzgerald
Quoted 75 lines · Krzysztof Kozlowski
Quoted 74 lines · Charles Keepax
Quoted 26 lines · Krzysztof Kozlowski
Quoted 10 lines · Charles Keepax
Quoted 8 lines · Krzysztof Kozlowski

Review

Quoted 4 lines · Paul Handrigan
(quoted diff) +4 -0
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2

I still don't see why these three are supposed to be bindings. Drop them.

Quoted 6 lines

In a binding one would presumably do:

cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

Apologies but I don't quite understand what you mean by the values are not used in the binding? The driver reads the property and sets

There is no user of these defines, so not a binding.

Quoted 1 line

the pin to have the appropriate function. Admittedly one could drop

It's not a proof that this is a binding.

Quoted 2 lines

the defines and then DTS would just have to do:

Quoted 9 lines
Quoted 3 lines

cirrus,aux-output-source = <0>;

But that feels a bit less helpful when reading the binding.

Binding and being helpful are two different things. This to be the binding, it has to be used as a binding, so some translation layer between driver and DTS. It must have an user in DTS. I keep repeating this over and over...

Apologies, but I not sure I totally follow this, and apologies if you have already explained this are there some docs I can look at?

I think you are saying because these defines merely represent the valid values for a device tree property and are not translated into different values you can't put defines for them in the binding header?

So this would not be allowed:

   #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 0

   cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

   device_property_read_u32(dev, "cirrus,aux-output-source", &val);
   regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

But this would be fine:

   #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 1

   cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

   device_property_read_u32(dev, "cirrus,aux-output-source", &val);
   switch (val) {
   case CS2600_AUX_OUTPUT_FREQ_UNLOCK:
     regmap_write(regmap, CS2600_OUTPUT_CFG2, 0);
   }

And this would also be fine?

   cirrus,aux-output-source = <0>;

   device_property_read_u32(dev, "cirrus,aux-output-source", &val);
   regmap_write(regmap, CS2600_OUTPUT_CFG2, val);
Quoted 6 lines
Quoted 2 lines

Yes. If you want to use in DTS user-readable values, then use string.

I don't understand this. Why should we have to use a string value for something that only needs a simple integer value? Why can't we define constants with meaningful names?

You can and you will find plenty examples of this, but as I explained earlier - this is not a binding. We avoid defining as a binding something which is not a binding.

Best regards,
Krzysztof

#9 lore raw

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

Quoted 80 lines · Krzysztof Kozlowski
Quoted 79 lines · Richard Fitzgerald
Quoted 77 lines · Krzysztof Kozlowski
Quoted 67 lines · Charles Keepax
Quoted 26 lines · Krzysztof Kozlowski
Quoted 10 lines · Charles Keepax
Quoted 8 lines · Krzysztof Kozlowski

Review

Quoted 4 lines · Paul Handrigan
(quoted diff) +4 -0
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2

I still don't see why these three are supposed to be bindings. Drop them.

Quoted 6 lines

In a binding one would presumably do:

cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

Apologies but I don't quite understand what you mean by the values are not used in the binding? The driver reads the property and sets

There is no user of these defines, so not a binding.

Quoted 1 line

the pin to have the appropriate function. Admittedly one could drop

It's not a proof that this is a binding.

Quoted 2 lines

the defines and then DTS would just have to do:

Quoted 9 lines
Quoted 3 lines

cirrus,aux-output-source = <0>;

But that feels a bit less helpful when reading the binding.

Binding and being helpful are two different things. This to be the binding, it has to be used as a binding, so some translation layer between driver and DTS. It must have an user in DTS. I keep repeating this over and over...

Apologies, but I not sure I totally follow this, and apologies if you have already explained this are there some docs I can look at?

I think you are saying because these defines merely represent the valid values for a device tree property and are not translated into different values you can't put defines for them in the binding header?

So this would not be allowed:

    #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 0

    cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

    device_property_read_u32(dev, "cirrus,aux-output-source", &val);
    regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

But this would be fine:

    #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 1

    cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

    device_property_read_u32(dev, "cirrus,aux-output-source", &val);
    switch (val) {
    case CS2600_AUX_OUTPUT_FREQ_UNLOCK:
      regmap_write(regmap, CS2600_OUTPUT_CFG2, 0);
    }
Quoted 7 lines

And this would also be fine?

    cirrus,aux-output-source = <0>;

    device_property_read_u32(dev, "cirrus,aux-output-source", &val);
    regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

Yes. If you want to use in DTS user-readable values, then use string.

Quoted 8 lines
Quoted 3 lines

I don't understand this. Why should we have to use a string value for something that only needs a simple integer value? Why can't we define constants with meaningful names?

You can and you will find plenty examples of this, but as I explained earlier - this is not a binding. We avoid defining as a binding something which is not a binding.

What does that mean?
Perhaps if you clearly explained what the problem is and what you want us to change instead of making cryptic statements like "this is not a binding" we wouldn't have to waste all this time exchanging emails that aren't getting anywhere.

You didn't explain earlier. You typed some words earlier, but they failed to explain, and you are continuing to fail to explain.

Quoted 2 lines

Best regards,
Krzysztof

#10 lore raw

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

Quoted 90 lines · Richard Fitzgerald
Quoted 80 lines · Krzysztof Kozlowski
Quoted 79 lines · Richard Fitzgerald
Quoted 77 lines · Krzysztof Kozlowski
Quoted 67 lines · Charles Keepax
Quoted 26 lines · Krzysztof Kozlowski
Quoted 10 lines · Charles Keepax
Quoted 8 lines · Krzysztof Kozlowski

Review

Quoted 4 lines · Paul Handrigan
(quoted diff) +4 -0
+/* CS2600 Auxiliary Output */
+#define CS2600_AUX_OUTPUT_FREQ_UNLOCK	0
+#define CS2600_AUX_OUTPUT_PHASE_UNLOCK	1
+#define CS2600_AUX_OUTPUT_NO_CLKIN	2

I still don't see why these three are supposed to be bindings. Drop them.

Quoted 6 lines

In a binding one would presumably do:

cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

Apologies but I don't quite understand what you mean by the values are not used in the binding? The driver reads the property and sets

There is no user of these defines, so not a binding.

Quoted 1 line

the pin to have the appropriate function. Admittedly one could drop

It's not a proof that this is a binding.

Quoted 2 lines

the defines and then DTS would just have to do:

Quoted 9 lines
Quoted 3 lines

cirrus,aux-output-source = <0>;

But that feels a bit less helpful when reading the binding.

Binding and being helpful are two different things. This to be the binding, it has to be used as a binding, so some translation layer between driver and DTS. It must have an user in DTS. I keep repeating this over and over...

Apologies, but I not sure I totally follow this, and apologies if you have already explained this are there some docs I can look at?

I think you are saying because these defines merely represent the valid values for a device tree property and are not translated into different values you can't put defines for them in the binding header?

So this would not be allowed:

    #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 0

    cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

    device_property_read_u32(dev, "cirrus,aux-output-source", &val);
    regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

But this would be fine:

    #define CS2600_AUX_OUTPUT_FREQ_UNLOCK 1

    cirrus,aux-output-source = <CS2600_AUX_OUTPUT_FREQ_UNLOCK>;

    device_property_read_u32(dev, "cirrus,aux-output-source", &val);
    switch (val) {
    case CS2600_AUX_OUTPUT_FREQ_UNLOCK:
      regmap_write(regmap, CS2600_OUTPUT_CFG2, 0);
    }
Quoted 7 lines

And this would also be fine?

    cirrus,aux-output-source = <0>;

    device_property_read_u32(dev, "cirrus,aux-output-source", &val);
    regmap_write(regmap, CS2600_OUTPUT_CFG2, val);

Yes. If you want to use in DTS user-readable values, then use string.

Quoted 8 lines
Quoted 3 lines

I don't understand this. Why should we have to use a string value for something that only needs a simple integer value? Why can't we define constants with meaningful names?

You can and you will find plenty examples of this, but as I explained earlier - this is not a binding. We avoid defining as a binding something which is not a binding.

Quoted 8 lines

What does that mean?
Perhaps if you clearly explained what the problem is and what you want us to change instead of making cryptic statements like "this is not a binding" we wouldn't have to waste all this time exchanging emails that aren't getting anywhere.

You didn't explain earlier. You typed some words earlier, but they failed to explain, and you are continuing to fail to explain.

Mentioned defines do not meet criteria of a binding, because of reasons I already stated very clear, so do not try to make them a binding.

You got also pretty clear answer from Charles what to do, so what is unclear here? Drop these defines and use register values or better strings. Or fix them to be really a binding (and then come with a reason why these are bindings).

Best regards,
Krzysztof

#11 lore raw

PATCH v2 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 | 1158 ++++++++++++++++++++++++++++++++++++++
 drivers/clk/clk-cs2600.h |  173 ++++++
 4 files changed, 1341 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 +1158 -0

1,158 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
#12 lore raw

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

Quoted 14 lines · Paul Handrigan
drivers/clk/clk-cs2600.h new file +14 -0
+/* DEVICE_ID2 */
+#define CS2600_AREVID_MASK		GENMASK(7, 4)
+#define CS2600_MTLRVID_MASK		GENMASK(3, 0)
+
+/* UNLOCK_INDICATORS */
+#define CS2600_P_UNLOCK_STICKY		BIT(3)
+#define CS2600_P_UNLOCK			BIT(2)
+#define CS2600_F_UNLOCK_STICKY		BIT(1)
+#define CS2600_F_UNLOCK			BIT(0)
+
+/* ERROR_STS */
+#define CS2600_ERR_DEV_DEFECT		BIT(7) /* Device defective */
+#define CS2600_ERR_OTP_CORRUPT		BIT(6)
+#define CS2600_ERR_REG_CFG		BIT(5) /* Invalid register config */

drivers/clk/clk-cs2600.h line 118

Quoted 10 lines
drivers/clk/clk-cs2600.h new file +10 -0
+#define CS2600_ERR_PLL_DISABLED		BIT(4)
+#define CS2600_ERR_HW_CFG		BIT(3) /* Invalid HW Config */
+#define CS2600_ERR_REFCLK_MISSING	BIT(2)
+#define CS2600_ERR_CLKIN_UNSTABLE	BIT(1)
+#define CS2600_ERR_CLKIN_MISSING	BIT(0)
+
+#define CS2600_PLL_OUT			0
+#define CS2600_CLK_OUT			1
+#define CS2600_BCLK_OUT			2
+#define CS2600_FSYNC_OUT		3

No, the entire point of the binding header is to bind. Drop all four above and use properly your header.

Otherwise I claim your binding header is not used or not really a binding.

Best regards,
Krzysztof

#13 lore raw

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

Quoted 29 lines · Krzysztof Kozlowski
Quoted 14 lines · Paul Handrigan
drivers/clk/clk-cs2600.h new file +14 -0
+/* DEVICE_ID2 */
+#define CS2600_AREVID_MASK		GENMASK(7, 4)
+#define CS2600_MTLRVID_MASK		GENMASK(3, 0)
+
+/* UNLOCK_INDICATORS */
+#define CS2600_P_UNLOCK_STICKY		BIT(3)
+#define CS2600_P_UNLOCK			BIT(2)
+#define CS2600_F_UNLOCK_STICKY		BIT(1)
+#define CS2600_F_UNLOCK			BIT(0)
+
+/* ERROR_STS */
+#define CS2600_ERR_DEV_DEFECT		BIT(7) /* Device defective */
+#define CS2600_ERR_OTP_CORRUPT		BIT(6)
+#define CS2600_ERR_REG_CFG		BIT(5) /* Invalid register config */

drivers/clk/clk-cs2600.h line 118

Quoted 10 lines
drivers/clk/clk-cs2600.h new file +10 -0
+#define CS2600_ERR_PLL_DISABLED		BIT(4)
+#define CS2600_ERR_HW_CFG		BIT(3) /* Invalid HW Config */
+#define CS2600_ERR_REFCLK_MISSING	BIT(2)
+#define CS2600_ERR_CLKIN_UNSTABLE	BIT(1)
+#define CS2600_ERR_CLKIN_MISSING	BIT(0)
+
+#define CS2600_PLL_OUT			0
+#define CS2600_CLK_OUT			1
+#define CS2600_BCLK_OUT			2
+#define CS2600_FSYNC_OUT		3

No, the entire point of the binding header is to bind. Drop all four above and use properly your header.

Quoted 3 lines

Otherwise I claim your binding header is not used or not really a binding.

This excert is from the drivers internal header not the binding header?

Thanks,
Charles

#14 lore raw

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

Quoted 30 lines · Charles Keepax
Quoted 29 lines · Krzysztof Kozlowski
Quoted 14 lines · Paul Handrigan
drivers/clk/clk-cs2600.h new file +14 -0
+/* DEVICE_ID2 */
+#define CS2600_AREVID_MASK		GENMASK(7, 4)
+#define CS2600_MTLRVID_MASK		GENMASK(3, 0)
+
+/* UNLOCK_INDICATORS */
+#define CS2600_P_UNLOCK_STICKY		BIT(3)
+#define CS2600_P_UNLOCK			BIT(2)
+#define CS2600_F_UNLOCK_STICKY		BIT(1)
+#define CS2600_F_UNLOCK			BIT(0)
+
+/* ERROR_STS */
+#define CS2600_ERR_DEV_DEFECT		BIT(7) /* Device defective */
+#define CS2600_ERR_OTP_CORRUPT		BIT(6)
+#define CS2600_ERR_REG_CFG		BIT(5) /* Invalid register config */

drivers/clk/clk-cs2600.h line 118

Quoted 10 lines
drivers/clk/clk-cs2600.h new file +10 -0
+#define CS2600_ERR_PLL_DISABLED		BIT(4)
+#define CS2600_ERR_HW_CFG		BIT(3) /* Invalid HW Config */
+#define CS2600_ERR_REFCLK_MISSING	BIT(2)
+#define CS2600_ERR_CLKIN_UNSTABLE	BIT(1)
+#define CS2600_ERR_CLKIN_MISSING	BIT(0)
+
+#define CS2600_PLL_OUT			0
+#define CS2600_CLK_OUT			1
+#define CS2600_BCLK_OUT			2
+#define CS2600_FSYNC_OUT		3

No, the entire point of the binding header is to bind. Drop all four above and use properly your header.

Quoted 6 lines
Quoted 3 lines

Otherwise I claim your binding header is not used or not really a binding.

This excert is from the drivers internal header not the binding header?

I replied in patch two, stripping unnecessary context. There is no binding header here, so I do not understand your comment.

Best regards,
Krzysztof

#15 lore raw

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

Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · Charles Keepax
Quoted 9 lines · Krzysztof Kozlowski

drivers/clk/clk-cs2600.h line 118

Quoted 4 lines · Paul Handrigan
drivers/clk/clk-cs2600.h new file +4 -0
+#define CS2600_PLL_OUT			0
+#define CS2600_CLK_OUT			1
+#define CS2600_BCLK_OUT			2
+#define CS2600_FSYNC_OUT		3

No, the entire point of the binding header is to bind. Drop all four above and use properly your header.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Otherwise I claim your binding header is not used or not really a binding.

This excert is from the drivers internal header not the binding header?

I replied in patch two, stripping unnecessary context. There is no binding header here, so I do not understand your comment.

Ah sorry yes my bad, you mean drop these defines and use the ones from the binding header instead.

Thanks,
Charles

#16 lore raw

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

Quoted 15 lines · Charles Keepax
Quoted 14 lines · Krzysztof Kozlowski
Quoted 13 lines · Charles Keepax
Quoted 11 lines · Krzysztof Kozlowski

drivers/clk/clk-cs2600.h line 118

Quoted 4 lines · Paul Handrigan
drivers/clk/clk-cs2600.h new file +4 -0
+#define CS2600_PLL_OUT			0
+#define CS2600_CLK_OUT			1
+#define CS2600_BCLK_OUT			2
+#define CS2600_FSYNC_OUT		3

No, the entire point of the binding header is to bind. Drop all four above and use properly your header.

Otherwise I claim your binding header is not used or not really a binding.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

This excert is from the drivers internal header not the binding header?

I replied in patch two, stripping unnecessary context. There is no binding header here, so I do not understand your comment.

Ah sorry yes my bad, you mean drop these defines and use the ones from the binding header instead.

Yes, otherwise binding is basically useless...

Best regards,
Krzysztof