devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Bjorn Andersson <andersson@kernel.org>,
	 Michael Turquette <mturquette@baylibre.com>,
	 Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	Taniya Das <quic_tdas@quicinc.com>,
	 Neil Armstrong <neil.armstrong@linaro.org>,
	 Philipp Zabel <p.zabel@pengutronix.de>,
	 Konrad Dybcio <konradybcio@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
	 devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 08/14] clk: qcom: rcg2: add clk_rcg2_shared_floor_ops
Date: Thu, 17 Oct 2024 19:56:58 +0300	[thread overview]
Message-ID: <20241017-sar2130p-clocks-v1-8-f75e740f0a8d@linaro.org> (raw)
In-Reply-To: <20241017-sar2130p-clocks-v1-0-f75e740f0a8d@linaro.org>

Generally SDCC clocks use clk_rcg2_floor_ops, however on SAR2130P
platform it's recommended to use rcg2_shared_ops for all Root Clock
Generators to park them instead of disabling. Implement a mix of those,
clk_rcg2_shared_floor_ops.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/clk/qcom/clk-rcg.h  |  1 +
 drivers/clk/qcom/clk-rcg2.c | 48 ++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h
index 8e0f3372dc7a8373d405ef38e3d5c747a6d51383..80f1f4fcd52a68d8da15e3e1405703b6ddc23421 100644
--- a/drivers/clk/qcom/clk-rcg.h
+++ b/drivers/clk/qcom/clk-rcg.h
@@ -198,6 +198,7 @@ extern const struct clk_ops clk_byte2_ops;
 extern const struct clk_ops clk_pixel_ops;
 extern const struct clk_ops clk_gfx3d_ops;
 extern const struct clk_ops clk_rcg2_shared_ops;
+extern const struct clk_ops clk_rcg2_shared_floor_ops;
 extern const struct clk_ops clk_rcg2_shared_no_init_park_ops;
 extern const struct clk_ops clk_dp_ops;
 
diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
index bf26c5448f006724b447bb0d9b11889d316cb6d0..bf6406f5279a4c75c0a42534c15e9884e4965c00 100644
--- a/drivers/clk/qcom/clk-rcg2.c
+++ b/drivers/clk/qcom/clk-rcg2.c
@@ -1186,15 +1186,23 @@ clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, const struct freq_tbl *f)
 	return clk_rcg2_clear_force_enable(hw);
 }
 
-static int clk_rcg2_shared_set_rate(struct clk_hw *hw, unsigned long rate,
-				    unsigned long parent_rate)
+static int __clk_rcg2_shared_set_rate(struct clk_hw *hw, unsigned long rate,
+				      unsigned long parent_rate,
+				      enum freq_policy policy)
 {
 	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
 	const struct freq_tbl *f;
 
-	f = qcom_find_freq(rcg->freq_tbl, rate);
-	if (!f)
+	switch (policy) {
+	case FLOOR:
+		f = qcom_find_freq_floor(rcg->freq_tbl, rate);
+		break;
+	case CEIL:
+		f = qcom_find_freq(rcg->freq_tbl, rate);
+		break;
+	default:
 		return -EINVAL;
+	}
 
 	/*
 	 * In case clock is disabled, update the M, N and D registers, cache
@@ -1207,10 +1215,28 @@ static int clk_rcg2_shared_set_rate(struct clk_hw *hw, unsigned long rate,
 	return clk_rcg2_shared_force_enable_clear(hw, f);
 }
 
+static int clk_rcg2_shared_set_rate(struct clk_hw *hw, unsigned long rate,
+				    unsigned long parent_rate)
+{
+	return __clk_rcg2_shared_set_rate(hw, rate, parent_rate, CEIL);
+}
+
 static int clk_rcg2_shared_set_rate_and_parent(struct clk_hw *hw,
 		unsigned long rate, unsigned long parent_rate, u8 index)
 {
-	return clk_rcg2_shared_set_rate(hw, rate, parent_rate);
+	return __clk_rcg2_shared_set_rate(hw, rate, parent_rate, CEIL);
+}
+
+static int clk_rcg2_shared_set_floor_rate(struct clk_hw *hw, unsigned long rate,
+					  unsigned long parent_rate)
+{
+	return __clk_rcg2_shared_set_rate(hw, rate, parent_rate, FLOOR);
+}
+
+static int clk_rcg2_shared_set_floor_rate_and_parent(struct clk_hw *hw,
+		unsigned long rate, unsigned long parent_rate, u8 index)
+{
+	return __clk_rcg2_shared_set_rate(hw, rate, parent_rate, FLOOR);
 }
 
 static int clk_rcg2_shared_enable(struct clk_hw *hw)
@@ -1348,6 +1374,18 @@ const struct clk_ops clk_rcg2_shared_ops = {
 };
 EXPORT_SYMBOL_GPL(clk_rcg2_shared_ops);
 
+const struct clk_ops clk_rcg2_shared_floor_ops = {
+	.enable = clk_rcg2_shared_enable,
+	.disable = clk_rcg2_shared_disable,
+	.get_parent = clk_rcg2_shared_get_parent,
+	.set_parent = clk_rcg2_shared_set_parent,
+	.recalc_rate = clk_rcg2_shared_recalc_rate,
+	.determine_rate = clk_rcg2_determine_floor_rate,
+	.set_rate = clk_rcg2_shared_set_floor_rate,
+	.set_rate_and_parent = clk_rcg2_shared_set_floor_rate_and_parent,
+};
+EXPORT_SYMBOL_GPL(clk_rcg2_shared_floor_ops);
+
 static int clk_rcg2_shared_no_init_park(struct clk_hw *hw)
 {
 	struct clk_rcg2 *rcg = to_clk_rcg2(hw);

-- 
2.39.5


  parent reply	other threads:[~2024-10-17 16:57 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17 16:56 [PATCH 00/14] clk: qcom: add support for clock controllers on the SAR2130P platform Dmitry Baryshkov
2024-10-17 16:56 ` [PATCH 01/14] dt-bindings: clock: qcom,rpmhcc: Add SAR2130P compatible Dmitry Baryshkov
2024-10-21  7:51   ` Krzysztof Kozlowski
2024-10-17 16:56 ` [PATCH 02/14] dt-bindings: clock: qcom: document SAR2130P Global Clock Controller Dmitry Baryshkov
2024-10-18  6:50   ` Krzysztof Kozlowski
2024-10-17 16:56 ` [PATCH 03/14] dt-bindings: clock: qcom,sm8550-tcsr: Add SAR2130P compatible Dmitry Baryshkov
2024-10-18  7:09   ` Krzysztof Kozlowski
2024-10-17 16:56 ` [PATCH 04/14] dt-bindings: clock: qcom,sm8550-dispcc: " Dmitry Baryshkov
2024-10-21  7:52   ` Krzysztof Kozlowski
2024-10-17 16:56 ` [PATCH 05/14] dt-bindings: clk: qcom,sm8450-gpucc: add SAR2130P compatibles Dmitry Baryshkov
2024-10-18  6:51   ` Krzysztof Kozlowski
2024-10-18  7:10   ` Krzysztof Kozlowski
2024-10-18  8:34     ` Dmitry Baryshkov
2024-10-17 16:56 ` [PATCH 06/14] clk: qcom: clk-branch: Add support for BRANCH_HALT_POLL flag Dmitry Baryshkov
2024-10-17 18:03   ` Stephen Boyd
2024-10-17 22:05     ` Dmitry Baryshkov
2024-10-18 11:02       ` Taniya Das
2024-10-18 11:12         ` Dmitry Baryshkov
2024-10-17 16:56 ` [PATCH 07/14] clk: qcom: clk-branch: Add support for SREG branch ops Dmitry Baryshkov
2024-10-17 18:10   ` Stephen Boyd
2024-10-17 22:00     ` Dmitry Baryshkov
2024-10-17 22:28       ` Stephen Boyd
2024-10-18  9:56         ` Dmitry Baryshkov
2024-10-18 10:50           ` Taniya Das
2024-10-18 10:53             ` Dmitry Baryshkov
2024-10-17 16:56 ` Dmitry Baryshkov [this message]
2024-10-17 16:56 ` [PATCH 09/14] clk: qcom: gdsc: add separate sleep state collapse vote support Dmitry Baryshkov
2024-10-18 10:28   ` Taniya Das
2024-10-18 10:48     ` Dmitry Baryshkov
2024-10-17 16:57 ` [PATCH 10/14] clk: qcom: rpmh: add support for SAR2130P Dmitry Baryshkov
2024-10-17 19:11   ` Konrad Dybcio
2024-10-17 16:57 ` [PATCH 11/14] clk: qcom: add support for GCC on SAR2130P Dmitry Baryshkov
2024-10-20 23:30   ` kernel test robot
2024-10-20 23:52   ` kernel test robot
2024-10-17 16:57 ` [PATCH 12/14] clk: qcom: tcsrcc-sm8550: add SAR2130P support Dmitry Baryshkov
2024-10-17 19:13   ` Konrad Dybcio
2024-10-17 16:57 ` [PATCH 13/14] clk: qcom: dispcc-sm8550: enable support for SAR2130P Dmitry Baryshkov
2024-10-18  7:26   ` Neil Armstrong
2024-10-17 16:57 ` [PATCH 14/14] clk: qcom: add SAR2130P GPU Clock Controller support Dmitry Baryshkov
2024-10-17 19:21   ` Konrad Dybcio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241017-sar2130p-clocks-v1-8-f75e740f0a8d@linaro.org \
    --to=dmitry.baryshkov@linaro.org \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=neil.armstrong@linaro.org \
    --cc=p.zabel@pengutronix.de \
    --cc=quic_tdas@quicinc.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).