All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: Biju Das <biju.das.jz@bp.renesas.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	Biju Das <biju.das.au@gmail.com>
Subject: [PATCH RFC 2/3] clk: renesas: rzg2l: Add disable_sync() callback
Date: Wed, 31 Jan 2024 16:09:46 +0000	[thread overview]
Message-ID: <20240131160947.96171-3-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20240131160947.96171-1-biju.das.jz@bp.renesas.com>

Add disable_sync() callback to synchronize clk gating operation.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/clk/renesas/rzg2l-cpg.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c
index 3d2daa4ba2a4..7baf0d7217e2 100644
--- a/drivers/clk/renesas/rzg2l-cpg.c
+++ b/drivers/clk/renesas/rzg2l-cpg.c
@@ -1277,6 +1277,28 @@ static void rzg2l_mod_clock_disable(struct clk_hw *hw)
 	rzg2l_mod_clock_endisable(hw, false);
 }
 
+static void rzg2l_mod_clock_disable_sync(struct clk_hw *hw)
+{
+	struct mstp_clock *clock = to_mod_clock(hw);
+	struct rzg2l_cpg_priv *priv = clock->priv;
+	struct device *dev = priv->dev;
+	unsigned int reg = clock->off;
+	u32 bitmask = BIT(clock->bit);
+	u32 value;
+	int error;
+
+	rzg2l_mod_clock_disable(hw);
+
+	if (!priv->info->has_clk_mon_regs)
+		return;
+
+	error = readl_poll_timeout_atomic(priv->base + CLK_MON_R(reg), value,
+					  !(value & bitmask), 0, 10);
+	if (error)
+		dev_err(dev, "Failed to disable CLK %p\n",
+			priv->base + CLK_ON_R(reg));
+}
+
 static int rzg2l_mod_clock_is_enabled(struct clk_hw *hw)
 {
 	struct mstp_clock *clock = to_mod_clock(hw);
@@ -1303,6 +1325,7 @@ static int rzg2l_mod_clock_is_enabled(struct clk_hw *hw)
 static const struct clk_ops rzg2l_mod_clock_ops = {
 	.enable = rzg2l_mod_clock_enable,
 	.disable = rzg2l_mod_clock_disable,
+	.disable_sync = rzg2l_mod_clock_disable_sync,
 	.is_enabled = rzg2l_mod_clock_is_enabled,
 };
 
-- 
2.25.1


  parent reply	other threads:[~2024-01-31 16:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31 16:09 [PATCH RFC 0/3] Add clk_disable_unprepare_sync() Biju Das
2024-01-31 16:09 ` [PATCH RFC 1/3] clk: " Biju Das
2024-02-06 22:58   ` Laurent Pinchart
2024-02-11 16:17     ` Biju Das
2024-01-31 16:09 ` Biju Das [this message]
2024-01-31 16:09 ` [PATCH RFC 3/3] media: platform: rzg2l-cru: rzg2l-video: Use clk_disable_unprepare_sync() Biju Das

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=20240131160947.96171-3-biju.das.jz@bp.renesas.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=biju.das.au@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=sakari.ailus@linux.intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.