From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: abelvesa@kernel.org, mturquette@baylibre.com, sboyd@kernel.org,
shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com
Cc: linux-imx@nxp.com, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH] clk: imx: imx93: introduce clk_bypassed module parameter
Date: Thu, 4 May 2023 16:55:06 +0800 [thread overview]
Message-ID: <20230504085506.504474-1-peng.fan@oss.nxp.com> (raw)
From: Peng Fan <peng.fan@nxp.com>
With the clk names specified in clk_bypassed module parameter, give
user an option to bypass the clk from managing them by Linux kernel.
This is useful when Cortex-M33 and Cortex-A55 both running, A55 may
shutdown the clocks used by M33. Although we have mcore_booted module
parameter, but it is only for composite gate, the CCGR gate could still
be shutdown by Linux.
So let's use clk_bypassed parameter to handle clk root and clk ccgr both.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
V1:
Depends on: https://lore.kernel.org/all/20230504075754.372780-1-peng.fan@oss.nxp.com/
drivers/clk/imx/clk-imx93.c | 55 +++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c
index 07b4a043e449..88ed824ca2ff 100644
--- a/drivers/clk/imx/clk-imx93.c
+++ b/drivers/clk/imx/clk-imx93.c
@@ -255,6 +255,51 @@ static const struct imx93_clk_ccgr {
static struct clk_hw_onecell_data *clk_hw_data;
static struct clk_hw **clks;
+#define IMX_NUM_CLK_ENTRY 64
+
+static char clk_bypassed_names[SZ_512];
+static char *clk_names[IMX_NUM_CLK_ENTRY];
+
+/* The module args format as this: clk-imx93.clk_bypassed="lpi2c8_root,spdif" */
+static int imx_clk_bypass_setup(struct device *dev, char *str)
+{
+ char *pos = str, *next;
+ int i = 0;
+
+ while (pos != NULL && (next = strchr(pos, ',')) != NULL) {
+ clk_names[i++] = devm_kstrndup(dev, pos, next - pos, GFP_KERNEL);
+ pos = ++next;
+ }
+
+ clk_names[i] = devm_kstrdup(dev, pos, GFP_KERNEL);
+
+ return 0;
+}
+
+static bool imx_clk_bypass_check(char *name)
+{
+ int i;
+
+ for (i = 0; i < IMX_NUM_CLK_ENTRY; i++) {
+ if (!clk_names[i])
+ return false;
+ if (!strcmp(name, clk_names[i]))
+ return true;
+ }
+
+ return false;
+}
+
+static int imx_clk_bypass_free(struct device *dev)
+{
+ int i;
+
+ for (i = 0; i < IMX_NUM_CLK_ENTRY; i++)
+ devm_kfree(dev, clk_names[i]);
+
+ return 0;
+}
+
static int imx93_clocks_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -264,6 +309,8 @@ static int imx93_clocks_probe(struct platform_device *pdev)
void __iomem *base, *anatop_base;
int i, ret;
+ imx_clk_bypass_setup(dev, clk_bypassed_names);
+
clk_hw_data = kzalloc(struct_size(clk_hw_data, hws,
IMX93_CLK_END), GFP_KERNEL);
if (!clk_hw_data)
@@ -310,6 +357,8 @@ static int imx93_clocks_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(root_array); i++) {
root = &root_array[i];
+ if (unlikely(imx_clk_bypass_check(root->name)))
+ continue;
clks[root->clk] = imx93_clk_composite_flags(root->name,
parent_names[root->sel],
4, base + root->off, 3,
@@ -318,6 +367,8 @@ static int imx93_clocks_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(ccgr_array); i++) {
ccgr = &ccgr_array[i];
+ if (unlikely(imx_clk_bypass_check(ccgr->name)))
+ continue;
clks[ccgr->clk] = imx93_clk_gate(NULL, ccgr->name, ccgr->parent_name,
ccgr->flags, base + ccgr->off, 0, 1, 1, 3,
ccgr->shared_count);
@@ -341,6 +392,8 @@ static int imx93_clocks_probe(struct platform_device *pdev)
imx_register_uart_clocks();
+ imx_clk_bypass_free(dev);
+
return 0;
unregister_hws:
@@ -367,6 +420,8 @@ static struct platform_driver imx93_clk_driver = {
module_platform_driver(imx93_clk_driver);
module_param(mcore_booted, bool, 0444);
MODULE_PARM_DESC(mcore_booted, "See Cortex-M core is booted or not");
+module_param_string(clk_bypassed, clk_bypassed_names, SZ_512, 0444);
+MODULE_PARM_DESC(clk_bypassed, "The clks will not be managed by Linux");
MODULE_DESCRIPTION("NXP i.MX93 clock driver");
MODULE_LICENSE("GPL v2");
--
2.37.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2023-05-04 8:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 8:55 Peng Fan (OSS) [this message]
2023-05-04 9:10 ` [PATCH] clk: imx: imx93: introduce clk_bypassed module parameter Greg KH
2023-05-04 9:17 ` Peng Fan
2023-05-04 9:30 ` Krzysztof Kozlowski
2023-05-04 9:34 ` Peng Fan
2023-05-04 10:04 ` Ahmad Fatoum
2023-05-04 11:37 ` Peng Fan
2023-05-04 11:01 ` Krzysztof Kozlowski
2023-05-04 11:39 ` Peng Fan
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=20230504085506.504474-1-peng.fan@oss.nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=abelvesa@kernel.org \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--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=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