• Mario Limonciello's avatar
    pinctrl: amd: Detect internal GPIO0 debounce handling · 968ab926
    Mario Limonciello authored
    commit 4e5a04be ("pinctrl: amd: disable and mask interrupts on probe")
    had a mistake in loop iteration 63 that it would clear offset 0xFC instead
    of 0x100.  Offset 0xFC is actually `WAKE_INT_MASTER_REG`.  This was
    clearing bits 13 and 15 from the register which significantly changed the
    expected handling for some platforms for GPIO0.
    
    commit b26cd932 ("pinctrl: amd: Disable and mask interrupts on resume")
    actually fixed this bug, but lead to regressions on Lenovo Z13 and some
    other systems.  This is because there was no handling in the driver for bit
    15 debounce behavior.
    
    Quoting a public BKDG:
    ```
    EnWinBlueBtn. Read-write. Reset: 0. 0=GPIO0 detect debounced power button;
    Power button override is 4 seconds. 1=GPIO0 detect debounced power button
    in S3/S5/S0i3, and detect "pressed less than 2 seconds" and "pressed 2~10
    seconds" in S0; Power button override is 10 seconds
    ```
    
    Cross referencing the same master register in Windows it's obvious that
    Windows doesn't use debounce values in this configuration.  So align the
    Linux driver to do this as well.  This fixes wake on lid when
    WAKE_INT_MASTER_REG is properly programmed.
    
    Cc: stable@vger.kernel.org
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=217315Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
    Link: https://lore.kernel.org/r/20230421120625.3366-2-mario.limonciello@amd.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    968ab926
pinctrl-amd.h 37.9 KB