mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org,
	abelvesa@kernel.org, abel.vesa@linaro.org,
	mturquette@baylibre.com, sboyd@kernel.org, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	festevam@gmail.com
Cc: linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
	linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org,
	linux-clk@vger.kernel.org
Subject: [RFC PATCH 1/2] clk: add support for critical always-on clocks
Date: Tue, 13 Sep 2022 12:21:40 +0200	[thread overview]
Message-ID: <20220913102141.971148-2-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20220913102141.971148-1-m.felsch@pengutronix.de>

Add support to mark specific clocks as always-on (critical), like the
regulator-alawys-on property. So the platform integrators can specify
the property on a per device basis by specifying it within the firmware
and not only within the driver. Unlike the regulator framework the clock
framework uses a 1:n matching, which means 1 firmware node can provide
up to n clock providers. Therefore the binding uses a string-array so we
can specify n clock providers as critical.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/clk/clk.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 7fc191c15507..c3651bf96f90 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3825,6 +3825,22 @@ static int clk_cpy_name(const char **dst_p, const char *src, bool must_exist)
 	return 0;
 }
 
+static void clk_core_check_critical(struct clk_core *core)
+{
+	struct fwnode_handle *fwnode = of_fwnode_handle(core->of_node);
+	const char *prop = "clocks-always-on";
+	int ret;
+
+	/* Very early added clocks don't have a fwnode */
+	if (!fwnode || !fwnode_property_present(fwnode, prop))
+		return;
+
+	/* Mark clock as critical if listed within the clocks-always-on array */
+	ret = fwnode_property_match_string(fwnode, prop, core->name);
+	if (!ret)
+		core->flags |= CLK_IS_CRITICAL;
+}
+
 static int clk_core_populate_parent_map(struct clk_core *core,
 					const struct clk_init_data *init)
 {
@@ -3946,6 +3962,8 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)
 	core->min_rate = 0;
 	core->max_rate = ULONG_MAX;
 
+	clk_core_check_critical(core);
+
 	ret = clk_core_populate_parent_map(core, init);
 	if (ret)
 		goto fail_parents;
-- 
2.30.2


  reply	other threads:[~2022-09-13 10:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 10:21 [RFC PATCH 0/2] Propose critical clocks Marco Felsch
2022-09-13 10:21 ` Marco Felsch [this message]
2022-09-13 10:21 ` [RFC PATCH 2/2] arm64: dts: imx8mm-evk: mark 32k pmic clock as always-on Marco Felsch
2022-09-13 10:33 ` [RFC PATCH 0/2] Propose critical clocks Marco Felsch
2022-09-13 10:48 ` Krzysztof Kozlowski
2022-09-13 11:51   ` Marco Felsch
2022-09-13 12:24 ` Peng Fan
2022-09-14  8:13   ` Marco Felsch
2022-10-05  8:23 ` Marco Felsch
2022-10-05 23:06   ` Stephen Boyd
2022-10-06 11:05     ` Marek Vasut
2023-01-17 16:45       ` Marco Felsch
2023-01-17 17:55     ` Marco Felsch
2023-03-29 19:40       ` Stephen Boyd

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=20220913102141.971148-2-m.felsch@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=abel.vesa@linaro.org \
    --cc=abelvesa@kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=peng.fan@nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@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

all inboxes | Powered by JetHome®