2021-05-30 16:52:50

by Mauri Sandberg

[permalink] [raw]
Subject: [PATCH v4 0/2] gpio: add generic gpio input multiplexer

Hello all!

I changed my email setup because there were serious issues with it
previously and patches were not delivered to people. Hopefully it's working
now. Because of that I am sending updated patches in v4, which consist of
the same functionality as in v3 added with cosmetic changes to Kconfig and
updated author email address.

Drew gave acked and tested-by tags in [1] so I took the liberty to include
them in the patches.

For convenience I am including also rangediff between v3 and v4 below.

Thanks,
Mauri

[1] https://www.spinics.net/lists/linux-gpio/msg61277.html

1: 1ca26bb53ab6 ! 1: 496558967cd8 dt-bindings: gpio-mux-input: add documentation
@@
## Metadata ##
-Author: Mauri Sandberg <[email protected]>
+Author: Mauri Sandberg <[email protected]>

## Commit message ##
dt-bindings: gpio-mux-input: add documentation

Add documentation for a general GPIO multiplexer.

- Signed-off-by: Mauri Sandberg <[email protected]>
+ Signed-off-by: Mauri Sandberg <[email protected]>
+ Tested-by: Drew Fustini <[email protected]>
+ Reviewed-by: Drew Fustini <[email protected]>
---
+ v3 -> v4:
+ - Changed author email
+ - Included Tested-by and Reviewed-by from Drew
v2 -> v3: added a complete example on dual 4-way multiplexer
v1 -> v2: added a little bit more text in the binding documenation

@@ Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml (new)
+title: Generic GPIO input multiplexer
+
+maintainers:
-+ - Mauri Sandberg <[email protected]>
++ - Mauri Sandberg <[email protected]>
+
+description: |
+ A generic GPIO based input multiplexer
2: dcd76ada9d34 ! 2: 782e009ba54b gpio: gpio-mux-input: add generic gpio input multiplexer
@@
## Metadata ##
-Author: Mauri Sandberg <[email protected]>
+Author: Mauri Sandberg <[email protected]>

## Commit message ##
gpio: gpio-mux-input: add generic gpio input multiplexer
@@ Commit message
pin.

Reported-by: kernel test robot <[email protected]>
- Signed-off-by: Mauri Sandberg <[email protected]>
+ Signed-off-by: Mauri Sandberg <[email protected]>
+ Tested-by: Drew Fustini <[email protected]>
+ Reviewed-by: Drew Fustini <[email protected]>
---
+ v3 -> v4:
+ - Changed author email
+ - Included Tested-by and Reviewed-by from Drew
v2 -> v3:
- use managed device resources
- update Kconfig description
@@ drivers/gpio/Kconfig: config GPIO_MOCKUP
+ help
+ Say yes here to enable support for generic GPIO input multiplexer.
+
-+ This driver uses a mux-controller to drive the multiplexer and has a
-+ single output pin for reading the inputs to the mux. The driver can be
-+ used in situations when GPIO pins are used to select what multiplexer
-+ pin should be used for reading input and the output pin of the
-+ multiplexer is connected to a GPIO input pin.
++ This driver uses a mux-controller to drive the multiplexer and has a
++ single output pin for reading the inputs to the mux. The driver can
++ be used in situations when GPIO pins are used to select what
++ multiplexer pin should be used for reading input and the output pin
++ of the multiplexer is connected to a GPIO input pin.
+
endif

@@ drivers/gpio/gpio-mux-input.c (new)
+/*
+ * A generic GPIO input multiplexer driver
+ *
-+ * Copyright (C) 2021 Mauri Sandberg <[email protected]>
++ * Copyright (C) 2021 Mauri Sandberg <[email protected]>
+ *
+ */
+
@@ drivers/gpio/gpio-mux-input.c (new)
+};
+module_platform_driver(gpio_mux_input_driver);
+
-+MODULE_AUTHOR("Mauri Sandberg <[email protected]>");
++MODULE_AUTHOR("Mauri Sandberg <[email protected]>");
+MODULE_DESCRIPTION("Generic GPIO input multiplexer");
+MODULE_LICENSE("GPL");

Mauri Sandberg (2):
dt-bindings: gpio-mux-input: add documentation
gpio: gpio-mux-input: add generic gpio input multiplexer

.../bindings/gpio/gpio-mux-input.yaml | 75 +++++++++++
drivers/gpio/Kconfig | 16 +++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-mux-input.c | 124 ++++++++++++++++++
4 files changed, 216 insertions(+)
create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml
create mode 100644 drivers/gpio/gpio-mux-input.c


base-commit: c354c29524eeabba63da51f30a09b85ec9dc853a
--
2.25.1


2021-05-30 16:52:50

by Mauri Sandberg

[permalink] [raw]
Subject: [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation

Add documentation for a general GPIO multiplexer.

Signed-off-by: Mauri Sandberg <[email protected]>
Tested-by: Drew Fustini <[email protected]>
Reviewed-by: Drew Fustini <[email protected]>
---
v3 -> v4:
- Changed author email
- Included Tested-by and Reviewed-by from Drew
v2 -> v3: added a complete example on dual 4-way multiplexer
v1 -> v2: added a little bit more text in the binding documenation
---
.../bindings/gpio/gpio-mux-input.yaml | 75 +++++++++++++++++++
1 file changed, 75 insertions(+)
create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml

diff --git a/Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml b/Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml
new file mode 100644
index 000000000000..1ca4c3c8d64b
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml
@@ -0,0 +1,75 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/gpio-mux-input.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic GPIO input multiplexer
+
+maintainers:
+ - Mauri Sandberg <[email protected]>
+
+description: |
+ A generic GPIO based input multiplexer
+
+ This driver uses a mux-controller to drive the multiplexer and has a single
+ output pin for reading the inputs to the mux.
+
+ For GPIO consumer documentation see gpio.txt.
+
+properties:
+ compatible:
+ enum:
+ - gpio-mux-input
+
+ gpio-controller: true
+
+ '#gpio-cells':
+ const: 2
+
+ pin-gpios:
+ description: |
+ The GPIO pin used as the output from the multiplexer
+
+required:
+ - compatible
+ - gpio-controller
+ - "#gpio-cells"
+ - pin-gpios
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+ mux: mux-controller {
+ compatible = "gpio-mux";
+ #mux-control-cells = <0>;
+
+ mux-gpios = <&gpio 9 GPIO_ACTIVE_HIGH>,
+ <&gpio 11 GPIO_ACTIVE_HIGH>;
+ };
+
+ gpio2: key-mux1 {
+ compatible = "gpio-mux-input";
+ mux-controls = <&mux>;
+
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ // GPIOs used by this node, mux pin
+ pin-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
+ };
+
+ gpio3: key-mux2 {
+ compatible = "gpio-mux-input";
+ mux-controls = <&mux>;
+
+ gpio-controller;
+ #gpio-cells = <2>;
+
+ // GPIOs used by this node, mux pin
+ pin-gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;
+ };
+
+...
--
2.25.1

2021-06-01 10:14:07

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation

On Sun, May 30, 2021 at 6:16 PM Mauri Sandberg <[email protected]> wrote:

> Add documentation for a general GPIO multiplexer.
>
> Signed-off-by: Mauri Sandberg <[email protected]>
> Tested-by: Drew Fustini <[email protected]>
> Reviewed-by: Drew Fustini <[email protected]>

Overall very interesting!

> + pin-gpios:
> + description: |
> + The GPIO pin used as the output from the multiplexer

This is not a good name. "pin" what pin? Choose a descriptive
name, like:

parent-gpios
multiplexed-gpios
cascaded-gpios
fanout-gpios

(My order of preference.)

Otherwise these bindings look good.

Yours,
Linus Walleij

2021-06-01 10:46:37

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation

On Sun, May 30, 2021 at 6:16 PM Mauri Sandberg <[email protected]> wrote:

> Add documentation for a general GPIO multiplexer.
>
> Signed-off-by: Mauri Sandberg <[email protected]>
> Tested-by: Drew Fustini <[email protected]>
> Reviewed-by: Drew Fustini <[email protected]>

After some thinking I realized these bindings should not
be restricted to just input. There exist electronic constructions
such as open drain that would make it possible to mux also
outputs.

> .../bindings/gpio/gpio-mux-input.yaml | 75 +++++++++++++++++++

Rename it just gpio-mux.yaml

> +$id: http://devicetree.org/schemas/gpio/gpio-mux-input.yaml#

Also here

> +title: Generic GPIO input multiplexer

Generic GPIO multiplexer

> +description: |
> + A generic GPIO based input multiplexer

Not just input

> + This driver uses a mux-controller to drive the multiplexer and has a single
> + output pin for reading the inputs to the mux.

Make this clearer and do not mention "driver".
Here is a suggestion:

This hardware construction multiplexes (cascades) several GPIO
lines from one-to-many using a software controlled multiplexer.
The most common use case is probably reading several inputs
by switching the multiplexer over several input lines, which in
practice works well since input lines has high impedance.

Constructions with multiplexed outputs are also possible using
open drain electronics.

> + For GPIO consumer documentation see gpio.txt.

No need to mention this I think, not your problem :D

> + pin-gpios:

I still want this renamed like in my previous mail.

Hope all is clear!

Yours,
Linus Walleij

2021-06-01 13:35:54

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation

On Sun, 30 May 2021 19:13:32 +0300, Mauri Sandberg wrote:
> Add documentation for a general GPIO multiplexer.
>
> Signed-off-by: Mauri Sandberg <[email protected]>
> Tested-by: Drew Fustini <[email protected]>
> Reviewed-by: Drew Fustini <[email protected]>
> ---
> v3 -> v4:
> - Changed author email
> - Included Tested-by and Reviewed-by from Drew
> v2 -> v3: added a complete example on dual 4-way multiplexer
> v1 -> v2: added a little bit more text in the binding documenation
> ---
> .../bindings/gpio/gpio-mux-input.yaml | 75 +++++++++++++++++++
> 1 file changed, 75 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml
>

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/gpio/gpio-mux-input.example.dt.yaml:0:0: /example-0/mux-controller: failed to match any schema with compatible: ['gpio-mux']
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/gpio/gpio-mux-input.example.dt.yaml: key-mux1: 'mux-controls' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/gpio/gpio-mux-input.example.dt.yaml: key-mux2: 'mux-controls' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml

See https://patchwork.ozlabs.org/patch/1485492

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit.

2021-06-02 10:37:03

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation

Hi Mauri,

On Wed, Jun 2, 2021 at 11:31 AM Mauri Sandberg <[email protected]> wrote:

> But there is a small detail that needs to be sorted out.
> The name 'gpio-mux'
> has already been taken by 'mux-gpio' driver [2] [3].

What about "gpio-multiplexer"?

It is not good that the thing using GPIOs to do multiplexing
has take a name that seem to infer that GPIOs are being
multiplexed. Now we can't do much about that we just have
to live with it. How typical of formal languages to screw
with the semantics of natural languages and create confusion...

> Should we look for another name for this driver and it's bindings or
> refactor the mux-gpio's bindings
> first?

Bindings are etched in stone and cannot be changed.
Unless we change them anyways.
But generally we can't.

> The bindings for mux-gpio need to be converted to .yaml anyhow

Yeah just do it if you have the time, all conversions are appreciated.
(Separate patch and work item though, don't know if you need to
mix that with this work?)

> and maybe
> the issues with the schema
> that Rob pointed out elsewhere would go away too. Otherwise I cannot
> really say what's wrong as the
> errors look unrelated to me.

I don't know about these, tell Rob if you have issues and I might
be able to pitch in, I write a fair amount of schema too.

Yours,
Linus Walleij

2021-06-02 11:22:30

by Mauri Sandberg

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation

Hi Linus,

On 2.6.2021 13.35, Linus Walleij wrote:
> On Wed, Jun 2, 2021 at 11:31 AM Mauri Sandberg <[email protected]> wrote:
>
>> But there is a small detail that needs to be sorted out.
>> The name 'gpio-mux'
>> has already been taken by 'mux-gpio' driver [2] [3].
>
> What about "gpio-multiplexer"?
>
> It is not good that the thing using GPIOs to do multiplexing
> has take a name that seem to infer that GPIOs are being
> multiplexed. Now we can't do much about that we just have
> to live with it. How typical of formal languages to screw
> with the semantics of natural languages and create confusion...
>

I am afraid having 'gpio-mux' and 'gpio-multiplexer' would create too
many what-were-they-thinking moments for any unfortunate reader so I
would rather choose something else. Can we just call it 'gpio-cascade'
without referral to the underlying mux? Maybe at somepoint in future
something else could be used in its place too.

-- Mauri

2021-06-02 11:53:53

by Mauri Sandberg

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation


On 1.6.2021 13.44, Linus Walleij wrote:
> On Sun, May 30, 2021 at 6:16 PM Mauri Sandberg <[email protected]> wrote:
>
>> Add documentation for a general GPIO multiplexer.
>>
>> Signed-off-by: Mauri Sandberg <[email protected]>
>> Tested-by: Drew Fustini <[email protected]>
>> Reviewed-by: Drew Fustini <[email protected]>
> After some thinking I realized these bindings should not
> be restricted to just input. There exist electronic constructions
> such as open drain that would make it possible to mux also
> outputs.
>
>> .../bindings/gpio/gpio-mux-input.yaml | 75 +++++++++++++++++++
> Rename it just gpio-mux.yaml
>
>> +$id: http://devicetree.org/schemas/gpio/gpio-mux-input.yaml#
> Also here
>
>> +title: Generic GPIO input multiplexer
> Generic GPIO multiplexer
>
>> +description: |
>> + A generic GPIO based input multiplexer
> Not just input
>
>> + This driver uses a mux-controller to drive the multiplexer and has a single
>> + output pin for reading the inputs to the mux.
> Make this clearer and do not mention "driver".
> Here is a suggestion:
>
> This hardware construction multiplexes (cascades) several GPIO
> lines from one-to-many using a software controlled multiplexer.
> The most common use case is probably reading several inputs
> by switching the multiplexer over several input lines, which in
> practice works well since input lines has high impedance.
>
> Constructions with multiplexed outputs are also possible using
> open drain electronics.
>
>> + For GPIO consumer documentation see gpio.txt.
> No need to mention this I think, not your problem :D
>
>> + pin-gpios:
> I still want this renamed like in my previous mail.
>
> Hope all is clear!
>
> Yours,
> Linus Walleij

Hi and thanks theĀ  comments.

Generally I agree with everything you noted above and elsewhere and will
make changes
accordingly. But there is a small detail that needs to be sorted out.
The name 'gpio-mux'
has already been taken by 'mux-gpio' driver [2] [3].

Should we look for another name for this driver and it's bindings or
refactor the mux-gpio's bindings
first? I would be inclined to do the latter as the config symbol for
mux-gpio is the same way around,
MUX_GPIO.

The bindings for mux-gpio need to be converted to .yaml anyhow and maybe
the issues with the schema
that Rob pointed out elsewhere would go away too. Otherwise I cannot
really say what's wrong as the
errors look unrelated to me.

-- Mauri

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/mux/gpio-mux.txt
[3]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mux/gpio.c





2021-06-02 11:57:43

by Mauri Sandberg

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation

Hi Rob,

On 1.6.2021 16.32, Rob Herring wrote:
> On Sun, 30 May 2021 19:13:32 +0300, Mauri Sandberg wrote:
>> Add documentation for a general GPIO multiplexer.
>>
>> Signed-off-by: Mauri Sandberg <[email protected]>
>> Tested-by: Drew Fustini <[email protected]>
>> Reviewed-by: Drew Fustini <[email protected]>
>> ---
>> v3 -> v4:
>> - Changed author email
>> - Included Tested-by and Reviewed-by from Drew
>> v2 -> v3: added a complete example on dual 4-way multiplexer
>> v1 -> v2: added a little bit more text in the binding documenation
>> ---
>> .../bindings/gpio/gpio-mux-input.yaml | 75 +++++++++++++++++++
>> 1 file changed, 75 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml
>>
>
> My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
> on your patch (DT_CHECKER_FLAGS is new in v5.13):
>
> yamllint warnings/errors:
>
> dtschema/dtc warnings/errors:
> Documentation/devicetree/bindings/gpio/gpio-mux-input.example.dt.yaml:0:0: /example-0/mux-controller: failed to match any schema with compatible: ['gpio-mux']
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/gpio/gpio-mux-input.example.dt.yaml: key-mux1: 'mux-controls' does not match any of the regexes: 'pinctrl-[0-9]+'
> From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/gpio/gpio-mux-input.example.dt.yaml: key-mux2: 'mux-controls' does not match any of the regexes: 'pinctrl-[0-9]+'
> From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/gpio/gpio-mux-input.yaml
>

These look like they could be caused by gpio-mux bindings [2], which
this depends on, not being formulated in yaml. Should it be addressed
before carrying on?

Thanks,
Mauri

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/mux/gpio-mux.txt

2021-06-04 07:54:24

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation

On Wed, Jun 2, 2021 at 1:21 PM Mauri Sandberg <[email protected]> wrote:

> Can we just call it 'gpio-cascade'
> without referral to the underlying mux? Maybe at somepoint in future
> something else could be used in its place too.

That has a nice ring to it, go with that!

Yours,
Linus Walleij