xref: /freebsd-src/share/man/man4/gpiokeys.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
175050aa9SAndriy Gapon.\"
2*4d846d26SWarner Losh.\" SPDX-License-Identifier: BSD-2-Clause
375050aa9SAndriy Gapon.\"
475050aa9SAndriy Gapon.\" Copyright (c) 2020 Andriy Gapon <avg@FreeBSD.org>
575050aa9SAndriy Gapon.\"
675050aa9SAndriy Gapon.\" Redistribution and use in source and binary forms, with or without
775050aa9SAndriy Gapon.\" modification, are permitted provided that the following conditions
875050aa9SAndriy Gapon.\" are met:
975050aa9SAndriy Gapon.\" 1. Redistributions of source code must retain the above copyright
1075050aa9SAndriy Gapon.\"    notice, this list of conditions and the following disclaimer.
1175050aa9SAndriy Gapon.\" 2. Redistributions in binary form must reproduce the above copyright
1275050aa9SAndriy Gapon.\"    notice, this list of conditions and the following disclaimer in the
1375050aa9SAndriy Gapon.\"    documentation and/or other materials provided with the distribution.
1475050aa9SAndriy Gapon.\"
1575050aa9SAndriy Gapon.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1675050aa9SAndriy Gapon.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1775050aa9SAndriy Gapon.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1875050aa9SAndriy Gapon.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1975050aa9SAndriy Gapon.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2075050aa9SAndriy Gapon.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2175050aa9SAndriy Gapon.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2275050aa9SAndriy Gapon.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2375050aa9SAndriy Gapon.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2475050aa9SAndriy Gapon.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2575050aa9SAndriy Gapon.\" SUCH DAMAGE.
2675050aa9SAndriy Gapon.\"
2775050aa9SAndriy Gapon.Dd August 5, 2020
2875050aa9SAndriy Gapon.Dt GPIOKEYS 4
2975050aa9SAndriy Gapon.Os
3075050aa9SAndriy Gapon.Sh NAME
3175050aa9SAndriy Gapon.Nm gpiokeys
3275050aa9SAndriy Gapon.Nd GPIO keys device driver
3375050aa9SAndriy Gapon.Sh SYNOPSIS
3475050aa9SAndriy GaponTo compile this driver into the kernel,
3575050aa9SAndriy Gaponplace the following lines in your
3675050aa9SAndriy Gaponkernel configuration file:
3775050aa9SAndriy Gapon.Bd -ragged -offset indent
3875050aa9SAndriy Gapon.Cd "options FDT"
3975050aa9SAndriy Gapon.Cd "device gpio"
4075050aa9SAndriy Gapon.Cd "device gpiokeys"
4175050aa9SAndriy Gapon.Ed
4275050aa9SAndriy Gapon.Pp
4375050aa9SAndriy GaponAlternatively, to load the driver as a
4475050aa9SAndriy Gaponmodule at boot time, place the following line in
4575050aa9SAndriy Gapon.Xr loader.conf 5 :
4675050aa9SAndriy Gapon.Bd -literal -offset indent
4775050aa9SAndriy Gapongpiokeys_load="YES"
4875050aa9SAndriy Gapon.Ed
4975050aa9SAndriy Gapon.Sh DESCRIPTION
5075050aa9SAndriy GaponThe
5175050aa9SAndriy Gapon.Nm
5275050aa9SAndriy Gapondriver provides a way to represent a set of general purpose inputs as a
5375050aa9SAndriy Gapon.Xr keyboard 4
5475050aa9SAndriy Gapondevice.
5575050aa9SAndriy GaponAt the moment the driver supports only
5675050aa9SAndriy Gapon.Xr FDT 4
5775050aa9SAndriy Gaponbased systems.
5875050aa9SAndriy GaponThe DTS determines what pins are mapped to buttons and what key codes are
5975050aa9SAndriy Gapongenerated for each virtual button.
6075050aa9SAndriy GaponThe
6175050aa9SAndriy Gapon.Xr keyboard 4
6275050aa9SAndriy Gapondevice can be used from userland to monitor for input changes.
6375050aa9SAndriy Gapon.Pp
6475050aa9SAndriy GaponOn an
6575050aa9SAndriy Gapon.Xr FDT 4
6675050aa9SAndriy Gaponbased system
6775050aa9SAndriy Gaponthe DTS part for a
6875050aa9SAndriy Gapon.Nm
6975050aa9SAndriy Gapondevice usually looks like:
7075050aa9SAndriy Gapon.Bd -literal
7175050aa9SAndriy Gapon/ {
7275050aa9SAndriy Gapon
7375050aa9SAndriy Gapon	...
7475050aa9SAndriy Gapon
7575050aa9SAndriy Gapon	gpio_keys {
7675050aa9SAndriy Gapon		compatible = "gpio-keys";
7775050aa9SAndriy Gapon
7875050aa9SAndriy Gapon		btn1 {
7975050aa9SAndriy Gapon			label = "button1";
8075050aa9SAndriy Gapon			linux,code = <KEY_1>;
8175050aa9SAndriy Gapon			gpios = <&gpio 0 3 GPIO_ACTIVE_LOW>
8275050aa9SAndriy Gapon		};
8375050aa9SAndriy Gapon
8475050aa9SAndriy Gapon		btn2 {
8575050aa9SAndriy Gapon			label = "button2";
8675050aa9SAndriy Gapon			linux,code = <KEY_2>;
8775050aa9SAndriy Gapon			gpios = <&gpio 0 4 GPIO_ACTIVE_LOW>
8875050aa9SAndriy Gapon		};
8975050aa9SAndriy Gapon	};
9075050aa9SAndriy Gapon};
9175050aa9SAndriy Gapon.Ed
9275050aa9SAndriy Gapon.Pp
9375050aa9SAndriy GaponFor more details about the
9475050aa9SAndriy Gapon.Va gpios
9575050aa9SAndriy Gaponproperty, please consult
9675050aa9SAndriy Gapon.Pa /usr/src/sys/dts/bindings-gpio.txt .
9775050aa9SAndriy Gapon.Pp
9875050aa9SAndriy GaponThe
9975050aa9SAndriy Gapon.Nm
10075050aa9SAndriy Gapondriver supports two properties for specifying a key code.
10175050aa9SAndriy Gapon.Pp
10275050aa9SAndriy GaponThe property
10375050aa9SAndriy Gapon.Va freebsd,code
10475050aa9SAndriy Gaponspecifies a
10575050aa9SAndriy Gapon.Fx
10675050aa9SAndriy Gaponnative scancode compatible with
10775050aa9SAndriy Gapon.Xr kbdmap 5
10875050aa9SAndriy Gaponkeyboard maps.
10975050aa9SAndriy Gapon.Pp
11075050aa9SAndriy GaponThe property
11175050aa9SAndriy Gapon.Va linux,code
11275050aa9SAndriy Gaponspecifies an evdev scancode.
11375050aa9SAndriy GaponThat scancode is internally translated to a native scancode.
11475050aa9SAndriy GaponNote that not all evdev scancodes have corresponding native scancodes.
11575050aa9SAndriy GaponIf a scancode cannot be translated, then a diagnostic message is printed
11675050aa9SAndriy Gaponand the input is ignored.
11775050aa9SAndriy Gapon.Pp
11875050aa9SAndriy GaponThe property
11975050aa9SAndriy Gapon.Va label
12075050aa9SAndriy Gaponis a descriptive name of a button.
12175050aa9SAndriy GaponIt is used for diagnostic messages only.
12275050aa9SAndriy GaponThis property is optional.
12375050aa9SAndriy GaponIf not set, the node name is used in its place.
12475050aa9SAndriy Gapon.Pp
12575050aa9SAndriy GaponThe property
12675050aa9SAndriy Gapon.Va autorepeat
12775050aa9SAndriy Gapondetermines whether autorepeat is enabled for a button.
12875050aa9SAndriy Gapon.Pp
12975050aa9SAndriy GaponThe property
13075050aa9SAndriy Gapon.Va debounce-interval
13175050aa9SAndriy Gapondefines debouncing interval time in milliseconds.
13275050aa9SAndriy GaponIf not specified the interval defaults to 5.
13375050aa9SAndriy Gapon.Sh SEE ALSO
13475050aa9SAndriy Gapon.Xr fdt 4 ,
13575050aa9SAndriy Gapon.Xr gpio 4 ,
13675050aa9SAndriy Gapon.Xr keyboard 4 ,
13775050aa9SAndriy Gapon.Xr kbdmap 5
13875050aa9SAndriy Gapon.Sh HISTORY
13975050aa9SAndriy GaponThe
14075050aa9SAndriy Gapon.Nm
14175050aa9SAndriy Gaponmanual page first appeared in
14275050aa9SAndriy Gapon.Fx 12.2 .
14375050aa9SAndriy Gapon.Sh AUTHORS
14475050aa9SAndriy GaponThe
14575050aa9SAndriy Gapon.Nm
14675050aa9SAndriy Gapondriver was written by
14775050aa9SAndriy Gapon.An Oleksandr Tymoshenko Aq Mt gonzo@FreeBSD.org .
14875050aa9SAndriy GaponThis
14975050aa9SAndriy Gaponmanual page was written by
15075050aa9SAndriy Gapon.An Andriy Gapon Aq Mt avg@FreeBSD.org .
151