[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251220-busy-grinning-iguana-87fdac@quoll>
Date: Sat, 20 Dec 2025 10:26:04 +0100
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Antoniu Miclaus <antoniu.miclaus@...log.com>
Cc: Peter Rosin <peda@...ntia.se>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Arnd Bergmann <arnd@...db.de>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] mux: adg2404: add driver support
On Fri, Dec 19, 2025 at 04:31:45PM +0200, Antoniu Miclaus wrote:
> Add support for ADG2404, a 4:1 analog multiplexer.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@...log.com>
> ---
> drivers/mux/Kconfig | 12 ++++
> drivers/mux/Makefile | 2 +
> drivers/mux/adg2404.c | 133 ++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 147 insertions(+)
> create mode 100644 drivers/mux/adg2404.c
>
> diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
> index c68132e38138..5aba66e6e210 100644
> --- a/drivers/mux/Kconfig
> +++ b/drivers/mux/Kconfig
> @@ -9,6 +9,18 @@ config MULTIPLEXER
> menu "Multiplexer drivers"
> depends on MULTIPLEXER
>
> +config MUX_ADG2404
> + tristate "Analog Devices ADG2404 Multiplexer"
> + depends on GPIOLIB || COMPILE_TEST
> + help
> + ADG2404 4:1 single-ended analog multiplexer controlled by GPIO.
> +
> + The multiplexer state is controlled by 3 GPIO pins: A0, A1
> + (address selection) and EN (enable).
> +
> + To compile the driver as a module, choose M here: the module will
> + be called mux-adg2404.
> +
> config MUX_ADG792A
> tristate "Analog Devices ADG792A/ADG792G Multiplexers"
> depends on I2C
> diff --git a/drivers/mux/Makefile b/drivers/mux/Makefile
> index 6e9fa47daf56..d3df403f8978 100644
> --- a/drivers/mux/Makefile
> +++ b/drivers/mux/Makefile
> @@ -4,12 +4,14 @@
> #
>
> mux-core-objs := core.o
> +mux-adg2404-objs := adg2404.o
> mux-adg792a-objs := adg792a.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_ADG2404) += mux-adg2404.o
> obj-$(CONFIG_MUX_ADG792A) += mux-adg792a.o
> obj-$(CONFIG_MUX_ADGS1408) += mux-adgs1408.o
> obj-$(CONFIG_MUX_GPIO) += mux-gpio.o
> diff --git a/drivers/mux/adg2404.c b/drivers/mux/adg2404.c
> new file mode 100644
> index 000000000000..5e7352ac7290
> --- /dev/null
> +++ b/drivers/mux/adg2404.c
> @@ -0,0 +1,133 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Analog Devices ADG2404 4:1 multiplexer driver
> + *
> + * Copyright 2025 Analog Devices Inc.
> + *
> + * Author: Antoniu Miclaus <antoniu.miclaus@...log.com>
> + */
> +
> +#include <linux/bitmap.h>
> +#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 ADG2404_CHANNELS 4
> +
> +struct adg2404_mux {
> + struct gpio_descs *addr_gpios;
> + struct gpio_desc *en_gpio;
> +};
> +
> +static int adg2404_set(struct mux_control *mux, int state)
> +{
> + struct adg2404_mux *adg2404 = mux_chip_priv(mux->chip);
> + DECLARE_BITMAP(values, BITS_PER_TYPE(state));
> + u32 value = state;
> +
> + if (state == MUX_IDLE_DISCONNECT) {
> + gpiod_set_value_cansleep(adg2404->en_gpio, 0);
> + return 0;
> + }
> +
> + /*
> + * Disable the mux before changing address lines to prevent
> + * glitches. Changing address while enabled could briefly activate
> + * an unintended channel during the transition.
> + */
> + gpiod_set_value_cansleep(adg2404->en_gpio, 0);
> +
> + bitmap_from_arr32(values, &value, BITS_PER_TYPE(value));
> + gpiod_set_array_value_cansleep(adg2404->addr_gpios->ndescs,
> + adg2404->addr_gpios->desc,
> + adg2404->addr_gpios->info,
> + values);
> +
> + /* Enable the mux with the new address */
> + gpiod_set_value_cansleep(adg2404->en_gpio, 1);
All this looks exactly the same as your other driver, so I don't get why
we need two.
Not sure if we even need any of them and this should be just
incorporated into gpio-mux driver.
...
> +
> + ret = devm_mux_chip_register(dev, mux_chip);
> + if (ret < 0)
> + return ret;
> +
> + dev_info(dev, "ADG2404 %u-way mux-controller registered\n",
> + mux_chip->mux->states);
Drop. We really do not need to know that every single device probed.
Best regards,
Krzysztof
Powered by blists - more mailing lists