mtk-pmic-keys: Ignore power button if pressed before driver loads

From: Arınç ÜNAL
Date: Mon Jan 30 2023 - 08:37:16 EST


Hi all,

The power button on my Bananapi BPI-R2 (MT7623NI SoC, mt6323-keys) is shorted, so the device automatically boots when there's power. This causes the device to reboot when KEYBOARD_MTK_PMIC is loaded because the driver sees the power button being pressed.

I was wondering if it's possible to change the driver in a way that doesn't break in this situation. Maybe don't do anything if the first state of the the power button the driver sees is being pressed, and if the state doesn't change.

To address an edge case, if the power button was being pressed before the driver loads, look for if it's ever released. Only after then start working as usual.

Looking forward to hearing your thoughts.
Arınç