GPIO Wake up

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GPIO Wake up

308 Views
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

Labels (1)
Tags (2)
0 Kudos
5 Replies

255 Views
Alejandro_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 Kudos

252 Views
cduarte0306
Contributor II

Would this be under the gpio-keys node?

 

Carlos

0 Kudos

248 Views
Alejandro_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 Kudos

141 Views
cduarte0306
Contributor II

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

0 Kudos

236 Views
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 Kudos