Hi Greg, Today seemed like a good day to send you the pull request for the new mux controller subsystem. I hope the details are ok. If not, let me know and I'll try to rework it. I also included some text for the merge commit, if you want/need it:
This adds a new mux controller subsystem with an interface for accessing mux controllers, along with two drivers providing the interface (gpio and adg792) and two consumers (iio and i2c). This is done in such a way that several consumers can independently access the same mux controller if one controller controls several multiplexers, thus allowing sharing. But sharing is by no means required, of course. It is perfectly fine to have a single consumer of a dedicated mux controller controlling only one mux for said consumer. The prediction is that the typical use case will be for gpio-based muxing (which is also what drove the development), where the below schematics show the flexibility with one gpio-based mux controller being shared by the iio-mux and i2c-mux-gpmux drivers. .----. |GPO0|-----------. |GPO1|---------. | | | | | | | .-------. | | |dg4052a| | | | | |ADC0|------|X X0|---- signal X0 | | | X1|---- signal X1 | | | X2|---- signal X2 | | | X3|---- signal X3 | | | | |SDA0|------|Y Y0|---- i2c segment Y0 |SCL0|--. | Y1|---- i2c segment Y1 '----' | | Y2|---- i2c segment Y2 | | Y3|---- i2c segment Y3 | '-------' | 0 1 2 3 (feed SCL0 to each of | | | | | the 4 muxed segments) '-----------------+-+-+-' GPO0 and GPO1 may also be fed to further parallel muxers, which is perhaps desired in a real application to minimize digital noise from the i2c Y channel leaking into the analog X channel. I.e. it might be a good idea to separate the analog and digital signals... And the below hypothetical schematics indicate something similar but using the i2c-based adg792a multiplexer instead. .----. |SDA0|-----------. |SCL0|---------. | | | | | | | .-------. | | |adg792a| | | | | |ADC0|------|D1 S1A|---- signal S1A | | | S1B|---- signal S1B | | | S1C|---- signal S1C | | | S1D|---- signal S1D | | | | |SDA1|---+--|D2 S2A|---- i2c segment S2A |SCL1|-. | | S2B|---- i2c segment S2B '----' | | | S2C|---- i2c segment S2C | | | S2D|---- i2c segment S2D | | | | | '--|D3 S3A|---- i2c segment S3A | | S3B|---- i2c segment S3B | | S3C|---- i2c segment S3C | | S3D|---- i2c segment S3D | '-------' | A B C D A B C D (feed SCL1 to each of | | | | | | | | | the 8 muxed segments) '------------------+-+-+-+---+-+-+-' Cheers, peda The following changes since commit c1ae3cfa0e89fa1a7ecc4c99031f5e9ae99d9201: Linux 4.11-rc1 (2017-03-05 12:59:56 -0800) are available in the git repository at: https://gitlab.com/peda-linux/mux.git togreg for you to fetch changes up to 9920ed1461bbe072a815c352f016cd08c756fba3: mux: core: fix error handling in devm_mux_chip_alloc (2017-03-15 23:14:48 +0100) ---------------------------------------------------------------- Peter Rosin (12): devres: trivial whitespace fix dt-bindings: document devicetree bindings for mux-controllers and gpio-mux mux: minimal mux subsystem and gpio-based mux controller iio: inkern: api for manipulating ext_info of iio channels dt-bindings: iio: io-channel-mux: document io-channel-mux bindings iio: multiplexer: new iio category and iio-mux driver dt-bindings: i2c: i2c-mux: document general purpose i2c-mux bindings i2c: i2c-mux-gpmux: new driver dt-bindings: mux-adg792a: document devicetree bindings for ADG792A/G mux mux: adg792a: add mux controller driver for ADG792A/G iio: multiplexer: fix unsigned check with less than zero mux: core: fix error handling in devm_mux_chip_alloc .../devicetree/bindings/i2c/i2c-mux-gpmux.txt | 99 +++++ .../bindings/iio/multiplexer/io-channel-mux.txt | 39 ++ .../devicetree/bindings/mux/adi,adg792a.txt | 75 ++++ Documentation/devicetree/bindings/mux/gpio-mux.txt | 69 ++++ .../devicetree/bindings/mux/mux-controller.txt | 157 +++++++ Documentation/driver-model/devres.txt | 10 +- MAINTAINERS | 15 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/i2c/muxes/Kconfig | 13 + drivers/i2c/muxes/Makefile | 1 + drivers/i2c/muxes/i2c-mux-gpmux.c | 173 ++++++++ drivers/iio/Kconfig | 1 + drivers/iio/Makefile | 1 + drivers/iio/inkern.c | 60 +++ drivers/iio/multiplexer/Kconfig | 18 + drivers/iio/multiplexer/Makefile | 6 + drivers/iio/multiplexer/iio-mux.c | 459 +++++++++++++++++++++ drivers/mux/Kconfig | 46 +++ drivers/mux/Makefile | 7 + drivers/mux/mux-adg792a.c | 140 +++++++ drivers/mux/mux-core.c | 422 +++++++++++++++++++ drivers/mux/mux-gpio.c | 114 +++++ include/dt-bindings/mux/mux.h | 16 + include/linux/iio/consumer.h | 37 ++ include/linux/mux.h | 252 +++++++++++ 26 files changed, 2232 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-mux-gpmux.txt create mode 100644 Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.txt create mode 100644 Documentation/devicetree/bindings/mux/adi,adg792a.txt create mode 100644 Documentation/devicetree/bindings/mux/gpio-mux.txt create mode 100644 Documentation/devicetree/bindings/mux/mux-controller.txt create mode 100644 drivers/i2c/muxes/i2c-mux-gpmux.c create mode 100644 drivers/iio/multiplexer/Kconfig create mode 100644 drivers/iio/multiplexer/Makefile create mode 100644 drivers/iio/multiplexer/iio-mux.c create mode 100644 drivers/mux/Kconfig create mode 100644 drivers/mux/Makefile create mode 100644 drivers/mux/mux-adg792a.c create mode 100644 drivers/mux/mux-core.c create mode 100644 drivers/mux/mux-gpio.c create mode 100644 include/dt-bindings/mux/mux.h create mode 100644 include/linux/mux.h