Cannot configure GPIO as wakeup source

Hi! I need to configure a GPIO as a wakeup source from the suspend or standby mode. My final goal is the configure the touchscreen as a wakeup source, but I am still waiting for a response regarding that and in the meantime I am trying to make a simpler configuration, by setting a GPIO as a wakeup source.

In order to use GPIO5.4 as a wakeup source, I’ve changed the file imx6ull-colibri-aster.dts as follows:

gpio-keys {
         compatible = "gpio-keys";
         pinctrl-names = "default";
         pinctrl-0 = <&pinctrl_snvs_gpio2>; // GPIO5.4 is defined in pinctrl_snvs_gpio2, in imx6ull-colibri.dtsi
 
         /*power {
             label = "Wake-Up";
             gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>; // GPIO5.1 is defined in pinctrl_snvs_gpiokeys
             linux,code = <KEY_WAKEUP>;
             debounce-interval = <10>;
             gpio-key,wakeup;
         };*/
 
         wake {
             label = "Wake";
             gpios = <&gpio5 4 GPIO_ACTIVE_HIGH>; // SODIMM 107
             linux,code = <KEY_WAKEUP>;
             gpio-key,wakeup;
         };
     };

The problem is that GPIO5.4 is not shown as a wakeup source:

cat /sys/kernel/debug/gpio
gpiochip4: GPIOs 128-159, parent: platform/20ac000.gpio, 20ac000.gpio:
  gpio-128 (SODIMM_43           |cd                  ) in  hi IRQ ACTIVE LOW
  gpio-129 (SODIMM_45           )
  gpio-130 (SODIMM_137          |id                  ) in  lo IRQ
  gpio-131 (SODIMM_95           )
  gpio-132 (SODIMM_107          )
  gpio-133 (SODIMM_131          )
  gpio-134 (                    )
  gpio-135 (                    )
  gpio-136 (                    )
  gpio-137 (                    |+V3.3_1.8_SD        ) out hi
  gpio-138 (SODIMM_105          )
  gpio-139 (                    |reset               ) out hi ACTIVE LOW

What am I doing wrong here? Or is there another way to do this?

Also, I would like to use also GPIO5.1 (SODIMM 45) as a wakeup source, but it corresponds to a different pinctrl ( pinctrl_snvs_gpiokeys ). How can I define both pinctrls so I can use both wakeup sources (GPIO5.1 and 5.4)?

Hello @CristianM ,

Thank you for your detailed message!

Could you tell us what SODIMM pin are you looking at?
Please note that not all the GPIOs are exported in Linux. Consult this page to get further Information about GPIOs in Linux?

Hi. I am trying to make GPIO5.4 (SODIMM 107) a wakeup source. As you can see from the output of the cat /sys/kernel/debug/gpio command above, this pin is exported.

Hello @CristianM ,

I see your in your .dts file that the function call is named “wake” instead of “wakeup”. Did you also modify the kernel accordingly?

I’ve changed it to:

wakeup {
   label = "Wake-Up";
   gpios = <&gpio5 4 GPIO_ACTIVE_HIGH>; // SODIMM 107
   linux,code = <KEY_WAKEUP>;
   gpio-key,wakeup;
 };

and, unfortunately, I get the same output as above for cat /sys/kernel/debug/gpio. What is wrong with this configuration? Also, out of curiosity, where can this function be modified in the kernel?

Hi @CristianM ,

It is strange that this happens. I see that you have commented this part in your imx6ull-colibri-aster.dts. What happens when you uncomment that? Do you see that SODIMM 45 is assigned as a wakeup source?

          /*power {
              label = "Wake-Up";
              gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>; // GPIO5.1 is defined in pinctrl_snvs_gpiokeys
              linux,code = <KEY_WAKEUP>;
              debounce-interval = <10>;
              gpio-key,wakeup;
          };*/

If that works, I would just try to add the other GPIO that you want to use as wakeup source there, like

                  ......
                  gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>;
                  gpios = <&gpio5 4 GPIO_ACTIVE_HIGH>;
                  linux,code = <KEY_WAKEUP>;
                  debounce-interval = <10>;
                  .........

Could you please try these at your end?

When none of these work, could you please share with us git diff of your device tree changes?

Best Regards,
Janani

When I uncomment the power pin, SODIMM 45 does not appear as a wakeup source (the output of cat /sys/kernel/debug/gpio is the same as that presented in my question).

If I also set pinctrl-0 = <&pinctrl_snvs_gpiokeys>, which corresponds to SODIMM 45, I get the same output.

It works only with the power pin defined, regardless of the pinctrl-0 definition, and only for SODIMM 45.

When adding the second GPIO as you suggested, I get the error: /gpio-keys/power:gpios: Duplicate property name. It seems the correct syntax is:

gpios = <
   &gpio5 1 GPIO_ACTIVE_HIGH /* SODIMM 45 */
   &gpio5 4 GPIO_ACTIVE_HIGH /* SODIMM 107 */
>;

In this case, only SODIMM 45 appears as a wakeup source.

I have attached the git diff output file.

Hello @CristianM ,

Thank you for your patience. What worked for me is this. I left the SODIMM 45 in the original device tree as the wake-up source and then added the following git diff:

diff --git a/arch/arm/boot/dts/imx6ull-colibri-aster.dtsi b/arch/arm/boot/dts/imx6ull-colibri-aster.dtsi
index ddb3146ff399..c272c9b03681 100644
--- a/arch/arm/boot/dts/imx6ull-colibri-aster.dtsi
+++ b/arch/arm/boot/dts/imx6ull-colibri-aster.dtsi
@@ -27,6 +27,14 @@
                        debounce-interval = <10>;
                        gpio-key,wakeup;
                };
+
+        power2 {
+                       label = "Wake-Up";
+                       gpios = <&gpio5 4 GPIO_ACTIVE_HIGH>;
+                       linux,code = <KEY_WAKEUP>;
+                       debounce-interval = <10>;
+                       gpio-key,wakeup;
+               };
        };

Hope it helps.

Best Regards,
Janani

I’ve tried your solution, but it doesn’t work. I get the same output of cat /sys/kernel/debug/gpio as that presented in my question. As said in my previous message, if I remove/comment power2, then SODIMM 45 appears as a wake up source.

What is wrong here? How can it work for you, but not for me also?

Greetings @CristianM!

I was able to add an extra wakeup source. I’m using kernel branch toradex_5.4-2.3.x-imx but the same principles should apply to other versions. Consider the following diff:

diff --git a/arch/arm/boot/dts/imx6ull-colibri-aster.dtsi b/arch/arm/boot/dts/imx6ull-colibri-aster.dtsi
index ddb3146ff399..fdc4f5e4db57 100644
--- a/arch/arm/boot/dts/imx6ull-colibri-aster.dtsi
+++ b/arch/arm/boot/dts/imx6ull-colibri-aster.dtsi
@@ -27,6 +27,14 @@
                        debounce-interval = <10>;
                        gpio-key,wakeup;
                };
+
+               wakeup {
+                       label = "Wake-Up_TEST";
+                       gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;
+                       linux,code = <KEY_WAKEUP>;
+                       debounce-interval = <10>;
+                       gpio-key,wakeup;
+               };
        };
 
        extcon_usbc_det: usbc_det {
@@ -259,7 +267,7 @@
 
 /* PWM <D> */
 &pwm7 {
-       status = "okay";
+       status = "disabled";
 };
 
 &uart1 {

By default, there’s a power wakeup source on the Aster device tree that is mapped to SODIMM_45. For testing, I’ve added another wakeup source (named wakeup) on SODIMM_67. I’ve just copied the power entry and changed label and the gpios assignment.

Note that this pin has another definition by default. It’s PWM7 on the Aster I’m using, so I had to disable the pwm7 node in the same device tree.

In the case of SODIMM_107 which you’re using, there’s no other peripheral assigned to that, at least on the Aster device tree I’m using, so this should work just fine for that peripheral. Can you please try that and report back?

Hi. I confirm that your solution for SODIMM_67 works. However, for SODIMM_107 it does not work, as described in my previous messages.

If it helps, I mention that I tried to change the interrupt pin to SODIMM_67 for the atmel_mxt_ts: atmel_mxt_ts@4a (just for testing), as follows:

interrupt-parent = <&gpio2>;
interrupts = <6 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 67 */

In this case, SODIMM_67 did not appear as an interrupt source. Therefore, this indicates that the problem is related to the fact that specific pin is also defined as an interrupt for the touch controller.

Have you made any progress? Did my previous comment helped you?

Hi @CristianM!

No progress yet, but I just got myself a display and I’m currently testing this.

On a brief research I ended up on the Linux kernel mailing list where I saw a patch proposing a change to this driver, but someone claimed the wakeup function should already be supported by the i2c subsystem itself.

Some other touch drivers have their own wakeup implementation in the driver itself, but it seems that’s not the most elegant way to do this.

I’ll let you know about my findings.

OK. Hopefully, you will make progress.

@CristianM,

I’ll close this topic and we can continue discussing on this one since it’s about the same subject: https://www.toradex.com/community/questions/53860/touchscreen-wakeup-in-imx6ull.html

I kindly suggest you to try testing the same thing I did there to see if you get the same results. Thanks!