On Mon, May 17, 2021 at 07:58:45PM +0300, Mauri Sandberg wrote: > Hello all! > > This patch set is closely related to another thread at [4], which I abandoned > against better judgement and created this one. > > Here I am sending revised versions of the patches. It builds on v2 and adopts > managed device resources as suggested by Andy on the thread mentioned > above [5]. > > I have tested the functionality on a NXP 74HC153 dual 4-way muxer. Drew, did > you find the time to have a go with this [6] and if so, did it work as expected? > > Thanks, > Mauri > > [4] https://www.spinics.net/lists/linux-gpio/msg58573.html > [5] https://www.spinics.net/lists/linux-gpio/msg60160.html > [6] https://www.spinics.net/lists/linux-gpio/msg60159.html > > > 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: 6453b9532b5f77d19837b159c4d074f0af9f141b > -- > 2.25.1 Tested-by: Drew Fustini <drew@xxxxxxxxxxxxxxx> Reviewed-by: Drew Fustini <drew@xxxxxxxxxxxxxxx> I have wired up the TI CD74HC153E to a BeagleBone Black: S0: P8_7 S1: P8_8 1Y: P8_10 2Y: P8_9 I added this to arch/arm/boot/dts/am335x-boneblack.dts mux: mux-controller { compatible = "gpio-mux"; #mux-control-cells = <0>; mux-gpios = <&gpio2 2 GPIO_ACTIVE_HIGH>, /* S0: P8_7 */ <&gpio2 3 GPIO_ACTIVE_HIGH> /* S1: P8_8 */; }; gpio8: key-mux1 { compatible = "gpio-mux-input"; mux-controls = <&mux>; gpio-controller; #gpio-cells = <2>; // GPIOs used by this node, mux pin pin-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>; /* 2Y: P8_9 */ }; gpio9: key-mux2 { compatible = "gpio-mux-input"; mux-controls = <&mux>; gpio-controller; #gpio-cells = <2>; // GPIOs used by this node, mux pin pin-gpios = <&gpio2 4 GPIO_ACTIVE_HIGH>; /* 1Y: P8_10 */ }; The two new gpiochips appear: root@beaglebone:~# gpiodetect gpiochip0 [gpio-0-31] (32 lines) gpiochip1 [gpio-32-63] (32 lines) gpiochip2 [gpio-64-95] (32 lines) gpiochip3 [gpio-96-127] (32 lines) gpiochip4 [key-mux1] (4 lines) gpiochip5 [key-mux2] (4 lines) The mux pins and input pins are connected to lines on gpiochip1: debian@beaglebone:~$ gpioinfo 1 gpiochip1 - 32 lines: line 0: "P9_15B" unused input active-high line 1: "P8_18" unused input active-high line 2: "P8_7" "mux" output active-high [used] line 3: "P8_8" "mux" output active-high [used] line 4: "P8_10" "pin" input active-high [used] line 5: "P8_9" "pin" input active-high [used] <snip> Test with all inputs connected to 3.3V (1I0:1I3 and 2I0:2I3) debian@beaglebone:~$ gpioget 4 0 1 debian@beaglebone:~$ gpioget 4 1 1 debian@beaglebone:~$ gpioget 4 2 1 debian@beaglebone:~$ gpioget 4 3 1 debian@beaglebone:~$ gpioget 5 0 1 debian@beaglebone:~$ gpioget 5 1 1 debian@beaglebone:~$ gpioget 5 2 1 debian@beaglebone:~$ gpioget 5 3 1 Connect 1I0 to GND debian@beaglebone:~$ gpioget 4 0 0 Connect 1I0 to 3V3 debian@beaglebone:~$ gpioget 4 0 1 I tried this with all the rest and got the same succesfull results. thanks, drew