Skip to contentSkip to conversation

clk: clocking-wizard: Driver updates

PATCH Superseded Shubhrajyoti Datta 4 participants 10 messages Aug 10, 2021 – Aug 24, 2021

Subsystems (2)

v12 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

v12 cover clk: clocking-wizard: Driver updates

The patch does the following
Update the versions of the clocking wizard ip.
Move from staging to clk directory.
Update the bindings.

v12:
No change.
Rebased

Shubhrajyoti Datta (5):
dt-bindings: add documentation of xilinx clocking wizard
clk: clocking-wizard: Add the clockwizard to clk directory
clk: clocking-wizard: Rename nr-outputs to xlnx,nr-outputs
clk: clocking-wizard: Fix the reconfig for 5.2
clk: clocking-wizard: Update the compatible

 .../bindings/clock/xlnx,clocking-wizard.yaml  |  77 +++
 drivers/clk/Kconfig                           |   9 +
 drivers/clk/Makefile                          |   1 +
 drivers/clk/clk-xlnx-clock-wizard.c           | 643 ++++++++++++++++++
 4 files changed, 730 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml
 create mode 100644 drivers/clk/clk-xlnx-clock-wizard.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH v12 1/5 dt-bindings: add documentation of xilinx clocking wizard

Add the devicetree binding for the xilinx clocking wizard.

---
v6:
Fix a yaml warning
v7:
Add vendor prefix speed-grade
v8:
Fix the warnings
v10:
Add nr-outputs
v11:
add the compatibles for various versions

 rename nr-outputs to xlnx,nr-outputs

v12:
No change

 .../bindings/clock/xlnx,clocking-wizard.yaml  | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml
Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml new file +77 -0
new file mode 100644
index 000000000000..74a121988e92
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/clock/xlnx,clocking-wizard.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Xilinx clocking wizard
+
+maintainers:
+  - Shubhrajyoti Datta <[email protected]>
+
+description:
+  The clocking wizard is a soft ip clocking block of Xilinx versal. It
+  reads required input clock frequencies from the devicetree and acts as clock
+  clock output.
+
+properties:
+  compatible:
+    enum:
+      - xlnx,clocking-wizard
+      - xlnx,clocking-wizard-v5-2 # version 5.2
+      - xlnx,clocking-wizard-v6-0 # version 6.0
+
+
+  reg:
+    maxItems: 1
+
+  "#clock-cells":
+    const: 1
+
+  clocks:
+    items:
+      - description: clock input
+      - description: axi clock
+
+  clock-names:
+    items:
+      - const: clk_in1
+      - const: s_axi_aclk
+
+
+  xlnx,speed-grade:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [1, 2, 3]
+    description:
+      Speed grade of the device. Higher the speed grade faster is the FPGA device.
+
+  xlnx,nr-outputs:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 1
+    maximum: 8
+    description:
+      Number of outputs.
+
+required:
+  - compatible
+  - reg
+  - "#clock-cells"
+  - clocks
+  - clock-names
+  - xlnx,speed-grade
+  - xlnx,nr-outputs
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@b0000000  {
+        compatible = "xlnx,clocking-wizard";
+        reg = <0xb0000000 0x10000>;
+        #clock-cells = <1>;
+        xlnx,speed-grade = <1>;
+        xlnx,nr-outputs = <6>;
+        clock-names = "clk_in1", "s_axi_aclk";
+        clocks = <&clkc 15>, <&clkc 15>;
+    };
+...
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v12 1/5] dt-bindings: add documentation of xilinx clocking wizard

Quoted 38 lines · Shubhrajyoti Datta

Add the devicetree binding for the xilinx clocking wizard.

---
v6:
Fix a yaml warning
v7:
Add vendor prefix speed-grade
v8:
Fix the warnings
v10:
Add nr-outputs
v11:
add the compatibles for various versions

 rename nr-outputs to xlnx,nr-outputs

v12:
No change

 .../bindings/clock/xlnx,clocking-wizard.yaml  | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml
Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml new file +10 -0
new file mode 100644
index 000000000000..74a121988e92
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/clock/xlnx,clocking-wizard.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Xilinx clocking wizard
+
+maintainers:
+  - Shubhrajyoti Datta <[email protected]>

Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml line 20

Quoted 10 lines
Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml new file +10 -0
+
+description:
+  The clocking wizard is a soft ip clocking block of Xilinx versal. It
+  reads required input clock frequencies from the devicetree and acts as clock
+  clock output.
+
+properties:
+  compatible:
+    enum:
+      - xlnx,clocking-wizard

What version is this one?

Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml line 22

Quoted 2 lines
Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml new file +2 -0
+      - xlnx,clocking-wizard-v5-2 # version 5.2
+      - xlnx,clocking-wizard-v6-0 # version 6.0

The comment is pretty pointless. And periods are allowed in compatible strings, so just do '-v5.2'.

Quoted 59 lines
Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml new file +55 -0
+
+
+  reg:
+    maxItems: 1
+
+  "#clock-cells":
+    const: 1
+
+  clocks:
+    items:
+      - description: clock input
+      - description: axi clock
+
+  clock-names:
+    items:
+      - const: clk_in1
+      - const: s_axi_aclk
+
+
+  xlnx,speed-grade:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [1, 2, 3]
+    description:
+      Speed grade of the device. Higher the speed grade faster is the FPGA device.
+
+  xlnx,nr-outputs:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 1
+    maximum: 8
+    description:
+      Number of outputs.
+
+required:
+  - compatible
+  - reg
+  - "#clock-cells"
+  - clocks
+  - clock-names
+  - xlnx,speed-grade
+  - xlnx,nr-outputs
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@b0000000  {
+        compatible = "xlnx,clocking-wizard";
+        reg = <0xb0000000 0x10000>;
+        #clock-cells = <1>;
+        xlnx,speed-grade = <1>;
+        xlnx,nr-outputs = <6>;
+        clock-names = "clk_in1", "s_axi_aclk";
+        clocks = <&clkc 15>, <&clkc 15>;
+    };
+...
Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH v12 1/5] dt-bindings: add documentation of xilinx clocking wizard

Quoted 44 lines · Rob Herring
Quoted 42 lines · Shubhrajyoti Datta

Add the devicetree binding for the xilinx clocking wizard.

---
v6:
Fix a yaml warning
v7:
Add vendor prefix speed-grade
v8:
Fix the warnings
v10:
Add nr-outputs
v11:
add the compatibles for various versions

 rename nr-outputs to xlnx,nr-outputs

v12:
No change

 .../bindings/clock/xlnx,clocking-wizard.yaml  | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml
Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml new file +14 -0
new file mode 100644
index 000000000000..74a121988e92
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/clock/xlnx,clocking-wizard.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Xilinx clocking wizard
+
+maintainers:
+  - Shubhrajyoti Datta <[email protected]>
+
+description:
+  The clocking wizard is a soft ip clocking block of Xilinx versal. It
+  reads required input clock frequencies from the devicetree and acts as clock
Quoted 8 lines

Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml line 20

Quoted 6 lines
Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml new file +6 -0
+  clock output.
+
+properties:
+  compatible:
+    enum:
+      - xlnx,clocking-wizard

What version is this one?

This is kept for backward compatibility the current driver expects this string

Quoted 6 lines

Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml line 22

Quoted 3 lines
Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml new file +2 -0
+      - xlnx,clocking-wizard-v5-2 # version 5.2
+      - xlnx,clocking-wizard-v6-0 # version 6.0

The comment is pretty pointless. And periods are allowed in compatible strings, so just do '-v5.2'.

sure will do.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml new file +5 -0
+
+
+  reg:
+    maxItems: 1
+
#4 lore raw

PATCH v12 2/5 clk: clocking-wizard: Add the clockwizard to clk directory

In reply to Shubhrajyoti Datta

Add clocking wizard driver to clk.
And delete the driver from the staging as it is in drivers/clk.

---

 drivers/clk/Kconfig                 |   9 +
 drivers/clk/Makefile                |   1 +
 drivers/clk/clk-xlnx-clock-wizard.c | 635 ++++++++++++++++++++++++++++
 3 files changed, 645 insertions(+)
 create mode 100644 drivers/clk/clk-xlnx-clock-wizard.c
drivers/clk/Kconfig +9 -0
index e873f9ea2e65..22817be89bd8 100644
@@ -390,6 +390,15 @@ config COMMON_CLK_K210
 	help
 	  Support for the Canaan Kendryte K210 RISC-V SoC clocks.
 
+config COMMON_CLK_XLNX_CLKWZRD
+	tristate "Xilinx Clocking Wizard"
+	depends on COMMON_CLK && OF
+	help
+	  Support for the Xilinx Clocking Wizard IP core clock generator.
+	  Adds support for clocking wizard and compatible.
+	  This driver supports the Xilinx clocking wizard programmable clock
+	  synthesizer. The number of output is configurable in the design.
+
 source "drivers/clk/actions/Kconfig"
 source "drivers/clk/analogbits/Kconfig"
 source "drivers/clk/baikal-t1/Kconfig"
drivers/clk/Makefile +1 -0
index 2b91d34c582b..15a75aa3f351 100644
@@ -68,6 +68,7 @@ obj-$(CONFIG_ARCH_VT8500)		+= clk-vt8500.o
 obj-$(CONFIG_COMMON_CLK_VC5)		+= clk-versaclock5.o
 obj-$(CONFIG_COMMON_CLK_WM831X)		+= clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_XGENE)		+= clk-xgene.o
+obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD)	+= clk-xlnx-clock-wizard.o
 
 # please keep this section sorted lexicographically by directory path name
 obj-y					+= actions/
drivers/clk/clk-xlnx-clock-wizard.c new file +635 -0

635 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw

Re: [PATCH v12 2/5] clk: clocking-wizard: Add the clockwizard to clk directory

Hi Shubhrajyoti,

Thanks for your patch!

Quoted 2 lines · Shubhrajyoti Datta

Add clocking wizard driver to clk.
And delete the driver from the staging as it is in drivers/clk.

The old driver is not deleted from staging?

Quoted 15 lines

---

 drivers/clk/Kconfig                 |   9 +
 drivers/clk/Makefile                |   1 +
 drivers/clk/clk-xlnx-clock-wizard.c | 635 ++++++++++++++++++++++++++++
 3 files changed, 645 insertions(+)
 create mode 100644 drivers/clk/clk-xlnx-clock-wizard.c
drivers/clk/Kconfig +0 -0
index e873f9ea2e65..22817be89bd8 100644

drivers/clk/Kconfig config COMMON_CLK_K210 · line 395

Quoted 6 lines
drivers/clk/Kconfig +3 -0
@@ -390,6 +390,15 @@ config COMMON_CLK_K210
        help
          Support for the Canaan Kendryte K210 RISC-V SoC clocks.
 
+config COMMON_CLK_XLNX_CLKWZRD
+       tristate "Xilinx Clocking Wizard"
+       depends on COMMON_CLK && OF

Should there be a platform dependency ("depends on <FOO> || COMPILE_TEST"), to avoid asking the user about this driver when configuring a kernel for a platform that does not have this device, or can this device be present on any platform?

Despite the original driver having been added 7 years ago, there are no upstream users of "xlnx,clocking-wizard" yet...

drivers/clk/Kconfig config COMMON_CLK_K210 · line 400

Quoted 5 lines
drivers/clk/Kconfig +5 -0
+       help
+         Support for the Xilinx Clocking Wizard IP core clock generator.
+         Adds support for clocking wizard and compatible.
+         This driver supports the Xilinx clocking wizard programmable clock
+         synthesizer. The number of output is configurable in the design.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#6 lore raw

PATCH v12 3/5 clk: clocking-wizard: Rename nr-outputs to xlnx,nr-outputs

In reply to Shubhrajyoti Datta

Rename nr-outputs to xlnx,output.

---
v11:
new patch
v12:
No change

 drivers/clk/clk-xlnx-clock-wizard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-xlnx-clock-wizard.c +1 -1
index ec377f0d569b..1e0818eb0435 100644
@@ -480,7 +480,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
 		goto err_disable_clk;
 	}
 
-	ret = of_property_read_u32(np, "nr-outputs", &nr_outputs);
+	ret = of_property_read_u32(np, "xlnx,nr-outputs", &nr_outputs);
 	if (ret || nr_outputs > WZRD_NUM_OUTPUTS) {
 		ret = -EINVAL;
 		goto err_disable_clk;
Signature · 1 line
2.17.1
#7 lore raw

PATCH v12 4/5 clk: clocking-wizard: Fix the reconfig for 5.2

In reply to Shubhrajyoti Datta

The 5.2 the reconfig is triggered by writing 7 followed by 2 to the reconfig reg. Add the same. Also 6.0 is backward compatible so it should be fine.

---
v11:
new patch
v12:
No change

 drivers/clk/clk-xlnx-clock-wizard.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/clk/clk-xlnx-clock-wizard.c +9 -3
index 1e0818eb0435..61c40e06e381 100644
@@ -44,6 +44,8 @@
 #define WZRD_DR_INIT_REG_OFFSET		0x25C
 #define WZRD_DR_DIV_TO_PHASE_OFFSET	4
 #define WZRD_DR_BEGIN_DYNA_RECONF	0x03
+#define WZRD_DR_BEGIN_DYNA_RECONF_5_2	0x07
+#define WZRD_DR_BEGIN_DYNA_RECONF1_5_2	0x02
 
 #define WZRD_USEC_POLL		10
 #define WZRD_TIMEOUT_POLL		1000
@@ -165,7 +167,9 @@ static int clk_wzrd_dynamic_reconfig(struct clk_hw *hw, unsigned long rate,
 		goto err_reconfig;
 
 	/* Initiate reconfiguration */
-	writel(WZRD_DR_BEGIN_DYNA_RECONF,
+	writel(WZRD_DR_BEGIN_DYNA_RECONF_5_2,
+	       divider->base + WZRD_DR_INIT_REG_OFFSET);
+	writel(WZRD_DR_BEGIN_DYNA_RECONF1_5_2,
 	       divider->base + WZRD_DR_INIT_REG_OFFSET);
 
 	/* Check status register */
@@ -224,7 +228,7 @@ static int clk_wzrd_dynamic_reconfig_f(struct clk_hw *hw, unsigned long rate,
 	struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
 	void __iomem *div_addr = divider->base + divider->offset;
 
-	rate_div = ((parent_rate * 1000) / rate);
+	rate_div = DIV_ROUND_DOWN_ULL(parent_rate * 1000, rate);
 	clockout0_div = rate_div / 1000;
 
 	pre = DIV_ROUND_CLOSEST((parent_rate * 1000), rate);
@@ -246,7 +250,9 @@ static int clk_wzrd_dynamic_reconfig_f(struct clk_hw *hw, unsigned long rate,
 		return err;
 
 	/* Initiate reconfiguration */
-	writel(WZRD_DR_BEGIN_DYNA_RECONF,
+	writel(WZRD_DR_BEGIN_DYNA_RECONF_5_2,
+	       divider->base + WZRD_DR_INIT_REG_OFFSET);
+	writel(WZRD_DR_BEGIN_DYNA_RECONF1_5_2,
 	       divider->base + WZRD_DR_INIT_REG_OFFSET);
 
 	/* Check status register */
Signature · 1 line
2.17.1
#8 lore raw

PATCH v12 5/5 clk: clocking-wizard: Update the compatible

In reply to Shubhrajyoti Datta

Update the compatible to indicate support for both 5.2 and 6.0

---
v11:
new patch
v12:
No change

 drivers/clk/clk-xlnx-clock-wizard.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clk/clk-xlnx-clock-wizard.c +2 -0
index 61c40e06e381..716fea83341a 100644
@@ -621,6 +621,8 @@ static int clk_wzrd_remove(struct platform_device *pdev)
 
 static const struct of_device_id clk_wzrd_ids[] = {
 	{ .compatible = "xlnx,clocking-wizard" },
+	{ .compatible = "xlnx,clocking-wizard-v5-2" },
+	{ .compatible = "xlnx,clocking-wizard-v6-0" },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, clk_wzrd_ids);
Signature · 1 line
2.17.1
#9 lore raw
In reply to Shubhrajyoti Datta

Hi Shubhrajyoti,

Quoted 4 lines · Shubhrajyoti Datta

The patch does the following
Update the versions of the clocking wizard ip.
Move from staging to clk directory.
Update the bindings.

Thanks for your series!

Quoted 3 lines

v12:
No change.
Rebased

There is a change: you lost the move from staging to clk.

Quoted 8 lines

Shubhrajyoti Datta (5):
dt-bindings: add documentation of xilinx clocking wizard
clk: clocking-wizard: Add the clockwizard to clk directory
clk: clocking-wizard: Rename nr-outputs to xlnx,nr-outputs
clk: clocking-wizard: Fix the reconfig for 5.2
clk: clocking-wizard: Update the compatible

Quoted 7 lines
 .../bindings/clock/xlnx,clocking-wizard.yaml  |  77 +++
 drivers/clk/Kconfig                           |   9 +
 drivers/clk/Makefile                          |   1 +
 drivers/clk/clk-xlnx-clock-wizard.c           | 643 ++++++++++++++++++
 4 files changed, 730 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml
 create mode 100644 drivers/clk/clk-xlnx-clock-wizard.c

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds