From: Abel Vesa <abel.vesa@linaro.org>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: abelvesa@kernel.org, mturquette@baylibre.com, sboyd@kernel.org,
shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, linux-imx@nxp.com,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH 2/2] clk: imx: support fsl,protected-clocks
Date: Mon, 15 Aug 2022 11:32:52 +0300 [thread overview]
Message-ID: <YvoEtKd7GCL865C3@linaro.org> (raw)
In-Reply-To: <20220815033632.1687854-3-peng.fan@oss.nxp.com>
On 22-08-15 11:36:32, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> For the clocks listed in fsl,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 AMP case.
Nitpick: s/benifit/benefit/
AMP?
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> 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 652ae58c2735..a95862cc04a4 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..307da8bd5243 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, "fsl,protected-clocks", prop, p, i) {
> + ret = clk_prepare_enable(clks[i]->clk);
I might be wrong here, but wouldn't CLK_IGNORE_UNUSED have the same effect?
I don't think we should circumvent that by adding vendor specific dts properties.
> + 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 dd49f90110e8..3f8099190b99 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
>
WARNING: multiple messages have this Message-ID (diff)
From: Abel Vesa <abel.vesa@linaro.org>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: abelvesa@kernel.org, mturquette@baylibre.com, sboyd@kernel.org,
shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, linux-imx@nxp.com,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH 2/2] clk: imx: support fsl,protected-clocks
Date: Mon, 15 Aug 2022 11:32:52 +0300 [thread overview]
Message-ID: <YvoEtKd7GCL865C3@linaro.org> (raw)
In-Reply-To: <20220815033632.1687854-3-peng.fan@oss.nxp.com>
On 22-08-15 11:36:32, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> For the clocks listed in fsl,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 AMP case.
Nitpick: s/benifit/benefit/
AMP?
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> 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 652ae58c2735..a95862cc04a4 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..307da8bd5243 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, "fsl,protected-clocks", prop, p, i) {
> + ret = clk_prepare_enable(clks[i]->clk);
I might be wrong here, but wouldn't CLK_IGNORE_UNUSED have the same effect?
I don't think we should circumvent that by adding vendor specific dts properties.
> + 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 dd49f90110e8..3f8099190b99 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
next prev parent reply other threads:[~2022-08-15 8:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 3:36 [PATCH 0/2] clk: imx: introduce fsl,protected-clocks Peng Fan (OSS)
2022-08-15 3:36 ` Peng Fan (OSS)
2022-08-15 3:36 ` [PATCH 1/2] dt-bindings: clock: imx8m: introduce fsl,protected-clocks property Peng Fan (OSS)
2022-08-15 3:36 ` Peng Fan (OSS)
2022-08-15 13:57 ` Sascha Hauer
2022-08-15 13:57 ` Sascha Hauer
2022-08-16 7:13 ` Peng Fan
2022-08-16 7:13 ` Peng Fan
2022-08-16 8:14 ` Sascha Hauer
2022-08-16 8:14 ` Sascha Hauer
2022-08-15 3:36 ` [PATCH 2/2] clk: imx: support fsl,protected-clocks Peng Fan (OSS)
2022-08-15 3:36 ` Peng Fan (OSS)
2022-08-15 8:32 ` Abel Vesa [this message]
2022-08-15 8:32 ` Abel Vesa
2022-08-15 8:42 ` Peng Fan
2022-08-15 8:42 ` 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=YvoEtKd7GCL865C3@linaro.org \
--to=abel.vesa@linaro.org \
--cc=abelvesa@kernel.org \
--cc=devicetree@vger.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=peng.fan@oss.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 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.