Hello,
I’m trying to figure out how to properly setup the GPIO power On\Off functionality in the embedded Linux we are using on our device.
I’ve read through the GPIO (Linux) document that you have available and found a section that gives information on how this should be done: GPIO (Linux).
I setup nodes in our carrier board specific device tree file as follows:
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_powerkeys>;
power {
label = "Power-Key";
gpios = <&gpio2 29 GPIO_ACTIVE_LOW>;
linux,code = <KEY_POWER>;
debounce-interval = <10>;
};
};
&iomuxc {
imx7d-p1100 {
pinctrl_powerkeys: powerkeys {
fsl,pins = <
MX7D_PAD_EPDC_BDR1__GPIO2_IO29 0X14 /*SODIMM 110*/
>;
};
};
};
and I’ve also setup the contents of the /etc/udev/rules.d/power-key.rules file as specified in the document:
ACTION=="remove", GOTO="power_switch_end"
SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_PATH}=="platform-gpio-keys*", ATTRS{keys}=="*", TAG+="power-switch"
LABEL="power_switch_end"
But when I go to press the power button on our device, power will not latch on. I have to hold the power button constantly. If I let go power is lost. I’ve configured everything the way that is specified in the document linked above, but it’s not working.
What am I doing wrong? Is there something that needs to be configured in U-boot to make this work correctly?
The document also mentions: HandlePowerKey/HandleSuspendKey and HandleHibernateKey in /etc/systemd/logind.conf
I’ve looked at this file as it exists in embedded Linux running on our device and here are the contents:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See logind.conf(5) for details.
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=yes
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#UserTasksMax=12288
Is there anything additional that I need to do in this file to make this work?
Thank You.