linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: peng.fan@nxp.com
To: shawnguo@kernel.org, s.hauer@pengutronix.de, sboyd@kernel.org
Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
	Anson.Huang@nxp.com, abel.vesa@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: introduce imx_clk_hw_critical
Date: Thu, 23 Apr 2020 14:52:28 +0800	[thread overview]
Message-ID: <1587624748-27228-1-git-send-email-peng.fan@nxp.com> (raw)

From: Peng Fan <peng.fan@nxp.com>

To i.MX8M SoC, there is an case is when running dual OSes
with hypervisor, the clk of the hardware that passthrough
to the 2nd OS needs to be setup by 1st Linux OS.
So detect clock-critical from ccm node and enable the clocks to let
the 2nd OS could use the hardware without touch CCM module.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/clk/imx/clk.c | 19 +++++++++++++++++++
 drivers/clk/imx/clk.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
index 87ab8db3d282..ec7d422540c1 100644
--- a/drivers/clk/imx/clk.c
+++ b/drivers/clk/imx/clk.c
@@ -177,3 +177,22 @@ static int __init imx_clk_disable_uart(void)
 	return 0;
 }
 late_initcall_sync(imx_clk_disable_uart);
+
+int imx_clk_hw_critical(struct device_node *np, struct clk_hw * const hws[])
+{
+	struct property *prop;
+	const __be32 *cur;
+	u32 idx;
+	int ret;
+
+	if (!np || !hws)
+		return -EINVAL;
+
+	of_property_for_each_u32(np, "clock-critical", prop, cur, idx) {
+		ret = clk_prepare_enable(hws[idx]->clk);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index d4ea1609bcb7..701d7440f98c 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -9,6 +9,7 @@ extern spinlock_t imx_ccm_lock;
 
 void imx_check_clocks(struct clk *clks[], unsigned int count);
 void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count);
+int imx_clk_hw_critical(struct device_node *np, struct clk_hw * const hws[]);
 void imx_register_uart_clocks(struct clk ** const clks[]);
 void imx_mmdc_mask_handshake(void __iomem *ccm_base, unsigned int chn);
 void imx_unregister_clocks(struct clk *clks[], unsigned int count);
-- 
2.16.4


             reply	other threads:[~2020-04-23  7:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  6:52 peng.fan [this message]
2020-04-23 10:42 ` [PATCH] clk: imx: introduce imx_clk_hw_critical Aisheng Dong
2020-04-23 10:53   ` Peng Fan
2020-04-23 14:03     ` Aisheng Dong
2020-04-24  1:07       ` Peng Fan
2020-04-24  1:59         ` Aisheng Dong
2020-04-24  2:02           ` Peng Fan
2020-04-27  8:43           ` 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=1587624748-27228-1-git-send-email-peng.fan@nxp.com \
    --to=peng.fan@nxp.com \
    --cc=Anson.Huang@nxp.com \
    --cc=abel.vesa@nxp.com \
    --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=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;
as well as URLs for NNTP newsgroup(s).