* [PATCH] gpio: mpc8xxx: Add wake on GPIO support
@ 2024-08-20 14:33 Martyn Welch
2024-09-02 10:35 ` Bartosz Golaszewski
2024-09-02 16:23 ` Andy Shevchenko
0 siblings, 2 replies; 3+ messages in thread
From: Martyn Welch @ 2024-08-20 14:33 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski
Cc: kernel, Martyn Welch, linux-gpio, linux-kernel
The mpc8xxx GPIO can generate an interrupt on state change. This
interrupt can be used to wake up the device from its sleep state if
enabled to do so. Add required support to the driver so that the GPIO
can be used in this way.
In order for the GPIO to actually function in this way, it is necessary
to also set the GPIO bit in the RCPM. This can be done via the device
tree fsl,rcpm-wakeup property.
Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
---
drivers/gpio/gpio-mpc8xxx.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index c0125ac73906..ab30c911c9d5 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -413,6 +413,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
goto err;
}
+ device_init_wakeup(&pdev->dev, true);
+
return 0;
err:
irq_domain_remove(mpc8xxx_gc->irq);
@@ -429,6 +431,31 @@ static void mpc8xxx_remove(struct platform_device *pdev)
}
}
+#ifdef CONFIG_PM
+static int mpc8xxx_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev);
+
+ if (mpc8xxx_gc->irqn && device_may_wakeup(&pdev->dev))
+ enable_irq_wake(mpc8xxx_gc->irqn);
+
+ return 0;
+}
+
+static int mpc8xxx_resume(struct platform_device *pdev)
+{
+ struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev);
+
+ if (mpc8xxx_gc->irqn && device_may_wakeup(&pdev->dev))
+ disable_irq_wake(mpc8xxx_gc->irqn);
+
+ return 0;
+}
+#else
+#define mpc8xxx_suspend NULL
+#define mpc8xxx_resume NULL
+#endif
+
#ifdef CONFIG_ACPI
static const struct acpi_device_id gpio_acpi_ids[] = {
{"NXP0031",},
@@ -440,6 +467,8 @@ MODULE_DEVICE_TABLE(acpi, gpio_acpi_ids);
static struct platform_driver mpc8xxx_plat_driver = {
.probe = mpc8xxx_probe,
.remove_new = mpc8xxx_remove,
+ .suspend = mpc8xxx_suspend,
+ .resume = mpc8xxx_resume,
.driver = {
.name = "gpio-mpc8xxx",
.of_match_table = mpc8xxx_gpio_ids,
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: mpc8xxx: Add wake on GPIO support
2024-08-20 14:33 [PATCH] gpio: mpc8xxx: Add wake on GPIO support Martyn Welch
@ 2024-09-02 10:35 ` Bartosz Golaszewski
2024-09-02 16:23 ` Andy Shevchenko
1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2024-09-02 10:35 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Martyn Welch
Cc: Bartosz Golaszewski, kernel, linux-gpio, linux-kernel
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Tue, 20 Aug 2024 15:33:27 +0100, Martyn Welch wrote:
> The mpc8xxx GPIO can generate an interrupt on state change. This
> interrupt can be used to wake up the device from its sleep state if
> enabled to do so. Add required support to the driver so that the GPIO
> can be used in this way.
>
> In order for the GPIO to actually function in this way, it is necessary
> to also set the GPIO bit in the RCPM. This can be done via the device
> tree fsl,rcpm-wakeup property.
>
> [...]
Applied, thanks!
[1/1] gpio: mpc8xxx: Add wake on GPIO support
commit: 520aa57ad7222806ebdfd05b8de07bccd0156cf8
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: mpc8xxx: Add wake on GPIO support
2024-08-20 14:33 [PATCH] gpio: mpc8xxx: Add wake on GPIO support Martyn Welch
2024-09-02 10:35 ` Bartosz Golaszewski
@ 2024-09-02 16:23 ` Andy Shevchenko
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2024-09-02 16:23 UTC (permalink / raw)
To: Martyn Welch
Cc: Linus Walleij, Bartosz Golaszewski, kernel, linux-gpio, linux-kernel
On Tue, Aug 20, 2024 at 03:33:27PM +0100, Martyn Welch wrote:
> The mpc8xxx GPIO can generate an interrupt on state change. This
> interrupt can be used to wake up the device from its sleep state if
> enabled to do so. Add required support to the driver so that the GPIO
> can be used in this way.
>
> In order for the GPIO to actually function in this way, it is necessary
> to also set the GPIO bit in the RCPM. This can be done via the device
> tree fsl,rcpm-wakeup property.
Any specific requirement(s) to:
1) avoid new PM macros (such as pm_ptr());
2) use quite outdated PM callbacks?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-02 16:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-20 14:33 [PATCH] gpio: mpc8xxx: Add wake on GPIO support Martyn Welch
2024-09-02 10:35 ` Bartosz Golaszewski
2024-09-02 16:23 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®