Commit e9482dc5 authored by Martyn Welch's avatar Martyn Welch Committed by Bartosz Golaszewski

gpio: mpc8xxx: Add wake on GPIO support

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: default avatarMartyn Welch <martyn.welch@collabora.com>
Link: https://lore.kernel.org/r/20240820143328.1987442-1-martyn.welch@collabora.comSigned-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent c10c762f
...@@ -413,6 +413,8 @@ static int mpc8xxx_probe(struct platform_device *pdev) ...@@ -413,6 +413,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
goto err; goto err;
} }
device_init_wakeup(&pdev->dev, true);
return 0; return 0;
err: err:
irq_domain_remove(mpc8xxx_gc->irq); irq_domain_remove(mpc8xxx_gc->irq);
...@@ -429,6 +431,31 @@ static void mpc8xxx_remove(struct platform_device *pdev) ...@@ -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 #ifdef CONFIG_ACPI
static const struct acpi_device_id gpio_acpi_ids[] = { static const struct acpi_device_id gpio_acpi_ids[] = {
{"NXP0031",}, {"NXP0031",},
...@@ -440,6 +467,8 @@ MODULE_DEVICE_TABLE(acpi, gpio_acpi_ids); ...@@ -440,6 +467,8 @@ MODULE_DEVICE_TABLE(acpi, gpio_acpi_ids);
static struct platform_driver mpc8xxx_plat_driver = { static struct platform_driver mpc8xxx_plat_driver = {
.probe = mpc8xxx_probe, .probe = mpc8xxx_probe,
.remove_new = mpc8xxx_remove, .remove_new = mpc8xxx_remove,
.suspend = mpc8xxx_suspend,
.resume = mpc8xxx_resume,
.driver = { .driver = {
.name = "gpio-mpc8xxx", .name = "gpio-mpc8xxx",
.of_match_table = mpc8xxx_gpio_ids, .of_match_table = mpc8xxx_gpio_ids,
......
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