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

From: Wadim Mueller

Date: Sun Jun 28 2026 - 17:03:43 EST


Add a binding for a generic GPIO-based counter. Two GPIOs (signal-a,
signal-b) drive two Counts; optional index GPIOs load a preset. The
counter function (quadrature, pulse-direction, increase/decrease) is
selected at runtime via 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..79b7afd7d
--- /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 <wafgo01@xxxxxxxxx>
+
+description: |
+ GPIO-based software counter with two Counts:
+ * Count 1: A + B. Quadrature X1/X2/X4, pulse-direction, inc/dec.
+ * Count 2: B. Inc / dec.
+ The function is selected at runtime via the counter sysfs ABI. Each
+ Count has an optional Index (Z) that loads its preset on rising edge.
+
+properties:
+ compatible:
+ const: gpio-counter
+
+ signal-a-gpios:
+ maxItems: 1
+ description: Signal A (phase A; pulse input in pulse-direction/inc/dec).
+
+ signal-b-gpios:
+ maxItems: 1
+ description:
+ Signal B (phase B; direction in pulse-direction; pulse input for
+ Count 2).
+
+ index-gpios:
+ minItems: 1
+ maxItems: 2
+ description:
+ Optional Index (Z) inputs. First entry indexes Count 1, second
+ (optional) indexes Count 2.
+
+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>,
+ <&gpio0 13 GPIO_ACTIVE_LOW>;
+ };
+
+...
--
2.52.0