linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/7] clk: qcom: clk-rcg2: add rcg2 mux ops
@ 2022-07-11 21:06 Robert Marko
  2022-07-11 21:06 ` [PATCH v2 2/7] clk: qcom: apss-ipq6018: fix apcs_alias0_clk_src Robert Marko
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Robert Marko @ 2022-07-11 21:06 UTC (permalink / raw)
  To: bjorn.andersson, agross, konrad.dybcio, mturquette, sboyd,
	robh+dt, krzysztof.kozlowski+dt, linux-arm-msm, linux-clk,
	devicetree, linux-kernel
  Cc: Christian Marangi, Robert Marko, Dmitry Baryshkov

From: Christian Marangi <ansuelsmth@gmail.com>

An RCG may act as a mux that switch between 2 parents.
This is the case on IPQ6018 and IPQ8074 where the APCS core clk that feeds
the CPU cluster clock just switches between XO and the PLL that feeds it.

Add the required ops to add support for this special configuration and use
the generic mux function to determine the rate.

This way we dont have to keep a essentially dummy frequency table to use
RCG2 as a mux.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/clk/qcom/clk-rcg.h  | 1 +
 drivers/clk/qcom/clk-rcg2.c | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h
index 012e745794fd..01581f4d2c39 100644
--- a/drivers/clk/qcom/clk-rcg.h
+++ b/drivers/clk/qcom/clk-rcg.h
@@ -167,6 +167,7 @@ struct clk_rcg2_gfx3d {
 
 extern const struct clk_ops clk_rcg2_ops;
 extern const struct clk_ops clk_rcg2_floor_ops;
+extern const struct clk_ops clk_rcg2_mux_closest_ops;
 extern const struct clk_ops clk_edp_pixel_ops;
 extern const struct clk_ops clk_byte_ops;
 extern const struct clk_ops clk_byte2_ops;
diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
index 28019edd2a50..609c10f8d0d9 100644
--- a/drivers/clk/qcom/clk-rcg2.c
+++ b/drivers/clk/qcom/clk-rcg2.c
@@ -509,6 +509,13 @@ const struct clk_ops clk_rcg2_floor_ops = {
 };
 EXPORT_SYMBOL_GPL(clk_rcg2_floor_ops);
 
+const struct clk_ops clk_rcg2_mux_closest_ops = {
+	.determine_rate = __clk_mux_determine_rate_closest,
+	.get_parent = clk_rcg2_get_parent,
+	.set_parent = clk_rcg2_set_parent,
+};
+EXPORT_SYMBOL_GPL(clk_rcg2_mux_closest_ops);
+
 struct frac_entry {
 	int num;
 	int den;
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/7] clk: qcom: apss-ipq6018: fix apcs_alias0_clk_src
  2022-07-11 21:06 [PATCH v2 1/7] clk: qcom: clk-rcg2: add rcg2 mux ops Robert Marko
@ 2022-07-11 21:06 ` Robert Marko
  2022-07-11 21:06 ` [PATCH v2 3/7] clk: qcom: apss-ipq6018: mark apcs_alias0_core_clk as critical Robert Marko
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Marko @ 2022-07-11 21:06 UTC (permalink / raw)
  To: bjorn.andersson, agross, konrad.dybcio, mturquette, sboyd,
	robh+dt, krzysztof.kozlowski+dt, linux-arm-msm, linux-clk,
	devicetree, linux-kernel
  Cc: Robert Marko, Dmitry Baryshkov

While working on IPQ8074 APSS driver it was discovered that IPQ6018 and
IPQ8074 use almost the same PLL and APSS clocks, however APSS driver is
currently broken.

More precisely apcs_alias0_clk_src is broken, it was added as regmap_mux
clock.
However after debugging why it was always stuck at 800Mhz, it was figured
out that its not regmap_mux compatible at all.
It is a simple mux but it uses RCG2 register layout and control bits, so
utilize the new clk_rcg2_mux_closest_ops to correctly drive it while not
having to provide a dummy frequency table.

While we are here, use ARRAY_SIZE for number of parents.

Tested on IPQ6018-CP01-C1 reference board and multiple IPQ8074 boards.

Fixes: 5e77b4ef1b19 ("clk: qcom: Add ipq6018 apss clock controller")
Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/clk/qcom/apss-ipq6018.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/qcom/apss-ipq6018.c b/drivers/clk/qcom/apss-ipq6018.c
index d78ff2f310bf..be952d417ded 100644
--- a/drivers/clk/qcom/apss-ipq6018.c
+++ b/drivers/clk/qcom/apss-ipq6018.c
@@ -16,7 +16,7 @@
 #include "clk-regmap.h"
 #include "clk-branch.h"
 #include "clk-alpha-pll.h"
-#include "clk-regmap-mux.h"
+#include "clk-rcg.h"
 
 enum {
 	P_XO,
@@ -33,16 +33,15 @@ static const struct parent_map parents_apcs_alias0_clk_src_map[] = {
 	{ P_APSS_PLL_EARLY, 5 },
 };
 
-static struct clk_regmap_mux apcs_alias0_clk_src = {
-	.reg = 0x0050,
-	.width = 3,
-	.shift = 7,
+static struct clk_rcg2 apcs_alias0_clk_src = {
+	.cmd_rcgr = 0x0050,
+	.hid_width = 5,
 	.parent_map = parents_apcs_alias0_clk_src_map,
 	.clkr.hw.init = &(struct clk_init_data){
 		.name = "apcs_alias0_clk_src",
 		.parent_data = parents_apcs_alias0_clk_src,
-		.num_parents = 2,
-		.ops = &clk_regmap_mux_closest_ops,
+		.num_parents = ARRAY_SIZE(parents_apcs_alias0_clk_src),
+		.ops = &clk_rcg2_mux_closest_ops,
 		.flags = CLK_SET_RATE_PARENT,
 	},
 };
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/7] clk: qcom: apss-ipq6018: mark apcs_alias0_core_clk as critical
  2022-07-11 21:06 [PATCH v2 1/7] clk: qcom: clk-rcg2: add rcg2 mux ops Robert Marko
  2022-07-11 21:06 ` [PATCH v2 2/7] clk: qcom: apss-ipq6018: fix apcs_alias0_clk_src Robert Marko
@ 2022-07-11 21:06 ` Robert Marko
  2022-07-11 21:06 ` [PATCH v2 4/7] dt-bindings: clock: qcom,a53pll: add IPQ8074 compatible Robert Marko
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Marko @ 2022-07-11 21:06 UTC (permalink / raw)
  To: bjorn.andersson, agross, konrad.dybcio, mturquette, sboyd,
	robh+dt, krzysztof.kozlowski+dt, linux-arm-msm, linux-clk,
	devicetree, linux-kernel
  Cc: Robert Marko, Dmitry Baryshkov

While fixing up the driver I noticed that my IPQ8074 board was hanging
after CPUFreq switched the frequency during boot, WDT would eventually
reset it.

So mark apcs_alias0_core_clk as critical since its the clock feeding the
CPU cluster and must never be disabled.

Fixes: 5e77b4ef1b19 ("clk: qcom: Add ipq6018 apss clock controller")
Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/clk/qcom/apss-ipq6018.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/qcom/apss-ipq6018.c b/drivers/clk/qcom/apss-ipq6018.c
index be952d417ded..f2f502e2d5a4 100644
--- a/drivers/clk/qcom/apss-ipq6018.c
+++ b/drivers/clk/qcom/apss-ipq6018.c
@@ -56,7 +56,7 @@ static struct clk_branch apcs_alias0_core_clk = {
 			.parent_hws = (const struct clk_hw *[]){
 				&apcs_alias0_clk_src.clkr.hw },
 			.num_parents = 1,
-			.flags = CLK_SET_RATE_PARENT,
+			.flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
 			.ops = &clk_branch2_ops,
 		},
 	},
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 4/7] dt-bindings: clock: qcom,a53pll: add IPQ8074 compatible
  2022-07-11 21:06 [PATCH v2 1/7] clk: qcom: clk-rcg2: add rcg2 mux ops Robert Marko
  2022-07-11 21:06 ` [PATCH v2 2/7] clk: qcom: apss-ipq6018: fix apcs_alias0_clk_src Robert Marko
  2022-07-11 21:06 ` [PATCH v2 3/7] clk: qcom: apss-ipq6018: mark apcs_alias0_core_clk as critical Robert Marko
@ 2022-07-11 21:06 ` Robert Marko
  2022-07-11 21:06 ` [PATCH v2 5/7] clk: qcom: apss-ipq-pll: use OF match data for Alpha PLL config Robert Marko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Marko @ 2022-07-11 21:06 UTC (permalink / raw)
  To: bjorn.andersson, agross, konrad.dybcio, mturquette, sboyd,
	robh+dt, krzysztof.kozlowski+dt, linux-arm-msm, linux-clk,
	devicetree, linux-kernel
  Cc: Robert Marko, Krzysztof Kozlowski

Add IPQ8074 compatible to A53 PLL bindings.

Signed-off-by: Robert Marko <robimarko@gmail.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 Documentation/devicetree/bindings/clock/qcom,a53pll.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/clock/qcom,a53pll.yaml b/Documentation/devicetree/bindings/clock/qcom,a53pll.yaml
index fbd758470b88..76830816982e 100644
--- a/Documentation/devicetree/bindings/clock/qcom,a53pll.yaml
+++ b/Documentation/devicetree/bindings/clock/qcom,a53pll.yaml
@@ -17,6 +17,7 @@ properties:
   compatible:
     enum:
       - qcom,ipq6018-a53pll
+      - qcom,ipq8074-a53pll
       - qcom,msm8916-a53pll
       - qcom,msm8939-a53pll
 
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 5/7] clk: qcom: apss-ipq-pll: use OF match data for Alpha PLL config
  2022-07-11 21:06 [PATCH v2 1/7] clk: qcom: clk-rcg2: add rcg2 mux ops Robert Marko
                   ` (2 preceding siblings ...)
  2022-07-11 21:06 ` [PATCH v2 4/7] dt-bindings: clock: qcom,a53pll: add IPQ8074 compatible Robert Marko
@ 2022-07-11 21:06 ` Robert Marko
  2022-07-11 21:06 ` [PATCH v2 6/7] clk: qcom: apss-ipq-pll: update IPQ6018 " Robert Marko
  2022-07-11 21:06 ` [PATCH v2 7/7] clk: qcom: apss-ipq-pll: add support for IPQ8074 Robert Marko
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Marko @ 2022-07-11 21:06 UTC (permalink / raw)
  To: bjorn.andersson, agross, konrad.dybcio, mturquette, sboyd,
	robh+dt, krzysztof.kozlowski+dt, linux-arm-msm, linux-clk,
	devicetree, linux-kernel
  Cc: Robert Marko

Convert the driver to use OF match data for providing the Alpha PLL config
per compatible.
This is required for IPQ8074 support since it uses a different Alpha PLL
config.

While we are here rename "ipq_pll_config" to "ipq6018_pll_config" to make
it clear that it is for IPQ6018 only.

Signed-off-by: Robert Marko <robimarko@gmail.com>
---
 drivers/clk/qcom/apss-ipq-pll.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/qcom/apss-ipq-pll.c b/drivers/clk/qcom/apss-ipq-pll.c
index bef7899ad0d6..ba77749b16c4 100644
--- a/drivers/clk/qcom/apss-ipq-pll.c
+++ b/drivers/clk/qcom/apss-ipq-pll.c
@@ -2,6 +2,7 @@
 // Copyright (c) 2018, The Linux Foundation. All rights reserved.
 #include <linux/clk-provider.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 
@@ -36,7 +37,7 @@ static struct clk_alpha_pll ipq_pll = {
 	},
 };
 
-static const struct alpha_pll_config ipq_pll_config = {
+static const struct alpha_pll_config ipq6018_pll_config = {
 	.l = 0x37,
 	.config_ctl_val = 0x04141200,
 	.config_ctl_hi_val = 0x0,
@@ -54,6 +55,7 @@ static const struct regmap_config ipq_pll_regmap_config = {
 
 static int apss_ipq_pll_probe(struct platform_device *pdev)
 {
+	const struct alpha_pll_config *ipq_pll_config;
 	struct device *dev = &pdev->dev;
 	struct regmap *regmap;
 	void __iomem *base;
@@ -67,7 +69,11 @@ static int apss_ipq_pll_probe(struct platform_device *pdev)
 	if (IS_ERR(regmap))
 		return PTR_ERR(regmap);
 
-	clk_alpha_pll_configure(&ipq_pll, regmap, &ipq_pll_config);
+	ipq_pll_config = of_device_get_match_data(&pdev->dev);
+	if (!ipq_pll_config)
+		return -ENODEV;
+
+	clk_alpha_pll_configure(&ipq_pll, regmap, ipq_pll_config);
 
 	ret = devm_clk_register_regmap(dev, &ipq_pll.clkr);
 	if (ret)
@@ -78,7 +84,7 @@ static int apss_ipq_pll_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id apss_ipq_pll_match_table[] = {
-	{ .compatible = "qcom,ipq6018-a53pll" },
+	{ .compatible = "qcom,ipq6018-a53pll", .data = &ipq6018_pll_config },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, apss_ipq_pll_match_table);
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 6/7] clk: qcom: apss-ipq-pll: update IPQ6018 Alpha PLL config
  2022-07-11 21:06 [PATCH v2 1/7] clk: qcom: clk-rcg2: add rcg2 mux ops Robert Marko
                   ` (3 preceding siblings ...)
  2022-07-11 21:06 ` [PATCH v2 5/7] clk: qcom: apss-ipq-pll: use OF match data for Alpha PLL config Robert Marko
@ 2022-07-11 21:06 ` Robert Marko
  2022-07-11 21:06 ` [PATCH v2 7/7] clk: qcom: apss-ipq-pll: add support for IPQ8074 Robert Marko
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Marko @ 2022-07-11 21:06 UTC (permalink / raw)
  To: bjorn.andersson, agross, konrad.dybcio, mturquette, sboyd,
	robh+dt, krzysztof.kozlowski+dt, linux-arm-msm, linux-clk,
	devicetree, linux-kernel
  Cc: Robert Marko

Update the IPQ6018 Alpha PLL config to the latest one from the downstream
5.4 kernel[1].

This one should match the production SoC-s.

Tested on IPQ6018 CP01-C1 reference board.

[1] https://git.codelinaro.org/clo/qsdk/oss/kernel/linux-ipq-5.4/-/blob/NHSS.QSDK.12.1.r4/drivers/clk/qcom/apss-ipq-pll.c#L41
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
 drivers/clk/qcom/apss-ipq-pll.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/qcom/apss-ipq-pll.c b/drivers/clk/qcom/apss-ipq-pll.c
index ba77749b16c4..a4016f3854c2 100644
--- a/drivers/clk/qcom/apss-ipq-pll.c
+++ b/drivers/clk/qcom/apss-ipq-pll.c
@@ -39,10 +39,14 @@ static struct clk_alpha_pll ipq_pll = {
 
 static const struct alpha_pll_config ipq6018_pll_config = {
 	.l = 0x37,
-	.config_ctl_val = 0x04141200,
-	.config_ctl_hi_val = 0x0,
+	.config_ctl_val = 0x240d4828,
+	.config_ctl_hi_val = 0x6,
 	.early_output_mask = BIT(3),
+	.aux2_output_mask = BIT(2),
+	.aux_output_mask = BIT(1),
 	.main_output_mask = BIT(0),
+	.test_ctl_val = 0x1c0000C0,
+	.test_ctl_hi_val = 0x4000,
 };
 
 static const struct regmap_config ipq_pll_regmap_config = {
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 7/7] clk: qcom: apss-ipq-pll: add support for IPQ8074
  2022-07-11 21:06 [PATCH v2 1/7] clk: qcom: clk-rcg2: add rcg2 mux ops Robert Marko
                   ` (4 preceding siblings ...)
  2022-07-11 21:06 ` [PATCH v2 6/7] clk: qcom: apss-ipq-pll: update IPQ6018 " Robert Marko
@ 2022-07-11 21:06 ` Robert Marko
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Marko @ 2022-07-11 21:06 UTC (permalink / raw)
  To: bjorn.andersson, agross, konrad.dybcio, mturquette, sboyd,
	robh+dt, krzysztof.kozlowski+dt, linux-arm-msm, linux-clk,
	devicetree, linux-kernel
  Cc: Robert Marko

Add support for IPQ8074 since it uses the same PLL setup, however it uses
slightly different Alpha PLL config.

Alpha PLL config was obtained by dumping PLL registers from a running
device.

Signed-off-by: Robert Marko <robimarko@gmail.com>
---
Changes in v2:
* Drop hardcoded compatible check for IPQ6018 to do the PLL config and
utilize match data provided by previous commit
* Add IPQ8074 Alpha PLL config using match data
* Update commit description to reflect changes
---
 drivers/clk/qcom/apss-ipq-pll.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/clk/qcom/apss-ipq-pll.c b/drivers/clk/qcom/apss-ipq-pll.c
index a4016f3854c2..a5aea27eb867 100644
--- a/drivers/clk/qcom/apss-ipq-pll.c
+++ b/drivers/clk/qcom/apss-ipq-pll.c
@@ -49,6 +49,18 @@ static const struct alpha_pll_config ipq6018_pll_config = {
 	.test_ctl_hi_val = 0x4000,
 };
 
+static const struct alpha_pll_config ipq8074_pll_config = {
+	.l = 0x48,
+	.config_ctl_val = 0x200d4828,
+	.config_ctl_hi_val = 0x6,
+	.early_output_mask = BIT(3),
+	.aux2_output_mask = BIT(2),
+	.aux_output_mask = BIT(1),
+	.main_output_mask = BIT(0),
+	.test_ctl_val = 0x1c000000,
+	.test_ctl_hi_val = 0x4000,
+};
+
 static const struct regmap_config ipq_pll_regmap_config = {
 	.reg_bits		= 32,
 	.reg_stride		= 4,
@@ -89,6 +101,7 @@ static int apss_ipq_pll_probe(struct platform_device *pdev)
 
 static const struct of_device_id apss_ipq_pll_match_table[] = {
 	{ .compatible = "qcom,ipq6018-a53pll", .data = &ipq6018_pll_config },
+	{ .compatible = "qcom,ipq8074-a53pll", .data = &ipq8074_pll_config },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, apss_ipq_pll_match_table);
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-11 21:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-11 21:06 [PATCH v2 1/7] clk: qcom: clk-rcg2: add rcg2 mux ops Robert Marko
2022-07-11 21:06 ` [PATCH v2 2/7] clk: qcom: apss-ipq6018: fix apcs_alias0_clk_src Robert Marko
2022-07-11 21:06 ` [PATCH v2 3/7] clk: qcom: apss-ipq6018: mark apcs_alias0_core_clk as critical Robert Marko
2022-07-11 21:06 ` [PATCH v2 4/7] dt-bindings: clock: qcom,a53pll: add IPQ8074 compatible Robert Marko
2022-07-11 21:06 ` [PATCH v2 5/7] clk: qcom: apss-ipq-pll: use OF match data for Alpha PLL config Robert Marko
2022-07-11 21:06 ` [PATCH v2 6/7] clk: qcom: apss-ipq-pll: update IPQ6018 " Robert Marko
2022-07-11 21:06 ` [PATCH v2 7/7] clk: qcom: apss-ipq-pll: add support for IPQ8074 Robert Marko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).