GPIO Wake up

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

GPIO Wake up

跳至解决方案
2,989 次查看
cduarte0306
Contributor II

Hi all,

I am working on a device based on an IMX8MP which uses a Trigger pin as a wake up pin when the unit is asleep, and a regular pin from user space when awake.

 

The pin is bound by the following functions 

 

 

int ret = 0;
    ret = system("echo gpio-keys > /sys/bus/platform/drivers/gpio-keys/unbind");
    if (ret != 0) {
        std::cerr << "Failed to set direction for GPIO pin 6." << std::endl;
        return 0;
    }

    ret = system("echo 6 > /sys/class/gpio/export");
    if (ret != 0) {
        std::cerr << "Failed to set direction for GPIO pin 6." << std::endl;
        return 0;
    }

    ret = system("echo out > /sys/class/gpio/gpio6/direction");
    if (ret != 0) {
        std::cerr << "Failed to set direction for GPIO pin 6." << std::endl;
        return 0;
    }

    ret = system("echo 1 > /sys/class/gpio/gpio6/value");
    if (ret != 0) {
        std::cerr << "Failed to set direction for GPIO pin 6." << std::endl;
        return 0;
    }

    return 1;

 

 

My problem is, despite my DTS settings, the pin is still waking up from both edges (falling and rising), when it should only wake up from a rising edge.

 

Would anyone happen to know why?

 

 

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

		trigger_in {
			label = "TRIGGER IN_PIN";
			gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_WAKEUP>;
			debounce-interval = <10>;
			wakeup-source;
		};
	};


pinctrl_gpio_keys: gpiokeysgrp {
		fsl,pins = <
			MX8MP_IOMUXC_GPIO1_IO06__GPIO1_IO06	0x19
		>;
	};

 

 

I am using kernel version 6.1

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
2,917 次查看
cduarte0306
Contributor II

I tried this and it works when I click the button. I should've mentioned that the pin's end of the connection is inverted form the button click by an optocoupler, meaning that the unit should wake up when the button is released ( a rising edge at the optocoupler, a falling edge at the SoM's Pin)

 

I tried changing it to 

 

 

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

		trigger_in {
			label = "TRIGGER IN_PIN";
			gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_WAKEUP>;
			debounce-interval = <10>;
                    interrupt-parent = <&gpio1>; 
                    interrupts = <6 IRQ_TYPE_EDGE_FALLING>;
			wakeup-source;
		};
	};

 

And it was waking on both edges once more

在原帖中查看解决方案

0 项奖励
回复
5 回复数
2,936 次查看
Manuel_Salas
NXP TechSupport
NXP TechSupport

Hello @cduarte0306 

 

Could you please try to add tou your dts:

 

interrupt-parent = <&gpio1>; 
interrupts = <6 IRQ_TYPE_EDGE_RISING>;

 

And let me know if that works.

 

Best regards.

 

Salas.

0 项奖励
回复
2,933 次查看
cduarte0306
Contributor II

Would this be under the gpio-keys node?

 

Carlos

0 项奖励
回复
2,929 次查看
Manuel_Salas
NXP TechSupport
NXP TechSupport

Hello,

 

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

		trigger_in {
			label = "TRIGGER IN_PIN";
			gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_WAKEUP>;
			debounce-interval = <10>;
                    interrupt-parent = <&gpio1>; 
                    interrupts = <6 IRQ_TYPE_EDGE_RISING>;
			wakeup-source;
		};
	};

 

Please try and let me know.

 

Best regards.

 

Salas. 

0 项奖励
回复
2,822 次查看
cduarte0306
Contributor II

I should let you know this solution is not working for some reason.

0 项奖励
回复
2,918 次查看
cduarte0306
Contributor II

I tried this and it works when I click the button. I should've mentioned that the pin's end of the connection is inverted form the button click by an optocoupler, meaning that the unit should wake up when the button is released ( a rising edge at the optocoupler, a falling edge at the SoM's Pin)

 

I tried changing it to 

 

 

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

		trigger_in {
			label = "TRIGGER IN_PIN";
			gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_WAKEUP>;
			debounce-interval = <10>;
                    interrupt-parent = <&gpio1>; 
                    interrupts = <6 IRQ_TYPE_EDGE_FALLING>;
			wakeup-source;
		};
	};

 

And it was waking on both edges once more

0 项奖励
回复