[PATCH v5 1/3] dt-bindings: counter: add gpio-counter binding

From: Wadim Mueller

Date: Sun May 24 2026 - 15:40:55 EST


Add a binding for a generic GPIO-based counter. Two GPIOs (signal-a,
signal-b) drive the counter; an optional index GPIO loads a preset.
The counter function (quadrature, pulse-direction, increase/decrease)
is choosen at runtime through the counter sysfs interface.

Signed-off-by: Wadim Mueller <wafgo01@xxxxxxxxx>
---
.../bindings/counter/gpio-counter.yaml | 59 +++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 Documentation/devicetree/bindings/counter/gpio-counter.yaml

diff --git a/Documentation/devicetree/bindings/counter/gpio-counter.yaml b/Documentation/devicetree/bindings/counter/gpio-counter.yaml
new file mode 100644
index 000000000..4bd972b61
--- /dev/null
+++ b/Documentation/devicetree/bindings/counter/gpio-counter.yaml
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/counter/gpio-counter.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: GPIO-based Counter
+
+maintainers:
+ - Wadim Mueller <wadim.mueller@xxxxxxxx>
+
+description:
+ GPIO-based software counter. Decodes up to two primary signals (A
+ and B) and an optional index pulse via edge-triggered GPIO interrupts
+ into a count. Supports quadrature X1/X2/X4, pulse-direction, and
+ pure increase/decrease modes; the mode is selected at runtime via
+ the counter sysfs ABI.
+
+properties:
+ compatible:
+ const: gpio-counter
+
+ signal-a-gpios:
+ maxItems: 1
+ description:
+ Signal A input (encoder phase A in quadrature modes; pulse
+ input in pulse-direction and increase/decrease modes).
+
+ signal-b-gpios:
+ maxItems: 1
+ description:
+ Signal B input (encoder phase B in quadrature modes; direction
+ input in pulse-direction mode; unused in increase/decrease).
+
+ index-gpios:
+ maxItems: 1
+ description:
+ Optional index (Z) input. When pulsed, loads the configured
+ preset into the count.
+
+required:
+ - compatible
+ - signal-a-gpios
+ - signal-b-gpios
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+
+ counter {
+ compatible = "gpio-counter";
+ signal-a-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
+ signal-b-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
+ index-gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
+ };
+
+...
--
2.52.0