gpio as both interrupt pin and wake-up source

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

gpio as both interrupt pin and wake-up source

879 次查看
akbar123
Contributor III

Hi,

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>;
        wakeup-source;
    };
};

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:

gpio-controller;
interrupt-controller;
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

标签 (2)
标记 (3)
0 项奖励
2 回复数

111 次查看
gauravsharma7
NXP Employee
NXP Employee

Hi @akbar123 ,

You can configure IRQ on a GPIO and set it as a wakeup source at the same time with something like below:-
This I had configured for imx93evk but you can modify it for your platform.

/ {

        gpio-keys {

                compatible = "gpio-keys";

                pinctrl-names = "default";

                pinctrl-0 = <&pinctrl_gpio_keys>;

 

                power {

                  label = "GPIO Key Power";

                  linux,code = <KEY_POWER>;

                  gpios = <&gpio2 7 GPIO_ACTIVE_LOW>;

                  wakeup-source;

                  debounce-interval = <20>;

                  interrupt-parent = <&gpio2>;

                  interrupts = <7 IRQ_TYPE_LEVEL_LOW>;

                };

        };

};

 

&iomuxc {

        pinctrl_gpio_keys: gpio_keys_grp {

                fsl,pins = <

                        MX93_PAD_GPIO_IO07__GPIO2_IO07  0x31e

                >;

        };

};

On your imx linux console, you can verify that interrupts have been mapped via /proc/interrupts

gauravsharma7_0-1709018433623.png

Cheers!!

0 项奖励

852 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Asghar

 

one can try to follow gpio-keys linux documentation, wakeup-source is optional:

https://github.com/varigit/linux-imx/blob/imx_4.14.78_1.0.0_ga_var01/Documentation/devicetree/bindin...

 

Best regards
igor

0 项奖励