Path: blob/master/Documentation/devicetree/bindings/input/gpio-charlieplex-keypad.yaml
170953 views
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)1%YAML 1.22---34$id: http://devicetree.org/schemas/input/gpio-charlieplex-keypad.yaml#5$schema: http://devicetree.org/meta-schemas/core.yaml#67title: GPIO charlieplex keypad89maintainers:10- Hugo Villeneuve <hvilleneuve@dimonoff.com>1112description: |13The charlieplex keypad supports N^2)-N different key combinations (where N is14the number of I/O lines). Key presses and releases are detected by configuring15only one line as output at a time, and reading other line states. This process16is repeated for each line. Diodes are required to ensure current flows in only17one direction between any pair of pins, as well as pull-up or pull-down18resistors on all I/O lines.19This mechanism doesn't allow to detect simultaneous key presses.2021Wiring example for 3 lines keyboard with 6 switches and 3 diodes (pull-up/down22resistors not shown but needed on L0, L1 and L2):2324L0 --+---------------------+----------------------+25| | |26L1 -------+-----------+---------------------+ |27| | | | | |28L2 -------------+----------------+-----+ | |29| | | | | | | | |30| | | | | | | | |31| S1 \ S2 \ | S3 \ S4 \ | S5 \ S6 \32| | | | | | | | |33| +--+--+ | +--+--+ | +--+--+34| | | | | |35| D1 v | D2 v | D3 v36| - (k) | - (k) | - (k)37| | | | | |38+-------+ +-------+ +-------+3940L: GPIO line41S: switch42D: diode (k indicates cathode)4344allOf:45- $ref: input.yaml#46- $ref: /schemas/input/matrix-keymap.yaml#4748properties:49compatible:50const: gpio-charlieplex-keypad5152autorepeat: true5354debounce-delay-ms:55default: 55657line-gpios:58description:59List of GPIOs used as lines. The gpio specifier for this property60depends on the gpio controller to which these lines are connected.6162linux,keymap: true6364poll-interval: true6566settling-time-us: true6768wakeup-source: true6970required:71- compatible72- line-gpios73- linux,keymap74- poll-interval7576additionalProperties: false7778examples:79- |80#include <dt-bindings/gpio/gpio.h>81#include <dt-bindings/input/input.h>8283keyboard {84compatible = "gpio-charlieplex-keypad";85debounce-delay-ms = <20>;86poll-interval = <5>;87settling-time-us = <2>;8889line-gpios = <&gpio2 25 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)90&gpio2 26 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)91&gpio2 27 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;9293/* MATRIX_KEY(output, input, key-code) */94linux,keymap = <95/*96* According to wiring diagram above, if L1 is configured as97* output and HIGH, and we detect a HIGH level on input L0,98* then it means S1 is pressed: MATRIX_KEY(L1, L0, KEY...)99*/100MATRIX_KEY(1, 0, KEY_F1) /* S1 */101MATRIX_KEY(2, 0, KEY_F2) /* S2 */102MATRIX_KEY(0, 1, KEY_F3) /* S3 */103MATRIX_KEY(2, 1, KEY_F4) /* S4 */104MATRIX_KEY(1, 2, KEY_F5) /* S5 */105MATRIX_KEY(0, 2, KEY_F6) /* S6 */106>;107};108109110