* good practice to use gpio as wakeup source
@ 2018-05-04 9:04 Arthur LAMBERT
0 siblings, 0 replies; only message in thread
From: Arthur LAMBERT @ 2018-05-04 9:04 UTC (permalink / raw)
To: kernelnewbies
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-05-04 9:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-04 9:04 good practice to use gpio as wakeup source Arthur LAMBERT
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).