Commit 06d7e914 authored by Antonio Borneo's avatar Antonio Borneo Committed by Thomas Gleixner

irqchip/stm32-exti: Convert driver to standard PM

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: default avatarAntonio Borneo <antonio.borneo@foss.st.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240415134926.1254428-5-antonio.borneo@foss.st.com
parent 77ec258f
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/syscore_ops.h> #include <linux/pm.h>
#include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/interrupt-controller/arm-gic.h>
...@@ -64,8 +64,6 @@ struct stm32_exti_host_data { ...@@ -64,8 +64,6 @@ struct stm32_exti_host_data {
bool dt_has_irqs_desc; /* skip internal desc_irqs array and get it from DT */ bool dt_has_irqs_desc; /* skip internal desc_irqs array and get it from DT */
}; };
static struct stm32_exti_host_data *stm32_host_data;
static const struct stm32_exti_bank stm32f4xx_exti_b1 = { static const struct stm32_exti_bank stm32f4xx_exti_b1 = {
.imr_ofst = 0x00, .imr_ofst = 0x00,
.emr_ofst = 0x04, .emr_ofst = 0x04,
...@@ -622,50 +620,32 @@ static int stm32_exti_h_set_affinity(struct irq_data *d, ...@@ -622,50 +620,32 @@ static int stm32_exti_h_set_affinity(struct irq_data *d,
return IRQ_SET_MASK_OK_DONE; 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; struct stm32_exti_chip_data *chip_data;
int i; int i;
for (i = 0; i < stm32_host_data->drv_data->bank_nr; i++) { for (i = 0; i < host_data->drv_data->bank_nr; i++) {
chip_data = &stm32_host_data->chips_data[i]; chip_data = &host_data->chips_data[i];
raw_spin_lock(&chip_data->rlock);
stm32_chip_suspend(chip_data, chip_data->wake_active); stm32_chip_suspend(chip_data, chip_data->wake_active);
raw_spin_unlock(&chip_data->rlock);
} }
return 0; 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; struct stm32_exti_chip_data *chip_data;
int i; int i;
for (i = 0; i < stm32_host_data->drv_data->bank_nr; i++) { for (i = 0; i < host_data->drv_data->bank_nr; i++) {
chip_data = &stm32_host_data->chips_data[i]; chip_data = &host_data->chips_data[i];
raw_spin_lock(&chip_data->rlock);
stm32_chip_resume(chip_data, chip_data->mask_cache); stm32_chip_resume(chip_data, chip_data->mask_cache);
raw_spin_unlock(&chip_data->rlock);
} }
}
static struct syscore_ops stm32_exti_h_syscore_ops = { return 0;
#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);
} }
static int stm32_exti_h_retrigger(struct irq_data *d) static int stm32_exti_h_retrigger(struct irq_data *d)
...@@ -789,8 +769,6 @@ stm32_exti_host_data *stm32_exti_host_init(const struct stm32_exti_drv_data *dd, ...@@ -789,8 +769,6 @@ stm32_exti_host_data *stm32_exti_host_init(const struct stm32_exti_drv_data *dd,
goto free_chips_data; goto free_chips_data;
} }
stm32_host_data = host_data;
return host_data; return host_data;
free_chips_data: free_chips_data:
...@@ -916,11 +894,6 @@ static void stm32_exti_remove_irq(void *data) ...@@ -916,11 +894,6 @@ static void stm32_exti_remove_irq(void *data)
irq_domain_remove(domain); irq_domain_remove(domain);
} }
static void stm32_exti_remove(struct platform_device *pdev)
{
stm32_exti_h_syscore_deinit();
}
static int stm32_exti_probe(struct platform_device *pdev) static int stm32_exti_probe(struct platform_device *pdev)
{ {
int ret, i; int ret, i;
...@@ -934,6 +907,8 @@ static int stm32_exti_probe(struct platform_device *pdev) ...@@ -934,6 +907,8 @@ static int stm32_exti_probe(struct platform_device *pdev)
if (!host_data) if (!host_data)
return -ENOMEM; return -ENOMEM;
dev_set_drvdata(dev, host_data);
/* check for optional hwspinlock which may be not available yet */ /* check for optional hwspinlock which may be not available yet */
ret = of_hwspin_lock_get_id(np, 0); ret = of_hwspin_lock_get_id(np, 0);
if (ret == -EPROBE_DEFER) if (ret == -EPROBE_DEFER)
...@@ -996,8 +971,6 @@ static int stm32_exti_probe(struct platform_device *pdev) ...@@ -996,8 +971,6 @@ static int stm32_exti_probe(struct platform_device *pdev)
if (of_property_read_bool(np, "interrupts-extended")) if (of_property_read_bool(np, "interrupts-extended"))
host_data->dt_has_irqs_desc = true; host_data->dt_has_irqs_desc = true;
stm32_exti_h_syscore_init(host_data);
return 0; return 0;
} }
...@@ -1009,12 +982,16 @@ static const struct of_device_id stm32_exti_ids[] = { ...@@ -1009,12 +982,16 @@ static const struct of_device_id stm32_exti_ids[] = {
}; };
MODULE_DEVICE_TABLE(of, 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 = { static struct platform_driver stm32_exti_driver = {
.probe = stm32_exti_probe, .probe = stm32_exti_probe,
.remove_new = stm32_exti_remove,
.driver = { .driver = {
.name = "stm32_exti", .name = "stm32_exti",
.of_match_table = stm32_exti_ids, .of_match_table = stm32_exti_ids,
.pm = &stm32_exti_dev_pm_ops,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment