GPIO shutdown

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GPIO shutdown

Jump to solution
5,437 Views
ksaiviswanadhul
Contributor II

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.

0 Kudos
Reply
1 Solution
5,349 Views
BiyongSUN
NXP Employee
NXP Employee

I already told you everything.

Untitled.png

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>;

};
};

 

View solution in original post

11 Replies
2,994 Views
HB010
Contributor I

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.

0 Kudos
Reply
5,425 Views
igorpadykov
NXP Employee
NXP Employee

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

MCIMX8QM-CPU MEK – Schematics

 

Best regards
igor

0 Kudos
Reply
5,420 Views
ksaiviswanadhul
Contributor II

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>;
};

0 Kudos
Reply
5,392 Views
BiyongSUN
NXP Employee
NXP Employee

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. 

0 Kudos
Reply
5,388 Views
ksaiviswanadhul
Contributor II

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

 

0 Kudos
Reply
5,382 Views
BiyongSUN
NXP Employee
NXP Employee

As previous reply, the hardware and BSP already have that function.

sc_pwrkey(compatible = "fsl,imx8-pwrkey") in dts;

 

Untitledffff.png

IMG_20210816_144531.jpg

 

5,373 Views
BiyongSUN
NXP Employee
NXP Employee

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:

Untitledxxx.png

 

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

 

Untitledfafd.png

 

5,366 Views
ksaiviswanadhul
Contributor II

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?

5,344 Views
BiyongSUN
NXP Employee
NXP Employee

HW:  i.MX8QM MEK

SW:  LF-v5.10.9_1.0.0

 

USDHC1_DATA7  -- > LSIO_GPIO5_IO22

Untitled.png

IMG_20210817_083413.jpg

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 )

Untitled1.png

 

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 )

 

Untitled3.png

 

 

 

0 Kudos
Reply
2,998 Views
HB010
Contributor I

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

 

0 Kudos
Reply
5,350 Views
BiyongSUN
NXP Employee
NXP Employee

I already told you everything.

Untitled.png

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>;

};
};