Skip to contentSkip to conversation

clk: qcom: Add support for SM8550

PATCH Applied Abel Vesa 4 participants 18 messages Nov 30, 2022 – Dec 6, 2022

Subsystems (4)

v4 of 9 Applied Latest is v9 →

lore
Share & tools
lore

Abel Vesa

author
#0 lore raw

v4 cover clk: qcom: Add support for SM8550

This patchset adds clock support for the Qualcomm SM8550 SoC, It adds support for the new type of PLL, the TCSR clock controller driver, support for configurable poll timeout, the RPMh clocks and the bindings.

Changes since v3:
* Dropped the GDSC configurable poll timeout patch, like Stephen suggested
* Added Krzysztof's R-b tag to TCSRCC and GCC binding patches

To: Andy Gross <[email protected]>
To: Bjorn Andersson <[email protected]>
To: Konrad Dybcio <[email protected]>
To: Michael Turquette <[email protected]>
To: Stephen Boyd <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Abel Vesa (9):
dt-bindings: clock: Add SM8550 GCC clocks
dt-bindings: clock: Add SM8550 TCSR CC clocks
clk: qcom: gdsc: Increase status poll timeout
clk: qcom: Add LUCID_OLE PLL type for SM8550
clk: qcom: Add GCC driver for SM8550
dt-bindings: clock: Add RPMHCC for SM8550
dt-bindings: clock: qcom,rpmh: Add CXO PAD clock IDs
clk: qcom: rpmh: Add support for SM8550 rpmh clocks
clk: qcom: Add TCSR clock driver for SM8550

 .../bindings/clock/qcom,rpmhcc.yaml           |    1 +
 .../bindings/clock/qcom,sm8550-gcc.yaml       |   62 +
 .../bindings/clock/qcom,sm8550-tcsrcc.yaml    |   45 +
 drivers/clk/qcom/Kconfig                      |   15 +
 drivers/clk/qcom/Makefile                     |    2 +
 drivers/clk/qcom/clk-alpha-pll.c              |   16 +
 drivers/clk/qcom/clk-alpha-pll.h              |    5 +
 drivers/clk/qcom/clk-rpmh.c                   |  110 +-
 drivers/clk/qcom/gcc-sm8550.c                 | 3388 +++++++++++++++++
 drivers/clk/qcom/gdsc.c                       |    3 +-
 drivers/clk/qcom/tcsrcc-sm8550.c              |  193 +
 include/dt-bindings/clock/qcom,rpmh.h         |    2 +
 include/dt-bindings/clock/qcom,sm8550-gcc.h   |  231 ++
 .../dt-bindings/clock/qcom,sm8550-tcsrcc.h    |   18 +
 14 files changed, 4070 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,sm8550-gcc.yaml
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml
 create mode 100644 drivers/clk/qcom/gcc-sm8550.c
 create mode 100644 drivers/clk/qcom/tcsrcc-sm8550.c
 create mode 100644 include/dt-bindings/clock/qcom,sm8550-gcc.h
 create mode 100644 include/dt-bindings/clock/qcom,sm8550-tcsrcc.h
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v4 1/9 dt-bindings: clock: Add SM8550 GCC clocks

Add device tree bindings for global clock controller on SM8550 SoCs.

---
 .../bindings/clock/qcom,sm8550-gcc.yaml       |  62 +++++
 include/dt-bindings/clock/qcom,sm8550-gcc.h   | 231 ++++++++++++++++++
 2 files changed, 293 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,sm8550-gcc.yaml
 create mode 100644 include/dt-bindings/clock/qcom,sm8550-gcc.h
Documentation/devicetree/bindings/clock/qcom,sm8550-gcc.yaml new file +62 -0
new file mode 100644
index 000000000000..0c706de31cf1
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/qcom,sm8550-gcc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Global Clock & Reset Controller on SM8550
+
+maintainers:
+  - Bjorn Andersson <[email protected]>
+
+description: |
+  Qualcomm global clock control module provides the clocks, resets and power
+  domains on SM8550
+
+  See also:: include/dt-bindings/clock/qcom,sm8550-gcc.h
+
+properties:
+  compatible:
+    const: qcom,sm8550-gcc
+
+  clocks:
+    items:
+      - description: Board XO source
+      - description: Sleep clock source
+      - description: PCIE 0 Pipe clock source
+      - description: PCIE 1 Pipe clock source
+      - description: PCIE 1 Phy Auxiliary clock source
+      - description: UFS Phy Rx symbol 0 clock source
+      - description: UFS Phy Rx symbol 1 clock source
+      - description: UFS Phy Tx symbol 0 clock source
+      - description: USB3 Phy wrapper pipe clock source
+
+required:
+  - compatible
+  - clocks
+
+allOf:
+  - $ref: qcom,gcc.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/qcom,rpmh.h>
+    clock-controller@100000 {
+      compatible = "qcom,sm8550-gcc";
+      reg = <0x00100000 0x001f4200>;
+      clocks = <&rpmhcc RPMH_CXO_CLK>, <&sleep_clk>,
+               <&pcie0_phy>,
+               <&pcie1_phy>,
+               <&pcie_1_phy_aux_clk>,
+               <&ufs_mem_phy 0>,
+               <&ufs_mem_phy 1>,
+               <&ufs_mem_phy 2>,
+               <&usb_1_qmpphy>;
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+      #power-domain-cells = <1>;
+    };
+
+...
include/dt-bindings/clock/qcom,sm8550-gcc.h new file +231 -0

231 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v4 2/9 dt-bindings: clock: Add SM8550 TCSR CC clocks

In reply to Abel Vesa

Add bindings documentation for clock TCSR driver on SM8550.

---
 .../bindings/clock/qcom,sm8550-tcsrcc.yaml    | 45 +++++++++++++++++++
 .../dt-bindings/clock/qcom,sm8550-tcsrcc.h    | 18 ++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml
 create mode 100644 include/dt-bindings/clock/qcom,sm8550-tcsrcc.h
Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml new file +45 -0
new file mode 100644
index 000000000000..b2de251328e4
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/qcom,sm8550-tcsrcc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm TCSR Clock Controller on SM8550
+
+maintainers:
+  - Bjorn Andersson <[email protected]>
+
+description: |
+  Qualcomm TCSR clock control module provides the clocks, resets and
+  power domains on SM8550
+
+  See also:: include/dt-bindings/clock/qcom,sm8550-tcsrcc.h
+
+properties:
+  compatible:
+    const: qcom,sm8550-tcsrcc
+
+  reg:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+
+  '#reset-cells':
+    const: 1
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@1fc0000 {
+      compatible = "qcom,sm8550-tcsrcc";
+      reg = <0x1fc0000 0x30000>;
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+    };
+
+...
include/dt-bindings/clock/qcom,sm8550-tcsrcc.h new file +18 -0
new file mode 100644
index 000000000000..091cb76f953a
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (c) 2022, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022, Linaro Limited
+ */
+
+#ifndef _DT_BINDINGS_CLK_QCOM_TCSR_CC_SM8550_H
+#define _DT_BINDINGS_CLK_QCOM_TCSR_CC_SM8550_H
+
+/* TCSR CC clocks */
+#define TCSR_PCIE_0_CLKREF_EN					0
+#define TCSR_PCIE_1_CLKREF_EN					1
+#define TCSR_UFS_CLKREF_EN					2
+#define TCSR_UFS_PAD_CLKREF_EN					3
+#define TCSR_USB2_CLKREF_EN					4
+#define TCSR_USB3_CLKREF_EN					5
+
+#endif
Signature · 1 line
2.34.1
maintainer
#3 lore raw

Re: [PATCH v4 2/9] dt-bindings: clock: Add SM8550 TCSR CC clocks

Quoted 27 lines · Abel Vesa

Add bindings documentation for clock TCSR driver on SM8550.

---
 .../bindings/clock/qcom,sm8550-tcsrcc.yaml    | 45 +++++++++++++++++++
 .../dt-bindings/clock/qcom,sm8550-tcsrcc.h    | 18 ++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml
 create mode 100644 include/dt-bindings/clock/qcom,sm8550-tcsrcc.h
Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml new file +10 -0
new file mode 100644
index 000000000000..b2de251328e4
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/qcom,sm8550-tcsrcc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm TCSR Clock Controller on SM8550
+
+maintainers:
+  - Bjorn Andersson <[email protected]>

Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml line 20

Quoted 10 lines
Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml new file +10 -0
+
+description: |
+  Qualcomm TCSR clock control module provides the clocks, resets and
+  power domains on SM8550
+
+  See also:: include/dt-bindings/clock/qcom,sm8550-tcsrcc.h
+
+properties:
+  compatible:
+    const: qcom,sm8550-tcsrcc

The block described is the TCSR block, the clock controller represents one of the functions provided. I think it would be more appropriate if the compatible represented the generic nature of the block, even though you currently only care about exposing these clocks.

Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml new file +10 -0
+
+  reg:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+
+  '#reset-cells':
+    const: 1
+

Your clocks are fed by cxo. While there might be reasons for not wire the parent up in the clocks, I think you should represent it in the binding.

Regards,
Bjorn

Quoted 42 lines
Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml new file +15 -0
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@1fc0000 {
+      compatible = "qcom,sm8550-tcsrcc";
+      reg = <0x1fc0000 0x30000>;
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+    };
+
+...
include/dt-bindings/clock/qcom,sm8550-tcsrcc.h new file +18 -0
new file mode 100644
index 000000000000..091cb76f953a
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (c) 2022, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022, Linaro Limited
+ */
+
+#ifndef _DT_BINDINGS_CLK_QCOM_TCSR_CC_SM8550_H
+#define _DT_BINDINGS_CLK_QCOM_TCSR_CC_SM8550_H
+
+/* TCSR CC clocks */
+#define TCSR_PCIE_0_CLKREF_EN					0
+#define TCSR_PCIE_1_CLKREF_EN					1
+#define TCSR_UFS_CLKREF_EN					2
+#define TCSR_UFS_PAD_CLKREF_EN					3
+#define TCSR_USB2_CLKREF_EN					4
+#define TCSR_USB3_CLKREF_EN					5
+
+#endif
Signature · 1 line
2.34.1
author
#4 lore raw

Re: [PATCH v4 2/9] dt-bindings: clock: Add SM8550 TCSR CC clocks

Quoted 35 lines · Bjorn Andersson
Quoted 34 lines · Abel Vesa

Add bindings documentation for clock TCSR driver on SM8550.

---
 .../bindings/clock/qcom,sm8550-tcsrcc.yaml    | 45 +++++++++++++++++++
 .../dt-bindings/clock/qcom,sm8550-tcsrcc.h    | 18 ++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml
 create mode 100644 include/dt-bindings/clock/qcom,sm8550-tcsrcc.h
Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml new file +17 -0
new file mode 100644
index 000000000000..b2de251328e4
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/qcom,sm8550-tcsrcc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm TCSR Clock Controller on SM8550
+
+maintainers:
+  - Bjorn Andersson <[email protected]>
+
+description: |
+  Qualcomm TCSR clock control module provides the clocks, resets and
+  power domains on SM8550
+
+  See also:: include/dt-bindings/clock/qcom,sm8550-tcsrcc.h
+
Quoted 8 lines

Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml line 20

Quoted 3 lines
Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml new file +3 -0
+properties:
+  compatible:
+    const: qcom,sm8550-tcsrcc

The block described is the TCSR block, the clock controller represents one of the functions provided. I think it would be more appropriate if the compatible represented the generic nature of the block, even though you currently only care about exposing these clocks.

I think there is a rule that says the compatible string to be the same as the schema filename.

Should I then also rename the schema file and also the binding IDs header? Like qcom,sm8550-tcsr.yaml and qcom,sm8550-tcsr.h ?

Quoted 15 lines

Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml line 30

Quoted 11 lines
Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml new file +10 -0
+
+  reg:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+
+  '#reset-cells':
+    const: 1
+

Your clocks are fed by cxo. While there might be reasons for not wire the parent up in the clocks, I think you should represent it in the binding.

Right, will document the clocks property as well and describe the clock as xo-board.

Quoted 46 lines

Regards,
Bjorn

Quoted 42 lines
Documentation/devicetree/bindings/clock/qcom,sm8550-tcsrcc.yaml new file +15 -0
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@1fc0000 {
+      compatible = "qcom,sm8550-tcsrcc";
+      reg = <0x1fc0000 0x30000>;
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+    };
+
+...
include/dt-bindings/clock/qcom,sm8550-tcsrcc.h new file +18 -0
new file mode 100644
index 000000000000..091cb76f953a
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (c) 2022, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022, Linaro Limited
+ */
+
+#ifndef _DT_BINDINGS_CLK_QCOM_TCSR_CC_SM8550_H
+#define _DT_BINDINGS_CLK_QCOM_TCSR_CC_SM8550_H
+
+/* TCSR CC clocks */
+#define TCSR_PCIE_0_CLKREF_EN					0
+#define TCSR_PCIE_1_CLKREF_EN					1
+#define TCSR_UFS_CLKREF_EN					2
+#define TCSR_UFS_PAD_CLKREF_EN					3
+#define TCSR_USB2_CLKREF_EN					4
+#define TCSR_USB3_CLKREF_EN					5
+
+#endif
Signature · 1 line
2.34.1
author
#5 lore raw

PATCH v4 3/9 clk: qcom: gdsc: Increase status poll timeout

In reply to Abel Vesa

The SM8550 GCC GDSCs need a higher timeout value when polling for status, so increase it to 1500us, while leaving the delay between disable-enable sequence for votable gdscs to stay the same.

---
 drivers/clk/qcom/gdsc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/qcom/gdsc.c +2 -1
index 0f21a8a767ac..9e4d6ce891aa 100644
@@ -46,6 +46,7 @@
 #define RETAIN_MEM		BIT(14)
 #define RETAIN_PERIPH		BIT(13)
 
+#define STATUS_POLL_TIMEOUT_US	1500
 #define TIMEOUT_US		500
 
 #define domain_to_gdsc(domain) container_of(domain, struct gdsc, pd)
@@ -107,7 +108,7 @@ static int gdsc_poll_status(struct gdsc *sc, enum gdsc_status status)
 	do {
 		if (gdsc_check_status(sc, status))
 			return 0;
-	} while (ktime_us_delta(ktime_get(), start) < TIMEOUT_US);
+	} while (ktime_us_delta(ktime_get(), start) < STATUS_POLL_TIMEOUT_US);
 
 	if (gdsc_check_status(sc, status))
 		return 0;
Signature · 1 line
2.34.1
Reviewed-by on v4 3/9
#6 lore raw

Re: [PATCH v4 3/9] clk: qcom: gdsc: Increase status poll timeout

Quoted 6 lines · Abel Vesa

The SM8550 GCC GDSCs need a higher timeout value when polling for status, so increase it to 1500us, while leaving the delay between disable-enable sequence for votable gdscs to stay the same.

---

Konrad

Quoted 24 lines
 drivers/clk/qcom/gdsc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/qcom/gdsc.c +2 -1
index 0f21a8a767ac..9e4d6ce891aa 100644
@@ -46,6 +46,7 @@
 #define RETAIN_MEM		BIT(14)
 #define RETAIN_PERIPH		BIT(13)
 
+#define STATUS_POLL_TIMEOUT_US	1500
 #define TIMEOUT_US		500
 
 #define domain_to_gdsc(domain) container_of(domain, struct gdsc, pd)
@@ -107,7 +108,7 @@ static int gdsc_poll_status(struct gdsc *sc, enum gdsc_status status)
 	do {
 		if (gdsc_check_status(sc, status))
 			return 0;
-	} while (ktime_us_delta(ktime_get(), start) < TIMEOUT_US);
+	} while (ktime_us_delta(ktime_get(), start) < STATUS_POLL_TIMEOUT_US);
 
 	if (gdsc_check_status(sc, status))
 		return 0;
author
#7 lore raw

PATCH v4 4/9 clk: qcom: Add LUCID_OLE PLL type for SM8550

In reply to Abel Vesa

Add a LUCID_OLE PLL type for SM8550 SoC from Qualcomm.

---
 drivers/clk/qcom/clk-alpha-pll.c | 16 ++++++++++++++++
 drivers/clk/qcom/clk-alpha-pll.h |  5 +++++
 2 files changed, 21 insertions(+)
drivers/clk/qcom/clk-alpha-pll.c +16 -0
index 1973d79c9465..f9e4cfd7261c 100644
@@ -155,6 +155,22 @@ const u8 clk_alpha_pll_regs[][PLL_OFF_MAX_REGS] = {
 		[PLL_OFF_TEST_CTL_U] = 0x30,
 		[PLL_OFF_TEST_CTL_U1] = 0x34,
 	},
+	[CLK_ALPHA_PLL_TYPE_LUCID_OLE] = {
+		[PLL_OFF_OPMODE] = 0x04,
+		[PLL_OFF_STATE] = 0x08,
+		[PLL_OFF_STATUS] = 0x0c,
+		[PLL_OFF_L_VAL] = 0x10,
+		[PLL_OFF_ALPHA_VAL] = 0x14,
+		[PLL_OFF_USER_CTL] = 0x18,
+		[PLL_OFF_USER_CTL_U] = 0x1c,
+		[PLL_OFF_CONFIG_CTL] = 0x20,
+		[PLL_OFF_CONFIG_CTL_U] = 0x24,
+		[PLL_OFF_CONFIG_CTL_U1] = 0x28,
+		[PLL_OFF_TEST_CTL] = 0x2c,
+		[PLL_OFF_TEST_CTL_U] = 0x30,
+		[PLL_OFF_TEST_CTL_U1] = 0x34,
+		[PLL_OFF_TEST_CTL_U2] = 0x38,
+	},
 	[CLK_ALPHA_PLL_TYPE_RIVIAN_EVO] = {
 		[PLL_OFF_OPMODE] = 0x04,
 		[PLL_OFF_STATUS] = 0x0c,
drivers/clk/qcom/clk-alpha-pll.h +5 -0
index f9524b3fce6b..2bdae362c827 100644
@@ -18,6 +18,7 @@ enum {
 	CLK_ALPHA_PLL_TYPE_AGERA,
 	CLK_ALPHA_PLL_TYPE_ZONDA,
 	CLK_ALPHA_PLL_TYPE_LUCID_EVO,
+	CLK_ALPHA_PLL_TYPE_LUCID_OLE,
 	CLK_ALPHA_PLL_TYPE_RIVIAN_EVO,
 	CLK_ALPHA_PLL_TYPE_DEFAULT_EVO,
 	CLK_ALPHA_PLL_TYPE_BRAMMO_EVO,
@@ -38,6 +39,8 @@ enum {
 	PLL_OFF_TEST_CTL,
 	PLL_OFF_TEST_CTL_U,
 	PLL_OFF_TEST_CTL_U1,
+	PLL_OFF_TEST_CTL_U2,
+	PLL_OFF_STATE,
 	PLL_OFF_STATUS,
 	PLL_OFF_OPMODE,
 	PLL_OFF_FRAC,
@@ -160,7 +163,9 @@ extern const struct clk_ops clk_alpha_pll_zonda_ops;
 extern const struct clk_ops clk_alpha_pll_lucid_evo_ops;
 extern const struct clk_ops clk_alpha_pll_reset_lucid_evo_ops;
 extern const struct clk_ops clk_alpha_pll_fixed_lucid_evo_ops;
+#define clk_alpha_pll_fixed_lucid_ole_ops clk_alpha_pll_fixed_lucid_evo_ops
 extern const struct clk_ops clk_alpha_pll_postdiv_lucid_evo_ops;
+#define clk_alpha_pll_postdiv_lucid_ole_ops clk_alpha_pll_postdiv_lucid_evo_ops
 
 extern const struct clk_ops clk_alpha_pll_rivian_evo_ops;
 #define clk_alpha_pll_postdiv_rivian_evo_ops clk_alpha_pll_postdiv_fabia_ops
Signature · 1 line
2.34.1
author
#8 lore raw

PATCH v4 5/9 clk: qcom: Add GCC driver for SM8550

In reply to Abel Vesa

Add Global Clock controller (GCC) driver for SM8550 SoC, which includes the gcc resets and gdsc.

This patch is based on an initial downstream driver.

---
 drivers/clk/qcom/Kconfig      |    8 +
 drivers/clk/qcom/Makefile     |    1 +
 drivers/clk/qcom/gcc-sm8550.c | 3388 +++++++++++++++++++++++++++++++++
 3 files changed, 3397 insertions(+)
 create mode 100644 drivers/clk/qcom/gcc-sm8550.c
drivers/clk/qcom/Kconfig +8 -0
index 76e6dee450d5..e2cfa9c74bcf 100644
@@ -739,6 +739,14 @@ config SM_GCC_8450
 	  Say Y if you want to use peripheral devices such as UART,
 	  SPI, I2C, USB, SD/UFS, PCIe etc.
 
+config SM_GCC_8550
+	tristate "SM8550 Global Clock Controller"
+	select QCOM_GDSC
+	help
+	  Support for the global clock controller on SM8550 devices.
+	  Say Y if you want to use peripheral devices such as UART,
+	  SPI, I2C, USB, SD/UFS, PCIe etc.
+
 config SM_GPUCC_6350
 	tristate "SM6350 Graphics Clock Controller"
 	select SM_GCC_6350
drivers/clk/qcom/Makefile +1 -0
index e6cecf9e0436..06ae671bdea6 100644
@@ -105,6 +105,7 @@ obj-$(CONFIG_SM_GCC_8150) += gcc-sm8150.o
 obj-$(CONFIG_SM_GCC_8250) += gcc-sm8250.o
 obj-$(CONFIG_SM_GCC_8350) += gcc-sm8350.o
 obj-$(CONFIG_SM_GCC_8450) += gcc-sm8450.o
+obj-$(CONFIG_SM_GCC_8550) += gcc-sm8550.o
 obj-$(CONFIG_SM_GPUCC_6350) += gpucc-sm6350.o
 obj-$(CONFIG_SM_GPUCC_8150) += gpucc-sm8150.o
 obj-$(CONFIG_SM_GPUCC_8250) += gpucc-sm8250.o
drivers/clk/qcom/gcc-sm8550.c new file +3388 -0

2,979 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.34.1

Part of the diff is not shown here. View the raw message.

author
#9 lore raw

PATCH v4 6/9 dt-bindings: clock: Add RPMHCC for SM8550

In reply to Abel Vesa

Add bindings and update documentation for clock rpmh driver on SM8550.

---
 Documentation/devicetree/bindings/clock/qcom,rpmhcc.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/clock/qcom,rpmhcc.yaml +1 -0
index 437a34b930e3..d465dd691107 100644
@@ -30,6 +30,7 @@ properties:
       - qcom,sm8250-rpmh-clk
       - qcom,sm8350-rpmh-clk
       - qcom,sm8450-rpmh-clk
+      - qcom,sm8550-rpmh-clk
 
   clocks:
     maxItems: 1
Signature · 1 line
2.34.1
author
#10 lore raw

PATCH v4 7/9 dt-bindings: clock: qcom,rpmh: Add CXO PAD clock IDs

In reply to Abel Vesa

The SM8550 has a new fixed divider as child clock of CXO called CXO_PAD, so add IDs for it.

---
 include/dt-bindings/clock/qcom,rpmh.h | 2 ++
 1 file changed, 2 insertions(+)
include/dt-bindings/clock/qcom,rpmh.h +2 -0
index 0a7d1be0d124..f3e0288420ce 100644
@@ -33,5 +33,7 @@
 #define RPMH_HWKM_CLK				24
 #define RPMH_QLINK_CLK				25
 #define RPMH_QLINK_CLK_A			26
+#define RPMH_CXO_PAD_CLK			27
+#define RPMH_CXO_PAD_CLK_A			28
 
 #endif
Signature · 1 line
2.34.1
author
#11 lore raw

PATCH v4 8/9 clk: qcom: rpmh: Add support for SM8550 rpmh clocks

In reply to Abel Vesa

Adds the RPMH clocks present in SM8550 SoC.

---
 drivers/clk/qcom/clk-rpmh.c | 110 +++++++++++++++++++++++++++++-------
 1 file changed, 90 insertions(+), 20 deletions(-)
drivers/clk/qcom/clk-rpmh.c +90 -20
index 0471bab82464..3204df3fda86 100644
@@ -132,6 +132,36 @@ static DEFINE_MUTEX(rpmh_clk_lock);
 		},							\
 	}
 
+#define DEFINE_CLK_RPMH_FIXED(_platform, _name, _name_active,	\
+				  _parent_name, _name_active_parent,	\
+				  _div)					\
+	static struct clk_fixed_factor _platform##_##_name = {		\
+		.mult = 1,						\
+		.div = _div,						\
+		.hw.init = &(struct clk_init_data){			\
+			.ops = &clk_fixed_factor_ops,			\
+			.name = #_name,					\
+			.parent_data =  &(const struct clk_parent_data){ \
+					.fw_name = #_parent_name,	\
+					.name = #_parent_name,		\
+			},						\
+			.num_parents = 1,				\
+		},							\
+	};								\
+	static struct clk_fixed_factor _platform##_##_name_active = {	\
+		.mult = 1,						\
+		.div = _div,						\
+		.hw.init = &(struct clk_init_data){			\
+			.ops = &clk_fixed_factor_ops,			\
+			.name = #_name_active,				\
+			.parent_data =  &(const struct clk_parent_data){ \
+					.fw_name = #_name_active_parent,\
+					.name = #_name_active_parent,	\
+			},						\
+			.num_parents = 1,				\
+		},							\
+	}
+
 static inline struct clk_rpmh *to_clk_rpmh(struct clk_hw *_hw)
 {
 	return container_of(_hw, struct clk_rpmh, hw);
@@ -579,6 +609,43 @@ static const struct clk_rpmh_desc clk_rpmh_sm8450 = {
 	.num_clks = ARRAY_SIZE(sm8450_rpmh_clocks),
 };
 
+DEFINE_CLK_RPMH_ARC(sm8550, xo_pad, xo_pad_ao, "xo.lvl", 0x03, 2);
+DEFINE_CLK_RPMH_FIXED(sm8550, bi_tcxo, bi_tcxo_ao, xo_pad, xo_pad_ao, 2);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk1, rf_clk1_ao, "clka1", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk2, rf_clk2_ao, "clka2", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk3, rf_clk3_ao, "clka3", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk4, rf_clk4_ao, "clka4", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk1, ln_bb_clk1_ao, "clka6", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk2, ln_bb_clk2_ao, "clka7", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk3, ln_bb_clk3_ao, "clka8", 2);
+
+static struct clk_hw *sm8550_rpmh_clocks[] = {
+	[RPMH_CXO_PAD_CLK]      = &sm8550_xo_pad.hw,
+	[RPMH_CXO_PAD_CLK_A]    = &sm8550_xo_pad_ao.hw,
+	[RPMH_CXO_CLK]		= &sm8550_bi_tcxo.hw,
+	[RPMH_CXO_CLK_A]	= &sm8550_bi_tcxo_ao.hw,
+	[RPMH_LN_BB_CLK1]	= &sm8550_ln_bb_clk1.hw,
+	[RPMH_LN_BB_CLK1_A]	= &sm8550_ln_bb_clk1_ao.hw,
+	[RPMH_LN_BB_CLK2]	= &sm8550_ln_bb_clk2.hw,
+	[RPMH_LN_BB_CLK2_A]	= &sm8550_ln_bb_clk2_ao.hw,
+	[RPMH_LN_BB_CLK3]	= &sm8550_ln_bb_clk3.hw,
+	[RPMH_LN_BB_CLK3_A]	= &sm8550_ln_bb_clk3_ao.hw,
+	[RPMH_RF_CLK1]		= &sm8550_rf_clk1.hw,
+	[RPMH_RF_CLK1_A]	= &sm8550_rf_clk1_ao.hw,
+	[RPMH_RF_CLK2]		= &sm8550_rf_clk2.hw,
+	[RPMH_RF_CLK2_A]	= &sm8550_rf_clk2_ao.hw,
+	[RPMH_RF_CLK3]		= &sm8550_rf_clk3.hw,
+	[RPMH_RF_CLK3_A]	= &sm8550_rf_clk3_ao.hw,
+	[RPMH_RF_CLK4]		= &sm8550_rf_clk4.hw,
+	[RPMH_RF_CLK4_A]	= &sm8550_rf_clk4_ao.hw,
+	[RPMH_IPA_CLK]		= &sdm845_ipa.hw,
+};
+
+static const struct clk_rpmh_desc clk_rpmh_sm8550 = {
+	.clks = sm8550_rpmh_clocks,
+	.num_clks = ARRAY_SIZE(sm8550_rpmh_clocks),
+};
+
 static struct clk_hw *sc7280_rpmh_clocks[] = {
 	[RPMH_CXO_CLK]      = &sc7280_bi_tcxo.hw,
 	[RPMH_CXO_CLK_A]    = &sc7280_bi_tcxo_ao.hw,
@@ -682,29 +749,31 @@ static int clk_rpmh_probe(struct platform_device *pdev)
 
 		name = hw_clks[i]->init->name;
 
-		rpmh_clk = to_clk_rpmh(hw_clks[i]);
-		res_addr = cmd_db_read_addr(rpmh_clk->res_name);
-		if (!res_addr) {
-			dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
-				rpmh_clk->res_name);
-			return -ENODEV;
-		}
+		if (hw_clks[i]->init->ops != &clk_fixed_factor_ops) {
+			rpmh_clk = to_clk_rpmh(hw_clks[i]);
+			res_addr = cmd_db_read_addr(rpmh_clk->res_name);
+			if (!res_addr) {
+				dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
+					rpmh_clk->res_name);
+				return -ENODEV;
+			}
 
-		data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
-		if (IS_ERR(data)) {
-			ret = PTR_ERR(data);
-			dev_err(&pdev->dev,
-				"error reading RPMh aux data for %s (%d)\n",
-				rpmh_clk->res_name, ret);
-			return ret;
-		}
+			data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
+			if (IS_ERR(data)) {
+				ret = PTR_ERR(data);
+				dev_err(&pdev->dev,
+					"error reading RPMh aux data for %s (%d)\n",
+					rpmh_clk->res_name, ret);
+				return ret;
+			}
 
-		/* Convert unit from Khz to Hz */
-		if (aux_data_len == sizeof(*data))
-			rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
+			/* Convert unit from Khz to Hz */
+			if (aux_data_len == sizeof(*data))
+				rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
 
-		rpmh_clk->res_addr += res_addr;
-		rpmh_clk->dev = &pdev->dev;
+			rpmh_clk->res_addr += res_addr;
+			rpmh_clk->dev = &pdev->dev;
+		}
 
 		ret = devm_clk_hw_register(&pdev->dev, hw_clks[i]);
 		if (ret) {
@@ -739,6 +808,7 @@ static const struct of_device_id clk_rpmh_match_table[] = {
 	{ .compatible = "qcom,sm8250-rpmh-clk", .data = &clk_rpmh_sm8250},
 	{ .compatible = "qcom,sm8350-rpmh-clk", .data = &clk_rpmh_sm8350},
 	{ .compatible = "qcom,sm8450-rpmh-clk", .data = &clk_rpmh_sm8450},
+	{ .compatible = "qcom,sm8550-rpmh-clk", .data = &clk_rpmh_sm8550},
 	{ .compatible = "qcom,sc7280-rpmh-clk", .data = &clk_rpmh_sc7280},
 	{ }
 };
Signature · 1 line
2.34.1
#12 lore raw

Re: [PATCH v4 8/9] clk: qcom: rpmh: Add support for SM8550 rpmh clocks

Quoted 37 lines · Abel Vesa

Adds the RPMH clocks present in SM8550 SoC.

---
 drivers/clk/qcom/clk-rpmh.c | 110 +++++++++++++++++++++++++++++-------
 1 file changed, 90 insertions(+), 20 deletions(-)
drivers/clk/qcom/clk-rpmh.c +20 -0
index 0471bab82464..3204df3fda86 100644
@@ -132,6 +132,36 @@ static DEFINE_MUTEX(rpmh_clk_lock);
                },                                                      \
        }
 
+#define DEFINE_CLK_RPMH_FIXED(_platform, _name, _name_active,  \
+                                 _parent_name, _name_active_parent,    \
+                                 _div)                                 \
+       static struct clk_fixed_factor _platform##_##_name = {          \
+               .mult = 1,                                              \
+               .div = _div,                                            \
+               .hw.init = &(struct clk_init_data){                     \
+                       .ops = &clk_fixed_factor_ops,                   \
+                       .name = #_name,                                 \
+                       .parent_data =  &(const struct clk_parent_data){ \
+                                       .fw_name = #_parent_name,       \
+                                       .name = #_parent_name,          \
+                       },                                              \
+                       .num_parents = 1,                               \
+               },                                                      \
+       };                                                              \
+       static struct clk_fixed_factor _platform##_##_name_active = {   \
+               .mult = 1,                                              \
+               .div = _div,                                            \
+               .hw.init = &(struct clk_init_data){                     \

drivers/clk/qcom/clk-rpmh.c static DEFINE_MUTEX(rpmh_clk_lock); · line 164

Quoted 10 lines
drivers/clk/qcom/clk-rpmh.c +10 -0
+                       .ops = &clk_fixed_factor_ops,                   \
+                       .name = #_name_active,                          \
+                       .parent_data =  &(const struct clk_parent_data){ \
+                                       .fw_name = #_name_active_parent,\
+                                       .name = #_name_active_parent,   \
+                       },                                              \
+                       .num_parents = 1,                               \
+               },                                                      \
+       }
+

Please use CLK_FIXED_FACTOR_FW_NAME() instead.

Quoted 49 lines
drivers/clk/qcom/clk-rpmh.c +37 -0
 static inline struct clk_rpmh *to_clk_rpmh(struct clk_hw *_hw)
 {
        return container_of(_hw, struct clk_rpmh, hw);
@@ -579,6 +609,43 @@ static const struct clk_rpmh_desc clk_rpmh_sm8450 = {
        .num_clks = ARRAY_SIZE(sm8450_rpmh_clocks),
 };
 
+DEFINE_CLK_RPMH_ARC(sm8550, xo_pad, xo_pad_ao, "xo.lvl", 0x03, 2);
+DEFINE_CLK_RPMH_FIXED(sm8550, bi_tcxo, bi_tcxo_ao, xo_pad, xo_pad_ao, 2);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk1, rf_clk1_ao, "clka1", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk2, rf_clk2_ao, "clka2", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk3, rf_clk3_ao, "clka3", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk4, rf_clk4_ao, "clka4", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk1, ln_bb_clk1_ao, "clka6", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk2, ln_bb_clk2_ao, "clka7", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk3, ln_bb_clk3_ao, "clka8", 2);
+
+static struct clk_hw *sm8550_rpmh_clocks[] = {
+       [RPMH_CXO_PAD_CLK]      = &sm8550_xo_pad.hw,
+       [RPMH_CXO_PAD_CLK_A]    = &sm8550_xo_pad_ao.hw,
+       [RPMH_CXO_CLK]          = &sm8550_bi_tcxo.hw,
+       [RPMH_CXO_CLK_A]        = &sm8550_bi_tcxo_ao.hw,
+       [RPMH_LN_BB_CLK1]       = &sm8550_ln_bb_clk1.hw,
+       [RPMH_LN_BB_CLK1_A]     = &sm8550_ln_bb_clk1_ao.hw,
+       [RPMH_LN_BB_CLK2]       = &sm8550_ln_bb_clk2.hw,
+       [RPMH_LN_BB_CLK2_A]     = &sm8550_ln_bb_clk2_ao.hw,
+       [RPMH_LN_BB_CLK3]       = &sm8550_ln_bb_clk3.hw,
+       [RPMH_LN_BB_CLK3_A]     = &sm8550_ln_bb_clk3_ao.hw,
+       [RPMH_RF_CLK1]          = &sm8550_rf_clk1.hw,
+       [RPMH_RF_CLK1_A]        = &sm8550_rf_clk1_ao.hw,
+       [RPMH_RF_CLK2]          = &sm8550_rf_clk2.hw,
+       [RPMH_RF_CLK2_A]        = &sm8550_rf_clk2_ao.hw,
+       [RPMH_RF_CLK3]          = &sm8550_rf_clk3.hw,
+       [RPMH_RF_CLK3_A]        = &sm8550_rf_clk3_ao.hw,
+       [RPMH_RF_CLK4]          = &sm8550_rf_clk4.hw,
+       [RPMH_RF_CLK4_A]        = &sm8550_rf_clk4_ao.hw,
+       [RPMH_IPA_CLK]          = &sdm845_ipa.hw,
+};
+
+static const struct clk_rpmh_desc clk_rpmh_sm8550 = {
+       .clks = sm8550_rpmh_clocks,
+       .num_clks = ARRAY_SIZE(sm8550_rpmh_clocks),
+};
+
 static struct clk_hw *sc7280_rpmh_clocks[] = {
        [RPMH_CXO_CLK]      = &sc7280_bi_tcxo.hw,
        [RPMH_CXO_CLK_A]    = &sc7280_bi_tcxo_ao.hw,
@@ -682,29 +749,31 @@ static int clk_rpmh_probe(struct platform_device *pdev)
 

drivers/clk/qcom/clk-rpmh.c static int clk_rpmh_probe(struct platform_device *pdev) · line 752

Quoted 10 lines
drivers/clk/qcom/clk-rpmh.c +1 -7
                name = hw_clks[i]->init->name;
 
-               rpmh_clk = to_clk_rpmh(hw_clks[i]);
-               res_addr = cmd_db_read_addr(rpmh_clk->res_name);
-               if (!res_addr) {
-                       dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
-                               rpmh_clk->res_name);
-                       return -ENODEV;
-               }
+               if (hw_clks[i]->init->ops != &clk_fixed_factor_ops) {

This looks ugly a bit. I'd rather add something like non_cmd_clks to the clk_rpmh_desc data and register them separately. Or even worse, you can keep the rpmh as is, with only cmd-db based clocks and add a fixed factor clock to the sm8550 dtsi directly. I have a slight preference for the former method, but the latter would also work.

Quoted 51 lines
drivers/clk/qcom/clk-rpmh.c +22 -14
+                       rpmh_clk = to_clk_rpmh(hw_clks[i]);
+                       res_addr = cmd_db_read_addr(rpmh_clk->res_name);
+                       if (!res_addr) {
+                               dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
+                                       rpmh_clk->res_name);
+                               return -ENODEV;
+                       }
 
-               data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
-               if (IS_ERR(data)) {
-                       ret = PTR_ERR(data);
-                       dev_err(&pdev->dev,
-                               "error reading RPMh aux data for %s (%d)\n",
-                               rpmh_clk->res_name, ret);
-                       return ret;
-               }
+                       data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
+                       if (IS_ERR(data)) {
+                               ret = PTR_ERR(data);
+                               dev_err(&pdev->dev,
+                                       "error reading RPMh aux data for %s (%d)\n",
+                                       rpmh_clk->res_name, ret);
+                               return ret;
+                       }
 
-               /* Convert unit from Khz to Hz */
-               if (aux_data_len == sizeof(*data))
-                       rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
+                       /* Convert unit from Khz to Hz */
+                       if (aux_data_len == sizeof(*data))
+                               rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
 
-               rpmh_clk->res_addr += res_addr;
-               rpmh_clk->dev = &pdev->dev;
+                       rpmh_clk->res_addr += res_addr;
+                       rpmh_clk->dev = &pdev->dev;
+               }
 
                ret = devm_clk_hw_register(&pdev->dev, hw_clks[i]);
                if (ret) {
@@ -739,6 +808,7 @@ static const struct of_device_id clk_rpmh_match_table[] = {
        { .compatible = "qcom,sm8250-rpmh-clk", .data = &clk_rpmh_sm8250},
        { .compatible = "qcom,sm8350-rpmh-clk", .data = &clk_rpmh_sm8350},
        { .compatible = "qcom,sm8450-rpmh-clk", .data = &clk_rpmh_sm8450},
+       { .compatible = "qcom,sm8550-rpmh-clk", .data = &clk_rpmh_sm8550},
        { .compatible = "qcom,sc7280-rpmh-clk", .data = &clk_rpmh_sc7280},
        { }
 };
--

2.34.1

Signature · 2 lines
With best wishes
Dmitry
#13 lore raw

Re: [PATCH v4 8/9] clk: qcom: rpmh: Add support for SM8550 rpmh clocks

Quoted 43 lines · Dmitry Baryshkov
Quoted 41 lines · Abel Vesa

Adds the RPMH clocks present in SM8550 SoC.

---
 drivers/clk/qcom/clk-rpmh.c | 110 +++++++++++++++++++++++++++++-------
 1 file changed, 90 insertions(+), 20 deletions(-)
drivers/clk/qcom/clk-rpmh.c +24 -0
index 0471bab82464..3204df3fda86 100644
@@ -132,6 +132,36 @@ static DEFINE_MUTEX(rpmh_clk_lock);
                },                                                      \
        }
 
+#define DEFINE_CLK_RPMH_FIXED(_platform, _name, _name_active,  \
+                                 _parent_name, _name_active_parent,    \
+                                 _div)                                 \
+       static struct clk_fixed_factor _platform##_##_name = {          \
+               .mult = 1,                                              \
+               .div = _div,                                            \
+               .hw.init = &(struct clk_init_data){                     \
+                       .ops = &clk_fixed_factor_ops,                   \
+                       .name = #_name,                                 \
+                       .parent_data =  &(const struct clk_parent_data){ \
+                                       .fw_name = #_parent_name,       \
+                                       .name = #_parent_name,          \
+                       },                                              \
+                       .num_parents = 1,                               \
+               },                                                      \
+       };                                                              \
+       static struct clk_fixed_factor _platform##_##_name_active = {   \
+               .mult = 1,                                              \
+               .div = _div,                                            \
+               .hw.init = &(struct clk_init_data){                     \
+                       .ops = &clk_fixed_factor_ops,                   \
+                       .name = #_name_active,                          \
+                       .parent_data =  &(const struct clk_parent_data){ \
+                                       .fw_name = #_name_active_parent,\
Quoted 8 lines

drivers/clk/qcom/clk-rpmh.c static DEFINE_MUTEX(rpmh_clk_lock); · line 164

Quoted 6 lines
drivers/clk/qcom/clk-rpmh.c +6 -0
+                                       .name = #_name_active_parent,   \
+                       },                                              \
+                       .num_parents = 1,                               \
+               },                                                      \
+       }
+

Please use CLK_FIXED_FACTOR_FW_NAME() instead.

Or even better CLK_FIXED_FACTOR_HW(). It fits better here.

Quoted 52 lines
Quoted 52 lines
drivers/clk/qcom/clk-rpmh.c +37 -0
 static inline struct clk_rpmh *to_clk_rpmh(struct clk_hw *_hw)
 {
        return container_of(_hw, struct clk_rpmh, hw);
@@ -579,6 +609,43 @@ static const struct clk_rpmh_desc clk_rpmh_sm8450 = {
        .num_clks = ARRAY_SIZE(sm8450_rpmh_clocks),
 };
 
+DEFINE_CLK_RPMH_ARC(sm8550, xo_pad, xo_pad_ao, "xo.lvl", 0x03, 2);
+DEFINE_CLK_RPMH_FIXED(sm8550, bi_tcxo, bi_tcxo_ao, xo_pad, xo_pad_ao, 2);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk1, rf_clk1_ao, "clka1", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk2, rf_clk2_ao, "clka2", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk3, rf_clk3_ao, "clka3", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk4, rf_clk4_ao, "clka4", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk1, ln_bb_clk1_ao, "clka6", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk2, ln_bb_clk2_ao, "clka7", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk3, ln_bb_clk3_ao, "clka8", 2);
+
+static struct clk_hw *sm8550_rpmh_clocks[] = {
+       [RPMH_CXO_PAD_CLK]      = &sm8550_xo_pad.hw,
+       [RPMH_CXO_PAD_CLK_A]    = &sm8550_xo_pad_ao.hw,
+       [RPMH_CXO_CLK]          = &sm8550_bi_tcxo.hw,
+       [RPMH_CXO_CLK_A]        = &sm8550_bi_tcxo_ao.hw,
+       [RPMH_LN_BB_CLK1]       = &sm8550_ln_bb_clk1.hw,
+       [RPMH_LN_BB_CLK1_A]     = &sm8550_ln_bb_clk1_ao.hw,
+       [RPMH_LN_BB_CLK2]       = &sm8550_ln_bb_clk2.hw,
+       [RPMH_LN_BB_CLK2_A]     = &sm8550_ln_bb_clk2_ao.hw,
+       [RPMH_LN_BB_CLK3]       = &sm8550_ln_bb_clk3.hw,
+       [RPMH_LN_BB_CLK3_A]     = &sm8550_ln_bb_clk3_ao.hw,
+       [RPMH_RF_CLK1]          = &sm8550_rf_clk1.hw,
+       [RPMH_RF_CLK1_A]        = &sm8550_rf_clk1_ao.hw,
+       [RPMH_RF_CLK2]          = &sm8550_rf_clk2.hw,
+       [RPMH_RF_CLK2_A]        = &sm8550_rf_clk2_ao.hw,
+       [RPMH_RF_CLK3]          = &sm8550_rf_clk3.hw,
+       [RPMH_RF_CLK3_A]        = &sm8550_rf_clk3_ao.hw,
+       [RPMH_RF_CLK4]          = &sm8550_rf_clk4.hw,
+       [RPMH_RF_CLK4_A]        = &sm8550_rf_clk4_ao.hw,
+       [RPMH_IPA_CLK]          = &sdm845_ipa.hw,
+};
+
+static const struct clk_rpmh_desc clk_rpmh_sm8550 = {
+       .clks = sm8550_rpmh_clocks,
+       .num_clks = ARRAY_SIZE(sm8550_rpmh_clocks),
+};
+
 static struct clk_hw *sc7280_rpmh_clocks[] = {
        [RPMH_CXO_CLK]      = &sc7280_bi_tcxo.hw,
        [RPMH_CXO_CLK_A]    = &sc7280_bi_tcxo_ao.hw,
@@ -682,29 +749,31 @@ static int clk_rpmh_probe(struct platform_device *pdev)
 
                name = hw_clks[i]->init->name;
 
Quoted 14 lines

drivers/clk/qcom/clk-rpmh.c static int clk_rpmh_probe(struct platform_device *pdev) · line 752

Quoted 8 lines
drivers/clk/qcom/clk-rpmh.c +1 -7
-               rpmh_clk = to_clk_rpmh(hw_clks[i]);
-               res_addr = cmd_db_read_addr(rpmh_clk->res_name);
-               if (!res_addr) {
-                       dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
-                               rpmh_clk->res_name);
-                       return -ENODEV;
-               }
+               if (hw_clks[i]->init->ops != &clk_fixed_factor_ops) {

This looks ugly a bit. I'd rather add something like non_cmd_clks to the clk_rpmh_desc data and register them separately. Or even worse, you can keep the rpmh as is, with only cmd-db based clocks and add a fixed factor clock to the sm8550 dtsi directly. I have a slight preference for the former method, but the latter would also work.

After a second thought, I'd withdraw the second method. Just add a separate array with non-cmd-db clocks.

Quoted 57 lines
Quoted 50 lines
drivers/clk/qcom/clk-rpmh.c +22 -14
+                       rpmh_clk = to_clk_rpmh(hw_clks[i]);
+                       res_addr = cmd_db_read_addr(rpmh_clk->res_name);
+                       if (!res_addr) {
+                               dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
+                                       rpmh_clk->res_name);
+                               return -ENODEV;
+                       }
 
-               data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
-               if (IS_ERR(data)) {
-                       ret = PTR_ERR(data);
-                       dev_err(&pdev->dev,
-                               "error reading RPMh aux data for %s (%d)\n",
-                               rpmh_clk->res_name, ret);
-                       return ret;
-               }
+                       data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
+                       if (IS_ERR(data)) {
+                               ret = PTR_ERR(data);
+                               dev_err(&pdev->dev,
+                                       "error reading RPMh aux data for %s (%d)\n",
+                                       rpmh_clk->res_name, ret);
+                               return ret;
+                       }
 
-               /* Convert unit from Khz to Hz */
-               if (aux_data_len == sizeof(*data))
-                       rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
+                       /* Convert unit from Khz to Hz */
+                       if (aux_data_len == sizeof(*data))
+                               rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
 
-               rpmh_clk->res_addr += res_addr;
-               rpmh_clk->dev = &pdev->dev;
+                       rpmh_clk->res_addr += res_addr;
+                       rpmh_clk->dev = &pdev->dev;
+               }
 
                ret = devm_clk_hw_register(&pdev->dev, hw_clks[i]);
                if (ret) {
@@ -739,6 +808,7 @@ static const struct of_device_id clk_rpmh_match_table[] = {
        { .compatible = "qcom,sm8250-rpmh-clk", .data = &clk_rpmh_sm8250},
        { .compatible = "qcom,sm8350-rpmh-clk", .data = &clk_rpmh_sm8350},
        { .compatible = "qcom,sm8450-rpmh-clk", .data = &clk_rpmh_sm8450},
+       { .compatible = "qcom,sm8550-rpmh-clk", .data = &clk_rpmh_sm8550},
        { .compatible = "qcom,sc7280-rpmh-clk", .data = &clk_rpmh_sc7280},
        { }
 };
--
Quoted 2 lines

2.34.1

--
With best wishes
Dmitry

Signature · 2 lines
With best wishes
Dmitry
author
#14 lore raw

Re: [PATCH v4 8/9] clk: qcom: rpmh: Add support for SM8550 rpmh clocks

Quoted 54 lines · Dmitry Baryshkov
Quoted 43 lines · Dmitry Baryshkov
Quoted 41 lines · Abel Vesa

Adds the RPMH clocks present in SM8550 SoC.

---
 drivers/clk/qcom/clk-rpmh.c | 110 +++++++++++++++++++++++++++++-------
 1 file changed, 90 insertions(+), 20 deletions(-)
drivers/clk/qcom/clk-rpmh.c +24 -0
index 0471bab82464..3204df3fda86 100644
@@ -132,6 +132,36 @@ static DEFINE_MUTEX(rpmh_clk_lock);
                },                                                      \
        }
 
+#define DEFINE_CLK_RPMH_FIXED(_platform, _name, _name_active,  \
+                                 _parent_name, _name_active_parent,    \
+                                 _div)                                 \
+       static struct clk_fixed_factor _platform##_##_name = {          \
+               .mult = 1,                                              \
+               .div = _div,                                            \
+               .hw.init = &(struct clk_init_data){                     \
+                       .ops = &clk_fixed_factor_ops,                   \
+                       .name = #_name,                                 \
+                       .parent_data =  &(const struct clk_parent_data){ \
+                                       .fw_name = #_parent_name,       \
+                                       .name = #_parent_name,          \
+                       },                                              \
+                       .num_parents = 1,                               \
+               },                                                      \
+       };                                                              \
+       static struct clk_fixed_factor _platform##_##_name_active = {   \
+               .mult = 1,                                              \
+               .div = _div,                                            \
+               .hw.init = &(struct clk_init_data){                     \
+                       .ops = &clk_fixed_factor_ops,                   \
+                       .name = #_name_active,                          \
+                       .parent_data =  &(const struct clk_parent_data){ \
+                                       .fw_name = #_name_active_parent,\
Quoted 8 lines

drivers/clk/qcom/clk-rpmh.c static DEFINE_MUTEX(rpmh_clk_lock); · line 164

Quoted 6 lines
drivers/clk/qcom/clk-rpmh.c +6 -0
+                                       .name = #_name_active_parent,   \
+                       },                                              \
+                       .num_parents = 1,                               \
+               },                                                      \
+       }
+

Please use CLK_FIXED_FACTOR_FW_NAME() instead.

Quoted 1 line

Or even better CLK_FIXED_FACTOR_HW(). It fits better here.

I think DEFINE_CLK_FIXED_FACTOR would be even a better fit. No _HW since we are not defining just the clk_hw. Also we should keep the DEFINE_ prefix to be consistent with the others.

Quoted 134 lines
Quoted 53 lines
Quoted 53 lines
drivers/clk/qcom/clk-rpmh.c +37 -0
 static inline struct clk_rpmh *to_clk_rpmh(struct clk_hw *_hw)
 {
        return container_of(_hw, struct clk_rpmh, hw);
@@ -579,6 +609,43 @@ static const struct clk_rpmh_desc clk_rpmh_sm8450 = {
        .num_clks = ARRAY_SIZE(sm8450_rpmh_clocks),
 };
 
+DEFINE_CLK_RPMH_ARC(sm8550, xo_pad, xo_pad_ao, "xo.lvl", 0x03, 2);
+DEFINE_CLK_RPMH_FIXED(sm8550, bi_tcxo, bi_tcxo_ao, xo_pad, xo_pad_ao, 2);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk1, rf_clk1_ao, "clka1", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk2, rf_clk2_ao, "clka2", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk3, rf_clk3_ao, "clka3", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk4, rf_clk4_ao, "clka4", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk1, ln_bb_clk1_ao, "clka6", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk2, ln_bb_clk2_ao, "clka7", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk3, ln_bb_clk3_ao, "clka8", 2);
+
+static struct clk_hw *sm8550_rpmh_clocks[] = {
+       [RPMH_CXO_PAD_CLK]      = &sm8550_xo_pad.hw,
+       [RPMH_CXO_PAD_CLK_A]    = &sm8550_xo_pad_ao.hw,
+       [RPMH_CXO_CLK]          = &sm8550_bi_tcxo.hw,
+       [RPMH_CXO_CLK_A]        = &sm8550_bi_tcxo_ao.hw,
+       [RPMH_LN_BB_CLK1]       = &sm8550_ln_bb_clk1.hw,
+       [RPMH_LN_BB_CLK1_A]     = &sm8550_ln_bb_clk1_ao.hw,
+       [RPMH_LN_BB_CLK2]       = &sm8550_ln_bb_clk2.hw,
+       [RPMH_LN_BB_CLK2_A]     = &sm8550_ln_bb_clk2_ao.hw,
+       [RPMH_LN_BB_CLK3]       = &sm8550_ln_bb_clk3.hw,
+       [RPMH_LN_BB_CLK3_A]     = &sm8550_ln_bb_clk3_ao.hw,
+       [RPMH_RF_CLK1]          = &sm8550_rf_clk1.hw,
+       [RPMH_RF_CLK1_A]        = &sm8550_rf_clk1_ao.hw,
+       [RPMH_RF_CLK2]          = &sm8550_rf_clk2.hw,
+       [RPMH_RF_CLK2_A]        = &sm8550_rf_clk2_ao.hw,
+       [RPMH_RF_CLK3]          = &sm8550_rf_clk3.hw,
+       [RPMH_RF_CLK3_A]        = &sm8550_rf_clk3_ao.hw,
+       [RPMH_RF_CLK4]          = &sm8550_rf_clk4.hw,
+       [RPMH_RF_CLK4_A]        = &sm8550_rf_clk4_ao.hw,
+       [RPMH_IPA_CLK]          = &sdm845_ipa.hw,
+};
+
+static const struct clk_rpmh_desc clk_rpmh_sm8550 = {
+       .clks = sm8550_rpmh_clocks,
+       .num_clks = ARRAY_SIZE(sm8550_rpmh_clocks),
+};
+
 static struct clk_hw *sc7280_rpmh_clocks[] = {
        [RPMH_CXO_CLK]      = &sc7280_bi_tcxo.hw,
        [RPMH_CXO_CLK_A]    = &sc7280_bi_tcxo_ao.hw,
@@ -682,29 +749,31 @@ static int clk_rpmh_probe(struct platform_device *pdev)
 
                name = hw_clks[i]->init->name;
 
Quoted 14 lines

drivers/clk/qcom/clk-rpmh.c static int clk_rpmh_probe(struct platform_device *pdev) · line 752

Quoted 8 lines
drivers/clk/qcom/clk-rpmh.c +1 -7
-               rpmh_clk = to_clk_rpmh(hw_clks[i]);
-               res_addr = cmd_db_read_addr(rpmh_clk->res_name);
-               if (!res_addr) {
-                       dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
-                               rpmh_clk->res_name);
-                       return -ENODEV;
-               }
+               if (hw_clks[i]->init->ops != &clk_fixed_factor_ops) {

This looks ugly a bit. I'd rather add something like non_cmd_clks to the clk_rpmh_desc data and register them separately. Or even worse, you can keep the rpmh as is, with only cmd-db based clocks and add a fixed factor clock to the sm8550 dtsi directly. I have a slight preference for the former method, but the latter would also work.

After a second thought, I'd withdraw the second method. Just add a separate array with non-cmd-db clocks.

Quoted 57 lines
Quoted 50 lines
drivers/clk/qcom/clk-rpmh.c +22 -14
+                       rpmh_clk = to_clk_rpmh(hw_clks[i]);
+                       res_addr = cmd_db_read_addr(rpmh_clk->res_name);
+                       if (!res_addr) {
+                               dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
+                                       rpmh_clk->res_name);
+                               return -ENODEV;
+                       }
 
-               data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
-               if (IS_ERR(data)) {
-                       ret = PTR_ERR(data);
-                       dev_err(&pdev->dev,
-                               "error reading RPMh aux data for %s (%d)\n",
-                               rpmh_clk->res_name, ret);
-                       return ret;
-               }
+                       data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
+                       if (IS_ERR(data)) {
+                               ret = PTR_ERR(data);
+                               dev_err(&pdev->dev,
+                                       "error reading RPMh aux data for %s (%d)\n",
+                                       rpmh_clk->res_name, ret);
+                               return ret;
+                       }
 
-               /* Convert unit from Khz to Hz */
-               if (aux_data_len == sizeof(*data))
-                       rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
+                       /* Convert unit from Khz to Hz */
+                       if (aux_data_len == sizeof(*data))
+                               rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
 
-               rpmh_clk->res_addr += res_addr;
-               rpmh_clk->dev = &pdev->dev;
+                       rpmh_clk->res_addr += res_addr;
+                       rpmh_clk->dev = &pdev->dev;
+               }
 
                ret = devm_clk_hw_register(&pdev->dev, hw_clks[i]);
                if (ret) {
@@ -739,6 +808,7 @@ static const struct of_device_id clk_rpmh_match_table[] = {
        { .compatible = "qcom,sm8250-rpmh-clk", .data = &clk_rpmh_sm8250},
        { .compatible = "qcom,sm8350-rpmh-clk", .data = &clk_rpmh_sm8350},
        { .compatible = "qcom,sm8450-rpmh-clk", .data = &clk_rpmh_sm8450},
+       { .compatible = "qcom,sm8550-rpmh-clk", .data = &clk_rpmh_sm8550},
        { .compatible = "qcom,sc7280-rpmh-clk", .data = &clk_rpmh_sc7280},
        { }
 };
--
Quoted 2 lines

2.34.1

--
With best wishes
Dmitry

Signature · 2 lines
With best wishes
Dmitry
author
#15 lore raw

Re: [PATCH v4 8/9] clk: qcom: rpmh: Add support for SM8550 rpmh clocks

In reply to Dmitry Baryshkov
Quoted 102 lines · Dmitry Baryshkov
Quoted 37 lines · Abel Vesa

Adds the RPMH clocks present in SM8550 SoC.

---
 drivers/clk/qcom/clk-rpmh.c | 110 +++++++++++++++++++++++++++++-------
 1 file changed, 90 insertions(+), 20 deletions(-)
drivers/clk/qcom/clk-rpmh.c +20 -0
index 0471bab82464..3204df3fda86 100644
@@ -132,6 +132,36 @@ static DEFINE_MUTEX(rpmh_clk_lock);
                },                                                      \
        }
 
+#define DEFINE_CLK_RPMH_FIXED(_platform, _name, _name_active,  \
+                                 _parent_name, _name_active_parent,    \
+                                 _div)                                 \
+       static struct clk_fixed_factor _platform##_##_name = {          \
+               .mult = 1,                                              \
+               .div = _div,                                            \
+               .hw.init = &(struct clk_init_data){                     \
+                       .ops = &clk_fixed_factor_ops,                   \
+                       .name = #_name,                                 \
+                       .parent_data =  &(const struct clk_parent_data){ \
+                                       .fw_name = #_parent_name,       \
+                                       .name = #_parent_name,          \
+                       },                                              \
+                       .num_parents = 1,                               \
+               },                                                      \
+       };                                                              \
+       static struct clk_fixed_factor _platform##_##_name_active = {   \
+               .mult = 1,                                              \
+               .div = _div,                                            \
+               .hw.init = &(struct clk_init_data){                     \

drivers/clk/qcom/clk-rpmh.c static DEFINE_MUTEX(rpmh_clk_lock); · line 164

Quoted 10 lines
drivers/clk/qcom/clk-rpmh.c +10 -0
+                       .ops = &clk_fixed_factor_ops,                   \
+                       .name = #_name_active,                          \
+                       .parent_data =  &(const struct clk_parent_data){ \
+                                       .fw_name = #_name_active_parent,\
+                                       .name = #_name_active_parent,   \
+                       },                                              \
+                       .num_parents = 1,                               \
+               },                                                      \
+       }
+

Please use CLK_FIXED_FACTOR_FW_NAME() instead.

Quoted 51 lines
drivers/clk/qcom/clk-rpmh.c +37 -0
 static inline struct clk_rpmh *to_clk_rpmh(struct clk_hw *_hw)
 {
        return container_of(_hw, struct clk_rpmh, hw);
@@ -579,6 +609,43 @@ static const struct clk_rpmh_desc clk_rpmh_sm8450 = {
        .num_clks = ARRAY_SIZE(sm8450_rpmh_clocks),
 };
 
+DEFINE_CLK_RPMH_ARC(sm8550, xo_pad, xo_pad_ao, "xo.lvl", 0x03, 2);
+DEFINE_CLK_RPMH_FIXED(sm8550, bi_tcxo, bi_tcxo_ao, xo_pad, xo_pad_ao, 2);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk1, rf_clk1_ao, "clka1", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk2, rf_clk2_ao, "clka2", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk3, rf_clk3_ao, "clka3", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, rf_clk4, rf_clk4_ao, "clka4", 1);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk1, ln_bb_clk1_ao, "clka6", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk2, ln_bb_clk2_ao, "clka7", 2);
+DEFINE_CLK_RPMH_VRM(sm8550, ln_bb_clk3, ln_bb_clk3_ao, "clka8", 2);
+
+static struct clk_hw *sm8550_rpmh_clocks[] = {
+       [RPMH_CXO_PAD_CLK]      = &sm8550_xo_pad.hw,
+       [RPMH_CXO_PAD_CLK_A]    = &sm8550_xo_pad_ao.hw,
+       [RPMH_CXO_CLK]          = &sm8550_bi_tcxo.hw,
+       [RPMH_CXO_CLK_A]        = &sm8550_bi_tcxo_ao.hw,
+       [RPMH_LN_BB_CLK1]       = &sm8550_ln_bb_clk1.hw,
+       [RPMH_LN_BB_CLK1_A]     = &sm8550_ln_bb_clk1_ao.hw,
+       [RPMH_LN_BB_CLK2]       = &sm8550_ln_bb_clk2.hw,
+       [RPMH_LN_BB_CLK2_A]     = &sm8550_ln_bb_clk2_ao.hw,
+       [RPMH_LN_BB_CLK3]       = &sm8550_ln_bb_clk3.hw,
+       [RPMH_LN_BB_CLK3_A]     = &sm8550_ln_bb_clk3_ao.hw,
+       [RPMH_RF_CLK1]          = &sm8550_rf_clk1.hw,
+       [RPMH_RF_CLK1_A]        = &sm8550_rf_clk1_ao.hw,
+       [RPMH_RF_CLK2]          = &sm8550_rf_clk2.hw,
+       [RPMH_RF_CLK2_A]        = &sm8550_rf_clk2_ao.hw,
+       [RPMH_RF_CLK3]          = &sm8550_rf_clk3.hw,
+       [RPMH_RF_CLK3_A]        = &sm8550_rf_clk3_ao.hw,
+       [RPMH_RF_CLK4]          = &sm8550_rf_clk4.hw,
+       [RPMH_RF_CLK4_A]        = &sm8550_rf_clk4_ao.hw,
+       [RPMH_IPA_CLK]          = &sdm845_ipa.hw,
+};
+
+static const struct clk_rpmh_desc clk_rpmh_sm8550 = {
+       .clks = sm8550_rpmh_clocks,
+       .num_clks = ARRAY_SIZE(sm8550_rpmh_clocks),
+};
+
 static struct clk_hw *sc7280_rpmh_clocks[] = {
        [RPMH_CXO_CLK]      = &sc7280_bi_tcxo.hw,
        [RPMH_CXO_CLK_A]    = &sc7280_bi_tcxo_ao.hw,
@@ -682,29 +749,31 @@ static int clk_rpmh_probe(struct platform_device *pdev)
 
                name = hw_clks[i]->init->name;
 
Quoted 10 lines

drivers/clk/qcom/clk-rpmh.c static int clk_rpmh_probe(struct platform_device *pdev) · line 752

Quoted 8 lines
drivers/clk/qcom/clk-rpmh.c +1 -7
-               rpmh_clk = to_clk_rpmh(hw_clks[i]);
-               res_addr = cmd_db_read_addr(rpmh_clk->res_name);
-               if (!res_addr) {
-                       dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
-                               rpmh_clk->res_name);
-                       return -ENODEV;
-               }
+               if (hw_clks[i]->init->ops != &clk_fixed_factor_ops) {

This looks ugly a bit. I'd rather add something like non_cmd_clks to

Right, but this complicates the xlate function without a really good reason. Assuming you meant multiple (different) arrays for cmd based and for non-cmd based (in this case fixed factor only), this would force the of_clk_rpmh_hw_get to look into different arrays, but then we only have one set of IDs. Wouldn't that make it even uglier? At least, right now we are being consistent after probe.

Quoted 61 lines

the clk_rpmh_desc data and register them separately. Or even worse, you can keep the rpmh as is, with only cmd-db based clocks and add a fixed factor clock to the sm8550 dtsi directly. I have a slight preference for the former method, but the latter would also work.

Quoted 51 lines
drivers/clk/qcom/clk-rpmh.c +22 -14
+                       rpmh_clk = to_clk_rpmh(hw_clks[i]);
+                       res_addr = cmd_db_read_addr(rpmh_clk->res_name);
+                       if (!res_addr) {
+                               dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
+                                       rpmh_clk->res_name);
+                               return -ENODEV;
+                       }
 
-               data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
-               if (IS_ERR(data)) {
-                       ret = PTR_ERR(data);
-                       dev_err(&pdev->dev,
-                               "error reading RPMh aux data for %s (%d)\n",
-                               rpmh_clk->res_name, ret);
-                       return ret;
-               }
+                       data = cmd_db_read_aux_data(rpmh_clk->res_name, &aux_data_len);
+                       if (IS_ERR(data)) {
+                               ret = PTR_ERR(data);
+                               dev_err(&pdev->dev,
+                                       "error reading RPMh aux data for %s (%d)\n",
+                                       rpmh_clk->res_name, ret);
+                               return ret;
+                       }
 
-               /* Convert unit from Khz to Hz */
-               if (aux_data_len == sizeof(*data))
-                       rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
+                       /* Convert unit from Khz to Hz */
+                       if (aux_data_len == sizeof(*data))
+                               rpmh_clk->unit = le32_to_cpu(data->unit) * 1000ULL;
 
-               rpmh_clk->res_addr += res_addr;
-               rpmh_clk->dev = &pdev->dev;
+                       rpmh_clk->res_addr += res_addr;
+                       rpmh_clk->dev = &pdev->dev;
+               }
 
                ret = devm_clk_hw_register(&pdev->dev, hw_clks[i]);
                if (ret) {
@@ -739,6 +808,7 @@ static const struct of_device_id clk_rpmh_match_table[] = {
        { .compatible = "qcom,sm8250-rpmh-clk", .data = &clk_rpmh_sm8250},
        { .compatible = "qcom,sm8350-rpmh-clk", .data = &clk_rpmh_sm8350},
        { .compatible = "qcom,sm8450-rpmh-clk", .data = &clk_rpmh_sm8450},
+       { .compatible = "qcom,sm8550-rpmh-clk", .data = &clk_rpmh_sm8550},
        { .compatible = "qcom,sc7280-rpmh-clk", .data = &clk_rpmh_sc7280},
        { }
 };
--

2.34.1

Signature · 2 lines
With best wishes
Dmitry
author
#16 lore raw

PATCH v4 9/9 clk: qcom: Add TCSR clock driver for SM8550

In reply to Abel Vesa

The TCSR clock controller found on SM8550 provides refclks for PCIE, USB and UFS. Add clock driver for it.

This patch is based on initial code downstream.

---
 drivers/clk/qcom/Kconfig         |   7 ++
 drivers/clk/qcom/Makefile        |   1 +
 drivers/clk/qcom/tcsrcc-sm8550.c | 193 +++++++++++++++++++++++++++++++
 3 files changed, 201 insertions(+)
 create mode 100644 drivers/clk/qcom/tcsrcc-sm8550.c
drivers/clk/qcom/Kconfig +7 -0
index e2cfa9c74bcf..67ce8c4d3ff9 100644
@@ -779,6 +779,13 @@ config SM_GPUCC_8350
 	  Say Y if you want to support graphics controller devices and
 	  functionality such as 3D graphics.
 
+config SM_TCSRCC_8550
+	tristate "SM8550 TCSR Clock Controller"
+	select QCOM_GDSC
+	help
+	  Support for the TCSR clock controller on SM8550 devices.
+	  Say Y if you want to use peripheral devices such as SD/UFS.
+
 config SM_VIDEOCC_8150
 	tristate "SM8150 Video Clock Controller"
 	select SM_GCC_8150
drivers/clk/qcom/Makefile +1 -0
index 06ae671bdea6..29469f1290e6 100644
@@ -110,6 +110,7 @@ obj-$(CONFIG_SM_GPUCC_6350) += gpucc-sm6350.o
 obj-$(CONFIG_SM_GPUCC_8150) += gpucc-sm8150.o
 obj-$(CONFIG_SM_GPUCC_8250) += gpucc-sm8250.o
 obj-$(CONFIG_SM_GPUCC_8350) += gpucc-sm8350.o
+obj-$(CONFIG_SM_TCSRCC_8550) += tcsrcc-sm8550.o
 obj-$(CONFIG_SM_VIDEOCC_8150) += videocc-sm8150.o
 obj-$(CONFIG_SM_VIDEOCC_8250) += videocc-sm8250.o
 obj-$(CONFIG_SPMI_PMIC_CLKDIV) += clk-spmi-pmic-div.o
drivers/clk/qcom/tcsrcc-sm8550.c new file +193 -0

193 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Applied
#17 lore raw

Re: (subset) [PATCH v4 0/9] clk: qcom: Add support for SM8550

In reply to Abel Vesa
Quoted 11 lines · Abel Vesa

This patchset adds clock support for the Qualcomm SM8550 SoC, It adds support for the new type of PLL, the TCSR clock controller driver, support for configurable poll timeout, the RPMh clocks and the bindings.

Changes since v3:
* Dropped the GDSC configurable poll timeout patch, like Stephen suggested
* Added Krzysztof's R-b tag to TCSRCC and GCC binding patches

[...]

Applied, thanks!

[1/9] dt-bindings: clock: Add SM8550 GCC clocks

      commit: 47ba9c50bbeb1c5005eb06ca0a2ab92604a54b62
[3/9] clk: qcom: gdsc: Increase status poll timeout
      commit: 7364379d725fc8240a90190dc9da662ada43d9d1
[4/9] clk: qcom: Add LUCID_OLE PLL type for SM8550
      commit: 1de7e70941fff80139df8a37d4b35264543e3fc0
[5/9] clk: qcom: Add GCC driver for SM8550
      commit: 955f2ea3b9e94d0fa20ce3a78ef3063923d41b58

Best regards,

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