linux gpio_keys driver
source:
drivers/input/keyboard/gpio_keys.c
documentation:
Documentation/devicetree/bindings/input/gpio-keys.txt
example,dts config:
gpio_keys {
compatible = "gpio-keys";
input-name = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&gpio_keys_default>;
key_1 {
label = "key_1";
gpios = <&gpio 07 GPIO_ACTIVE_HIGH>;
linux,input-type = <1>;
linux,code = <0x01>; /* KEY_1 */
gpio-key,wakeup;
debounce-interval = <15>;
};
};
debug log:
[root]# hexdump /dev/input/event0
[ 49.799309] gpio_keys_gpio_report_event() key code:1, state:0
0000000 0031 0000 2536 000c 0001 0001 0000 0000
0000010 0031 0000 2536 000c 0000 0000 0000 0000
[ 52.139315] gpio_keys_gpio_report_event() key code:1, state:1
0000020 0034 0000 1319 0002 0001 0001 0001 0000
0000030 0034 0000 1319 0002 0000 0000 0000 0000
[root]#