All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joakim Zhang <qiangqing.zhang@nxp.com>
To: tglx@linutronix.de, jason@lakedaemon.net, maz@kernel.org,
	shawnguo@kernel.org, s.hauer@pengutronix.de
Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.or
Subject: [PATCH 1/2] irqchip: imx-intmux: add system PM support
Date: Fri, 17 Jul 2020 03:32:43 +0800	[thread overview]
Message-ID: <20200716193244.31090-2-qiangqing.zhang@nxp.com> (raw)
In-Reply-To: <20200716193244.31090-1-qiangqing.zhang@nxp.com>

Add system PM support for intmux interrupt controller.

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;
+#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)
+			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));
+}
+
+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 */ },
-- 
2.17.1


  reply	other threads:[~2020-07-16 11:31 UTC|newest]

Thread overview: 12+ 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 ` Joakim Zhang [this message]
2020-07-17  1:27   ` [PATCH 1/2] irqchip: imx-intmux: add system " kernel test robot
2020-07-17  1:27     ` kernel test robot
2020-07-17  6:40   ` kernel test robot
2020-07-17  6:40     ` kernel test robot
2020-07-17  8:41   ` Marc Zyngier
2020-07-17 10:40   ` kernel test robot
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=20200716193244.31090-2-qiangqing.zhang@nxp.com \
    --to=qiangqing.zhang@nxp.com \
    --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=maz@kernel.org \
    --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 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.