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

From: Mattijs Korpershoek
Date: Mon Jan 30 2023 - 12:21:20 EST


Hi Arınç,

On lun., janv. 30, 2023 at 16:36, Arınç ÜNAL <arinc.unal@xxxxxxxxxx> wrote:

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

What evidence do you have that there is actually a "press" event being
received by userspace? Did you tested this with evtest or something
similar?

If a "power button press" is generated, than I imagine that a userspace
process must receive it and halt the system, right?

The PMIC also has a feature to shutdown in case detect a long key-press,
which is controlled by the mediatek,long-press-mode device-tree
property.
So is it the pmic that shutdown your board (probably no evidence in
logs, just a "power cut" behaviour) or is it userspace?

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

If the driver is an issue, can't we blacklist it from being probed
instead? or do you want to use the home key feature that that same
driver provides?

Hope that helps,

Mattijs

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