Skip to content

Commit e9482dc

Browse files
mwelchukBartosz Golaszewski
authored andcommitted
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: Martyn Welch <martyn.welch@collabora.com> Link: https://lore.kernel.org/r/20240820143328.1987442-1-martyn.welch@collabora.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent c10c762 commit e9482dc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/gpio/gpio-mpc8xxx.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
413413
goto err;
414414
}
415415

416+
device_init_wakeup(&pdev->dev, true);
417+
416418
return 0;
417419
err:
418420
irq_domain_remove(mpc8xxx_gc->irq);
@@ -429,6 +431,31 @@ static void mpc8xxx_remove(struct platform_device *pdev)
429431
}
430432
}
431433

434+
#ifdef CONFIG_PM
435+
static int mpc8xxx_suspend(struct platform_device *pdev, pm_message_t state)
436+
{
437+
struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev);
438+
439+
if (mpc8xxx_gc->irqn && device_may_wakeup(&pdev->dev))
440+
enable_irq_wake(mpc8xxx_gc->irqn);
441+
442+
return 0;
443+
}
444+
445+
static int mpc8xxx_resume(struct platform_device *pdev)
446+
{
447+
struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev);
448+
449+
if (mpc8xxx_gc->irqn && device_may_wakeup(&pdev->dev))
450+
disable_irq_wake(mpc8xxx_gc->irqn);
451+
452+
return 0;
453+
}
454+
#else
455+
#define mpc8xxx_suspend NULL
456+
#define mpc8xxx_resume NULL
457+
#endif
458+
432459
#ifdef CONFIG_ACPI
433460
static const struct acpi_device_id gpio_acpi_ids[] = {
434461
{"NXP0031",},
@@ -440,6 +467,8 @@ MODULE_DEVICE_TABLE(acpi, gpio_acpi_ids);
440467
static struct platform_driver mpc8xxx_plat_driver = {
441468
.probe = mpc8xxx_probe,
442469
.remove_new = mpc8xxx_remove,
470+
.suspend = mpc8xxx_suspend,
471+
.resume = mpc8xxx_resume,
443472
.driver = {
444473
.name = "gpio-mpc8xxx",
445474
.of_match_table = mpc8xxx_gpio_ids,

0 commit comments

Comments
 (0)