devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Borneo <antonio.borneo@foss.st.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>
Cc: Antonio Borneo <antonio.borneo@foss.st.com>,
	<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>
Subject: [PATCH 04/12] irqchip/stm32-exti: Convert driver to standard PM
Date: Fri, 16 Feb 2024 10:47:49 +0100	[thread overview]
Message-ID: <20240216094758.916722-5-antonio.borneo@foss.st.com> (raw)
In-Reply-To: <20240216094758.916722-1-antonio.borneo@foss.st.com>

All driver's dependencies for suspend/resume have been fixed long
ago. There are no more reasons to use syscore PM for the part of
this driver related to Cortex-A MPU.

Switch to standard PM using NOIRQ_SYSTEM_SLEEP_PM_OPS, so all the
registers of the interrupt controller get resumed before any irq
gets enabled.

A side effect of this change is to drop the only global variable
'stm32_host_data', used to keep the driver's data for syscore_ops.
This makes the driver ready to support multiple EXTI instances.

Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
---
 drivers/irqchip/irq-stm32-exti.c | 58 ++++++++++----------------------
 1 file changed, 17 insertions(+), 41 deletions(-)

diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c
index 95bb3dd10b2c..de18cddf6b88 100644
--- a/drivers/irqchip/irq-stm32-exti.c
+++ b/drivers/irqchip/irq-stm32-exti.c
@@ -19,7 +19,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
-#include <linux/syscore_ops.h>
+#include <linux/pm.h>
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 
@@ -64,8 +64,6 @@ struct stm32_exti_host_data {
 	struct device_node *irq_map_node;
 };
 
-static struct stm32_exti_host_data *stm32_host_data;
-
 static const struct stm32_exti_bank stm32f4xx_exti_b1 = {
 	.imr_ofst	= 0x00,
 	.emr_ofst	= 0x04,
@@ -622,50 +620,32 @@ static int stm32_exti_h_set_affinity(struct irq_data *d,
 	return IRQ_SET_MASK_OK_DONE;
 }
 
-static int __maybe_unused stm32_exti_h_suspend(void)
+static int stm32_exti_h_suspend(struct device *dev)
 {
+	struct stm32_exti_host_data *host_data = dev_get_drvdata(dev);
 	struct stm32_exti_chip_data *chip_data;
 	int i;
 
-	for (i = 0; i < stm32_host_data->drv_data->bank_nr; i++) {
-		chip_data = &stm32_host_data->chips_data[i];
-		raw_spin_lock(&chip_data->rlock);
+	for (i = 0; i < host_data->drv_data->bank_nr; i++) {
+		chip_data = &host_data->chips_data[i];
 		stm32_chip_suspend(chip_data, chip_data->wake_active);
-		raw_spin_unlock(&chip_data->rlock);
 	}
 
 	return 0;
 }
 
-static void __maybe_unused stm32_exti_h_resume(void)
+static int stm32_exti_h_resume(struct device *dev)
 {
+	struct stm32_exti_host_data *host_data = dev_get_drvdata(dev);
 	struct stm32_exti_chip_data *chip_data;
 	int i;
 
-	for (i = 0; i < stm32_host_data->drv_data->bank_nr; i++) {
-		chip_data = &stm32_host_data->chips_data[i];
-		raw_spin_lock(&chip_data->rlock);
+	for (i = 0; i < host_data->drv_data->bank_nr; i++) {
+		chip_data = &host_data->chips_data[i];
 		stm32_chip_resume(chip_data, chip_data->mask_cache);
-		raw_spin_unlock(&chip_data->rlock);
 	}
-}
 
-static struct syscore_ops stm32_exti_h_syscore_ops = {
-#ifdef CONFIG_PM_SLEEP
-	.suspend	= stm32_exti_h_suspend,
-	.resume		= stm32_exti_h_resume,
-#endif
-};
-
-static void stm32_exti_h_syscore_init(struct stm32_exti_host_data *host_data)
-{
-	stm32_host_data = host_data;
-	register_syscore_ops(&stm32_exti_h_syscore_ops);
-}
-
-static void stm32_exti_h_syscore_deinit(void)
-{
-	unregister_syscore_ops(&stm32_exti_h_syscore_ops);
+	return 0;
 }
 
 static int stm32_exti_h_retrigger(struct irq_data *d)
@@ -792,8 +772,6 @@ stm32_exti_host_data *stm32_exti_host_init(const struct stm32_exti_drv_data *dd,
 		goto free_chips_data;
 	}
 
-	stm32_host_data = host_data;
-
 	return host_data;
 
 free_chips_data:
@@ -919,12 +897,6 @@ static void stm32_exti_remove_irq(void *data)
 	irq_domain_remove(domain);
 }
 
-static int stm32_exti_remove(struct platform_device *pdev)
-{
-	stm32_exti_h_syscore_deinit();
-	return 0;
-}
-
 static int stm32_exti_probe(struct platform_device *pdev)
 {
 	int ret, i;
@@ -938,6 +910,8 @@ static int stm32_exti_probe(struct platform_device *pdev)
 	if (!host_data)
 		return -ENOMEM;
 
+	dev_set_drvdata(dev, host_data);
+
 	/* check for optional hwspinlock which may be not available yet */
 	ret = of_hwspin_lock_get_id(np, 0);
 	if (ret == -EPROBE_DEFER)
@@ -1001,8 +975,6 @@ static int stm32_exti_probe(struct platform_device *pdev)
 	if (child && of_property_read_bool(child, "interrupt-map"))
 		host_data->irq_map_node = child;
 
-	stm32_exti_h_syscore_init(host_data);
-
 	return 0;
 }
 
@@ -1014,12 +986,16 @@ static const struct of_device_id stm32_exti_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, stm32_exti_ids);
 
+static const struct dev_pm_ops stm32_exti_dev_pm_ops = {
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(stm32_exti_h_suspend, stm32_exti_h_resume)
+};
+
 static struct platform_driver stm32_exti_driver = {
 	.probe		= stm32_exti_probe,
-	.remove		= stm32_exti_remove,
 	.driver		= {
 		.name	= "stm32_exti",
 		.of_match_table = stm32_exti_ids,
+		.pm	= &stm32_exti_dev_pm_ops,
 	},
 };
 
-- 
2.34.1


  parent reply	other threads:[~2024-02-16  9:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-16  9:47 [PATCH 00/12] irqchip/stm32-exti: add irq-map and STM32MP25 support Antonio Borneo
2024-02-16  9:47 ` [PATCH 01/12] irqchip/stm32-exti: Fix minor indentation issue Antonio Borneo
2024-02-19 14:16   ` Thomas Gleixner
2024-02-16  9:47 ` [PATCH 02/12] dt-bindings: interrupt-controller: stm32-exti: Add irq nexus child node Antonio Borneo
2024-02-19 14:19   ` Thomas Gleixner
2024-04-15 13:37     ` Antonio Borneo
2024-02-22 23:43   ` Rob Herring
2024-02-23 13:39     ` Antonio Borneo
2024-02-16  9:47 ` [PATCH 03/12] irqchip/stm32-exti: Map interrupts through interrupt nexus node Antonio Borneo
2024-02-19 14:22   ` Thomas Gleixner
2024-02-16  9:47 ` Antonio Borneo [this message]
2024-02-16  9:47 ` [PATCH 05/12] irqchip/stm32-exti: Skip secure events Antonio Borneo
2024-02-16  9:47 ` [PATCH 06/12] irqchip/stm32-exti: Mark events reserved with RIF configuration check Antonio Borneo
2024-02-16  9:47 ` [PATCH 07/12] arm64: Kconfig.platforms: Enable STM32_EXTI for ARCH_STM32 Antonio Borneo
2024-02-16  9:47 ` [PATCH 08/12] ARM: dts: stm32: Use exti interrupt-map on stm32mp151 Antonio Borneo
2024-02-16  9:47 ` [PATCH 09/12] ARM: dts: stm32: Use exti interrupt-map on stm32mp131 Antonio Borneo
2024-02-16  9:47 ` [PATCH 10/12] arm64: dts: st: Add v2m to GIC node on stm32mp251 Antonio Borneo
2024-02-16  9:47 ` [PATCH 11/12] arm64: dts: st: Add exti1 and exti2 nodes " Antonio Borneo
2024-02-16  9:47 ` [PATCH 12/12] arm64: dts: st: Add interrupt parent to pinctrl " Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 00/11] irqchip/stm32-exti: add irq map in DT and STM32MP25 support Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 01/11] irqchip/stm32-exti: Fix minor indentation issue Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 02/11] dt-bindings: interrupt-controller: stm32-exti: Add irq mapping to parent Antonio Borneo
2024-04-17 18:09   ` Rob Herring
2024-04-15 13:49 ` [PATCH v2 03/11] irqchip/stm32-exti: Map interrupts through interrupts-extended Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 04/11] irqchip/stm32-exti: Convert driver to standard PM Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 05/11] irqchip/stm32-exti: Skip secure events Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 06/11] irqchip/stm32-exti: Mark events reserved with RIF configuration check Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 07/11] arm64: Kconfig.platforms: Enable STM32_EXTI for ARCH_STM32 Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 08/11] ARM: dts: stm32: List exti parent interrupts on stm32mp151 Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 09/11] ARM: dts: stm32: List exti parent interrupts on stm32mp131 Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 10/11] arm64: dts: st: Add exti1 and exti2 nodes on stm32mp251 Antonio Borneo
2024-04-15 13:49 ` [PATCH v2 11/11] arm64: dts: st: Add interrupt parent to pinctrl " Antonio Borneo

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=20240216094758.916722-5-antonio.borneo@foss.st.com \
    --to=antonio.borneo@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=will@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).