Gpio as both interrupt pin and wake-up source


I have used GPIO pin as wake-up source in my imx6 apalis board by enabling it with the following snippet in device tree:

gpio-keys {
    compatible = "gpio-keys";
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpio_keys>;

    wakeup {
        label = "Wake-Up";
        gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
        linux,code = <KEY_WAKEUP>;
        debounce-interval = <10>;

Now I can wake up imx6 when it’s in sleep by the gpio pin

I have test another scenario to generate interrupt by a gpio pin with the following snippet in the device tree:

interrupt-parent = <&gpio1>;
interrupts = <4 IRQ_TYPE_EDGE_FALLING>;

Now, I want to combine these two scenarios. I want a gpio pin to act as both wake-up source and interrupt pin, i.e. when imx6 is in sleep, the interrupt will wake it up, and when it’s wakeup, the interrupt acts as usual and be received by other parts such as a driver willing to receive it

Question: How can I do the above scenario?

Thanks in advance

We can use GPIO as both for interrupt (when Linux works normally) and wake-up(when Linux is in sleep).
We need to do three things in driver code:

1- In the probe function we say that our device is capable of making wake-up by using the following function:

device_init_wakeup(&i2c->dev, 1);

We need to implement power management functions so that we get notified when Linux is going to sleep and when it wakes up:

2- In the suspend function, we need to make the gpio pin interrupt capable of waking up by using the following function:


3- In the resume function, we need to disable gpio pin interrupt wake-up capability by using the following function:


Hope it helps you


Glad that this change works for you, thanks for the feedback!

Johnatahan, can you please tell me where to make the changes you described? I want to achieve a similar goal: to use a pin as both a wakeup source and regular input (not interrupt source, as you needed). I posted my question here.