Re: [RFC v5 4/4] gpio: dt-bindings: add gpio-mmio bindings

From: Linus Walleij
Date: Fri Apr 29 2016 - 10:29:18 EST


On Fri, Apr 29, 2016 at 2:53 AM, Christian Lamparter
<chunkeey@xxxxxxxxxxxxxx> wrote:

> From: Ãlvaro FernÃndez Rojas <noltari@xxxxxxxxx>
>
> This patch adds the device tree bindings for the gpio-mmio.
> The gpio-mmio is already part of a the GPIO generic library.
>
> Signed-off-by: Ãlvaro FernÃndez Rojas <noltari@xxxxxxxxx>
> Signed-off-by: Christian Lamparter <chunkeey@xxxxxxxxxxxxxx>

I share your ambition to create something generic for this class
of hardware(s).

> +Bindings for the generic driver for memory-mapped GPIO controllers.
> +
> +Required properties:
> + - compatible: should be "linux,gpio-mmio"

Why?
"memory-mapped-gpio" sits nicely with me.

Read another very generic binding for inspiration:
Documentation/devicetree/bindings/leds/register-bit-led.txt

> + - reg-names: must contain
> + "dat" - data register
> + may contain
> + "set" - data set register
> + "clr" - data clear register
> + "dirout" - direction output register
> + "dirin" - direction input register

I would just be more verbose:

data-in-register
data-out-set-register
data-out-clear-register
direction-output-register
direction-input-register

Some should be optional so we can support input-only
and output-only GPIO controllers too.

I would take this opportunity to add bindings also for stuff that
the generic MMIO driver does not support today but
could be made to support:

open-drain-register
open-source-register
debounce-register

etc

> +Optional properties:
> + - ngpio: specifies the number of gpio mapped in the register.

Just reference the generic docs.

> + - big-endian: force big endian register accesses.
> + - big-endian-byte-order: assign GPIOs in reverse order.
> + - unreadable-reg-set: data set register is not readable.
> + - read-output-reg-set: cache value set for reads.
> + - unreadable-reg-dir: dirout/dirin register is not readable.
> + - no-output: GPIOs are read-only.

I think it's better to imply that if there is no data-in-register
specified, then it is output-only etc.

> +The GPIO generic library provides support for memory-mapped GPIO
> +controllers. The configuration is detected by which resources are present.
> +The simplest form of a GPIO controller that the driver support is just a
> +single "dat" register, where GPIO state can be read and/or written.
> +However, the driver supports far more:
> + - 8/16/32/64 bits registers. The number of GPIOs is automatically
> + determined by the width of the registers.
> + - GPIO controllers with clear/set registers.
> + - GPIO controllers with a single "dat" register.
> + - Big endian bits/GPIOs ordering.


Skip this. It is Linux-specific.

Yours,
Linus Walleij