From: Marc Zyngier <maz@kernel.org>
To: Joakim Zhang <qiangqing.zhang@nxp.com>
Cc: tglx@linutronix.de, jason@lakedaemon.net, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, linux-imx@nxp.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.or
Subject: Re: [PATCH 1/2] irqchip: imx-intmux: add system PM support
Date: Fri, 17 Jul 2020 09:41:56 +0100 [thread overview]
Message-ID: <364c4a4dc83618f937169ce07e6a6908@kernel.org> (raw)
In-Reply-To: <20200716193244.31090-2-qiangqing.zhang@nxp.com>
On 2020-07-16 20:32, Joakim Zhang wrote:
> Add system PM support for intmux interrupt controller.
Care to be a little more descriptive?
>
> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> ---
> drivers/irqchip/irq-imx-intmux.c | 59 ++++++++++++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
>
> diff --git a/drivers/irqchip/irq-imx-intmux.c
> b/drivers/irqchip/irq-imx-intmux.c
> index c27577c81126..6095f76c4f0d 100644
> --- a/drivers/irqchip/irq-imx-intmux.c
> +++ b/drivers/irqchip/irq-imx-intmux.c
> @@ -70,6 +70,9 @@ struct intmux_data {
> void __iomem *regs;
> struct clk *ipg_clk;
> int channum;
> +#ifdef CONFIG_PM
> + unsigned int *saved_reg;
Please use u32 for 32bit HW registers.
> +#endif
> struct intmux_irqchip_data irqchip_data[];
> };
>
> @@ -232,6 +235,15 @@ static int imx_intmux_probe(struct platform_device
> *pdev)
> data->channum = channum;
> raw_spin_lock_init(&data->lock);
>
> + if (IS_ENABLED(CONFIG_PM)) {
> + /* save CHANIER register */
> + data->saved_reg = devm_kzalloc(&pdev->dev,
> + sizeof(unsigned int) * channum,
> + GFP_KERNEL);
> + if (!data->saved_reg)
Which isn't defined when !CONFIG_PM. The compiler is allowed to
bail here, and does (see the two kbuild failures).
> + return -ENOMEM;
> + }
> +
> ret = clk_prepare_enable(data->ipg_clk);
> if (ret) {
> dev_err(&pdev->dev, "failed to enable ipg clk: %d\n", ret);
> @@ -293,6 +305,53 @@ static int imx_intmux_remove(struct
> platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_PM
> +static void imx_intmux_save_regs(struct intmux_data *data)
> +{
> + int i;
> +
> + for (i = 0; i < data->channum; i++)
> + data->saved_reg[i] = readl_relaxed(data->regs + CHANIER(i));
> +}
> +
> +static void imx_intmux_restore_regs(struct intmux_data *data)
> +{
> + int i;
> +
> + for (i = 0; i < data->channum; i++)
> + writel_relaxed(data->saved_reg[i], data->regs + CHANIER(i));
> +}
Please move these two trivial functions into their respective callers.
> +
> +static int imx_intmux_suspend(struct device *dev)
> +{
> + struct intmux_data *data = dev_get_drvdata(dev);
> +
> + imx_intmux_save_regs(data);
> + clk_disable_unprepare(data->ipg_clk);
> +
> + return 0;
> +}
> +
> +static int imx_intmux_resume(struct device *dev)
> +{
> + struct intmux_data *data = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = clk_prepare_enable(data->ipg_clk);
> + if (ret) {
> + dev_err(dev, "failed to enable ipg clk: %d\n", ret);
> + return ret;
> + }
> + imx_intmux_restore_regs(data);
> +
> + return 0;
> +}
> +#endif
> +
> +static const struct dev_pm_ops imx_intmux_pm_ops = {
> + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx_intmux_suspend, imx_intmux_resume)
> +};
> +
> static const struct of_device_id imx_intmux_id[] = {
> { .compatible = "fsl,imx-intmux", },
> { /* sentinel */ },
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2020-07-17 8:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-16 19:32 [PATCH 0/2] irqchip: imx-intmux: add PM support Joakim Zhang
2020-07-16 19:32 ` [PATCH 1/2] irqchip: imx-intmux: add system " Joakim Zhang
2020-07-17 1:27 ` kernel test robot
2020-07-17 6:40 ` kernel test robot
2020-07-17 8:41 ` Marc Zyngier [this message]
2020-07-17 10:40 ` kernel test robot
2020-07-16 19:32 ` [PATCH 2/2] irqchip: imx-intmux: add runtime " Joakim Zhang
2020-07-17 8:58 ` Marc Zyngier
2020-07-17 10:48 ` Joakim Zhang
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=364c4a4dc83618f937169ce07e6a6908@kernel.org \
--to=maz@kernel.org \
--cc=festevam@gmail.com \
--cc=jason@lakedaemon.net \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.or \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=qiangqing.zhang@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=tglx@linutronix.de \
/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