* [PATCH v3 0/2] Add ADG1712 SPST switch controller support
@ 2025-11-17 9:13 Antoniu Miclaus
2025-11-17 9:13 ` [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support Antoniu Miclaus
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Antoniu Miclaus @ 2025-11-17 9:13 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij,
Bartosz Golaszewski, Antoniu Miclaus, devicetree, linux-kernel,
linux-gpio
This series adds support for the Analog Devices ADG1712 quad single-pole,
single-throw (SPST) switch controller.
The ADG1712 contains four independent analog switches, each controlled by
a dedicated GPIO input pin. This implementation configures the switches
once at probe time based on device tree properties.
Changes in v3:
- Moved device tree bindings from gpio/ to switch/ subsystem
- Completely redesigned driver architecture: removed GPIO controller interface
- Added 'switch-states' device tree property for configuring initial switch states
- Driver now sets switches once at probe time based on DT properties
- Updated descriptions to clarify that switches cannot be changed from userspace
- Simplified driver structure and removed all GPIO chip functionality
Antoniu Miclaus (2):
dt-bindings: switch: adg1712: add adg1712 support
gpio: adg1712: add driver support
.../bindings/switch/adi,adg1712.yaml | 68 +++++++++++++++
drivers/gpio/Kconfig | 9 ++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-adg1712.c | 87 +++++++++++++++++++
4 files changed, 165 insertions(+)
create mode 100644 Documentation/devicetree/bindings/switch/adi,adg1712.yaml
create mode 100644 drivers/gpio/gpio-adg1712.c
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support 2025-11-17 9:13 [PATCH v3 0/2] Add ADG1712 SPST switch controller support Antoniu Miclaus @ 2025-11-17 9:13 ` Antoniu Miclaus 2025-11-19 13:45 ` Linus Walleij 2025-11-19 17:56 ` Conor Dooley 2025-11-17 9:13 ` [PATCH v3 2/2] gpio: adg1712: add driver support Antoniu Miclaus 2025-11-17 15:06 ` [PATCH v3 0/2] Add ADG1712 SPST switch controller support Nuno Sá 2 siblings, 2 replies; 11+ messages in thread From: Antoniu Miclaus @ 2025-11-17 9:13 UTC (permalink / raw) To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij, Bartosz Golaszewski, Antoniu Miclaus, devicetree, linux-kernel, linux-gpio Add devicetree bindings for adg1712 SPST quad switch. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> --- Changes in v3: - Move bindings from gpio/ to switch/ subsystem - Remove gpio-controller interface - Add 'switch-states' property for initial configuration - Update description and example --- .../bindings/switch/adi,adg1712.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/switch/adi,adg1712.yaml diff --git a/Documentation/devicetree/bindings/switch/adi,adg1712.yaml b/Documentation/devicetree/bindings/switch/adi,adg1712.yaml new file mode 100644 index 000000000000..eed142eb5b05 --- /dev/null +++ b/Documentation/devicetree/bindings/switch/adi,adg1712.yaml @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/switch/adi,adg1712.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices ADG1712 quad SPST switch controller + +maintainers: + - Antoniu Miclaus <antoniu.miclaus@analog.com> + +description: | + Bindings for Analog Devices ADG1712 quad single-pole, single-throw (SPST) + switch controlled by GPIOs. The device features four independent switches, + each controlled by a dedicated GPIO input pin. + + The switches are configured at probe time based on device tree properties + and cannot be changed from userspace after initialization. + +properties: + compatible: + const: adi,adg1712 + + switch-gpios: + description: | + Array of GPIOs connected to the IN1-IN4 control pins. + Index 0 corresponds to IN1 (controls SW1), + Index 1 corresponds to IN2 (controls SW2), + Index 2 corresponds to IN3 (controls SW3), + Index 3 corresponds to IN4 (controls SW4). + minItems: 4 + maxItems: 4 + + switch-states: + description: | + Initial states for the four switches (SW1-SW4). + Each element corresponds to the desired state of the respective switch: + 0 = switch disabled (open), 1 = switch enabled (closed). + If not specified, all switches default to disabled (0). + $ref: /schemas/types.yaml#/definitions/uint32-array + items: + minimum: 0 + maximum: 1 + minItems: 4 + maxItems: 4 + +required: + - compatible + - switch-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + adg1712: switch-controller { + compatible = "adi,adg1712"; + + switch-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>, + <&gpio 11 GPIO_ACTIVE_HIGH>, + <&gpio 12 GPIO_ACTIVE_HIGH>, + <&gpio 13 GPIO_ACTIVE_HIGH>; + + /* Enable SW1 and SW3, disable SW2 and SW4 */ + switch-states = <1 0 1 0>; + }; +... -- 2.43.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support 2025-11-17 9:13 ` [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support Antoniu Miclaus @ 2025-11-19 13:45 ` Linus Walleij 2025-11-19 17:56 ` Conor Dooley 1 sibling, 0 replies; 11+ messages in thread From: Linus Walleij @ 2025-11-19 13:45 UTC (permalink / raw) To: Antoniu Miclaus Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bartosz Golaszewski, devicetree, linux-kernel, linux-gpio Hi Antoniu, I like the looks of this! On Mon, Nov 17, 2025 at 10:15 AM Antoniu Miclaus <antoniu.miclaus@analog.com> wrote: > + The switches are configured at probe time based on device tree properties > + and cannot be changed from userspace after initialization. Please drop this paragraph. The DT bindings are for several operating systems and this seems to be Linux specifics and also not every operating system has a kernelspace/userspace separation. With that change: Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support 2025-11-17 9:13 ` [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support Antoniu Miclaus 2025-11-19 13:45 ` Linus Walleij @ 2025-11-19 17:56 ` Conor Dooley 2025-11-19 21:22 ` Linus Walleij 1 sibling, 1 reply; 11+ messages in thread From: Conor Dooley @ 2025-11-19 17:56 UTC (permalink / raw) To: Antoniu Miclaus Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij, Bartosz Golaszewski, devicetree, linux-kernel, linux-gpio [-- Attachment #1: Type: text/plain, Size: 3547 bytes --] On Mon, Nov 17, 2025 at 09:13:22AM +0000, Antoniu Miclaus wrote: > Add devicetree bindings for adg1712 SPST quad switch. > > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> > --- > Changes in v3: > - Move bindings from gpio/ to switch/ subsystem > - Remove gpio-controller interface > - Add 'switch-states' property for initial configuration > - Update description and example > --- > .../bindings/switch/adi,adg1712.yaml | 68 +++++++++++++++++++ > 1 file changed, 68 insertions(+) > create mode 100644 Documentation/devicetree/bindings/switch/adi,adg1712.yaml > > diff --git a/Documentation/devicetree/bindings/switch/adi,adg1712.yaml b/Documentation/devicetree/bindings/switch/adi,adg1712.yaml > new file mode 100644 > index 000000000000..eed142eb5b05 > --- /dev/null > +++ b/Documentation/devicetree/bindings/switch/adi,adg1712.yaml > @@ -0,0 +1,68 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/switch/adi,adg1712.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Analog Devices ADG1712 quad SPST switch controller > + > +maintainers: > + - Antoniu Miclaus <antoniu.miclaus@analog.com> > + > +description: | > + Bindings for Analog Devices ADG1712 quad single-pole, single-throw (SPST) > + switch controlled by GPIOs. The device features four independent switches, > + each controlled by a dedicated GPIO input pin. > + > + The switches are configured at probe time based on device tree properties > + and cannot be changed from userspace after initialization. > + > +properties: > + compatible: > + const: adi,adg1712 > + > + switch-gpios: > + description: | > + Array of GPIOs connected to the IN1-IN4 control pins. > + Index 0 corresponds to IN1 (controls SW1), > + Index 1 corresponds to IN2 (controls SW2), > + Index 2 corresponds to IN3 (controls SW3), > + Index 3 corresponds to IN4 (controls SW4). Did I miss a reply about my comment on this switch-gpios? I was asking if a binding like this, which doesn't permit any of these not being provided is a good idea. > + minItems: 4 > + maxItems: 4 > + > + switch-states: > + description: | > + Initial states for the four switches (SW1-SW4). Missing an adi prefix? Also, probably should say initial if it is initial states. Linus commented on the commit mesage, so you're gonna at least need to change that. pw-bot: changes-requested > + Each element corresponds to the desired state of the respective switch: > + 0 = switch disabled (open), 1 = switch enabled (closed). > + If not specified, all switches default to disabled (0). > + $ref: /schemas/types.yaml#/definitions/uint32-array > + items: > + minimum: 0 > + maximum: 1 > + minItems: 4 > + maxItems: 4 > + > +required: > + - compatible > + - switch-gpios > + > +additionalProperties: false > + > +examples: > + - | > + #include <dt-bindings/gpio/gpio.h> > + > + adg1712: switch-controller { > + compatible = "adi,adg1712"; > + > + switch-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>, > + <&gpio 11 GPIO_ACTIVE_HIGH>, > + <&gpio 12 GPIO_ACTIVE_HIGH>, > + <&gpio 13 GPIO_ACTIVE_HIGH>; > + > + /* Enable SW1 and SW3, disable SW2 and SW4 */ > + switch-states = <1 0 1 0>; > + }; > +... > -- > 2.43.0 > > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support 2025-11-19 17:56 ` Conor Dooley @ 2025-11-19 21:22 ` Linus Walleij 2025-11-20 0:31 ` Conor Dooley 0 siblings, 1 reply; 11+ messages in thread From: Linus Walleij @ 2025-11-19 21:22 UTC (permalink / raw) To: Conor Dooley Cc: Antoniu Miclaus, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bartosz Golaszewski, devicetree, linux-kernel, linux-gpio On Wed, Nov 19, 2025 at 6:56 PM Conor Dooley <conor@kernel.org> wrote: > On Mon, Nov 17, 2025 at 09:13:22AM +0000, Antoniu Miclaus wrote: > > + switch-gpios: > > + description: | > > + Array of GPIOs connected to the IN1-IN4 control pins. > > + Index 0 corresponds to IN1 (controls SW1), > > + Index 1 corresponds to IN2 (controls SW2), > > + Index 2 corresponds to IN3 (controls SW3), > > + Index 3 corresponds to IN4 (controls SW4). > > Did I miss a reply about my comment on this switch-gpios? I was asking > if a binding like this, which doesn't permit any of these not being > provided is a good idea. > > > + minItems: 4 > > + maxItems: 4 Maybe we should make them named GPIOs after all, as the switch has exactly 4 possible GPIOs. It was my request to have an array I think, and now I feel a bit stupid about that :( > > + switch-states: > > + description: | > > + Initial states for the four switches (SW1-SW4). > > Missing an adi prefix? Also, probably should say initial if it is > initial states. It should probably be initial-switch-states. I vote for a generic binding as it is a new "subsystem" in DT, and this can be exepected for any new switch. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support 2025-11-19 21:22 ` Linus Walleij @ 2025-11-20 0:31 ` Conor Dooley 2025-11-20 23:19 ` Linus Walleij 0 siblings, 1 reply; 11+ messages in thread From: Conor Dooley @ 2025-11-20 0:31 UTC (permalink / raw) To: Linus Walleij Cc: Antoniu Miclaus, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bartosz Golaszewski, devicetree, linux-kernel, linux-gpio [-- Attachment #1: Type: text/plain, Size: 1731 bytes --] On Wed, Nov 19, 2025 at 10:22:02PM +0100, Linus Walleij wrote: > On Wed, Nov 19, 2025 at 6:56 PM Conor Dooley <conor@kernel.org> wrote: > > On Mon, Nov 17, 2025 at 09:13:22AM +0000, Antoniu Miclaus wrote: > > > > + switch-gpios: > > > + description: | > > > + Array of GPIOs connected to the IN1-IN4 control pins. > > > + Index 0 corresponds to IN1 (controls SW1), > > > + Index 1 corresponds to IN2 (controls SW2), > > > + Index 2 corresponds to IN3 (controls SW3), > > > + Index 3 corresponds to IN4 (controls SW4). > > > > Did I miss a reply about my comment on this switch-gpios? I was asking > > if a binding like this, which doesn't permit any of these not being > > provided is a good idea. > > > > > + minItems: 4 > > > + maxItems: 4 > > Maybe we should make them named GPIOs after all, as the switch > has exactly 4 possible GPIOs. It was my request to have an > array I think, and now I feel a bit stupid about that :( It might cause havoc dt-schema wise, but is having a switch-gpio-names a silly suggestion? Seems more usable than having 16 or 32 individual -gpios properties on a larger device. > > > + switch-states: > > > + description: | > > > + Initial states for the four switches (SW1-SW4). > > > > Missing an adi prefix? Also, probably should say initial if it is > > initial states. > > It should probably be initial-switch-states. > > I vote for a generic binding as it is a new "subsystem" in DT, > and this can be exepected for any new switch. Cool, prefix-less is fine in the case - although Rob's usual requirement is two users for some common thing to make sure that it is actually suitable for being common. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support 2025-11-20 0:31 ` Conor Dooley @ 2025-11-20 23:19 ` Linus Walleij 0 siblings, 0 replies; 11+ messages in thread From: Linus Walleij @ 2025-11-20 23:19 UTC (permalink / raw) To: Conor Dooley Cc: Antoniu Miclaus, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bartosz Golaszewski, devicetree, linux-kernel, linux-gpio On Thu, Nov 20, 2025 at 1:31 AM Conor Dooley <conor@kernel.org> wrote: > > Maybe we should make them named GPIOs after all, as the switch > > has exactly 4 possible GPIOs. It was my request to have an > > array I think, and now I feel a bit stupid about that :( > > It might cause havoc dt-schema wise, but is having a switch-gpio-names > a silly suggestion? Seems more usable than having 16 or 32 individual > -gpios properties on a larger device. I think in DT the "name" if a GPIO is kind of the string before -gpios so "foo" is the name in foo-gpios. We already have gpio-line-names to set up names for GPIO lines but it has never been used like this (to find a GPIO for a certain line name) before. > > It should probably be initial-switch-states. > > > > I vote for a generic binding as it is a new "subsystem" in DT, > > and this can be exepected for any new switch. > > Cool, prefix-less is fine in the case - although Rob's usual requirement > is two users for some common thing to make sure that it is actually > suitable for being common. It's a reasonable stance, but if we zoom out and look at the usecase, who wants to leave all of the switches in their house in "undefined" state after installing them? Everyone is going to want an initial state. Lamps switched off and heating switched on or something like this. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 2/2] gpio: adg1712: add driver support 2025-11-17 9:13 [PATCH v3 0/2] Add ADG1712 SPST switch controller support Antoniu Miclaus 2025-11-17 9:13 ` [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support Antoniu Miclaus @ 2025-11-17 9:13 ` Antoniu Miclaus 2025-11-17 14:46 ` Bartosz Golaszewski 2025-11-19 13:59 ` Linus Walleij 2025-11-17 15:06 ` [PATCH v3 0/2] Add ADG1712 SPST switch controller support Nuno Sá 2 siblings, 2 replies; 11+ messages in thread From: Antoniu Miclaus @ 2025-11-17 9:13 UTC (permalink / raw) To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij, Bartosz Golaszewski, Antoniu Miclaus, devicetree, linux-kernel, linux-gpio Add driver support for the ADG1712, which contains four independent single-pole/single-throw (SPST) switches and operates with a low-voltage single supply range from +1.08V to +5.5V or a low-voltage dual supply range from ±1.08V to ±2.75V. The driver configures switches once at probe time based on device tree properties and does not expose any userspace interface for runtime control. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> --- Changes in v3: - Remove GPIO controller interface - Configure switches from device tree at probe time only - Add 'switch-states' property parsing - Change from GPIOD_ASIS to GPIOD_OUT_LOW --- drivers/gpio/Kconfig | 9 ++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-adg1712.c | 87 +++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 drivers/gpio/gpio-adg1712.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 7ee3afbc2b05..3fac05823eae 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -157,6 +157,15 @@ config GPIO_74XX_MMIO 8 bits: 74244 (Input), 74273 (Output) 16 bits: 741624 (Input), 7416374 (Output) +config GPIO_ADG1712 + tristate "Analog Devices ADG1712 quad SPST switch GPIO driver" + depends on GPIOLIB + help + GPIO driver for Analog Devices ADG1712 quad single-pole, + single-throw (SPST) switch. The driver provides a GPIO controller + interface where each GPIO line controls one of the four independent + analog switches on the ADG1712. + config GPIO_ALTERA tristate "Altera GPIO" select GPIOLIB_IRQCHIP diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index ec296fa14bfd..9043d2d07a15 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_GPIO_104_IDI_48) += gpio-104-idi-48.o obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o +obj-$(CONFIG_GPIO_ADG1712) += gpio-adg1712.o obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o obj-$(CONFIG_GPIO_ADP5585) += gpio-adp5585.o diff --git a/drivers/gpio/gpio-adg1712.c b/drivers/gpio/gpio-adg1712.c new file mode 100644 index 000000000000..86f8645cf2ad --- /dev/null +++ b/drivers/gpio/gpio-adg1712.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Analog Devices ADG1712 quad SPST switch 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/platform_device.h> +#include <linux/property.h> + +#define ADG1712_NUM_SWITCHES 4 + +struct adg1712 { + struct gpio_descs *switch_gpios; +}; + +static int adg1712_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct adg1712 *adg1712; + u32 switch_states[ADG1712_NUM_SWITCHES] = {0}; /* Default all switches off */ + int ret, i; + + adg1712 = devm_kzalloc(dev, sizeof(*adg1712), GFP_KERNEL); + if (!adg1712) + return -ENOMEM; + + adg1712->switch_gpios = devm_gpiod_get_array(dev, "switch", GPIOD_OUT_LOW); + if (IS_ERR(adg1712->switch_gpios)) + return dev_err_probe(dev, PTR_ERR(adg1712->switch_gpios), + "failed to get switch gpios\n"); + + if (adg1712->switch_gpios->ndescs != ADG1712_NUM_SWITCHES) + return dev_err_probe(dev, -EINVAL, + "expected %d gpios, got %d\n", + ADG1712_NUM_SWITCHES, + adg1712->switch_gpios->ndescs); + + ret = device_property_read_u32_array(dev, "switch-states", switch_states, + ADG1712_NUM_SWITCHES); + if (ret && ret != -EINVAL) + return dev_err_probe(dev, ret, "failed to read switch-states\n"); + + for (i = 0; i < ADG1712_NUM_SWITCHES; i++) { + if (switch_states[i] > 1) { + dev_warn(dev, "invalid switch state %u for switch %d, using 0\n", + switch_states[i], i); + switch_states[i] = 0; + } + + ret = gpiod_set_value_cansleep(adg1712->switch_gpios->desc[i], + switch_states[i]); + if (ret) + return dev_err_probe(dev, ret, "failed to set switch %d\n", i); + } + + platform_set_drvdata(pdev, adg1712); + + dev_info(dev, "ADG1712 switch controller configured\n"); + + return 0; +} + +static const struct of_device_id adg1712_dt_ids[] = { + { .compatible = "adi,adg1712", }, + { } +}; +MODULE_DEVICE_TABLE(of, adg1712_dt_ids); + +static struct platform_driver adg1712_driver = { + .driver = { + .name = "adg1712", + .of_match_table = adg1712_dt_ids, + }, + .probe = adg1712_probe, +}; +module_platform_driver(adg1712_driver); + +MODULE_DESCRIPTION("Analog Devices ADG1712 quad SPST switch driver"); +MODULE_AUTHOR("Antoniu Miclaus <antoniu.miclaus@analog.com>"); +MODULE_LICENSE("GPL"); -- 2.43.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3 2/2] gpio: adg1712: add driver support 2025-11-17 9:13 ` [PATCH v3 2/2] gpio: adg1712: add driver support Antoniu Miclaus @ 2025-11-17 14:46 ` Bartosz Golaszewski 2025-11-19 13:59 ` Linus Walleij 1 sibling, 0 replies; 11+ messages in thread From: Bartosz Golaszewski @ 2025-11-17 14:46 UTC (permalink / raw) To: Antoniu Miclaus Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij, devicetree, linux-kernel, linux-gpio On Mon, Nov 17, 2025 at 10:15 AM Antoniu Miclaus <antoniu.miclaus@analog.com> wrote: > > Add driver support for the ADG1712, which contains four independent > single-pole/single-throw (SPST) switches and operates with a > low-voltage single supply range from +1.08V to +5.5V or a low-voltage > dual supply range from ±1.08V to ±2.75V. > > The driver configures switches once at probe time based on device tree > properties and does not expose any userspace interface for runtime control. > > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> > --- > Changes in v3: > - Remove GPIO controller interface > - Configure switches from device tree at probe time only > - Add 'switch-states' property parsing > - Change from GPIOD_ASIS to GPIOD_OUT_LOW > --- > drivers/gpio/Kconfig | 9 ++++ > drivers/gpio/Makefile | 1 + > drivers/gpio/gpio-adg1712.c | 87 +++++++++++++++++++++++++++++++++++++ > 3 files changed, 97 insertions(+) > create mode 100644 drivers/gpio/gpio-adg1712.c > > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig > index 7ee3afbc2b05..3fac05823eae 100644 > --- a/drivers/gpio/Kconfig > +++ b/drivers/gpio/Kconfig > @@ -157,6 +157,15 @@ config GPIO_74XX_MMIO > 8 bits: 74244 (Input), 74273 (Output) > 16 bits: 741624 (Input), 7416374 (Output) > > +config GPIO_ADG1712 > + tristate "Analog Devices ADG1712 quad SPST switch GPIO driver" > + depends on GPIOLIB > + help > + GPIO driver for Analog Devices ADG1712 quad single-pole, > + single-throw (SPST) switch. The driver provides a GPIO controller > + interface where each GPIO line controls one of the four independent > + analog switches on the ADG1712. > + I'm finding it hard to understand how this is a GPIO driver. It's a GPIO consumer but does it really belong under drivers/gpio/? > config GPIO_ALTERA > tristate "Altera GPIO" > select GPIOLIB_IRQCHIP > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile > index ec296fa14bfd..9043d2d07a15 100644 > --- a/drivers/gpio/Makefile > +++ b/drivers/gpio/Makefile > @@ -28,6 +28,7 @@ obj-$(CONFIG_GPIO_104_IDI_48) += gpio-104-idi-48.o > obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o > obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o > obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o > +obj-$(CONFIG_GPIO_ADG1712) += gpio-adg1712.o > obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o > obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o > obj-$(CONFIG_GPIO_ADP5585) += gpio-adp5585.o > diff --git a/drivers/gpio/gpio-adg1712.c b/drivers/gpio/gpio-adg1712.c > new file mode 100644 > index 000000000000..86f8645cf2ad > --- /dev/null > +++ b/drivers/gpio/gpio-adg1712.c > @@ -0,0 +1,87 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Analog Devices ADG1712 quad SPST switch 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/platform_device.h> > +#include <linux/property.h> > + > +#define ADG1712_NUM_SWITCHES 4 > + > +struct adg1712 { > + struct gpio_descs *switch_gpios; > +}; > + > +static int adg1712_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct adg1712 *adg1712; > + u32 switch_states[ADG1712_NUM_SWITCHES] = {0}; /* Default all switches off */ > + int ret, i; > + > + adg1712 = devm_kzalloc(dev, sizeof(*adg1712), GFP_KERNEL); > + if (!adg1712) > + return -ENOMEM; > + > + adg1712->switch_gpios = devm_gpiod_get_array(dev, "switch", GPIOD_OUT_LOW); > + if (IS_ERR(adg1712->switch_gpios)) > + return dev_err_probe(dev, PTR_ERR(adg1712->switch_gpios), > + "failed to get switch gpios\n"); > + > + if (adg1712->switch_gpios->ndescs != ADG1712_NUM_SWITCHES) > + return dev_err_probe(dev, -EINVAL, > + "expected %d gpios, got %d\n", > + ADG1712_NUM_SWITCHES, > + adg1712->switch_gpios->ndescs); > + > + ret = device_property_read_u32_array(dev, "switch-states", switch_states, > + ADG1712_NUM_SWITCHES); > + if (ret && ret != -EINVAL) > + return dev_err_probe(dev, ret, "failed to read switch-states\n"); > + > + for (i = 0; i < ADG1712_NUM_SWITCHES; i++) { > + if (switch_states[i] > 1) { > + dev_warn(dev, "invalid switch state %u for switch %d, using 0\n", > + switch_states[i], i); > + switch_states[i] = 0; > + } > + > + ret = gpiod_set_value_cansleep(adg1712->switch_gpios->desc[i], > + switch_states[i]); I don't see anything here that cannot be achieved with gpio hogs in device-tree. Do we really need a separate driver for it? If we really really need it, you don't really need to implement a new driver, you could literally just extend gpio-virtuser with a real compatible and it would request the GPIOs for you. > + if (ret) > + return dev_err_probe(dev, ret, "failed to set switch %d\n", i); > + } > + > + platform_set_drvdata(pdev, adg1712); Where is the corresponding platform_get_drvdata()? > + > + dev_info(dev, "ADG1712 switch controller configured\n"); Please remove this, no need to be noisy. Bart ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 2/2] gpio: adg1712: add driver support 2025-11-17 9:13 ` [PATCH v3 2/2] gpio: adg1712: add driver support Antoniu Miclaus 2025-11-17 14:46 ` Bartosz Golaszewski @ 2025-11-19 13:59 ` Linus Walleij 1 sibling, 0 replies; 11+ messages in thread From: Linus Walleij @ 2025-11-19 13:59 UTC (permalink / raw) To: Antoniu Miclaus Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bartosz Golaszewski, devicetree, linux-kernel, linux-gpio On Mon, Nov 17, 2025 at 10:15 AM Antoniu Miclaus <antoniu.miclaus@analog.com> wrote: > Add driver support for the ADG1712, which contains four independent > single-pole/single-throw (SPST) switches and operates with a > low-voltage single supply range from +1.08V to +5.5V or a low-voltage > dual supply range from ±1.08V to ±2.75V. > > The driver configures switches once at probe time based on device tree > properties and does not expose any userspace interface for runtime control. > > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> > --- > Changes in v3: > - Remove GPIO controller interface > - Configure switches from device tree at probe time only > - Add 'switch-states' property parsing > - Change from GPIOD_ASIS to GPIOD_OUT_LOW If you do it this way, as Bartosz says this is not a GPIO driver anymore. Create drivers/switch and discuss with Greg how to proceed with the new subsystem if you want to take this approach (and maybe eventually create a userspace ABI). What I've said about using the GPIO subsystem for this (which may be OK if there is some consensus around it) can be found here: https://lore.kernel.org/linux-gpio/CACRpkdZf9D2PH5AR46Pwi8UoyfwumKS4P3ncJ=RN4iu_cJzZ5w@mail.gmail.com/ and here: https://lore.kernel.org/linux-gpio/CACRpkdbZgxWaf7B7vwD3n-OSbt8h8vGKQ_CmB_SNjDG6aXHayA@mail.gmail.com/ Yours, Linus Walleij ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 0/2] Add ADG1712 SPST switch controller support 2025-11-17 9:13 [PATCH v3 0/2] Add ADG1712 SPST switch controller support Antoniu Miclaus 2025-11-17 9:13 ` [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support Antoniu Miclaus 2025-11-17 9:13 ` [PATCH v3 2/2] gpio: adg1712: add driver support Antoniu Miclaus @ 2025-11-17 15:06 ` Nuno Sá 2 siblings, 0 replies; 11+ messages in thread From: Nuno Sá @ 2025-11-17 15:06 UTC (permalink / raw) To: Antoniu Miclaus, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij, Bartosz Golaszewski, devicetree, linux-kernel, linux-gpio On Mon, 2025-11-17 at 09:13 +0000, Antoniu Miclaus wrote: > This series adds support for the Analog Devices ADG1712 quad single-pole, > single-throw (SPST) switch controller. > > The ADG1712 contains four independent analog switches, each controlled by > a dedicated GPIO input pin. This implementation configures the switches > once at probe time based on device tree properties. > > Changes in v3: > - Moved device tree bindings from gpio/ to switch/ subsystem > - Completely redesigned driver architecture: removed GPIO controller interface > - Added 'switch-states' device tree property for configuring initial switch states Hmm but if we are going that direction, I wonder if this should be in drivers/gpio at all? We have drivers/mux/gpio.c. While this is a switch (and not a mux) I guess it would still be more appropriate in there and probably works out of the box? - Nuno Sá ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-11-20 23:19 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-11-17 9:13 [PATCH v3 0/2] Add ADG1712 SPST switch controller support Antoniu Miclaus 2025-11-17 9:13 ` [PATCH v3 1/2] dt-bindings: switch: adg1712: add adg1712 support Antoniu Miclaus 2025-11-19 13:45 ` Linus Walleij 2025-11-19 17:56 ` Conor Dooley 2025-11-19 21:22 ` Linus Walleij 2025-11-20 0:31 ` Conor Dooley 2025-11-20 23:19 ` Linus Walleij 2025-11-17 9:13 ` [PATCH v3 2/2] gpio: adg1712: add driver support Antoniu Miclaus 2025-11-17 14:46 ` Bartosz Golaszewski 2025-11-19 13:59 ` Linus Walleij 2025-11-17 15:06 ` [PATCH v3 0/2] Add ADG1712 SPST switch controller support Nuno Sá
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).