mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v7 0/2] iio: amplifiers: add support for ADL8113 Low Noise Amplifier
@ 2025-12-12 15:38 Antoniu Miclaus
  2025-12-12 15:38 ` [PATCH v7 1/2] dt-bindings: iio: amplifiers: add adl8113 Antoniu Miclaus
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Antoniu Miclaus @ 2025-12-12 15:38 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Antoniu Miclaus, linux-iio, devicetree, linux-kernel

This patch series adds support for the Analog Devices ADL8113, a 10MHz to 12GHz
Low Noise Amplifier with integrated bypass switches.

The ADL8113 provides four operation modes controlled by two GPIO pins:
- Internal Amplifier (14dB gain)
- Internal Bypass (-2dB insertion loss)
- External Bypass A (configurable gain) - Signal routes from RFIN to OUT_A and from IN_A to RFOUT
- External Bypass B (configurable gain) - Signal routes from RFIN to OUT_B and from IN_B to RFOUT

The driver allows selecting between these paths via the IIO hardwaregain attribute,
with optional external amplifier gains configured through device tree properties.

Antoniu Miclaus (2):
  dt-bindings: iio: amplifiers: add adl8113
  iio: amplifiers: adl8113: add driver support

 .../bindings/iio/amplifiers/adi,adl8113.yaml  |  87 ++++++
 drivers/iio/amplifiers/Kconfig                |  12 +
 drivers/iio/amplifiers/Makefile               |   1 +
 drivers/iio/amplifiers/adl8113.c              | 269 ++++++++++++++++++
 4 files changed, 369 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/amplifiers/adi,adl8113.yaml
 create mode 100644 drivers/iio/amplifiers/adl8113.c

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v7 1/2] dt-bindings: iio: amplifiers: add adl8113
  2025-12-12 15:38 [PATCH v7 0/2] iio: amplifiers: add support for ADL8113 Low Noise Amplifier Antoniu Miclaus
@ 2025-12-12 15:38 ` Antoniu Miclaus
  2025-12-12 15:38 ` [PATCH v7 2/2] iio: amplifiers: adl8113: add driver support Antoniu Miclaus
  2025-12-13 16:28 ` [PATCH v7 0/2] iio: amplifiers: add support for ADL8113 Low Noise Amplifier Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Antoniu Miclaus @ 2025-12-12 15:38 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Antoniu Miclaus, linux-iio, devicetree, linux-kernel

Add devicetree bindings for the ADL8113 Low Noise Amplifier.

The bindings include support for specifying gain values of external
amplifiers connected to the two external bypass paths (A and B). These
optional properties allow the gain values to be selectable via the
hardwaregain attribute, enabling complete devicetree description of
the signal chain including external components.

Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
changes in v7:
 - Enhanced commit message to describe the external bypass gains feature

 .../bindings/iio/amplifiers/adi,adl8113.yaml  | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/amplifiers/adi,adl8113.yaml

diff --git a/Documentation/devicetree/bindings/iio/amplifiers/adi,adl8113.yaml b/Documentation/devicetree/bindings/iio/amplifiers/adi,adl8113.yaml
new file mode 100644
index 000000000000..6b8491d18139
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/amplifiers/adi,adl8113.yaml
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/amplifiers/adi,adl8113.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices ADL8113 Low Noise Amplifier with integrated bypass switches
+
+maintainers:
+  - Antoniu Miclaus <antoniu.miclaus@analog.com>
+
+description: |
+  The ADL8113 is a 10MHz to 12GHz Low Noise Amplifier with integrated bypass
+  switches controlled by two GPIO pins (VA and VB). The device supports four
+  operation modes:
+    - Internal Amplifier: VA=0, VB=0 - Signal passes through the internal LNA
+    - Internal Bypass: VA=1, VB=1 - Signal bypasses through internal path
+    - External Bypass A: VA=0, VB=1 - Signal routes from RFIN to OUT_A and from IN_A to RFOUT
+    - External Bypass B: VA=1, VB=0 - Signal routes from RFIN to OUT_B and from IN_B to RFOUT
+
+    https://www.analog.com/en/products/adl8113.html
+
+properties:
+  compatible:
+    const: adi,adl8113
+
+  vdd1-supply: true
+
+  vdd2-supply: true
+
+  vss2-supply: true
+
+  ctrl-gpios:
+    items:
+      - description: VA control pin
+      - description: VB control pin
+
+  adi,external-bypass-a-gain-db:
+    description:
+      Gain in dB of external amplifier connected to bypass path A (OUT_A/IN_A).
+      When specified, this gain value becomes selectable via the hardwaregain
+      attribute and automatically routes through the external A path.
+
+  adi,external-bypass-b-gain-db:
+    description:
+      Gain in dB of external amplifier connected to bypass path B (OUT_B/IN_B).
+      When specified, this gain value becomes selectable via the hardwaregain
+      attribute and automatically routes through the external B path.
+
+required:
+  - compatible
+  - ctrl-gpios
+  - vdd1-supply
+  - vdd2-supply
+  - vss2-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    /* Basic configuration with only internal paths */
+    amplifier {
+        compatible = "adi,adl8113";
+        ctrl-gpios = <&gpio 22 GPIO_ACTIVE_HIGH>,
+                     <&gpio 23 GPIO_ACTIVE_HIGH>;
+        vdd1-supply = <&vdd1_5v>;
+        vdd2-supply = <&vdd2_3v3>;
+        vss2-supply = <&vss2_neg>;
+    };
+
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    /* Configuration with external bypass amplifiers */
+    amplifier {
+        compatible = "adi,adl8113";
+        ctrl-gpios = <&gpio 24 GPIO_ACTIVE_HIGH>,
+                     <&gpio 25 GPIO_ACTIVE_HIGH>;
+        vdd1-supply = <&vdd1_5v>;
+        vdd2-supply = <&vdd2_3v3>;
+        vss2-supply = <&vss2_neg>;
+        adi,external-bypass-a-gain-db = <20>;  /* 20dB external amp on path A */
+        adi,external-bypass-b-gain-db = <6>;   /* 6dB external amp on path B */
+    };
+...
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v7 2/2] iio: amplifiers: adl8113: add driver support
  2025-12-12 15:38 [PATCH v7 0/2] iio: amplifiers: add support for ADL8113 Low Noise Amplifier Antoniu Miclaus
  2025-12-12 15:38 ` [PATCH v7 1/2] dt-bindings: iio: amplifiers: add adl8113 Antoniu Miclaus
@ 2025-12-12 15:38 ` Antoniu Miclaus
  2025-12-13 16:28 ` [PATCH v7 0/2] iio: amplifiers: add support for ADL8113 Low Noise Amplifier Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Antoniu Miclaus @ 2025-12-12 15:38 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Antoniu Miclaus, linux-iio, devicetree, linux-kernel

Add support for adl8113 10MHz to 12GHz Low Noise Amplifier with
10MHz to 14GHz bypass switches.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
changes in v7:
 - Removed includes: limits.h, device.h, slab.h, sysfs.h
 - Added includes: bitmap.h, types.h, dev_printk.h, device/driver.h
 - Removed unused va and vb struct fields
 - Added trailing comma to supply names array
 - Changed num_gain_configs to unsigned int
 - Replaced bitmap operations with bitmap_write()
 - Enhanced comment showing bit mapping
 - Changed loop counters to unsigned int
 - Used compound literals for struct initialization
 - Fixed devm_kcalloc() line wrapping
 - Removed INT_MIN testing code
 - Removed duplicate gain validation
 - Fixed format specifier to %u for ndescs
 - Removed redundant blank line

 drivers/iio/amplifiers/Kconfig   |  12 ++
 drivers/iio/amplifiers/Makefile  |   1 +
 drivers/iio/amplifiers/adl8113.c | 269 +++++++++++++++++++++++++++++++
 3 files changed, 282 insertions(+)
 create mode 100644 drivers/iio/amplifiers/adl8113.c

diff --git a/drivers/iio/amplifiers/Kconfig b/drivers/iio/amplifiers/Kconfig
index 55eb16b32f6c..a8a604863eed 100644
--- a/drivers/iio/amplifiers/Kconfig
+++ b/drivers/iio/amplifiers/Kconfig
@@ -36,6 +36,18 @@ config ADA4250
 	  To compile this driver as a module, choose M here: the
 	  module will be called ada4250.
 
+config ADL8113
+	tristate "Analog Devices ADL8113 Low Noise Amplifier"
+	depends on GPIOLIB
+	help
+	  Say yes here to build support for Analog Devices ADL8113 Low Noise
+	  Amplifier with integrated bypass switches. The device supports four
+	  operation modes controlled by GPIO pins: internal amplifier,
+	  internal bypass, and two external bypass modes.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called adl8113.
+
 config HMC425
 	tristate "Analog Devices HMC425A and similar GPIO Gain Amplifiers"
 	depends on GPIOLIB
diff --git a/drivers/iio/amplifiers/Makefile b/drivers/iio/amplifiers/Makefile
index 2126331129cf..0a76443be1aa 100644
--- a/drivers/iio/amplifiers/Makefile
+++ b/drivers/iio/amplifiers/Makefile
@@ -6,4 +6,5 @@
 # When adding new entries keep the list in alphabetical order
 obj-$(CONFIG_AD8366) += ad8366.o
 obj-$(CONFIG_ADA4250) += ada4250.o
+obj-$(CONFIG_ADL8113) += adl8113.o
 obj-$(CONFIG_HMC425) += hmc425a.o
diff --git a/drivers/iio/amplifiers/adl8113.c b/drivers/iio/amplifiers/adl8113.c
new file mode 100644
index 000000000000..b8a431b6616b
--- /dev/null
+++ b/drivers/iio/amplifiers/adl8113.c
@@ -0,0 +1,269 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ADL8113 Low Noise Amplifier with integrated bypass switches
+ *
+ * Copyright 2025 Analog Devices Inc.
+ */
+
+#include <linux/array_size.h>
+#include <linux/bitmap.h>
+#include <linux/device/driver.h>
+#include <linux/dev_printk.h>
+#include <linux/err.h>
+#include <linux/gpio/consumer.h>
+#include <linux/iio/iio.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/regulator/consumer.h>
+#include <linux/types.h>
+
+enum adl8113_signal_path {
+	ADL8113_INTERNAL_AMP,
+	ADL8113_INTERNAL_BYPASS,
+	ADL8113_EXTERNAL_A,
+	ADL8113_EXTERNAL_B,
+};
+
+struct adl8113_gain_config {
+	enum adl8113_signal_path path;
+	int gain_db;
+};
+
+struct adl8113_state {
+	struct gpio_descs *gpios;
+	struct adl8113_gain_config *gain_configs;
+	unsigned int num_gain_configs;
+	enum adl8113_signal_path current_path;
+};
+
+static const char * const adl8113_supply_names[] = {
+	"vdd1",
+	"vss2",
+	"vdd2",
+};
+
+static int adl8113_set_path(struct adl8113_state *st,
+			    enum adl8113_signal_path path)
+{
+	DECLARE_BITMAP(values, 2);
+	int ret;
+
+	/*
+	 * Determine GPIO values based on signal path.
+	 * Va: bit 0, Vb: bit 1.
+	 */
+	switch (path) {
+	case ADL8113_INTERNAL_AMP:
+		bitmap_write(values, 0x00, 0, 2);
+		break;
+	case ADL8113_INTERNAL_BYPASS:
+		bitmap_write(values, 0x03, 0, 2);
+		break;
+	case ADL8113_EXTERNAL_A:
+		bitmap_write(values, 0x02, 0, 2);
+		break;
+	case ADL8113_EXTERNAL_B:
+		bitmap_write(values, 0x01, 0, 2);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	ret = gpiod_set_array_value_cansleep(st->gpios->ndescs, st->gpios->desc,
+					     st->gpios->info, values);
+	if (ret)
+		return ret;
+
+	st->current_path = path;
+	return 0;
+}
+
+static int adl8113_find_gain_config(struct adl8113_state *st, int gain_db)
+{
+	unsigned int i;
+
+	for (i = 0; i < st->num_gain_configs; i++) {
+		if (st->gain_configs[i].gain_db == gain_db)
+			return i;
+	}
+	return -EINVAL;
+}
+
+static const struct iio_chan_spec adl8113_channels[] = {
+	{
+		.type = IIO_VOLTAGE,
+		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_HARDWAREGAIN),
+	},
+};
+
+static int adl8113_read_raw(struct iio_dev *indio_dev,
+			    struct iio_chan_spec const *chan,
+			    int *val, int *val2, long mask)
+{
+	struct adl8113_state *st = iio_priv(indio_dev);
+	unsigned int i;
+
+	switch (mask) {
+	case IIO_CHAN_INFO_HARDWAREGAIN:
+		/* Find current gain configuration */
+		for (i = 0; i < st->num_gain_configs; i++) {
+			if (st->gain_configs[i].path == st->current_path) {
+				*val = st->gain_configs[i].gain_db;
+				*val2 = 0;
+				return IIO_VAL_INT_PLUS_MICRO_DB;
+			}
+		}
+		return -EINVAL;
+	default:
+		return -EINVAL;
+	}
+}
+
+static int adl8113_write_raw(struct iio_dev *indio_dev,
+			     struct iio_chan_spec const *chan,
+			     int val, int val2, long mask)
+{
+	struct adl8113_state *st = iio_priv(indio_dev);
+	int config_idx;
+
+	switch (mask) {
+	case IIO_CHAN_INFO_HARDWAREGAIN:
+		if (val2 != 0)
+			return -EINVAL;
+
+		config_idx = adl8113_find_gain_config(st, val);
+		if (config_idx < 0)
+			return config_idx;
+
+		return adl8113_set_path(st, st->gain_configs[config_idx].path);
+	default:
+		return -EINVAL;
+	}
+}
+
+static const struct iio_info adl8113_info = {
+	.read_raw = adl8113_read_raw,
+	.write_raw = adl8113_write_raw,
+};
+
+static int adl8113_init_gain_configs(struct device *dev, struct adl8113_state *st)
+{
+	int external_a_gain, external_b_gain;
+	unsigned int i;
+
+	/*
+	 * Allocate for all 4 possible paths:
+	 * - Internal amp and bypass (always present)
+	 * - External bypass A and B (optional if configured)
+	 */
+	st->gain_configs = devm_kcalloc(dev, 4, sizeof(*st->gain_configs),
+					GFP_KERNEL);
+	if (!st->gain_configs)
+		return -ENOMEM;
+
+	/* Start filling the gain configurations with data */
+	i = 0;
+
+	/* Always include internal amplifier (14dB) */
+	st->gain_configs[i++] = (struct adl8113_gain_config) {
+		.path = ADL8113_INTERNAL_AMP,
+		.gain_db = 14,
+	};
+
+	/* Always include internal bypass (-2dB insertion loss) */
+	st->gain_configs[i++] = (struct adl8113_gain_config) {
+		.path = ADL8113_INTERNAL_BYPASS,
+		.gain_db = -2,
+	};
+
+	/* Add external bypass A if configured */
+	if (!device_property_read_u32(dev, "adi,external-bypass-a-gain-db",
+				      &external_a_gain)) {
+		st->gain_configs[i++] = (struct adl8113_gain_config) {
+			.path = ADL8113_EXTERNAL_A,
+			.gain_db = external_a_gain,
+		};
+	}
+
+	/* Add external bypass B if configured */
+	if (!device_property_read_u32(dev, "adi,external-bypass-b-gain-db",
+				      &external_b_gain)) {
+		st->gain_configs[i++] = (struct adl8113_gain_config) {
+			.path = ADL8113_EXTERNAL_B,
+			.gain_db = external_b_gain,
+		};
+	}
+
+	st->num_gain_configs = i;
+
+	return 0;
+}
+
+static int adl8113_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct adl8113_state *st;
+	struct iio_dev *indio_dev;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	st = iio_priv(indio_dev);
+
+	st->gpios = devm_gpiod_get_array(dev, "ctrl", GPIOD_OUT_LOW);
+	if (IS_ERR(st->gpios))
+		return dev_err_probe(dev, PTR_ERR(st->gpios),
+				     "failed to get control GPIOs\n");
+
+	if (st->gpios->ndescs != 2)
+		return dev_err_probe(dev, -EINVAL,
+				     "expected 2 control GPIOs, got %u\n",
+				     st->gpios->ndescs);
+
+	ret = devm_regulator_bulk_get_enable(dev,
+					     ARRAY_SIZE(adl8113_supply_names),
+					     adl8113_supply_names);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "failed to get and enable supplies\n");
+
+	/* Initialize gain configurations from devicetree */
+	ret = adl8113_init_gain_configs(dev, st);
+	if (ret)
+		return ret;
+
+	/* Initialize to internal amplifier path (14dB) */
+	ret = adl8113_set_path(st, ADL8113_INTERNAL_AMP);
+	if (ret)
+		return ret;
+
+	indio_dev->info = &adl8113_info;
+	indio_dev->name = "adl8113";
+	indio_dev->channels = adl8113_channels;
+	indio_dev->num_channels = ARRAY_SIZE(adl8113_channels);
+
+	return devm_iio_device_register(dev, indio_dev);
+}
+
+static const struct of_device_id adl8113_of_match[] = {
+	{ .compatible = "adi,adl8113" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, adl8113_of_match);
+
+static struct platform_driver adl8113_driver = {
+	.driver = {
+		.name = "adl8113",
+		.of_match_table = adl8113_of_match,
+	},
+	.probe = adl8113_probe,
+};
+module_platform_driver(adl8113_driver);
+
+MODULE_AUTHOR("Antoniu Miclaus <antoniu.miclaus@analog.com>");
+MODULE_DESCRIPTION("Analog Devices ADL8113 Low Noise Amplifier");
+MODULE_LICENSE("GPL");
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v7 0/2] iio: amplifiers: add support for ADL8113 Low Noise Amplifier
  2025-12-12 15:38 [PATCH v7 0/2] iio: amplifiers: add support for ADL8113 Low Noise Amplifier Antoniu Miclaus
  2025-12-12 15:38 ` [PATCH v7 1/2] dt-bindings: iio: amplifiers: add adl8113 Antoniu Miclaus
  2025-12-12 15:38 ` [PATCH v7 2/2] iio: amplifiers: adl8113: add driver support Antoniu Miclaus
@ 2025-12-13 16:28 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2025-12-13 16:28 UTC (permalink / raw)
  To: Antoniu Miclaus
  Cc: Lars-Peter Clausen, Michael Hennerich, David Lechner,
	Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-iio, devicetree, linux-kernel

On Fri, 12 Dec 2025 17:38:24 +0200
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:

> This patch series adds support for the Analog Devices ADL8113, a 10MHz to 12GHz
> Low Noise Amplifier with integrated bypass switches.
> 
> The ADL8113 provides four operation modes controlled by two GPIO pins:
> - Internal Amplifier (14dB gain)
> - Internal Bypass (-2dB insertion loss)
> - External Bypass A (configurable gain) - Signal routes from RFIN to OUT_A and from IN_A to RFOUT
> - External Bypass B (configurable gain) - Signal routes from RFIN to OUT_B and from IN_B to RFOUT

Applied to the testing branch of iio.git.

Thanks,

Jonathan

> 
> The driver allows selecting between these paths via the IIO hardwaregain attribute,
> with optional external amplifier gains configured through device tree properties.
> 
> Antoniu Miclaus (2):
>   dt-bindings: iio: amplifiers: add adl8113
>   iio: amplifiers: adl8113: add driver support
> 
>  .../bindings/iio/amplifiers/adi,adl8113.yaml  |  87 ++++++
>  drivers/iio/amplifiers/Kconfig                |  12 +
>  drivers/iio/amplifiers/Makefile               |   1 +
>  drivers/iio/amplifiers/adl8113.c              | 269 ++++++++++++++++++
>  4 files changed, 369 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/amplifiers/adi,adl8113.yaml
>  create mode 100644 drivers/iio/amplifiers/adl8113.c
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-13 16:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-12 15:38 [PATCH v7 0/2] iio: amplifiers: add support for ADL8113 Low Noise Amplifier Antoniu Miclaus
2025-12-12 15:38 ` [PATCH v7 1/2] dt-bindings: iio: amplifiers: add adl8113 Antoniu Miclaus
2025-12-12 15:38 ` [PATCH v7 2/2] iio: amplifiers: adl8113: add driver support Antoniu Miclaus
2025-12-13 16:28 ` [PATCH v7 0/2] iio: amplifiers: add support for ADL8113 Low Noise Amplifier Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®