xref: /freebsd/share/man/man4/gpiokeys.4 (revision 06c3fb27)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause
3.\"
4.\" Copyright (c) 2020 Andriy Gapon <avg@FreeBSD.org>
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.Dd August 5, 2020
28.Dt GPIOKEYS 4
29.Os
30.Sh NAME
31.Nm gpiokeys
32.Nd GPIO keys device driver
33.Sh SYNOPSIS
34To compile this driver into the kernel,
35place the following lines in your
36kernel configuration file:
37.Bd -ragged -offset indent
38.Cd "options FDT"
39.Cd "device gpio"
40.Cd "device gpiokeys"
41.Ed
42.Pp
43Alternatively, to load the driver as a
44module at boot time, place the following line in
45.Xr loader.conf 5 :
46.Bd -literal -offset indent
47gpiokeys_load="YES"
48.Ed
49.Sh DESCRIPTION
50The
51.Nm
52driver provides a way to represent a set of general purpose inputs as a
53.Xr keyboard 4
54device.
55At the moment the driver supports only
56.Xr FDT 4
57based systems.
58The DTS determines what pins are mapped to buttons and what key codes are
59generated for each virtual button.
60The
61.Xr keyboard 4
62device can be used from userland to monitor for input changes.
63.Pp
64On an
65.Xr FDT 4
66based system
67the DTS part for a
68.Nm
69device usually looks like:
70.Bd -literal
71/ {
72
73	...
74
75	gpio_keys {
76		compatible = "gpio-keys";
77
78		btn1 {
79			label = "button1";
80			linux,code = <KEY_1>;
81			gpios = <&gpio 0 3 GPIO_ACTIVE_LOW>
82		};
83
84		btn2 {
85			label = "button2";
86			linux,code = <KEY_2>;
87			gpios = <&gpio 0 4 GPIO_ACTIVE_LOW>
88		};
89	};
90};
91.Ed
92.Pp
93For more details about the
94.Va gpios
95property, please consult
96.Pa /usr/src/sys/dts/bindings-gpio.txt .
97.Pp
98The
99.Nm
100driver supports two properties for specifying a key code.
101.Pp
102The property
103.Va freebsd,code
104specifies a
105.Fx
106native scancode compatible with
107.Xr kbdmap 5
108keyboard maps.
109.Pp
110The property
111.Va linux,code
112specifies an evdev scancode.
113That scancode is internally translated to a native scancode.
114Note that not all evdev scancodes have corresponding native scancodes.
115If a scancode cannot be translated, then a diagnostic message is printed
116and the input is ignored.
117.Pp
118The property
119.Va label
120is a descriptive name of a button.
121It is used for diagnostic messages only.
122This property is optional.
123If not set, the node name is used in its place.
124.Pp
125The property
126.Va autorepeat
127determines whether autorepeat is enabled for a button.
128.Pp
129The property
130.Va debounce-interval
131defines debouncing interval time in milliseconds.
132If not specified the interval defaults to 5.
133.Sh SEE ALSO
134.Xr fdt 4 ,
135.Xr gpio 4 ,
136.Xr keyboard 4 ,
137.Xr kbdmap 5
138.Sh HISTORY
139The
140.Nm
141manual page first appeared in
142.Fx 12.2 .
143.Sh AUTHORS
144The
145.Nm
146driver was written by
147.An Oleksandr Tymoshenko Aq Mt gonzo@FreeBSD.org .
148This
149manual page was written by
150.An Andriy Gapon Aq Mt avg@FreeBSD.org .
151