Skip to contentSkip to conversation

clk: qcom: Drop use of pxo/cxo_board for rpm devices

PATCH Applied Christian Marangi 3 participants 9 messages Jul 6, 2022 – Jul 19, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover clk: qcom: Drop use of pxo/cxo_board for rpm devices

Trying to convert every driver used by ipq806x to parent_data api, I notice RPM was still using pxo_board clk.

pxo and pxo_board are the same clock and are defined just to handle old clock definition. It was discovered that rpm is the last driver using pxo_board instead of pxo.

While updating the rpm driver I notice the documentation was also wrong, so this series also fix that.

v2:
- Add review tag to DTS patch
- Drop clock-output-names patch
- Use pxo/cxo_board clock names
- Remove if nesting from Documentation
- Use min/maxItems in Documentation to describe clocks

Christian Marangi (4):
dt-bindings: clock: fix wrong clock documentation for qcom,rpmcc
ARM: DTS: qcom: add rpmcc missing clocks for apq/ipq8064 and msm8660
clk: qcom: clk-rpm: convert to parent_data API
clk: qcom: gcc-ipq806x: remove cc_register_board for pxo and cxo

 .../devicetree/bindings/clock/qcom,rpmcc.yaml | 85 ++++++++++++++++++-
 arch/arm/boot/dts/qcom-apq8064.dtsi           |  2 +
 arch/arm/boot/dts/qcom-ipq8064.dtsi           |  2 +
 arch/arm/boot/dts/qcom-msm8660.dtsi           |  4 +-
 drivers/clk/qcom/clk-rpm.c                    | 24 ++++--
 drivers/clk/qcom/gcc-ipq806x.c                |  8 --
 6 files changed, 106 insertions(+), 19 deletions(-)
Signature · 1 line
2.36.1
#1 lore raw

PATCH v2 1/4 dt-bindings: clock: fix wrong clock documentation for qcom,rpmcc

qcom,rpmcc describe 2 different kind of device. Currently we have definition for rpm-smd based device but we lack Documentation for simple rpm based device.

Add the missing clk for ipq806x, apq8060, msm8660 and apq8064 and provide additional example to describe these new simple rpm based devices.

---
 .../devicetree/bindings/clock/qcom,rpmcc.yaml | 85 ++++++++++++++++++-
 1 file changed, 83 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/qcom,rpmcc.yaml +83 -2
index 9d296b89a8d0..d63b45ad06e8 100644
@@ -49,15 +49,86 @@ properties:
     const: 1
 
   clocks:
-    maxItems: 1
+    minItems: 1
+    maxItems: 2
 
   clock-names:
-    const: xo
+    minItems: 1
+    maxItems: 2
 
 required:
   - compatible
   - '#clock-cells'
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - qcom,rpmcc-apq8060
+              - qcom,rpmcc-ipq806x
+              - qcom,rpmcc-msm8660
+
+    then:
+      properties:
+        clocks:
+          items:
+            - description: pxo clock
+
+        clock-names:
+          items:
+            - const: pxo
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: qcom,rpmcc-apq8064
+    then:
+      properties:
+        clocks:
+          items:
+            - description: pxo clock
+            - description: cxo clock
+
+        clock-names:
+          items:
+            - const: pxo
+            - const: cxo
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - qcom,rpmcc-mdm9607
+              - qcom,rpmcc-msm8226
+              - qcom,rpmcc-msm8916
+              - qcom,rpmcc-msm8936
+              - qcom,rpmcc-msm8953
+              - qcom,rpmcc-msm8974
+              - qcom,rpmcc-msm8976
+              - qcom,rpmcc-msm8992
+              - qcom,rpmcc-msm8994
+              - qcom,rpmcc-msm8996
+              - qcom,rpmcc-msm8998
+              - qcom,rpmcc-qcm2290
+              - qcom,rpmcc-qcs404
+              - qcom,rpmcc-sdm660
+              - qcom,rpmcc-sm6115
+              - qcom,rpmcc-sm6125
+
+    then:
+      properties:
+        clocks:
+          items:
+            - description: xo clock
+
+        clock-names:
+          items:
+            - const: xo
+
 additionalProperties: false
 
 examples:
@@ -73,3 +144,13 @@ examples:
             };
         };
     };
+
+  - |
+    rpm {
+        clock-controller {
+            compatible = "qcom,rpmcc-ipq806x", "qcom,rpmcc";
+            #clock-cells = <1>;
+            clocks = <&pxo_board>;
+            clock-names = "pxo";
+        };
+    };
Signature · 1 line
2.36.1
maintainer Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] dt-bindings: clock: fix wrong clock documentation for qcom,rpmcc

Quoted 4 lines · Christian Marangi

qcom,rpmcc describe 2 different kind of device. Currently we have definition for rpm-smd based device but we lack Documentation for simple rpm based device.

Quoted 9 lines

Add the missing clk for ipq806x, apq8060, msm8660 and apq8064 and provide additional example to describe these new simple rpm based devices.

---
 .../devicetree/bindings/clock/qcom,rpmcc.yaml | 85 ++++++++++++++++++-
 1 file changed, 83 insertions(+), 2 deletions(-)
#3 lore raw

PATCH v2 2/4 ARM: DTS: qcom: add rpmcc missing clocks for apq/ipq8064 and msm8660

In reply to Christian Marangi

Add missing rpmcc pxo and cxo clock for apq8064, ipq8064 and msm8660 dtsi.

---
 arch/arm/boot/dts/qcom-apq8064.dtsi | 2 ++
 arch/arm/boot/dts/qcom-ipq8064.dtsi | 2 ++
 arch/arm/boot/dts/qcom-msm8660.dtsi | 4 +++-
 3 files changed, 7 insertions(+), 1 deletion(-)
arch/arm/boot/dts/qcom-apq8064.dtsi +2 -0
index 91adcbd54b17..6a88e616ea01 100644
@@ -853,6 +853,8 @@ rpm@108000 {
 			rpmcc: clock-controller {
 				compatible = "qcom,rpmcc-apq8064", "qcom,rpmcc";
 				#clock-cells = <1>;
+				clocks = <&pxo_board>, <&cxo_board>;
+				clock-names = "pxo", "cxo";
 			};
 
 			regulators {
arch/arm/boot/dts/qcom-ipq8064.dtsi +2 -0
index 4b475d98343c..1425a4e4283f 100644
@@ -773,6 +773,8 @@ rpm: rpm@108000 {
 			rpmcc: clock-controller {
 				compatible = "qcom,rpmcc-ipq806x", "qcom,rpmcc";
 				#clock-cells = <1>;
+				clocks = <&pxo_board>;
+				clock-names = "pxo";
 			};
 		};
 
arch/arm/boot/dts/qcom-msm8660.dtsi +3 -1
index b9cded35b1cc..63a501c63cf8 100644
@@ -56,7 +56,7 @@ cxo_board {
 			clock-frequency = <19200000>;
 		};
 
-		pxo_board {
+		pxo_board: pxo_board {
 			compatible = "fixed-clock";
 			#clock-cells = <0>;
 			clock-frequency = <27000000>;
@@ -411,6 +411,8 @@ rpm: rpm@104000 {
 			rpmcc: clock-controller {
 				compatible = "qcom,rpmcc-msm8660", "qcom,rpmcc";
 				#clock-cells = <1>;
+				clocks = <&pxo_board>;
+				clock-names = "pxo";
 			};
 
 			pm8901-regulators {
Signature · 1 line
2.36.1
#4 lore raw

PATCH v2 3/4 clk: qcom: clk-rpm: convert to parent_data API

In reply to Christian Marangi

Convert clk-rpm driver to parent_data API.
We keep the old pxo/cxo_board parent naming to keep compatibility with old DT and we use the new pxo/cxo for new implementation where these clock are defined in DTS.

---
 drivers/clk/qcom/clk-rpm.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/clk/qcom/clk-rpm.c +16 -8
index a18811c38018..747c473b0b5e 100644
@@ -23,6 +23,14 @@
 #define QCOM_RPM_SCALING_ENABLE_ID			0x2
 #define QCOM_RPM_XO_MODE_ON				0x2
 
+static const struct clk_parent_data gcc_pxo[] = {
+	{ .fw_name = "pxo", .name = "pxo_board" },
+};
+
+static const struct clk_parent_data gcc_cxo[] = {
+	{ .fw_name = "cxo", .name = "cxo_board" },
+};
+
 #define DEFINE_CLK_RPM(_platform, _name, _active, r_id)			      \
 	static struct clk_rpm _platform##_##_active;			      \
 	static struct clk_rpm _platform##_##_name = {			      \
@@ -32,8 +40,8 @@
 		.hw.init = &(struct clk_init_data){			      \
 			.ops = &clk_rpm_ops,				      \
 			.name = #_name,					      \
-			.parent_names = (const char *[]){ "pxo_board" },      \
-			.num_parents = 1,				      \
+			.parent_data = gcc_pxo,				      \
+			.num_parents = ARRAY_SIZE(gcc_pxo),		      \
 		},							      \
 	};								      \
 	static struct clk_rpm _platform##_##_active = {			      \
@@ -44,8 +52,8 @@
 		.hw.init = &(struct clk_init_data){			      \
 			.ops = &clk_rpm_ops,				      \
 			.name = #_active,				      \
-			.parent_names = (const char *[]){ "pxo_board" },      \
-			.num_parents = 1,				      \
+			.parent_data = gcc_pxo,				      \
+			.num_parents = ARRAY_SIZE(gcc_pxo),		      \
 		},							      \
 	}
 
@@ -56,8 +64,8 @@
 		.hw.init = &(struct clk_init_data){			      \
 			.ops = &clk_rpm_xo_ops,			      \
 			.name = #_name,					      \
-			.parent_names = (const char *[]){ "cxo_board" },      \
-			.num_parents = 1,				      \
+			.parent_data = gcc_cxo,				      \
+			.num_parents = ARRAY_SIZE(gcc_cxo),		      \
 		},							      \
 	}
 
@@ -68,8 +76,8 @@
 		.hw.init = &(struct clk_init_data){			      \
 			.ops = &clk_rpm_fixed_ops,			      \
 			.name = #_name,					      \
-			.parent_names = (const char *[]){ "pxo" },	      \
-			.num_parents = 1,				      \
+			.parent_data = gcc_pxo,				      \
+			.num_parents = ARRAY_SIZE(gcc_pxo),		      \
 		},							      \
 	}
 
Signature · 1 line
2.36.1
#5 lore raw

PATCH v2 4/4 clk: qcom: gcc-ipq806x: remove cc_register_board for pxo and cxo

In reply to Christian Marangi

Now that these clock are defined as fixed clk in dts, we can drop the register_board_clk for cxo_board and pxo_board in gcc_ipq806x_probe.

---
 drivers/clk/qcom/gcc-ipq806x.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/clk/qcom/gcc-ipq806x.c +0 -8
index 718de17a1e60..883629de2751 100644
@@ -3384,14 +3384,6 @@ static int gcc_ipq806x_probe(struct platform_device *pdev)
 	struct regmap *regmap;
 	int ret;
 
-	ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 25000000);
-	if (ret)
-		return ret;
-
-	ret = qcom_cc_register_board_clk(dev, "pxo_board", "pxo", 25000000);
-	if (ret)
-		return ret;
-
 	if (of_machine_is_compatible("qcom,ipq8065")) {
 		ubi32_core1_src_clk.freq_tbl = clk_tbl_nss_ipq8065;
 		ubi32_core2_src_clk.freq_tbl = clk_tbl_nss_ipq8065;
Signature · 1 line
2.36.1
#6 lore raw

Re: [PATCH v2 4/4] clk: qcom: gcc-ipq806x: remove cc_register_board for pxo and cxo

Quoted 3 lines · Christian Marangi

Now that these clock are defined as fixed clk in dts, we can drop the register_board_clk for cxo_board and pxo_board in gcc_ipq806x_probe.

Are you trying to say, that now that we have .fw_name based lookup of these clocks we don't need the globally registered [cp]xo clocks to bridge towards the [cp]xo_board_clocks which was introduced in:

30fc4212d541 ("arm: dts: qcom: Add more board clocks")

I think this change would work out if you also replace .name = "pxo" with .name = "pxo_board_clk" (and same for cxo)...

But I don't think we can just drop these, as it would break compatibility with existing devicetree.

Regards,
Bjorn

Quoted 27 lines
---
 drivers/clk/qcom/gcc-ipq806x.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/clk/qcom/gcc-ipq806x.c +0 -8
index 718de17a1e60..883629de2751 100644
@@ -3384,14 +3384,6 @@ static int gcc_ipq806x_probe(struct platform_device *pdev)
 	struct regmap *regmap;
 	int ret;
 
-	ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 25000000);
-	if (ret)
-		return ret;
-
-	ret = qcom_cc_register_board_clk(dev, "pxo_board", "pxo", 25000000);
-	if (ret)
-		return ret;
-
 	if (of_machine_is_compatible("qcom,ipq8065")) {
 		ubi32_core1_src_clk.freq_tbl = clk_tbl_nss_ipq8065;
 		ubi32_core2_src_clk.freq_tbl = clk_tbl_nss_ipq8065;
Signature · 1 line
2.36.1
#7 lore raw

Re: [PATCH v2 4/4] clk: qcom: gcc-ipq806x: remove cc_register_board for pxo and cxo

Quoted 6 lines · Bjorn Andersson
Quoted 3 lines · Christian Marangi

Now that these clock are defined as fixed clk in dts, we can drop the register_board_clk for cxo_board and pxo_board in gcc_ipq806x_probe.

Quoted 9 lines

Are you trying to say, that now that we have .fw_name based lookup of these clocks we don't need the globally registered [cp]xo clocks to bridge towards the [cp]xo_board_clocks which was introduced in:

30fc4212d541 ("arm: dts: qcom: Add more board clocks")

I think this change would work out if you also replace .name = "pxo" with .name = "pxo_board_clk" (and same for cxo)...

Mhhh why pxo_board_clk? Why _clk? It should be pxo_board. Anyway about this, only the rpm clocks use pxo_board as parent, everything else use pxo. Aside from rpm and gcc the other user of pxo is the lcc driver and the krait-xcc clock. I sent patches to convert them.

Quoted 3 lines

But I don't think we can just drop these, as it would break compatibility with existing devicetree.

Wonder if we will be able to drop this ever?

Quoted 27 lines
Quoted 27 lines
---
 drivers/clk/qcom/gcc-ipq806x.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/clk/qcom/gcc-ipq806x.c +0 -8
index 718de17a1e60..883629de2751 100644
@@ -3384,14 +3384,6 @@ static int gcc_ipq806x_probe(struct platform_device *pdev)
 	struct regmap *regmap;
 	int ret;
 
-	ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 25000000);
-	if (ret)
-		return ret;
-
-	ret = qcom_cc_register_board_clk(dev, "pxo_board", "pxo", 25000000);
-	if (ret)
-		return ret;
-
 	if (of_machine_is_compatible("qcom,ipq8065")) {
 		ubi32_core1_src_clk.freq_tbl = clk_tbl_nss_ipq8065;
 		ubi32_core2_src_clk.freq_tbl = clk_tbl_nss_ipq8065;
Signature · 1 line
2.36.1
Signature · 1 line
	Ansuel
#8 lore raw

Re: (subset) [PATCH v2 0/4] clk: qcom: Drop use of pxo/cxo_board for rpm devices

In reply to Christian Marangi
Quoted 8 lines · Christian Marangi

Trying to convert every driver used by ipq806x to parent_data api, I notice RPM was still using pxo_board clk.

pxo and pxo_board are the same clock and are defined just to handle old clock definition. It was discovered that rpm is the last driver using pxo_board instead of pxo.

[...]

Applied, thanks!

[2/4] ARM: DTS: qcom: add rpmcc missing clocks for apq/ipq8064 and msm8660

      commit: aa7fd3bb6017b343585e97a909f9b7d2fe174018

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>