* [PATCH 1/2] dt-bindings: mux: adg1736: add support
2025-12-19 14:35 [PATCH 0/2] Add support for ADG1736 Dual 2:1 Multiplexer Antoniu Miclaus
@ 2025-12-19 14:35 ` Antoniu Miclaus
2025-12-19 17:52 ` Krzysztof Kozlowski
2025-12-19 14:35 ` [PATCH 2/2] mux: adg1736: add driver support Antoniu Miclaus
1 sibling, 1 reply; 5+ messages in thread
From: Antoniu Miclaus @ 2025-12-19 14:35 UTC (permalink / raw)
To: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Antoniu Miclaus, Arnd Bergmann, Greg Kroah-Hartman, devicetree,
linux-kernel
Add device tree bindings for ADG1736 analog multiplerer.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
.../devicetree/bindings/mux/adi,adg1736.yaml | 77 +++++++++++++++++++
1 file changed, 77 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mux/adi,adg1736.yaml
diff --git a/Documentation/devicetree/bindings/mux/adi,adg1736.yaml b/Documentation/devicetree/bindings/mux/adi,adg1736.yaml
new file mode 100644
index 000000000000..0ba662ffc9cc
--- /dev/null
+++ b/Documentation/devicetree/bindings/mux/adi,adg1736.yaml
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mux/adi,adg1736.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices ADG1736 Dual SPDT Switch Multiplexer
+
+maintainers:
+ - Antoniu Miclaus <antoniu.miclaus@analog.com>
+
+description: |
+ Bindings for Analog Devices ADG1736 dual single-pole, double-throw (SPDT)
+ switch. The device features two independent SPDT switches, each functioning
+ as a 2:1 multiplexer. Each switch can connect its common drain terminal (D)
+ to one of two source terminals (SA or SB).
+
+ The device has two independent mux controllers (mux 0 and mux 1), each with
+ two states:
+ * 0: SxB to Dx (control GPIO low)
+ * 1: SxA to Dx (control GPIO high)
+
+ The EN pin is shared between both switches and can disable all channels when
+ set low (inactive).
+
+allOf:
+ - $ref: mux-controller.yaml#
+
+properties:
+ compatible:
+ const: adi,adg1736
+
+ ctrl-gpios:
+ description: |
+ GPIO pins connected to the control inputs IN1 and IN2. Index 0 controls
+ switch 1 (S1A/S1B to D1) and index 1 controls switch 2 (S2A/S2B to D2).
+ minItems: 2
+ maxItems: 2
+
+ en-gpios:
+ description: |
+ GPIO connected to the EN (enable) pin. When low, all switches are
+ disabled (high-impedance). When high, switches are controlled by
+ their respective ctrl-gpios.
+ maxItems: 1
+
+ '#mux-control-cells':
+ const: 1
+ description: |
+ Mux controller index (0 or 1) to select which SPDT switch to control.
+
+required:
+ - compatible
+ - ctrl-gpios
+ - en-gpios
+ - '#mux-control-cells'
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+ #include <dt-bindings/mux/mux.h>
+
+ mux-controller {
+ compatible = "adi,adg1736";
+ #mux-control-cells = <1>;
+
+ ctrl-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>,
+ <&gpio 11 GPIO_ACTIVE_HIGH>;
+ en-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
+
+ /* Disconnect both switches when idle */
+ idle-states = <MUX_IDLE_DISCONNECT MUX_IDLE_DISCONNECT>;
+ };
+
+...
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/2] mux: adg1736: add driver support
2025-12-19 14:35 [PATCH 0/2] Add support for ADG1736 Dual 2:1 Multiplexer Antoniu Miclaus
2025-12-19 14:35 ` [PATCH 1/2] dt-bindings: mux: adg1736: add support Antoniu Miclaus
@ 2025-12-19 14:35 ` Antoniu Miclaus
2025-12-19 17:57 ` Krzysztof Kozlowski
1 sibling, 1 reply; 5+ messages in thread
From: Antoniu Miclaus @ 2025-12-19 14:35 UTC (permalink / raw)
To: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Antoniu Miclaus, Greg Kroah-Hartman, Arnd Bergmann, devicetree,
linux-kernel
Add support for ADG1736 analog multiplexer. The device
features two independent 2:1 analog multiplexers, each
controlled by a GPIO pin. Each switch connects its drain
terminal (D) to one of two source terminals (SA or SB) based on
the control input state.
The driver implements two independent mux controllers with a shared
enable GPIO that can disable all switches when set low. Each mux
controller supports idle-state configuration for disconnecting
when not in use.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/mux/Kconfig | 12 ++++
drivers/mux/Makefile | 2 +
drivers/mux/adg1736.c | 143 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 157 insertions(+)
create mode 100644 drivers/mux/adg1736.c
diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
index c68132e38138..bdf16e0983cc 100644
--- a/drivers/mux/Kconfig
+++ b/drivers/mux/Kconfig
@@ -21,6 +21,18 @@ config MUX_ADG792A
To compile the driver as a module, choose M here: the module will
be called mux-adg792a.
+config MUX_ADG1736
+ tristate "Analog Devices ADG1736 Dual SPDT Switch Multiplexer"
+ depends on GPIOLIB || COMPILE_TEST
+ help
+ ADG1736 Dual SPDT (single-pole, double-throw) Switch.
+
+ The driver supports two independent 2:1 multiplexers, each
+ controlled by a GPIO pin.
+
+ To compile the driver as a module, choose M here: the module will
+ be called mux-adg1736.
+
config MUX_ADGS1408
tristate "Analog Devices ADGS1408/ADGS1409 Multiplexers"
depends on SPI
diff --git a/drivers/mux/Makefile b/drivers/mux/Makefile
index 6e9fa47daf56..f1497c319bcf 100644
--- a/drivers/mux/Makefile
+++ b/drivers/mux/Makefile
@@ -5,12 +5,14 @@
mux-core-objs := core.o
mux-adg792a-objs := adg792a.o
+mux-adg1736-objs := adg1736.o
mux-adgs1408-objs := adgs1408.o
mux-gpio-objs := gpio.o
mux-mmio-objs := mmio.o
obj-$(CONFIG_MULTIPLEXER) += mux-core.o
obj-$(CONFIG_MUX_ADG792A) += mux-adg792a.o
+obj-$(CONFIG_MUX_ADG1736) += mux-adg1736.o
obj-$(CONFIG_MUX_ADGS1408) += mux-adgs1408.o
obj-$(CONFIG_MUX_GPIO) += mux-gpio.o
obj-$(CONFIG_MUX_MMIO) += mux-mmio.o
diff --git a/drivers/mux/adg1736.c b/drivers/mux/adg1736.c
new file mode 100644
index 000000000000..b3998121487e
--- /dev/null
+++ b/drivers/mux/adg1736.c
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Analog Devices ADG1736 Dual SPDT Switch Multiplexer driver
+ *
+ * Copyright 2025 Analog Devices Inc.
+ *
+ * Author: Antoniu Miclaus <antoniu.miclaus@analog.com>
+ */
+
+#include <linux/err.h>
+#include <linux/gpio/consumer.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/mux/driver.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+
+#define ADG1736_MUX_CONTROLLERS 2
+#define ADG1736_MUX_STATES 2
+
+struct adg1736_mux {
+ struct gpio_desc *ctrl_gpios[ADG1736_MUX_CONTROLLERS];
+ struct gpio_desc *en_gpio;
+};
+
+static int adg1736_set(struct mux_control *mux, int state)
+{
+ struct adg1736_mux *adg1736 = mux_chip_priv(mux->chip);
+ unsigned int controller = mux_control_get_index(mux);
+
+ if (controller >= ADG1736_MUX_CONTROLLERS)
+ return -EINVAL;
+
+ if (state == MUX_IDLE_DISCONNECT) {
+ /* When idle disconnect is requested, disable the EN pin */
+ if (controller == 0)
+ gpiod_set_value_cansleep(adg1736->en_gpio, 0);
+ return 0;
+ }
+
+ /* Set the control GPIO for this mux controller */
+ gpiod_set_value_cansleep(adg1736->ctrl_gpios[controller], state);
+
+ /* Enable the mux if disabled */
+ gpiod_set_value_cansleep(adg1736->en_gpio, 1);
+
+ return 0;
+}
+
+static const struct mux_control_ops adg1736_ops = {
+ .set = adg1736_set,
+};
+
+static int adg1736_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct mux_chip *mux_chip;
+ struct adg1736_mux *adg1736;
+ s32 idle_state[ADG1736_MUX_CONTROLLERS];
+ char gpio_name[16];
+ int ret, i;
+
+ mux_chip = devm_mux_chip_alloc(dev, ADG1736_MUX_CONTROLLERS,
+ sizeof(*adg1736));
+ if (IS_ERR(mux_chip))
+ return PTR_ERR(mux_chip);
+
+ adg1736 = mux_chip_priv(mux_chip);
+ mux_chip->ops = &adg1736_ops;
+
+ /* Get control GPIOs (IN1, IN2) */
+ for (i = 0; i < ADG1736_MUX_CONTROLLERS; i++) {
+ snprintf(gpio_name, sizeof(gpio_name), "ctrl%d", i);
+ adg1736->ctrl_gpios[i] = devm_gpiod_get_index(dev, "ctrl", i,
+ GPIOD_OUT_LOW);
+ if (IS_ERR(adg1736->ctrl_gpios[i]))
+ return dev_err_probe(dev, PTR_ERR(adg1736->ctrl_gpios[i]),
+ "failed to get ctrl%d gpio\n", i);
+ }
+
+ /* Get enable GPIO (EN) */
+ adg1736->en_gpio = devm_gpiod_get(dev, "en", GPIOD_OUT_LOW);
+ if (IS_ERR(adg1736->en_gpio))
+ return dev_err_probe(dev, PTR_ERR(adg1736->en_gpio),
+ "failed to get en gpio\n");
+
+ /* Read idle-state property */
+ ret = device_property_read_u32_array(dev, "idle-state",
+ (u32 *)idle_state,
+ ADG1736_MUX_CONTROLLERS);
+ if (ret < 0) {
+ /* Default to AS_IS if not specified */
+ idle_state[0] = MUX_IDLE_AS_IS;
+ idle_state[1] = MUX_IDLE_AS_IS;
+ }
+
+ /* Configure each mux controller */
+ for (i = 0; i < ADG1736_MUX_CONTROLLERS; i++) {
+ struct mux_control *mux = &mux_chip->mux[i];
+
+ mux->states = ADG1736_MUX_STATES;
+
+ switch (idle_state[i]) {
+ case MUX_IDLE_DISCONNECT:
+ case MUX_IDLE_AS_IS:
+ case 0 ... ADG1736_MUX_STATES - 1:
+ mux->idle_state = idle_state[i];
+ break;
+ default:
+ dev_err(dev, "invalid idle-state[%d] = %d\n",
+ i, idle_state[i]);
+ return -EINVAL;
+ }
+ }
+
+ ret = devm_mux_chip_register(dev, mux_chip);
+ if (ret < 0)
+ return ret;
+
+ dev_info(dev, "ADG1736 %u dual SPDT mux controllers registered\n",
+ mux_chip->controllers);
+
+ return 0;
+}
+
+static const struct of_device_id adg1736_dt_ids[] = {
+ { .compatible = "adi,adg1736", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, adg1736_dt_ids);
+
+static struct platform_driver adg1736_driver = {
+ .driver = {
+ .name = "adg1736",
+ .of_match_table = adg1736_dt_ids,
+ },
+ .probe = adg1736_probe,
+};
+module_platform_driver(adg1736_driver);
+
+MODULE_DESCRIPTION("Analog Devices ADG1736 Dual SPDT Switch Multiplexer driver");
+MODULE_AUTHOR("Antoniu Miclaus <antoniu.miclaus@analog.com>");
+MODULE_LICENSE("GPL");
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread