Skip to contentSkip to conversation

clk: keystone: Add new driver to handle syscon based clock

PATCH Superseded Vignesh Raghavendra 3 participants 6 messages Mar 12, 2019 – Apr 9, 2019

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover clk: keystone: Add new driver to handle syscon based clock

On TI's K2 and K3 SoCs, certain clocks can be gated/ungated by setting a single bit in SoC's System Control registers. Sometime more than one clock control can be in the same register. But these registers might also have bits to control other SoC functionalities.
For example, Time Base clock(tbclk) enable bits for various EPWM IPs are all in EPWM_CTRL Syscon registers on K2G SoC.

This series adds a new clk driver to support such clocks. Registers which control clocks will be grouped into a syscon DT node, thus enabling sharing of register across clk drivers and other drivers. Each clock node will be child of the syscon node describing offset and bit within the regmap that controls the clock output.

Vignesh Raghavendra (2):
dt-bindings: clock: Add binding documentation for TI syscon gate clock
clk: keystone: Add new driver to handle syscon based clock

 .../bindings/clock/ti,syscon-gate-clock.txt   |  35 +++++
 drivers/clk/keystone/Kconfig                  |   8 +
 drivers/clk/keystone/Makefile                 |   1 +
 drivers/clk/keystone/syscon-clk.c             | 143 ++++++++++++++++++
 4 files changed, 187 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt
 create mode 100644 drivers/clk/keystone/syscon-clk.c
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/2 dt-bindings: clock: Add binding documentation for TI syscon gate clock

Add dt bindings for TI syscon gate clock.

---
 .../bindings/clock/ti,syscon-gate-clock.txt   | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +35 -0
new file mode 100644
index 000000000000..f2bc4281ddba
@@ -0,0 +1,35 @@
+TI syscon gate clock
+
+The gate clock node must be provided inside a system controller node.
+
+Required:
+- comaptible: Must be "ti,syscon-gate-clock"
+- reg: Offset of register that controls the clock within syscon regmap
+- ti,clock-bit-idx: bit index that control gate/ungating of clock
+- clocks: phandle to the clock parent
+- #clock-cells: must be <0>
+
+Example:
+	ctrlmmr_epwm_ctrl: syscon@104140{
+		compatible = "syscon", "simple-bus";
+		reg = <0x0 0x104140 0x0 0x18>;
+		ranges = <0x0 0x0 0x104140>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		ehrpwm0_tbclk: clk@0 {
+			compatible = "ti,syscon-gate-clock";
+			reg = <0x0>;
+			#clock-cells = <0>;
+			clocks = <&k3_clks 40 0>;
+			ti,clock-bit-idx = <0>;
+		};
+
+		ehrpwm1_tbclk: clk@4 {
+			compatible = "ti,syscon-gate-clock";
+			reg = <0x4>;
+			#clock-cells = <0>;
+			clocks = <&k3_clks 41 0>;
+			ti,clock-bit-idx = <0>;
+		};
+	};
Signature · 1 line
2.21.0
#5 lore raw

PATCH 2/2 clk: keystone: Add new driver to handle syscon based clock

In reply to Vignesh Raghavendra

On TI's K2 and K3 SoCs, certain clocks can be gated/ungated by setting a single bit in SoC's System Control Module registers. Sometime more than one clock control can be in the same register.
Add driver to support such clocks. Registers that control clocks will be grouped into a syscon regmap. Each clock node will be child of the syscon node.

---
 drivers/clk/keystone/Kconfig      |   8 ++
 drivers/clk/keystone/Makefile     |   1 +
 drivers/clk/keystone/syscon-clk.c | 143 ++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+)
 create mode 100644 drivers/clk/keystone/syscon-clk.c
drivers/clk/keystone/Kconfig +8 -0
index b04927d06cd1..6a7b80ee62c9 100644
@@ -14,3 +14,11 @@ config TI_SCI_CLK
 	  This adds the clock driver support over TI System Control Interface.
 	  If you wish to use clock resources from the PMMC firmware, say Y.
 	  Otherwise, say N.
+
+config TI_SYSCON_CLK
+	tristate "Syscon based clock driver for K2/K3 SoCs"
+	depends on (ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST) && OF
+	default (ARCH_KEYSTONE || ARCH_K3)
+	help
+	  This adds clock driver support for syscon based gate
+	  clocks on TI's K2 and K3 SoCs.
drivers/clk/keystone/Makefile +1 -0
index c12593966f9b..30e481386316 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_COMMON_CLK_KEYSTONE)	+= pll.o gate.o
 obj-$(CONFIG_TI_SCI_CLK)		+= sci-clk.o
+obj-$(CONFIG_TI_SYSCON_CLK)		+= syscon-clk.o
drivers/clk/keystone/syscon-clk.c new file +143 -0

143 lines not on this page · raw message

Signature · 1 line
2.21.0
maintainer
#2 lore raw

Re: [PATCH 1/2] dt-bindings: clock: Add binding documentation for TI syscon gate clock

In reply to Vignesh Raghavendra
Quoted 18 lines · Vignesh Raghavendra

Add dt bindings for TI syscon gate clock.

---
 .../bindings/clock/ti,syscon-gate-clock.txt   | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +4 -0
new file mode 100644
index 000000000000..f2bc4281ddba
@@ -0,0 +1,35 @@
+TI syscon gate clock
+
+The gate clock node must be provided inside a system controller node.
+

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt line 14

Quoted 10 lines
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +10 -0
+Required:
+- comaptible: Must be "ti,syscon-gate-clock"
+- reg: Offset of register that controls the clock within syscon regmap
+- ti,clock-bit-idx: bit index that control gate/ungating of clock
+- clocks: phandle to the clock parent
+- #clock-cells: must be <0>
+
+Example:
+	ctrlmmr_epwm_ctrl: syscon@104140{
+		compatible = "syscon", "simple-bus";

Can't be both of these...

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt line 25

Quoted 11 lines
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +11 -0
+		reg = <0x0 0x104140 0x0 0x18>;
+		ranges = <0x0 0x0 0x104140>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		ehrpwm0_tbclk: clk@0 {
+			compatible = "ti,syscon-gate-clock";
+			reg = <0x0>;
+			#clock-cells = <0>;
+			clocks = <&k3_clks 40 0>;
+			ti,clock-bit-idx = <0>;

This would imply you have multiple nodes at one address which is discouraged.

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt line 26

Quoted 1 line
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +1 -0
+		};

We generally don't describe clocks as 1 clock per node. Give the parent a specific compatible and make it a clock provider.

Quoted 12 lines
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +9 -0
+
+		ehrpwm1_tbclk: clk@4 {
+			compatible = "ti,syscon-gate-clock";
+			reg = <0x4>;
+			#clock-cells = <0>;
+			clocks = <&k3_clks 41 0>;
+			ti,clock-bit-idx = <0>;
+		};
+	};
Signature · 1 line
2.21.0
#3 lore raw

Re: [PATCH 1/2] dt-bindings: clock: Add binding documentation for TI syscon gate clock

Quoted 23 lines · Rob Herring
Quoted 22 lines · Vignesh Raghavendra

Add dt bindings for TI syscon gate clock.

---
  .../bindings/clock/ti,syscon-gate-clock.txt   | 35 +++++++++++++++++++
  1 file changed, 35 insertions(+)

create mode 100644 Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +8 -0
new file mode 100644
index 000000000000..f2bc4281ddba
@@ -0,0 +1,35 @@
+TI syscon gate clock
+
+The gate clock node must be provided inside a system controller node.
+
+Required:
+- comaptible: Must be "ti,syscon-gate-clock"
+- reg: Offset of register that controls the clock within syscon regmap
+- ti,clock-bit-idx: bit index that control gate/ungating of clock
Quoted 8 lines

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt line 14

Quoted 6 lines
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +6 -0
+- clocks: phandle to the clock parent
+- #clock-cells: must be <0>
+
+Example:
+	ctrlmmr_epwm_ctrl: syscon@104140{
+		compatible = "syscon", "simple-bus";

Can't be both of these...

Is this a hard requirement? We seem to have few instances in the various DTS files for various vendors where this is done, syscon is paired with simple-mfd or simple-bus, or something else.

Basically, syscon by itself does not probe its children, and you can't have the simple syscon support from kernel side if you don't have the syscon compatible. Alternative is that we don't add any of the syscon children under the syscon but add them as separate nodes outside it.

The above is not an issue for this patch itself if we ditch the separate clock nodes, but it is more of a question about the syscon functionality itself.

-Tero

Quoted 21 lines

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt line 25

Quoted 12 lines
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +11 -0
+		reg = <0x0 0x104140 0x0 0x18>;
+		ranges = <0x0 0x0 0x104140>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		ehrpwm0_tbclk: clk@0 {
+			compatible = "ti,syscon-gate-clock";
+			reg = <0x0>;
+			#clock-cells = <0>;
+			clocks = <&k3_clks 40 0>;
+			ti,clock-bit-idx = <0>;

This would imply you have multiple nodes at one address which is discouraged.

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt line 26

Quoted 1 line
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +1 -0
+		};

We generally don't describe clocks as 1 clock per node. Give the parent a specific compatible and make it a clock provider.

Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +9 -0
+
+		ehrpwm1_tbclk: clk@4 {
+			compatible = "ti,syscon-gate-clock";
+			reg = <0x4>;
+			#clock-cells = <0>;
+			clocks = <&k3_clks 41 0>;
+			ti,clock-bit-idx = <0>;
+		};
+	};
Signature · 1 line
2.21.0

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

#4 lore raw

Re: [PATCH 1/2] dt-bindings: clock: Add binding documentation for TI syscon gate clock

In reply to Rob Herring

Hi Rob,

Quoted 23 lines · Rob Herring
Quoted 22 lines · Vignesh Raghavendra

Add dt bindings for TI syscon gate clock.

---
 .../bindings/clock/ti,syscon-gate-clock.txt   | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +8 -0
new file mode 100644
index 000000000000..f2bc4281ddba
@@ -0,0 +1,35 @@
+TI syscon gate clock
+
+The gate clock node must be provided inside a system controller node.
+
+Required:
+- comaptible: Must be "ti,syscon-gate-clock"
+- reg: Offset of register that controls the clock within syscon regmap
+- ti,clock-bit-idx: bit index that control gate/ungating of clock
Quoted 9 lines

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt line 14

Quoted 6 lines
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +6 -0
+- clocks: phandle to the clock parent
+- #clock-cells: must be <0>
+
+Example:
+	ctrlmmr_epwm_ctrl: syscon@104140{
+		compatible = "syscon", "simple-bus";

Can't be both of these...

These registers have bits that control other functionalities apart from PWM clocks. Therefore, I modeled them as "syscon", "simple-bus";

Or is it recommended to use:
compatible = "syscon", "simple-mfd";

Quoted 15 lines

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt line 25

Quoted 11 lines
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +11 -0
+		reg = <0x0 0x104140 0x0 0x18>;
+		ranges = <0x0 0x0 0x104140>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		ehrpwm0_tbclk: clk@0 {
+			compatible = "ti,syscon-gate-clock";
+			reg = <0x0>;
+			#clock-cells = <0>;
+			clocks = <&k3_clks 40 0>;
+			ti,clock-bit-idx = <0>;

This would imply you have multiple nodes at one address which is discouraged.

Quoted 5 lines

Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt line 26

Quoted 1 line
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +1 -0
+		};

We generally don't describe clocks as 1 clock per node. Give the parent a specific compatible and make it a clock provider.

Ok, I can change this to single clock node and use #clock-cells to pass register offset of and bit index from each consumer:

       ctrlmmr_epwm_ctrl: syscon@104140{
               compatible = "syscon", "simple-mfd";
               reg = <0x0 0x104140 0x0 0x18>;
               ranges = <0x0 0x0 0x104140>;
               #address-cells = <1>;
               #size-cells = <0>;

               ehrpwm_tbclk: clk {
                       compatible = "ti,syscon-gate-clock";
                       #clock-cells = <2>;
               };
	};

And consumer node:

       ehrpwm1: pwm@3010000 {
               compatible = "ti,am654-ehrpwm", "ti,am3352-ehrpwm";
               #pwm-cells = <3>;
               reg = <0x0 0x3000000 0x0 0x100>;
               power-domains = <&k3_pds 40>;
               clocks = <&ehrpwm_tbclk 4 0>; /* offset 4, bit 0 */
	       clock-names = "tbclk";
       };

Would that be acceptable?

Regards
Vignesh

Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/clock/ti,syscon-gate-clock.txt new file +9 -0
+
+		ehrpwm1_tbclk: clk@4 {
+			compatible = "ti,syscon-gate-clock";
+			reg = <0x4>;
+			#clock-cells = <0>;
+			clocks = <&k3_clks 41 0>;
+			ti,clock-bit-idx = <0>;
+		};
+	};
Signature · 1 line
2.21.0