1# Copyright 2023 Google LLC 2# SPDX-License-Identifier: Apache-2.0 3 4description: | 5 GPIO based QDEC input device 6 7 Implement an input device generating relative axis event reports for a rotary 8 encoder connected to two GPIOs. The driver is normally idling until it sees a 9 transition on any of the encoder signal lines, then switches to polling mode 10 and samples the two signal lines periodically to track the encoder position, 11 and goes back to idling after the specified timeout. 12 13 Example configuration: 14 15 #include <zephyr/dt-bindings/input/input-event-codes.h> 16 17 qdec { 18 compatible = "gpio-qdec"; 19 gpios = <&gpio0 14 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH)>, 20 <&gpio0 13 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH)>; 21 steps-per-period = <4>; 22 zephyr,axis = <INPUT_REL_WHEEL>; 23 sample-time-us = <2000>; 24 idle-timeout-ms = <200>; 25 }; 26 27compatible: "gpio-qdec" 28 29include: base.yaml 30 31properties: 32 gpios: 33 type: phandle-array 34 required: true 35 description: | 36 GPIO for the A and B encoder signals. 37 38 steps-per-period: 39 type: int 40 required: true 41 description: | 42 How many steps to count before reporting an input event. 43 44 zephyr,axis: 45 type: int 46 required: true 47 description: | 48 The input code for the axis to report for the device, typically any of 49 INPUT_REL_*. 50 51 sample-time-us: 52 type: int 53 required: true 54 description: | 55 How often to sample the A and B signal lines when tracking the encoder 56 movement. 57 58 idle-timeout-ms: 59 type: int 60 required: true 61 description: | 62 Timeout for the last detected transition before stopping the sampling 63 timer and going back to idle state. 64