Skip to contentSkip to conversation

SDM670 Global Clocks

PATCH Applied Richard Acayan 2 participants 5 messages Sep 14, 2022 – Sep 15, 2022

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

v4 cover SDM670 Global Clocks

Changes since v3:
- rebase onto next-20220913
- accumulate review tags

Changes since v2:
- drop GCC_SDCC1_BCR reset
- reorder gcc-sdm845 and gcc-sdm670 if statements in bindings
- add space
- accumulate review tags

Changes since v1:
- regenerate patches to fixed malformed patch
- fix schema so that the parent clocks are specified correctly
- remove core_bi_test_pll_se from new parent_data to match array sizes
- reference correct frequency table for gcc_sdm670_cpuss_rbcpr_clk_src
- set correct index for sdcc1_ice_core_clk_src

This patch series adds global clocks essential for features of the Qualcomm Snapdragon 670 (hopefully) cleanly into the SDM845 driver without doing runtime fixups like in Google's bonito kernel (see patch 3).

This series (mostly patch 2) affects kernels made for Snapdragon 845 and might need some further testing on SDM845 devices. I do not have a Snapdragon 845-based device so someone else will have to double check if necessary.

 .../devicetree/bindings/clock/qcom,gcc-sdm845.yaml |  59 ++-
 drivers/clk/qcom/Kconfig                           |   4 +-
 drivers/clk/qcom/gcc-sdm845.c                      | 400 ++++++++++++++++++++-
 include/dt-bindings/clock/qcom,gcc-sdm845.h        |   1 +
 4 files changed, 447 insertions(+), 17 deletions(-)
#1 lore raw

PATCH v4 1/3 dt-bindings: clock: gcc-sdm845: add sdm670 global clocks

The Snapdragon 670 clocks will be added into the sdm845 gcc driver. Most of the new clocks, GDSCs, and resets already have reserved IDs but there are some resources that don't. Add the new clock from Snapdragon 670 and document the differences between the SoC parent clocks.

---
 .../bindings/clock/qcom,gcc-sdm845.yaml       | 59 +++++++++++++++----
 include/dt-bindings/clock/qcom,gcc-sdm845.h   |  1 +
 2 files changed, 47 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/clock/qcom,gcc-sdm845.yaml +46 -13
index 610332a6af14..e169d46c78f8 100644
@@ -19,23 +19,17 @@ description: |
 
 properties:
   compatible:
-    const: qcom,gcc-sdm845
+    enum:
+      - qcom,gcc-sdm670
+      - qcom,gcc-sdm845
 
   clocks:
-    items:
-      - description: Board XO source
-      - description: Board active XO source
-      - description: Sleep clock source
-      - description: PCIE 0 Pipe clock source
-      - description: PCIE 1 Pipe clock source
+    minItems: 3
+    maxItems: 5
 
   clock-names:
-    items:
-      - const: bi_tcxo
-      - const: bi_tcxo_ao
-      - const: sleep_clk
-      - const: pcie_0_pipe_clk
-      - const: pcie_1_pipe_clk
+    minItems: 3
+    maxItems: 5
 
   power-domains:
     maxItems: 1
@@ -45,6 +39,45 @@ required:
 
 allOf:
   - $ref: qcom,gcc.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: qcom,gcc-sdm670
+    then:
+      properties:
+        clocks:
+          items:
+            - description: Board XO source
+            - description: Board active XO source
+            - description: Sleep clock source
+        clock-names:
+          items:
+            - const: bi_tcxo
+            - const: bi_tcxo_ao
+            - const: sleep_clk
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: qcom,gcc-sdm845
+    then:
+      properties:
+        clocks:
+          items:
+            - description: Board XO source
+            - description: Board active XO source
+            - description: Sleep clock source
+            - description: PCIE 0 Pipe clock source
+            - description: PCIE 1 Pipe clock source
+        clock-names:
+          items:
+            - const: bi_tcxo
+            - const: bi_tcxo_ao
+            - const: sleep_clk
+            - const: pcie_0_pipe_clk
+            - const: pcie_1_pipe_clk
 
 unevaluatedProperties: false
 
include/dt-bindings/clock/qcom,gcc-sdm845.h +1 -0
index 968fa65b9c42..d78b899263a2 100644
@@ -199,6 +199,7 @@
 #define GCC_QSPI_CNOC_PERIPH_AHB_CLK				189
 #define GCC_LPASS_Q6_AXI_CLK					190
 #define GCC_LPASS_SWAY_CLK					191
+#define GPLL6							192
 
 /* GCC Resets */
 #define GCC_MMSS_BCR						0
Signature · 1 line
2.37.3
#2 lore raw

PATCH v4 2/3 clk: qcom: gcc-sdm845: use device tree match data

In reply to Richard Acayan

This driver will support more than one SoC's set of clocks, and set of GDSCs. This behavior would be unclean with hard-coded static variables. Support it by grabbing clocks, GDSCs, and BCRs in the match data.

---
 drivers/clk/qcom/gcc-sdm845.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sdm845.c +4 -2
index 58aa3ec9a7fc..cd6e4e41dc9b 100644
@@ -3574,7 +3574,7 @@ static const struct qcom_cc_desc gcc_sdm845_desc = {
 };
 
 static const struct of_device_id gcc_sdm845_match_table[] = {
-	{ .compatible = "qcom,gcc-sdm845" },
+	{ .compatible = "qcom,gcc-sdm845", .data = &gcc_sdm845_desc },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, gcc_sdm845_match_table);
@@ -3600,6 +3600,7 @@ static const struct clk_rcg_dfs_data gcc_dfs_clocks[] = {
 
 static int gcc_sdm845_probe(struct platform_device *pdev)
 {
+	const struct qcom_cc_desc *gcc_desc;
 	struct regmap *regmap;
 	int ret;
 
@@ -3616,7 +3617,8 @@ static int gcc_sdm845_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	return qcom_cc_really_probe(pdev, &gcc_sdm845_desc, regmap);
+	gcc_desc = of_device_get_match_data(&pdev->dev);
+	return qcom_cc_really_probe(pdev, gcc_desc, regmap);
 }
 
 static struct platform_driver gcc_sdm845_driver = {
Signature · 1 line
2.37.3
#3 lore raw

PATCH v4 3/3 clk: qcom: gcc-sdm845: add sdm670 global clock data

In reply to Richard Acayan

The Snapdragon 670 adds and removes some clocks, adds new frequencies, and adds a new GPLL (Global Phase-Locked Loop) in reference to SDM845, while also removing some GDSCs. Despite these differences, there are many similarities with SDM670. Add data for SDM670 in the driver for SDM845 to reuse the most of the clock data.

Advantages and disadvantages of this approach:
+ maintenance applies to both sdm670 and sdm845 by default
+ less duplicate code (clocks) means smaller distro/pre-built kernels with all drivers enabled
- clocks for both SoC's must be compiled if the user wants clocks for one specific SoC (both or none)
- additional testing needed for sdm845 devices

---
 drivers/clk/qcom/Kconfig      |   4 +-
 drivers/clk/qcom/gcc-sdm845.c | 394 ++++++++++++++++++++++++++++++++++
 2 files changed, 396 insertions(+), 2 deletions(-)
drivers/clk/qcom/Kconfig +2 -2
index 1cf1ef70e347..17951088b1db 100644
@@ -545,10 +545,10 @@ config QCS_Q6SSTOP_404
 	  controller to reset the Q6SSTOP subsystem.
 
 config SDM_GCC_845
-	tristate "SDM845 Global Clock Controller"
+	tristate "SDM845/SDM670 Global Clock Controller"
 	select QCOM_GDSC
 	help
-	  Support for the global clock controller on SDM845 devices.
+	  Support for the global clock controller on SDM845 and SDM670 devices.
 	  Say Y if you want to use peripheral devices such as UART, SPI,
 	  i2C, USB, UFS, SDDC, PCIe, etc.
 
drivers/clk/qcom/gcc-sdm845.c +394 -0

472 lines not on this page · raw message

Signature · 1 line
2.37.3
maintainer Applied
#4 lore raw
In reply to Richard Acayan
Quoted 11 lines · Richard Acayan

Changes since v3:
- rebase onto next-20220913
- accumulate review tags

Changes since v2:
- drop GCC_SDCC1_BCR reset
- reorder gcc-sdm845 and gcc-sdm670 if statements in bindings
- add space
- accumulate review tags

[...]

Applied, thanks!

[1/3] dt-bindings: clock: gcc-sdm845: add sdm670 global clocks

      commit: 657e9326658c1c570eb1e8fd122a4a7936433673
[2/3] clk: qcom: gcc-sdm845: use device tree match data
      commit: 8e90216d2db99f0b883be3b40d5b581437dc4a5d
[3/3] clk: qcom: gcc-sdm845: add sdm670 global clock data
      commit: ae66b1fe48e2dd91229f2b8f25295bce629382d0

Best regards,

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