AnsweredAssumed Answered

iMX6 Power Button behavior

Question asked by Konstantyn Prokopenko on Sep 21, 2018
Latest reply on Sep 24, 2018 by Konstantyn Prokopenko


I'm working on a project running Yocto Rocko Release 01-4.9.11 build for imx6 quad. I'd like to add some custom processing of the power button event. According to the imx6 specification pressing button between 750msec and 5 second would generate IRQ which is handled by the pwrkey_snvs module in drivers/input/keyboard.

The problem is that i'd like to trap IRQ when button was pressed. However it seems that IRQ is generated only when button is released. It is not really adequate solution for me because if i hold button more than 5 seconds SoC shuts down.

Is there a way around it? Also i understand that >5 second behavior when SoC shuts down is 'hard-wired', so there is no way to disable it, is it true?

In addition, i fired up a kernel timer in the pwrkey_snvs module to check SNVS registers every 100 msec as a test. The SNVS_HPSR status should indicate bits for Button Interrupt and Value of the BTN input. Both bits are off no matter how long i press the power button or if i press and release it multiple times. ISR for the IRQ is entered when button is released.

My device tree entry for the power button (I've tried several IRQ trigger types - nothing works):


snvs_pwrkey: snvs-powerkey {
compatible = "fsl,sec-v4.0-pwrkey";
regmap = <&snvs>;
interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
linux,keycode = <KEY_POWER>;
gpio_white_led = <&gpio2 31 0>;
gpio_red_led = <&gpio3 25 0>;
gpio_green_led = <&gpio3 23 0>;
status = "enabled";

I've added couple of GPIOs for my custom needs which should not interfere with the power button logic.


Thank you