Skip to contentSkip to conversation

gcc-sdm845: Add general purpose clock ops

PATCH In review Dzmitry Sankouski 2 participants 3 messages Jul 19, 2024 – Sep 13, 2024 1 message not in the archive

Subsystems (7)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20240719-starqltechn_integration_upstream-v4-0-a7f644821941@gmail.com

#1 lore raw

PATCH v4 27/28 gcc-sdm845: Add general purpose clock ops

SDM845 has "General Purpose" clocks that can be muxed to SoC pins to clock various external devices.
Those clocks may be used as e.g. PWM sources for external peripherals.

GPCLK can in theory have arbitrary value depending on the use case, so the concept of frequency tables, used in rcg2 clock driver, is not efficient, because it allows only defined frequencies.

Introduce clk_rcg2_gp_ops, which automatically calculate clock mnd values for arbitrary clock rate.

---
 drivers/clk/qcom/clk-rcg.h    |   1 +
 drivers/clk/qcom/clk-rcg2.c   | 162 ++++++++++++++++++++++++++++++++++++++++--
 drivers/clk/qcom/gcc-sdm845.c |  19 ++---
 drivers/pwm/pwm-clk.c         |   5 ++
 4 files changed, 167 insertions(+), 20 deletions(-)
drivers/clk/qcom/clk-rcg.h +1 -0
index d7414361e432..5bd86bce0c4d 100644
@@ -189,6 +189,7 @@ struct clk_rcg2_gfx3d {
 	container_of(to_clk_rcg2(_hw), struct clk_rcg2_gfx3d, rcg)
 
 extern const struct clk_ops clk_rcg2_ops;
+extern const struct clk_ops clk_rcg2_gp_ops;
 extern const struct clk_ops clk_rcg2_floor_ops;
 extern const struct clk_ops clk_rcg2_fm_ops;
 extern const struct clk_ops clk_rcg2_mux_closest_ops;
drivers/clk/qcom/clk-rcg2.c +156 -6

211 lines not on this page · raw message

drivers/clk/qcom/gcc-sdm845.c +5 -14
index 8d61d5a31542..1fb617b0ee47 100644
@@ -291,18 +291,9 @@ static struct clk_rcg2 gcc_sdm670_cpuss_rbcpr_clk_src = {
  * See comment in gcc-mam8916.c at ftbl_gcc_gp1_3_clk.
  */
 static const struct freq_tbl ftbl_gcc_gp1_clk_src[] = {
-	F(10000,   P_BI_TCXO,    16,  1, 120),
-	F(20000,   P_BI_TCXO,    16,  1, 60),
-	F(100000,  P_BI_TCXO,    16,  1,  12),
-	F(500000,  P_GPLL0_OUT_EVEN, 12, 1, 100),
-	F(1000000, P_GPLL0_OUT_EVEN, 12, 1, 50),
-	F(2500000, P_GPLL0_OUT_EVEN, 12, 1, 10),
-	F(5000000, P_GPLL0_OUT_EVEN, 12, 1, 5),
 	F(19200000, P_BI_TCXO, 1, 0, 0),
-	F(25000000, P_GPLL0_OUT_EVEN, 12, 0, 0),
-	F(50000000, P_GPLL0_OUT_EVEN, 6, 0, 0),
-	F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0),
-	F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
+	F(300000000, P_GPLL0_OUT_EVEN, 1, 0, 0),
+	F(600000000, P_GPLL0_OUT_MAIN, 1, 0, 0),
 	{ }
 };
 
@@ -316,7 +307,7 @@ static struct clk_rcg2 gcc_gp1_clk_src = {
 		.name = "gcc_gp1_clk_src",
 		.parent_data = gcc_parent_data_1,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_1),
-		.ops = &clk_rcg2_ops,
+		.ops = &clk_rcg2_gp_ops,
 	},
 };
 
@@ -330,7 +321,7 @@ static struct clk_rcg2 gcc_gp2_clk_src = {
 		.name = "gcc_gp2_clk_src",
 		.parent_data = gcc_parent_data_1,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_1),
-		.ops = &clk_rcg2_ops,
+		.ops = &clk_rcg2_gp_ops,
 	},
 };
 
@@ -344,7 +335,7 @@ static struct clk_rcg2 gcc_gp3_clk_src = {
 		.name = "gcc_gp3_clk_src",
 		.parent_data = gcc_parent_data_1,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_1),
-		.ops = &clk_rcg2_ops,
+		.ops = &clk_rcg2_gp_ops,
 	},
 };
 
drivers/pwm/pwm-clk.c +5 -0
index c19a482d7e28..1bfc7870e3aa 100644
@@ -25,6 +25,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/clk/clk-conf.h>
 #include <linux/pwm.h>
 
 struct pwm_clk_chip {
@@ -87,6 +88,10 @@ static int pwm_clk_probe(struct platform_device *pdev)
 	struct pwm_clk_chip *pcchip;
 	int ret;
 
+	ret = of_clk_set_defaults(pdev->dev.of_node, false);
+	if (ret < 0)
+		return -EINVAL;
+
 	chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*pcchip));
 	if (IS_ERR(chip))
 		return PTR_ERR(chip);
Signature · 1 line
2.39.2
#2 lore raw

Hello,

Quoted 11 lines · Dzmitry Sankouski

SDM845 has "General Purpose" clocks that can be muxed to SoC pins to clock various external devices.
Those clocks may be used as e.g. PWM sources for external peripherals.

GPCLK can in theory have arbitrary value depending on the use case, so the concept of frequency tables, used in rcg2 clock driver, is not efficient, because it allows only defined frequencies.

Introduce clk_rcg2_gp_ops, which automatically calculate clock mnd values for arbitrary clock rate.

Quoted 6 lines
---
 drivers/clk/qcom/clk-rcg.h    |   1 +
 drivers/clk/qcom/clk-rcg2.c   | 162 ++++++++++++++++++++++++++++++++++++++++--
 drivers/clk/qcom/gcc-sdm845.c |  19 ++---
 drivers/pwm/pwm-clk.c         |   5 ++

I don't understand why a change to some qcom clk implementation detail needs a change to drivers/pwm/pwm-clk.c in the same commit. I guess if the change to drivers/pwm/pwm-clk.c is needed it should better go into a separate patch with an appropriate commit log?!

Best regards
Uwe

#3 lore raw

вт, 10 сент. 2024 г. в 12:59, Uwe Kleine-König <[email protected]>:

Quoted 22 lines

Hello,

Quoted 11 lines · Dzmitry Sankouski

SDM845 has "General Purpose" clocks that can be muxed to SoC pins to clock various external devices.
Those clocks may be used as e.g. PWM sources for external peripherals.

GPCLK can in theory have arbitrary value depending on the use case, so the concept of frequency tables, used in rcg2 clock driver, is not efficient, because it allows only defined frequencies.

Introduce clk_rcg2_gp_ops, which automatically calculate clock mnd values for arbitrary clock rate.

Quoted 6 lines
---
 drivers/clk/qcom/clk-rcg.h    |   1 +
 drivers/clk/qcom/clk-rcg2.c   | 162 ++++++++++++++++++++++++++++++++++++++++--
 drivers/clk/qcom/gcc-sdm845.c |  19 ++---
 drivers/pwm/pwm-clk.c         |   5 ++
Quoted 5 lines

I don't understand why a change to some qcom clk implementation detail needs a change to drivers/pwm/pwm-clk.c in the same commit. I guess if the change to drivers/pwm/pwm-clk.c is needed it should better go into a separate patch with an appropriate commit log?!

You're right, I'll fix that. Also I heavily rewrote this patch, and included it in
starqltechn patch series. Since this patch has the wrong version (sorry for my mistake) and order numbering, please consider the next patch a successor of it.

Signature · 2 lines
Best regards,
Dzmitry