gpio中断时发送按键消息

有个android项目有个功能,按压时发送一个按键消息给上层, 抬起时发送另一个按键消息给上层,模拟传统电话挂断和抬起接听的功能。
请问驱动怎么实现?dts怎么配置该gpio呢。

需要提供实现code.


gpio-keys {
        compatible = "gpio-keys";
        autorepeat;

        pinctrl-names = "default";
        pinctrl-0 = <&button_key>;
        
        answer {
            gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>;
            linux,code = <11>;
            label = "Key Answer";
            wakeup-source;
            debounce-interval = <50>;
        }; 
};

我不清楚题主用的什么平台,我之前做的事瑞芯微平台的,这个是按键的DTS写法。
之后可以通过读/dev/input/event1来获取按键事件,具体对应哪个event还需要看你那边具体的平台
读event1的方法可以用poll的方法去读。下面的代码片段中读到的ev.code和DTS中linux,code = <11>;这个值对应

void input_key_cb(struct io_event *i_event)
{
    struct input_event ev;
    struct key_state *key;
    int ret = -1;
    if (i_event->fd <= 0)
        return;
    
    ret = read(i_event->fd, &ev, sizeof(ev));
    if (ret != sizeof(ev))
    {
        slogn("Event from input is failed, ret : %d", ret);
        return;
    }


    switch (ev.code) {
        
    }

    return;
}