Hi,
I'm using imx8qm mek board yocto based board bring up. I want to do whenever gpio high then board power off(shutdown) state. how to implement this requirement. I need gpio intrrupt based not polling based. Could you please help me out.
解決済! 解決策の投稿を見る。
I already told you everything.
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_keys>;
power {
label = "GPIO Key Power";
linux,code = <KEY_POWER>;
<&gpio2 9 GPIO_ACTIVE_LOW>;
debounce-interval = <50>;
};
};
Hi,
I am also using imx8x family. Did you find a way to get the approach to send out a GPIO change event as part of the processor shut down? I have an external net that needs to be switched off.
Hi KUMAR
for shutdown seems most easy way is to use "SCU_WDOG_OUT", "PMIC_WDOG_IN"
signals on p.18 i.MX8QM MEK SPF-29420 schematic
Best regards
igor
Hi,
yes correct, But I want particular gpio pin high then only shutdown otherwise normal operation. below attached sample code. I did like this but not poweroff
gpio-poweroff {
compatible = "gpio-poweroff";
gpios = <&lsio_gpio2 9 GPIO_ACTIVE_LOW>;
};
the chip has this feature and BSP has already implement the sc_pwrkey(compatible = "fsl,imx8-pwrkey";
).
short press as wakeup source and long press power off and power on(working with PMIC).
for you case, you may need as hardware invert signal.
Hi BiyongSUN,
Thanks for the reply, yes we inverted hardware signal. Do we have a sample code for GPIO shutdown .If you have please post here. so that I'll cross check with my code.
I need complete this task please help me out.
Regards,
Saikumar
As previous reply, the hardware and BSP already have that function.
sc_pwrkey(compatible = "fsl,imx8-pwrkey") in dts;
If you don't want the snvs on off button as power off button, you can use gpio-key add one key for that.
It is the same thing, just use that gpio to send KEY_POWER event.
The KEY_POWER event:
With KEY_POWER event, you can modify the systemd configurate to handle this event
uncomment HandlePowerKey=poweroff and comment #HandlePowerKey=ignore
/etc/systemd/logind.conf
#ReserveVT=6
#KillUserProcesses=yes
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
HandlePowerKey=poweroff
# i.MX-specific
#HandlePowerKey=ignore
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
Thanks for the reply.
I want to shutdown particular gpio low. I added below code to dts file is it correct?
gpio-poweroff {
compatible = "gpio-poweroff";
gpios = <&gpio2 9 GPIO_ACTIVE_LOW>;
};
If wrong add to dts file.. what to add code in dts file?
HW: i.MX8QM MEK
SW: LF-v5.10.9_1.0.0
USDHC1_DATA7 -- > LSIO_GPIO5_IO22
imx8qm-mek-gpio-poweroff.dts
#include "imx8qm-mek.dts"
/{
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_keys>;
power {
label = "GPIO Key Power";
linux,code = <KEY_POWER>;
gpios = <&lsio_gpio5 22 GPIO_ACTIVE_LOW>;
debounce-interval = <50>;
};
};
};
&iomuxc {
/delete-node/ pinctrl_usdhc2;
/delete-node/ pinctrl_usdhc2_gpio;
pinctrl_gpio_keys: gpio_keys_grp {
fsl,pins = <
IMX8QM_USDHC1_DATA7_LSIO_GPIO5_IO22 0x00000021
>;
};
};
&usdhc2 {
status = "disabled";
};
event check:
plugin sdcard to tigger the pin(sdcard CD, now it is LSIO_GPIO5_IO22 )
check the power off:
1. modify the /etc/systemd/logind.conf and restart systemd or reboot the board
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
HandlePowerKey=poweroff
# i.MX-specific
#HandlePowerKey=ignore
#HandleSuspendKey=suspe
2. plugin sdcard to tigger the pin(sdcard CD, now it is LSIO_GPIO5_IO22 )
This looks great. How do I customise this to make a GPIO pin change state just as this closes?
The previous approach was "gpio-poweroff" which made a GPIO pin low immediately before HALT. This GPIO is needed to operate a switch to deactivate the other voltage regulators on the board, and prevent the battery from discharging.
Your help is much appreciated.
Richard
I already told you everything.
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_keys>;
power {
label = "GPIO Key Power";
linux,code = <KEY_POWER>;
<&gpio2 9 GPIO_ACTIVE_LOW>;
debounce-interval = <50>;
};
};