hansemro / kc1-linux

Documentation of mainline Linux on First Generation Kindle Fire
GNU General Public License v2.0
4 stars 0 forks source link

Add power button support to device tree #40

Closed hansemro closed 2 years ago

hansemro commented 3 years ago

References:

Issue: Power button cannot be used as an input due to it missing proper drivers.

Notes:

kc1_twl6030 snippet:

#define PHOENIX_STS_HW_CONDITIONS           0x21
#define PWR_PWRON_IRQ (1 << 0)

int twl6030_get_power_button_status(void)
{   
    u8 data;
    twl6030_i2c_read_u8 (TWL6030_CHIP_PM, PHOENIX_STS_HW_CONDITIONS, &data);
    return (data & PWR_PWRON_IRQ);
}

Tasks/Status:

hansemro commented 3 years ago
&twl {
    twl_pwrbutton: pwrbutton {
        compatible = "ti,twl4030-pwrbutton";
        interrupts = <0>;
    };
};

Adding the following (and enabling its corresponding kernel config) will create an input device, but evtest reports no events upon pressing the power button.

hansemro commented 2 years ago

twl6030-pwrbutton driver support from klokik's Jem (Kindle Fire HD 8.9") mainline linux fork works great. I will prepare patches for this repo soon.

amazon-otter:~$ evtest /dev/input/event1
Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "twl4030_pwrbutton"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 116 (KEY_POWER)
Properties:
Testing ... (interrupt to exit)
Event: time 1643193696.698334, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1643193696.698334, -------------- SYN_REPORT ------------
Event: time 1643193696.884893, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1643193696.884893, -------------- SYN_REPORT ------------
Event: time 1643193697.471046, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1643193697.471046, -------------- SYN_REPORT ------------
Event: time 1643193697.646950, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1643193697.646950, -------------- SYN_REPORT ------------
Event: time 1643193698.847149, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1643193698.847149, -------------- SYN_REPORT ------------
Event: time 1643193699.891891, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1643193699.891891, -------------- SYN_REPORT ------------
hansemro commented 2 years ago

Added patches which were tested on 5.16.2 kernel: https://github.com/hansemro/kc1-linux/blob/v5.16.x/patches/0009-HACK-Input-twl4030-pwrbutton-Support-twl6030-variant.patch https://github.com/hansemro/kc1-linux/blob/v5.16.x/patches/0010-HACK-ARM-dts-omap4-kc1-update-twl6030-power-button.patch