Lines Matching +full:device +full:- +full:state +full:- +full:gpios
1 .. _gpio-kbd:
6 The :dtcompatible:`gpio-kbd-matrix` driver supports a large variety of keyboard
12 row GPIOs (inputs) and selects on the columns GPIOs (output).
14 Base use case, no isolation diodes, interrupt capable GPIOs
21 .. figure:: no-diodes.svg
28 row GPIOs at the same time.
30 .. code-block:: devicetree
32 kbd-matrix {
33 compatible = "gpio-kbd-matrix";
34 row-gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
37 col-gpios = <&gpio0 3 GPIO_ACTIVE_LOW>,
46 GPIOs for columns that are not currently selected are configured in high
47 impedance mode. This means that the row state may need some time to settle to
48 avoid misreading the key state from a column to the following one. The settle
49 time can be tweaked by changing the ``settle-time-us`` property.
56 - disable ghosting detection, allowing any key combination to be detected
57 - configuring the driver to drive unselected columns GPIO to inactive state
62 Matrixes with diodes going from rows to columns must use pull-ups on rows and
65 .. figure:: diodes-rc.svg
71 .. code-block:: devicetree
73 kbd-matrix {
74 compatible = "gpio-kbd-matrix";
75 row-gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
78 col-gpios = <&gpio0 3 GPIO_ACTIVE_LOW>,
81 col-drive-inactive;
82 settle-time-us = <0>;
83 no-ghostkey-check;
86 Matrixes with diodes going from columns to rows must use pull-downs on rows and
89 .. figure:: diodes-cr.svg
95 .. code-block:: devicetree
97 kbd-matrix {
98 compatible = "gpio-kbd-matrix";
99 row-gpios = <&gpio0 0 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
102 col-gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>,
105 col-drive-inactive;
106 settle-time-us = <0>;
107 no-ghostkey-check;
114 enabling interrupts on all row GPIOs at the same time.
117 instead idle by selecting all columns and keep polling on the row GPIOs, which
120 This configuration can be enabled by setting the ``idle-mode`` property to
123 .. code-block:: devicetree
125 kbd-matrix {
126 compatible = "gpio-kbd-matrix";
128 idle-mode = "poll";
138 This can be done by setting ``idle-mode`` to ``scan`` and ``poll-timeout-ms``
141 .. code-block:: devicetree
143 kbd-matrix {
144 compatible = "gpio-kbd-matrix";
146 poll-timeout-ms = <0>;
147 idle-mode = "scan";
153 If the row GPIOs are sequential and on the same gpio controller, the driver
155 individual pins. This is particularly useful if the GPIOs are not memory
159 The same is true for column GPIOs, but only if the matrix is configured for
160 ``col-drive-inactive``, so that is only usable for matrixes with isolation
163 16-bit row support
166 The driver uses an 8-bit datatype to store the row state by default, which
174 populated can be specified using the ``actual-key-mask`` property. This allows
175 the matrix state to be filtered to remove keys that are not present before
181 .. figure:: no-sw4.svg
187 .. code-block:: devicetree
189 kbd-matrix {
190 compatible = "gpio-kbd-matrix";
192 actual-key-mask = <0x07 0x05 0x07>;
206 mapped to normal key events using the :dtcompatible:`input-keymap` driver.
208 For example, the following would setup a ``keymap`` device that take the
212 .. code-block:: devicetree
217 compatible = "input-keymap";
229 row-size = <3>;
230 col-size = <3>;
239 matrix library. Once enabled it logs the state of the matrix every time it
240 changes, and once disabled it prints an or-mask of any key that has been
241 detected, which can be used to set the ``actual-key-mask`` property.
248 .. code-block:: console
250 uart:~$ device list
252 - kbd-matrix (READY)
253 uart:~$ input kbd_matrix_state_dump kbd-matrix
254 Keyboard state logging enabled for kbd-matrix
255 [00:01:41.678,466] <inf> input: kbd-matrix state [01 -- -- --] (1)
256 [00:01:41.784,912] <inf> input: kbd-matrix state [-- -- -- --] (0)
261 Keyboard state logging disabled
262 [00:01:47.967,651] <inf> input: kbd-matrix key-mask [07 05 07 --] (8)