From: Mauri Sandberg <hidden> Date: 2021-10-19 20:10:09
Add documentation for a general GPIO cascade. It allows building
one-to-many cascades of GPIO lines using multiplexer to choose
the cascaded line.
Signed-off-by: Mauri Sandberg <redacted>
Reviewed-by: Rob Herring <robh@kernel.org>
---
v5 -> v6:
- added Reviewed-by tag by Rob
v4 -> v5:
- renamed gpio-mux-input -> gpio-cascade
- changed vague term 'pin' to 'upstream line'
- added more verbose description for the module
- added missing 'mux-controls' entry
- dropped Tested-by and Reviewed-by due to changes in bindings
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-cascade.yaml | 103 ++++++++++++++++++
1 file changed, 103 insertions(+)
create mode 100644 Documentation/devicetree/bindings/gpio/gpio-cascade.yaml
@@ -0,0 +1,103 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/gpio/gpio-cascade.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:Generic GPIO cascade++maintainers:+-Mauri Sandberg <maukka@ext.kapsi.fi>++description:|+A generic GPIO cascade++This hardware construction cascades (multiplexes) 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.++The number of cascaded GPIO lines is limited by the technology used to+switch over the cascaded lines. There are readily available dual/triple+4-to-1 multiplexers, for example, and others.++Illustration (pins used to drive the multiplexer are omitted for clarity)++/|---- Cascaded GPIO line 0+Upstream | |---- Cascaded GPIO line 1+GPIO line ----+ | .+| | .+\|---- Cascaded GPIO line n++properties:+compatible:+enum:+-gpio-cascade++gpio-controller:true++'#gpio-cells':+const:2++mux-controls:+minItems:1+maxItems:1+description:|+The mux controller that will be driving the GPIO cascade.++upstream-gpios:+description:|+The GPIO line used as the upstream line will convey the status to/from+cascaded GPIO lines. In an input mode, by using this line, it is+possible to read the status from selected cascaded GPIO line.++In an output mode the status of the upstream GPIO will be conveyed to+the selected cascaded GPIO line.++required:+-compatible+-gpio-controller+-"#gpio-cells"+-mux-controls+-upstream-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-cascade";+mux-controls = <&mux>;++gpio-controller;+#gpio-cells = <2>;++// GPIOs used by this node, upstream pin+upstream-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;+};++gpio3:key-mux2 {+compatible = "gpio-cascade";+mux-controls = <&mux>;++gpio-controller;+#gpio-cells = <2>;++// GPIOs used by this node, upstream pin+upstream-gpios = <&gpio 14 GPIO_ACTIVE_HIGH>;+};++...
From: Mauri Sandberg <hidden> Date: 2021-10-19 20:10:17
Adds support for building cascades of GPIO lines. That is, it allows
setups when there is one upstream line and multiple cascaded lines, out
of which one can be chosen at a time. The status of the upstream line
can be conveyed to the selected cascaded line or, vice versa, the status
of the cascaded line can be conveyed to the upstream line.
A multiplexer is being used to select, which cascaded GPIO line is being
used at any given time.
At the moment only input direction is supported. In future it should be
possible to add support for output direction, too.
Signed-off-by: Mauri Sandberg <redacted>
---
v6 -> v7:
- In Kconfig add info about module name
- adhere to new convention that allows lines longer than 80 chars
- use dev_probe_err with upstream gpio line too
- refactor for cleaner exit of probe function.
v5 -> v6:
- In Kconfig, remove dependency to OF_GPIO and select only MULTIPLEXER
- refactor code preferring one-liners
- clean up prints, removing them from success-path.
- don't explicitly set gpio_chip.of_node as it's done in the GPIO library
- use devm_gpiochip_add_data instead of gpiochip_add
v4 -> v5:
- renamed gpio-mux-input -> gpio-cascade. refactored code accordingly
here and there and changed to use new bindings and compatible string
- ambigious and vague 'pin' was rename to 'upstream_line'
- dropped Tested-by and Reviewed-by due to changes in bindings
- dropped Reported-by suggested by an automatic bot as it was not really
appropriate to begin with
- functionally it's the same as v4
v3 -> v4:
- Changed author email
- Included Tested-by and Reviewed-by from Drew
v2 -> v3:
- use managed device resources
- update Kconfig description
v1 -> v2:
- removed .owner from platform_driver as per test bot's instruction
- added MODULE_AUTHOR, MODULE_DESCRIPTION, MODULE_LICENSE
- added gpio_mux_input_get_direction as it's recommended for all chips
- removed because this is input only chip: gpio_mux_input_set_value
- removed because they are not needed for input/output only chips:
gpio_mux_input_direction_input
gpio_mux_input_direction_output
- fixed typo in an error message
- added info message about successful registration
- removed can_sleep flag as this does not sleep while getting GPIO value
like I2C or SPI do
- Updated description in Kconfig
---
drivers/gpio/Kconfig | 15 +++++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-cascade.c | 118 ++++++++++++++++++++++++++++++++++++
3 files changed, 134 insertions(+)
create mode 100644 drivers/gpio/gpio-cascade.c
On Tue, Oct 19, 2021 at 10:10 PM Mauri Sandberg [off-list ref] wrote:
Adds support for building cascades of GPIO lines. That is, it allows
setups when there is one upstream line and multiple cascaded lines, out
of which one can be chosen at a time. The status of the upstream line
can be conveyed to the selected cascaded line or, vice versa, the status
of the cascaded line can be conveyed to the upstream line.
A multiplexer is being used to select, which cascaded GPIO line is being
used at any given time.
At the moment only input direction is supported. In future it should be
possible to add support for output direction, too.
Signed-off-by: Mauri Sandberg <redacted>
---
v6 -> v7:
This v7 looks like clean and nice merge material to me,
Reviewed-by: Linus Walleij <redacted>
Yours,
Linus Walleij
On Tue, Oct 19, 2021 at 10:10 PM Mauri Sandberg [off-list ref] wrote:
Add documentation for a general GPIO cascade. It allows building
one-to-many cascades of GPIO lines using multiplexer to choose
the cascaded line.
Signed-off-by: Mauri Sandberg <redacted>
Reviewed-by: Rob Herring <robh@kernel.org>
From: Andy Shevchenko <hidden> Date: 2021-10-25 09:30:30
On Tue, Oct 19, 2021 at 11:10 PM Mauri Sandberg [off-list ref] wrote:
Adds support for building cascades of GPIO lines. That is, it allows
setups when there is one upstream line and multiple cascaded lines, out
of which one can be chosen at a time. The status of the upstream line
can be conveyed to the selected cascaded line or, vice versa, the status
of the cascaded line can be conveyed to the upstream line.
A multiplexer is being used to select, which cascaded GPIO line is being
used at any given time.
At the moment only input direction is supported. In future it should be
possible to add support for output direction, too.
A nit-pick below and you may have my
Reviewed-by: Andy Shevchenko <redacted>
quoted hunk
Signed-off-by: Mauri Sandberg <redacted>
---
v6 -> v7:
- In Kconfig add info about module name
- adhere to new convention that allows lines longer than 80 chars
- use dev_probe_err with upstream gpio line too
- refactor for cleaner exit of probe function.
v5 -> v6:
- In Kconfig, remove dependency to OF_GPIO and select only MULTIPLEXER
- refactor code preferring one-liners
- clean up prints, removing them from success-path.
- don't explicitly set gpio_chip.of_node as it's done in the GPIO library
- use devm_gpiochip_add_data instead of gpiochip_add
v4 -> v5:
- renamed gpio-mux-input -> gpio-cascade. refactored code accordingly
here and there and changed to use new bindings and compatible string
- ambigious and vague 'pin' was rename to 'upstream_line'
- dropped Tested-by and Reviewed-by due to changes in bindings
- dropped Reported-by suggested by an automatic bot as it was not really
appropriate to begin with
- functionally it's the same as v4
v3 -> v4:
- Changed author email
- Included Tested-by and Reviewed-by from Drew
v2 -> v3:
- use managed device resources
- update Kconfig description
v1 -> v2:
- removed .owner from platform_driver as per test bot's instruction
- added MODULE_AUTHOR, MODULE_DESCRIPTION, MODULE_LICENSE
- added gpio_mux_input_get_direction as it's recommended for all chips
- removed because this is input only chip: gpio_mux_input_set_value
- removed because they are not needed for input/output only chips:
gpio_mux_input_direction_input
gpio_mux_input_direction_output
- fixed typo in an error message
- added info message about successful registration
- removed can_sleep flag as this does not sleep while getting GPIO value
like I2C or SPI do
- Updated description in Kconfig
---
drivers/gpio/Kconfig | 15 +++++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-cascade.c | 118 ++++++++++++++++++++++++++++++++++++
3 files changed, 134 insertions(+)
create mode 100644 drivers/gpio/gpio-cascade.c