GPIOKEYS(4)
π GPIOKEYS π
okay bestie, so this is a kernel interfaces manual page for gpiokeys β the GPIO keys device driver. yes we're in the kernel, yes it's giving embedded systems main character energy, and yes you're gonna understand it. let's go π¦
β¨ NAME β¨
gpiokeys β GPIO keys device driver π
πΈ SYNOPSIS πΈ
so if you wanna compile this driver into the kernel, you drop these lines into your kernel configuration file:
options FDT
device gpio
device gpiokeys
or β alternate route, bestie β if you'd rather load it as a module at boot time, you put this line in loader.conf(5):
gpiokeys_load="YES"
slay, either way works β¨
π DESCRIPTION π
k so here's the vibe: the gpiokeys driver gives you a way to represent a set of general purpose inputs as a keyboard(4) device. cute, right?
ngl though β at the moment the driver supports only FDT(4) based systems. no cap. the DTS is the one that decides which pins get mapped to buttons and what key codes get generated for each virtual button. then you can use that keyboard(4) device from userland to monitor for input changes. obsessed with the flexibility fr fr π
on an FDT(4) based system, the DTS part for a gpiokeys device usually looks like this:
/ {
...
gpio_keys {
compatible = "gpio-keys";
btn1 {
label = "button1";
linux,code = <KEY_1>;
gpios = <&gpio 0 3 GPIO_ACTIVE_LOW>
};
btn2 {
label = "button2";
linux,code = <KEY_2>;
gpios = <&gpio 0 4 GPIO_ACTIVE_LOW>
};
};
};
for more deets about the gpios property, please go consult /usr/src/sys/dts/bindings-gpio.txt β it's literally right there, iykyk π
π₯ the key code properties π₯
the gpiokeys driver supports two properties for specifying a key code:
- the property
freebsd,codespecifies a FreeBSD native scancode compatible withkbdmap(5)keyboard maps π - the property
linux,codespecifies an evdev scancode. that scancode gets internally translated to a native scancode. heads up though: not all evdev scancodes have corresponding native scancodes. if a scancode can't be translated, then a diagnostic message is printed and the input is ignored. π
okay important side note, bestie β that "input is ignored" part is real. like, silently-ish dropped. not a crash, just a little shrug and a log line. don't come for me, i'm just the messenger π
π«Ά the other properties π«Ά
- the property
labelis a descriptive name of a button. it is used for diagnostic messages only. this property is optional. if it's not set, the node name is used in its place. periodt π - the property
autorepeatdetermines whether autorepeat is enabled for a button. β - the property
debounce-intervaldefines debouncing interval time in milliseconds. if not specified, the interval defaults to5. πΈ
π SEE ALSO π
fdt(4), gpio(4), keyboard(4), kbdmap(5)
go read them, they're all iconic in their own way π¦
π HISTORY π
the gpiokeys manual page first appeared in FreeBSD 12.2. vintage-ish, but make it embedded π
π AUTHORS π
the gpiokeys driver was written by Oleksandr Tymoshenko <gonzo@FreeBSD.org>.
this manual page was written by Andriy Gapon <avg@FreeBSD.org>.
absolute legends, we stan π«Ά
and that's the whole page bestie!! this one's a Debian production, dated August 5, 2020, sitting pretty as part of the Kernel Interfaces Manual. ty for coming to my ted talk, go press a button π β¨π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- π the page's license: BSD-2-Clause-FreeBSD
- Copyright (c) 2020 Andriy Gapon <avg@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms