Kevin Posted September 17, 2016 Posted September 17, 2016 All of the docs that I see on how to use the kernel gpio_keys refers to dts (device tree). The kernel module is present in Armbian legacy 5.20 Jessie Desktop. /lib/modules/3.4.112...../gpio_keys.ko I understand it should map gpio inputs to keystrokes. But all usage/configuration info I can find refers to entries made in Device Tree -- gpio-keys { compatible = "gpio-keys"; left-key { label = "Left key"; gpios = <&gpio0 17 0>; linux,code = <69>; /* KEY_LEFT */ }; } This refers to some other underlying hardware, but it is an example... So my question... I don't believe Armbian legacy handles device tree. So what would I need to do to map a gpio pin to a keystroke in kernel space. Or is there a sysfs option I'm missing also missing? I can write a kernel module if needed, but I'd prefer not to actually modify/compile the armbian kernel as provided. Thanks, Kevin
zador.blood.stained Posted September 17, 2016 Posted September 17, 2016 Depending on number of buttons that you need, you could write your own implementation of gpio_keys_get_devtree_pdata (in drivers/input/keyboard/gpio_keys.c or drivers/input/keyboard/gpio_keys_polled.c) that would use fex file instead of DT for data check out sunxi-keyboard.c and sunxi-keypad.c in the same directory. Looking at the code, sunxi-keyboard is LRADC based, and sunxi-keypad is for matrix keypads, but they are using predefined pins for LRADC and keypad controllers, you'll have to check datasheet and schematics to see if these pins are available on pin headers.
Kevin Posted September 17, 2016 Author Posted September 17, 2016 Thank you for the quick response. sunxi-keyboard and sunxi-keypad seem to be too specific for my use.... I'm just looking for one or two push buttons, and something that can be dynamically set (kernel module params or sysfs or fex) I like your idea of taking gpio_keys.c and making a new kernel module and having read the fex file. That may be the route I take. Have you ever heard of a kernel module which takes settings from sysfs and performs gpio to keyboard input? Thanks, Kevin
zador.blood.stained Posted September 18, 2016 Posted September 18, 2016 Have you ever heard of a kernel module which takes settings from sysfs and performs gpio to keyboard input? No, this is too specific to be included in the kernel IMO. Single buttons (like "Suspend/Wake" button on Orange Pi boards) have its own driver, and keypads or keyboards with big number of buttons are designed to work with specific controllers or with generic drivers like gpio_keys.
Recommended Posts