linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] clk: imx: support protected-clocks
@ 2022-08-16 13:03 Peng Fan (OSS)
  2022-08-16 15:02 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Fan (OSS) @ 2022-08-16 13:03 UTC (permalink / raw)
  To: abelvesa, abel.vesa, mturquette, sboyd, shawnguo, s.hauer,
	kernel, festevam
  Cc: linux-imx, linux-clk, linux-arm-kernel, linux-kernel, Peng Fan

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

For the clocks listed in protected-clocks, enable them to avoid
Linux disable them. This will benifit root Linux and inmate cell run
on top of Jailhouse hypervisor, and benifit the other case(
A53 Linux run together with M7 RTOS).

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V2:
 Per Sascha, use common protected-clocks property.
 Drop patch 1 in V1

 drivers/clk/imx/clk-imx8mm.c |  2 ++
 drivers/clk/imx/clk-imx8mn.c |  2 ++
 drivers/clk/imx/clk-imx8mp.c |  2 ++
 drivers/clk/imx/clk-imx8mq.c |  2 ++
 drivers/clk/imx/clk.c        | 21 +++++++++++++++++++++
 drivers/clk/imx/clk.h        |  2 ++
 6 files changed, 31 insertions(+)

diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
index b6d275855b36..24ddb1620bce 100644
--- a/drivers/clk/imx/clk-imx8mm.c
+++ b/drivers/clk/imx/clk-imx8mm.c
@@ -611,6 +611,8 @@ static int imx8mm_clocks_probe(struct platform_device *pdev)
 
 	imx_register_uart_clocks(4);
 
+	imx_clk_protect(dev, hws);
+
 	return 0;
 
 unregister_hws:
diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
index d37c45b676ab..57c486317d28 100644
--- a/drivers/clk/imx/clk-imx8mn.c
+++ b/drivers/clk/imx/clk-imx8mn.c
@@ -604,6 +604,8 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
 
 	imx_register_uart_clocks(4);
 
+	imx_clk_protect(dev, hws);
+
 	return 0;
 
 unregister_hws:
diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
index e89db568f5a8..13015973a696 100644
--- a/drivers/clk/imx/clk-imx8mp.c
+++ b/drivers/clk/imx/clk-imx8mp.c
@@ -713,6 +713,8 @@ static int imx8mp_clocks_probe(struct platform_device *pdev)
 
 	imx_register_uart_clocks(4);
 
+	imx_clk_protect(dev, hws);
+
 	return 0;
 }
 
diff --git a/drivers/clk/imx/clk-imx8mq.c b/drivers/clk/imx/clk-imx8mq.c
index 882dcad4817d..2868e2390667 100644
--- a/drivers/clk/imx/clk-imx8mq.c
+++ b/drivers/clk/imx/clk-imx8mq.c
@@ -603,6 +603,8 @@ static int imx8mq_clocks_probe(struct platform_device *pdev)
 
 	imx_register_uart_clocks(4);
 
+	imx_clk_protect(dev, hws);
+
 	return 0;
 
 unregister_hws:
diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
index 5582f18dd632..bacba1728fab 100644
--- a/drivers/clk/imx/clk.c
+++ b/drivers/clk/imx/clk.c
@@ -2,6 +2,7 @@
 #include <linux/bits.h>
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
+#include <linux/device.h>
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -214,4 +215,24 @@ static int __init imx_clk_disable_uart(void)
 late_initcall_sync(imx_clk_disable_uart);
 #endif
 
+int imx_clk_protect(struct device *dev, struct clk_hw * const clks[])
+{
+	struct device_node *np = dev->of_node;
+	struct property *prop;
+	const __be32 *p;
+	u32 i;
+	int ret;
+
+	of_property_for_each_u32(np, "protected-clocks", prop, p, i) {
+		ret = clk_prepare_enable(clks[i]->clk);
+		if (ret) {
+			dev_err(dev, "failed to enable %s\n", clk_hw_get_name(clks[i]));
+			return ret;
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(imx_clk_protect);
+
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 5061a06468df..0b9a236e8da8 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -22,6 +22,8 @@ void imx_mmdc_mask_handshake(void __iomem *ccm_base, unsigned int chn);
 void imx_unregister_clocks(struct clk *clks[], unsigned int count);
 void imx_unregister_hw_clocks(struct clk_hw *hws[], unsigned int count);
 
+int imx_clk_protect(struct device *dev, struct clk_hw * const clks[]);
+
 extern void imx_cscmr1_fixup(u32 *val);
 
 enum imx_pllv1_type {
-- 
2.37.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] clk: imx: support protected-clocks
  2022-08-16 13:03 [PATCH V2] clk: imx: support protected-clocks Peng Fan (OSS)
@ 2022-08-16 15:02 ` Sascha Hauer
  2022-08-23  1:05   ` Peng Fan
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2022-08-16 15:02 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: abelvesa, abel.vesa, mturquette, sboyd, shawnguo, kernel,
	festevam, linux-imx, linux-clk, linux-arm-kernel, linux-kernel,
	Peng Fan

On Tue, Aug 16, 2022 at 09:03:27PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> For the clocks listed in protected-clocks, enable them to avoid
> Linux disable them. This will benifit root Linux and inmate cell run
> on top of Jailhouse hypervisor, and benifit the other case(
> A53 Linux run together with M7 RTOS).
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> 
> V2:
>  Per Sascha, use common protected-clocks property.

See my mail to v1. I did not request that you should use the
protected-clocks property:

> There were cases when a property first started with a "soc," prefix and
> later when people realized that it could be useful for other
> drivers/SoCs as well, the prefix was removed. With that in mind I
> would expect that a "fsl,protected-clocks" property behaves the same
> as a "protected-clocks" property without the prefix.
> 
> If it doesn't please pick a different name. I didn't want to suggest
> to just drop the "fsl," prefix and to use the generic property name
> when the properties have a different meaning.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] clk: imx: support protected-clocks
  2022-08-16 15:02 ` Sascha Hauer
@ 2022-08-23  1:05   ` Peng Fan
  0 siblings, 0 replies; 3+ messages in thread
From: Peng Fan @ 2022-08-23  1:05 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: abelvesa, abel.vesa, mturquette, sboyd, shawnguo, kernel,
	festevam, linux-imx, linux-clk, linux-arm-kernel, linux-kernel,
	Peng Fan



On 8/16/2022 11:02 PM, Sascha Hauer wrote:
> On Tue, Aug 16, 2022 at 09:03:27PM +0800, Peng Fan (OSS) wrote:
>> From: Peng Fan <peng.fan@nxp.com>
>>
>> For the clocks listed in protected-clocks, enable them to avoid
>> Linux disable them. This will benifit root Linux and inmate cell run
>> on top of Jailhouse hypervisor, and benifit the other case(
>> A53 Linux run together with M7 RTOS).
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>>
>> V2:
>>   Per Sascha, use common protected-clocks property.
> 
> See my mail to v1. I did not request that you should use the
> protected-clocks property:
> 
>> There were cases when a property first started with a "soc," prefix and
>> later when people realized that it could be useful for other
>> drivers/SoCs as well, the prefix was removed. With that in mind I
>> would expect that a "fsl,protected-clocks" property behaves the same
>> as a "protected-clocks" property without the prefix.
>>
>> If it doesn't please pick a different name. I didn't want to suggest
>> to just drop the "fsl," prefix and to use the generic property name
>> when the properties have a different meaning.

oh, I misunderstood.

Here I just wanna linux prepare enable clks and never off them,
the clks may vary per different usecase.

how about
fsl,init-on-clks=<xx>?
or extend to
fsl,init-on-clks-with-rate=<xx>?

Thanks,
Peng.
> 
> Sascha
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-23  1:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16 13:03 [PATCH V2] clk: imx: support protected-clocks Peng Fan (OSS)
2022-08-16 15:02 ` Sascha Hauer
2022-08-23  1:05   ` Peng Fan

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).