Re: [PATCH 1/3] dt-bindings: counter: add gpio-quadrature-encoder binding
From: Conor Dooley
Date: Fri Apr 17 2026 - 12:23:36 EST
On Thu, Apr 16, 2026 at 10:48:17PM +0200, Wadim Mueller wrote:
> Add devicetree binding documentation for the GPIO-based quadrature
> encoder counter driver. The driver reads A/B quadrature signals and
> an optional index pulse via edge-triggered GPIO interrupts, supporting
> X1, X2, X4 quadrature decoding and pulse-direction mode.
>
> This is useful on SoCs that lack a dedicated hardware quadrature
> decoder or where the encoder is wired to generic GPIO pins.
>
> Signed-off-by: Wadim Mueller <wafgo01@xxxxxxxxx>
> ---
> .../counter/gpio-quadrature-encoder.yaml | 69 +++++++++++++++++++
> 1 file changed, 69 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/counter/gpio-quadrature-encoder.yaml
>
> diff --git a/Documentation/devicetree/bindings/counter/gpio-quadrature-encoder.yaml b/Documentation/devicetree/bindings/counter/gpio-quadrature-encoder.yaml
> new file mode 100644
> index 000000000..a52deaab6
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/counter/gpio-quadrature-encoder.yaml
> @@ -0,0 +1,69 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/counter/gpio-quadrature-encoder.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: GPIO-based Quadrature Encoder
> +
> +maintainers:
> + - Wadim Mueller <wadim.mueller@xxxxxxxx>
> +
> +description: |
> + A generic GPIO-based quadrature encoder counter. Reads A/B quadrature
> + signals and an optional index pulse via edge-triggered GPIO interrupts.
> + Supports X1, X2, X4 quadrature decoding and pulse-direction mode.
> +
> + This driver is useful on SoCs that lack a dedicated hardware quadrature
> + decoder (eQEP, QEI, etc.) or where the encoder is wired to generic GPIO
> + pins rather than to a dedicated peripheral.
Idea seems okay to me. Please rephrase this section to avoid talking
about drivers...
> +
> +properties:
> + compatible:
> + const: gpio-quadrature-encoder
> +
> + encoder-a-gpios:
> + maxItems: 1
> + description:
> + GPIO connected to the encoder's A (phase A) output.
> +
> + encoder-b-gpios:
> + maxItems: 1
> + description:
> + GPIO connected to the encoder's B (phase B) output.
> +
> + encoder-index-gpios:
> + maxItems: 1
> + description:
> + Optional GPIO connected to the encoder's index (Z) output.
> + When the index input is enabled via sysfs, the count resets
> + to zero on each index pulse.
...and this to stop talking about sysfs and driver behaviour though.
Bindings are about hardware.
pw-bot: changes-requested
> +
> +required:
> + - compatible
> + - encoder-a-gpios
> + - encoder-b-gpios
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/gpio/gpio.h>
> +
> + quadrature-encoder-0 {
> + compatible = "gpio-quadrature-encoder";
> + encoder-a-gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
> + encoder-b-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
> + };
> +
> + - |
> + #include <dt-bindings/gpio/gpio.h>
> +
> + quadrature-encoder-1 {
> + compatible = "gpio-quadrature-encoder";
> + encoder-a-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
> + encoder-b-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
> + encoder-index-gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
> + };
I think this example alone is sufficient btw.
Cheers,
Conor.
> +
> +...
> --
> 2.52.0
>
Attachment:
signature.asc
Description: PGP signature