good practice to use gpio as wakeup source

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am working on arm custom board with  kernel 4.1.X at this moment.
I used to handle usb (gpio1) et push button (gpio0) event thanks to gpio through
userspace in my code with '/sys/class/gpio'. I would like to use the
suspend/resume feature with 'echo mem > /sys/power/state'.It is working great.
But currently I am not able to wake up the board in suspend mode with usb or push
button event.

After some research I add this in my device tree :

+       gpio_usb {
+               compatible = "gpio-keys";
+               wakeup_usb {
+                       label = "wakeup-usb-gpio";
+                       gpios = <&gpio1 1 1>;
+                       linux,code = <29>;
+                       gpio-key,wakeup;
+               };
+       };
+
+       gpio_button {
+               compatible = "gpio-keys";
+               wakeup_button {
+                       label = "wakeup-button-gpio";
+                       gpios = <&gpio1 0 1>;
+                       linux,code = <29>;
+                       gpio-key,wakeup;
+               };
+       };
+

It works ! I am able to wake up from sleep mode by unplugging/plugging board or
pushing the push button. Problem is that now I cannot use anymore my gpio in
userspace. gpio-keys kernel driver request the both gpio. When I try to export
them in /sys/class/gpio the gpio is busy.

Anyway I was able to retrieve the gpio in /dev/input. I was able to write a piece
of code in userspace to process event in /dev/input/inputX. Problem now is that
I am able to get event on these gpio but not initial state. When the userspace
code is starting on boot, I need to know current usb plug/unplug status to put
state machine in right state. But /dev/input is always able to send event and not
current status.

I tried to remove the gpio-keys compatible in device tree and just keep wakeup
keyword. But by removing that wakeup from suspend with usb and push button is
not working anymore.

What is my next move ? Do I have completely wrong ? Do I have to patch gpio-keys
driver to add a char device to read the gpio state ?

Thanks !
Arthur.


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux