Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/Documentation/devicetree/bindings/input/gpio-charlieplex-keypad.yaml
170953 views
1
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2
%YAML 1.2
3
---
4
5
$id: http://devicetree.org/schemas/input/gpio-charlieplex-keypad.yaml#
6
$schema: http://devicetree.org/meta-schemas/core.yaml#
7
8
title: GPIO charlieplex keypad
9
10
maintainers:
11
- Hugo Villeneuve <hvilleneuve@dimonoff.com>
12
13
description: |
14
The charlieplex keypad supports N^2)-N different key combinations (where N is
15
the number of I/O lines). Key presses and releases are detected by configuring
16
only one line as output at a time, and reading other line states. This process
17
is repeated for each line. Diodes are required to ensure current flows in only
18
one direction between any pair of pins, as well as pull-up or pull-down
19
resistors on all I/O lines.
20
This mechanism doesn't allow to detect simultaneous key presses.
21
22
Wiring example for 3 lines keyboard with 6 switches and 3 diodes (pull-up/down
23
resistors not shown but needed on L0, L1 and L2):
24
25
L0 --+---------------------+----------------------+
26
| | |
27
L1 -------+-----------+---------------------+ |
28
| | | | | |
29
L2 -------------+----------------+-----+ | |
30
| | | | | | | | |
31
| | | | | | | | |
32
| S1 \ S2 \ | S3 \ S4 \ | S5 \ S6 \
33
| | | | | | | | |
34
| +--+--+ | +--+--+ | +--+--+
35
| | | | | |
36
| D1 v | D2 v | D3 v
37
| - (k) | - (k) | - (k)
38
| | | | | |
39
+-------+ +-------+ +-------+
40
41
L: GPIO line
42
S: switch
43
D: diode (k indicates cathode)
44
45
allOf:
46
- $ref: input.yaml#
47
- $ref: /schemas/input/matrix-keymap.yaml#
48
49
properties:
50
compatible:
51
const: gpio-charlieplex-keypad
52
53
autorepeat: true
54
55
debounce-delay-ms:
56
default: 5
57
58
line-gpios:
59
description:
60
List of GPIOs used as lines. The gpio specifier for this property
61
depends on the gpio controller to which these lines are connected.
62
63
linux,keymap: true
64
65
poll-interval: true
66
67
settling-time-us: true
68
69
wakeup-source: true
70
71
required:
72
- compatible
73
- line-gpios
74
- linux,keymap
75
- poll-interval
76
77
additionalProperties: false
78
79
examples:
80
- |
81
#include <dt-bindings/gpio/gpio.h>
82
#include <dt-bindings/input/input.h>
83
84
keyboard {
85
compatible = "gpio-charlieplex-keypad";
86
debounce-delay-ms = <20>;
87
poll-interval = <5>;
88
settling-time-us = <2>;
89
90
line-gpios = <&gpio2 25 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)
91
&gpio2 26 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)
92
&gpio2 27 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
93
94
/* MATRIX_KEY(output, input, key-code) */
95
linux,keymap = <
96
/*
97
* According to wiring diagram above, if L1 is configured as
98
* output and HIGH, and we detect a HIGH level on input L0,
99
* then it means S1 is pressed: MATRIX_KEY(L1, L0, KEY...)
100
*/
101
MATRIX_KEY(1, 0, KEY_F1) /* S1 */
102
MATRIX_KEY(2, 0, KEY_F2) /* S2 */
103
MATRIX_KEY(0, 1, KEY_F3) /* S3 */
104
MATRIX_KEY(2, 1, KEY_F4) /* S4 */
105
MATRIX_KEY(1, 2, KEY_F5) /* S5 */
106
MATRIX_KEY(0, 2, KEY_F6) /* S6 */
107
>;
108
};
109
110