All of lore.kernel.org
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@linaro.org>
To: Mike Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-arm-msm@vger.kernel.org, Abel Vesa <abel.vesa@linaro.org>
Subject: [RFC] clk: Add clk_hw based provider enable/disable API
Date: Mon,  4 Jul 2022 21:57:33 +0300	[thread overview]
Message-ID: <20220704185733.1288578-1-abel.vesa@linaro.org> (raw)

Sometimes, a clock needs to be enabled or disabled by the provider,
without actually touching the enable count. For example, a clock
provider driver might choose to disable some unused clocks on sync state
callback rather than on the default clk_disable_unused. Such clocks are
usually enabled by bootloader and need to stay ungated until some driver
built as module probes. So add clk_hw enable/disable to allow the clock
provider drivers to disable such clocks on sync state callback.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
 drivers/clk/clk.c            | 25 +++++++++++++++++++++++++
 include/linux/clk-provider.h |  2 ++
 2 files changed, 27 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index f00d4c1158d7..a727cffb6bba 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1011,6 +1011,17 @@ void clk_disable(struct clk *clk)
 }
 EXPORT_SYMBOL_GPL(clk_disable);
 
+void clk_hw_disable(const struct clk_hw *hw)
+{
+	struct clk_core *core = hw->core;
+
+	trace_clk_disable(core);
+	if (core->ops->disable)
+		core->ops->disable(core->hw);
+	trace_clk_disable_complete(core);
+}
+EXPORT_SYMBOL_GPL(clk_hw_disable);
+
 static int clk_core_enable(struct clk_core *core)
 {
 	int ret = 0;
@@ -1176,6 +1187,20 @@ int clk_enable(struct clk *clk)
 }
 EXPORT_SYMBOL_GPL(clk_enable);
 
+int clk_hw_enable(const struct clk_hw *hw)
+{
+	struct clk_core *core = hw->core;
+	int ret = 0;
+
+	trace_clk_enable(core);
+	if (core->ops->enable)
+		ret = core->ops->enable(core->hw);
+	trace_clk_enable_complete(core);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(clk_hw_enable);
+
 /**
  * clk_is_enabled_when_prepared - indicate if preparing a clock also enables it.
  * @clk: clock source
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index c10dc4c659e2..0f9968a7a6d2 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -1212,6 +1212,8 @@ unsigned long clk_hw_get_flags(const struct clk_hw *hw);
 bool clk_hw_is_prepared(const struct clk_hw *hw);
 bool clk_hw_rate_is_protected(const struct clk_hw *hw);
 bool clk_hw_is_enabled(const struct clk_hw *hw);
+int clk_hw_enable(const struct clk_hw *hw);
+void clk_hw_disable(const struct clk_hw *hw);
 bool __clk_is_enabled(struct clk *clk);
 struct clk *__clk_lookup(const char *name);
 int __clk_mux_determine_rate(struct clk_hw *hw,
-- 
2.34.3


             reply	other threads:[~2022-07-04 18:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04 18:57 Abel Vesa [this message]
2022-07-06 15:08 ` [RFC] clk: Add clk_hw based provider enable/disable API Abel Vesa

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=20220704185733.1288578-1-abel.vesa@linaro.org \
    --to=abel.vesa@linaro.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=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.