From nobody Sun Feb 8 15:53:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA9D1332904; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; cv=none; b=E6fvmpm76j/+r8snu/Pv1BnOOZVQmKFbJmhULRA1wzbHipU6FigfFGqdpsW0gaKxPZ7TYCeTKaTMLSvdr0ib6EZh6PTcm+v4OGVTcQeigGM4x+34mBLL8PNZX+vv1912gAJY5MgN5bvmGHHGueGaIeb+ndTp18JifH5AhtHCttw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; c=relaxed/simple; bh=a5QjQ3PG7ITD2hiQFfp+OrtAgisDTZc/xGs1de1sIPU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NEK5XJMgajGokDQd8RKdMTFNfK+3B6V7iw+afSY74kWVQWUWhnrQAPAou6uppfS8N4U6jGu71ylTLoKTfdNvDDZJOuLWGCwsfkR/2YvjUPgVIGrDfzZl8BGRCTl6gH0tuoNFgyqYcbm5qaydZVYmLxa9WBxqlSSnXvJuEdRKEyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hh3rwkku; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hh3rwkku" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6CDFFC2BC86; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769436113; bh=a5QjQ3PG7ITD2hiQFfp+OrtAgisDTZc/xGs1de1sIPU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=hh3rwkkusjv65vYfvTJwSFsBr3QOki7esd2YuyOyRcnGbOgh/Gfg4mHA6abBytebY 0FBtJS5zYXGaoksSyRcPMyMftmGN+OYhI0CfZyAwhK5R6xFBGZRXhCYAH1qolNvl6W BcIApTesJritei5L0wWY3BX2qZjUqb7qQcPg1uSaateGSolOKNqAJoU2heAql66ril GIu1MRQgtZta9Fp9Uy1zOf2Vh9a7oMh9wu1HAxCQbYV3d0LaEONLWIN5mqEFBMAmxW uu5+g/b94GYVXObM97uyorcxuv7N/+WEksPHSZ93C0QGVx0FC3sbYIOjSWvC8O8Qsb 45XlbpqhCDk7Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57BC4D13C19; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 26 Jan 2026 13:51:02 +0000 Subject: [PATCH v2 1/6] MAINTAINERS: Add missing maintainer entry for AD8366 driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-iio-ad8366-update-v2-1-c9a4d31aeb01@analog.com> References: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> In-Reply-To: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769436111; l=890; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=ET7QWwvR/DLNtNfKbs9BRAfqEi8TYdOGcMvnzqQgSnQ=; b=jSsUuX9xPZJUQNsfsp5b10Uwe6oMsNtjLIyTGEVPdB2Zg0RKllfJbGOeu/0YOTsbwv8oPllRZ v7x7IWd+knPADwXYXe89Oau+HYilM+UXGHsUlYCLdW+FPp8tc040DIt X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Add maintainers entry for drivers/iio/amplifiers/ad8366.c Signed-off-by: Rodrigo Alencar --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 70163f939602..8b5bb7030fa6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1583,6 +1583,14 @@ W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml F: drivers/iio/adc/ad7780.c =20 +ANALOG DEVICES INC AD8366 DRIVER +M: Michael Hennerich +M: Rodrigo Alencar +L: linux-iio@vger.kernel.org +S: Supported +W: https://ez.analog.com/linux-software-drivers +F: drivers/iio/amplifiers/ad8366.c + ANALOG DEVICES INC AD9467 DRIVER M: Michael Hennerich M: Nuno Sa --=20 2.43.0 From nobody Sun Feb 8 15:53:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAB143385B2; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; cv=none; b=uoRz3S3DFh8zGdWIYLUDVrafyHtlgmCeBw3rXtcpuBgaV73v0S6qawCwy0Sj7Hbx8SHEzpBUQtnJEeq3FMeqARSu1me/xZBPn7ypm3JITgWDthV3gHNuaHKrSkJaELrTMqge/6TjEN1CwM19z9W88AdJEIIPttIp7sTfmhmdXLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; c=relaxed/simple; bh=lUrvkbVAkhcasr7sLxxFFv65MuvFiA8vFFbwSu7C8C8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qG4ifOXjF8slRHnh5a7sDXlxVqPMf3hf/qW/93epz7LMJUM9Sg0j2w/KRztmtoBeT5h/RWbxxGtk2e3zgRWjQ7aP+1NTA/iilgLf10pSS7hkNKkoj8cMB/mhSRUlrmW9e7EdC8K5zw4SGwJ6V6yN/7bdLLmHFjC6VCWa7VrqYXk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H3hmLCHx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H3hmLCHx" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7CE6CC2BCB0; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769436113; bh=lUrvkbVAkhcasr7sLxxFFv65MuvFiA8vFFbwSu7C8C8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=H3hmLCHxXx2MFE7YC2UqIjfFbRYy4WJwp0tvJ7BjEVzMoaS27t7kkt23jB4yvyVsy /g3mmbw6+9QmYuRRMCrhAPIHua5V2NLa8n2mx3h4ujwK3h227M9iV93pf73TqgATA9 yGjt82RKE6zji+IezV6MiRYl5zZ8cdZqO8pKE9HnpR70XnztHh4t0ckxKrwNndT0gi T5KsuM80jbxI3DuYOZCK+rAmXHD2Utc1Dsa9j8nJ7ZrZsUxQhD97cpLWiaq+Xw2nf/ Fsn4+yx3zQNx7vu4JQCIyKaXiGfIjD6z0Io9F3xoKr+rsZz888ecfdfnWX3S8yVYfx cB1btbnBqTFCA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68E2AD13C1B; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 26 Jan 2026 13:51:03 +0000 Subject: [PATCH v2 2/6] dt-bindings: iio: amplifiers: Add AD8366 support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-iio-ad8366-update-v2-2-c9a4d31aeb01@analog.com> References: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> In-Reply-To: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769436111; l=2610; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=PH30WSr8qpiolFuH2hsqx+jrXGR0KzrfQM8KgsHyz8Q=; b=JcPFr/Gu8SY4SPvzzEjP7VQraWwBjQXjUTHeQehJT5ayaH+75nBdTyKdmUcgcYikDu49lFqK/ Ha0SwqEVu0UBH4qG56bEQ0jPtL5ob+ECvm9UZcAsg7QsW7BhD90kVFT X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Add device tree binding documentation for amplifiers and digital attenuators. This covers different device variants with similar SPI control. Signed-off-by: Rodrigo Alencar --- .../bindings/iio/amplifiers/adi,ad8366.yaml | 68 ++++++++++++++++++= ++++ MAINTAINERS | 1 + 2 files changed, 69 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.ya= ml b/Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.yaml new file mode 100644 index 000000000000..02f790fd73d7 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.yaml @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/amplifiers/adi,ad8366.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AD8366 and similar Gain Amplifiers and Digital Attenuators + +maintainers: + - Michael Hennerich + - Rodrigo Alencar + +description: + Digital Variable Gain Amplifiers (VGAs) and Digital Attenuators with + SPI interface. + +properties: + compatible: + enum: + - adi,ad8366 + - adi,ada4961 + - adi,adl5240 + - adi,adrf5720 + - adi,adrf5730 + - adi,adrf5731 + - adi,hmc271a + - adi,hmc792a + - adi,hmc1018a + - adi,hmc1019a + - adi,hmc1119 + + reg: + maxItems: 1 + + vcc-supply: + description: Regulator that provides power to the device. + + reset-gpios: + maxItems: 1 + + enable-gpios: + maxItems: 1 + +required: + - compatible + - reg + - vcc-supply + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples: + - | + #include + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + amplifier@0 { + compatible =3D "adi,ad8366"; + reg =3D <0>; + spi-max-frequency =3D <1000000>; + vcc-supply =3D <&vcc_3v3>; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index 8b5bb7030fa6..c3403ae478b7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1589,6 +1589,7 @@ M: Rodrigo Alencar L: linux-iio@vger.kernel.org S: Supported W: https://ez.analog.com/linux-software-drivers +F: Documentation/devicetree/bindings/iio/amplifiers/adi,ad8366.yaml F: drivers/iio/amplifiers/ad8366.c =20 ANALOG DEVICES INC AD9467 DRIVER --=20 2.43.0 From nobody Sun Feb 8 15:53:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3E9F33BBC4; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; cv=none; b=m/ylF9PXbTyytoFZZCxnA6IqONt7K4Wnx7ISDmMcce65GkrKCAljGw2ObYwx+hI9BTikuta9VCWtQ4Nnr0ktk+cls1tIf9HfbvnfL/YZmez/76xhRhscvmBGnCCd5MQnf4Oosr2FZ0TP2YN9o9tvlIowFslNFj3KUFzYgAAXrlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; c=relaxed/simple; bh=NIUoV8JQngN+NzuxFM8eg0SbnCws9nM7RSFj26CxTrM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Rgo2BX8ThlXThnjtm1fOqn2SdjhbODlNH9Evk7fJPAgv3O1vHdKUT2LKdJDwoJadbz9zDiVQ6KMpvr2QDlZn5kc81YyjCT5fx5lcSwoAe1xW3mD7ZRZsDQotCHZ5fBi085xJRpqwL9rmIsFSe0EZTq04PvMN4adPxQGQga9VcF8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kn1Nm7SX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kn1Nm7SX" Received: by smtp.kernel.org (Postfix) with ESMTPS id 87B1FC2BCB3; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769436113; bh=NIUoV8JQngN+NzuxFM8eg0SbnCws9nM7RSFj26CxTrM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=kn1Nm7SXQRL2tl0Fno9UgeAJ/sphzAOj0FrZFrn+4pt77jhYPsP/6wm91d+zdEPbK KGj+O/FDtCgcaW8EhLjnfQ0Hfr4RQ9HcnyK7XcIn/gX7yiOlgZiudTvfxGLHmabesy dW5fNU67QDhmzf/Q9VgaZwEn3kQxeSYnsiAV3JwKUtr+RvGaZ1EDGU76ZW5iqLh/Zp uG+Mf4jDhCmDgOOKXB6Kx6qTz0IGpLnpuzouIgzy7E2yJbtp8VRNWc/+pPsbIWuZme 795pTARBXgNiMaFRCAyac9f5etFkT39AXUDDhgqKwyB71VkVZN3j9cfJtSYPUxllwS yePuOw2ZQ9Tew== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78B44D13C1A; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 26 Jan 2026 13:51:04 +0000 Subject: [PATCH v2 3/6] iio: amplifiers: ad8366: refactor device resource management Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-iio-ad8366-update-v2-3-c9a4d31aeb01@analog.com> References: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> In-Reply-To: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769436111; l=3912; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=MSyQPvX4zNZ9Tempwgh6myGBaPDft1zW3aPPK5Ky45k=; b=iRrnsTBOCGHBh+cGIhPDTQxDnpG8Q7e5JRwKzVbTLfKy/FyOA9//ebZnMa/kSc9WypPuMuqm8 HLUaGeXuUF1DmpKrnJ1qMgxo6F1Z7PHxsf0zA6puwETxvAtN5LbAhVl X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Adhere modern device resource management with the following: - Voltage regulator managed and enabled internally; - Proper mutex lifecycle with devm_mutex_init(), replacing mutex_init(); - IIO device registration handled with devm_iio_device_register(); - removal of goto's from the probe function; - ad8366_remove() removed as it is not needed anymore; Also, dev_err_probe() is used to report probe errors with created local device pointer. Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 60 ++++++++++++-------------------------= ---- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index d06ac786501c..0f3fc79ebbf3 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -40,7 +40,6 @@ struct ad8366_info { =20 struct ad8366_state { struct spi_device *spi; - struct regulator *reg; struct mutex lock; /* protect sensor state */ struct gpio_desc *reset_gpio; unsigned char ch[2]; @@ -245,25 +244,25 @@ static const struct iio_chan_spec ada4961_channels[] = =3D { =20 static int ad8366_probe(struct spi_device *spi) { + struct device *dev =3D &spi->dev; struct iio_dev *indio_dev; struct ad8366_state *st; int ret; =20 - indio_dev =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); if (indio_dev =3D=3D NULL) return -ENOMEM; =20 st =3D iio_priv(indio_dev); =20 - st->reg =3D devm_regulator_get(&spi->dev, "vcc"); - if (!IS_ERR(st->reg)) { - ret =3D regulator_enable(st->reg); - if (ret) - return ret; - } + ret =3D devm_regulator_get_enable(dev, "vcc"); + if (ret) + return dev_err_probe(dev, ret, "Failed to get regulator\n"); + + ret =3D devm_mutex_init(dev, &st->lock); + if (ret) + return ret; =20 - spi_set_drvdata(spi, indio_dev); - mutex_init(&st->lock); st->spi =3D spi; st->type =3D spi_get_device_id(spi)->driver_data; =20 @@ -276,18 +275,16 @@ static int ad8366_probe(struct spi_device *spi) case ID_ADL5240: case ID_HMC792: case ID_HMC1119: - st->reset_gpio =3D devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT= _HIGH); - if (IS_ERR(st->reset_gpio)) { - ret =3D PTR_ERR(st->reset_gpio); - goto error_disable_reg; - } + st->reset_gpio =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(st->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(st->reset_gpio), + "Failed to get reset GPIO\n"); + indio_dev->channels =3D ada4961_channels; indio_dev->num_channels =3D ARRAY_SIZE(ada4961_channels); break; default: - dev_err(&spi->dev, "Invalid device ID\n"); - ret =3D -EINVAL; - goto error_disable_reg; + return dev_err_probe(dev, -EINVAL, "Invalid device ID\n"); } =20 st->info =3D &ad8366_infos[st->type]; @@ -297,31 +294,9 @@ static int ad8366_probe(struct spi_device *spi) =20 ret =3D ad8366_write(indio_dev, 0, 0); if (ret < 0) - goto error_disable_reg; + return dev_err_probe(dev, ret, "failed to write initial gain\n"); =20 - ret =3D iio_device_register(indio_dev); - if (ret) - goto error_disable_reg; - - return 0; - -error_disable_reg: - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); - - return ret; -} - -static void ad8366_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev =3D spi_get_drvdata(spi); - struct ad8366_state *st =3D iio_priv(indio_dev); - struct regulator *reg =3D st->reg; - - iio_device_unregister(indio_dev); - - if (!IS_ERR(reg)) - regulator_disable(reg); + return devm_iio_device_register(dev, indio_dev); } =20 static const struct spi_device_id ad8366_id[] =3D { @@ -339,7 +314,6 @@ static struct spi_driver ad8366_driver =3D { .name =3D KBUILD_MODNAME, }, .probe =3D ad8366_probe, - .remove =3D ad8366_remove, .id_table =3D ad8366_id, }; =20 --=20 2.43.0 From nobody Sun Feb 8 15:53:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3FE733BBCB; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; cv=none; b=HOrMc8gmOrQHjHYmj2hQBun1qTcySP/n1bbL4SALLJ6JBfRlGTqZjv/mgL+KYivcj5apTO66IAC/2G1VPzSZRR+2EbrUn/FKX1GpsTHSevni3Lb5dBZxCdcx2bJzGGRImtotXOlURaqypN9RC7JUzlG4NRs0yxR+mLX0RmIISgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; c=relaxed/simple; bh=RE+ZfgECqSmAtddy46Bf4SfXaAmm7UsS6vY1rlFwuhk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EYVzDQMyOdnZggkACgD1BPYXGMG2I/FyMSzkBLKgu8eOau4k62XgO1JkJ3bKg3dW4Xq4jtUjPn3F+bYpgvBx4B99SaBAuXDfcWJAHqH/hqEvFKuzQM3AOiPG15Mo2N7L1XK5zCvSSjv8o/9soce5tkV1UmNMOnDTCI3bXrjUB9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e6/646VA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e6/646VA" Received: by smtp.kernel.org (Postfix) with ESMTPS id 968E7C2BCB5; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769436113; bh=RE+ZfgECqSmAtddy46Bf4SfXaAmm7UsS6vY1rlFwuhk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=e6/646VADqi7nopZ8OV5kyED0TJIVBhn99hukhSaVN9olcSj3ObHM17KJvY5uYqal nCrau3AGjEaHx/oJ6s7dsGuxfLcLnj2od1JxSOLT4piKR4m8ccFiwpE9C+I3E+3oTQ 8bOa7KfZUGnAJFQ+dJuw+NQRORB6G+iAYNElmD1d4L/RKh9fW9SJXho7S+kwMvoqoH X+kuaNngZznfUiEWiUxdXIngjL7b3Zy3M9h2yxTSnltTfT8BmiZRYZZTsWAf4kf6ml rMdlXivBlCn8KXi6NN/0LE7pIBMxjZsuUUx8/W9jGjh8FsmYoTO4SuXYo038gAGlBd RQhHYD5qMQbtQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89A54D13C1D; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 26 Jan 2026 13:51:05 +0000 Subject: [PATCH v2 4/6] iio: amplifiers: ad8366: add device tree support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-iio-ad8366-update-v2-4-c9a4d31aeb01@analog.com> References: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> In-Reply-To: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769436111; l=10446; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=BlhuFj3wy+WCVV4cdkTh82AUdgR5J3RfyGbE+fBPHkI=; b=g2v3Zi/49Ave97BBzPEONFJMzj6pe/w6jUZYWJMDIBQeHJQsHjP2JCBdL2ZH6vTdialugsjnU YHj0x5NtKx+CDUK9294AsBS6M5c0vqq/2DNThq/rYCjB/I3LEsCYql4 X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Add device-tree support by dropping the enum ID in favor of extended chip info table, containing: - gain_step, indicating with sign the start of the code range; - num_channels, to indicate the number IIO channels; - pack_code() function to describe how SPI buffer is populated; With this, switch cases on the device type were dropped: - probe() function adjusted accordingly; - Simplified read_raw() and write_raw() callbacks; - mutex_lock()/mutex_unlock() replaced for guard(mutex)() to allow moving to early returns; Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 259 +++++++++++++++++-------------------= ---- 1 file changed, 107 insertions(+), 152 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 0f3fc79ebbf3..134188db2e15 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -11,6 +11,7 @@ * Copyright 2012-2019 Analog Devices Inc. */ =20 +#include #include #include #include @@ -20,22 +21,20 @@ #include #include #include +#include #include =20 #include #include =20 -enum ad8366_type { - ID_AD8366, - ID_ADA4961, - ID_ADL5240, - ID_HMC792, - ID_HMC1119, -}; +struct ad8366_state; =20 struct ad8366_info { int gain_min; int gain_max; + int gain_step; + int num_channels; + size_t (*pack_code)(struct ad8366_state *st); }; =20 struct ad8366_state { @@ -43,7 +42,6 @@ struct ad8366_state { struct mutex lock; /* protect sensor state */ struct gpio_desc *reset_gpio; unsigned char ch[2]; - enum ad8366_type type; const struct ad8366_info *info; /* * DMA (thus cache coherency maintenance) may require the @@ -52,108 +50,91 @@ struct ad8366_state { unsigned char data[2] __aligned(IIO_DMA_MINALIGN); }; =20 -static const struct ad8366_info ad8366_infos[] =3D { - [ID_AD8366] =3D { - .gain_min =3D 4500, - .gain_max =3D 20500, - }, - [ID_ADA4961] =3D { - .gain_min =3D -6000, - .gain_max =3D 15000, - }, - [ID_ADL5240] =3D { - .gain_min =3D -11500, - .gain_max =3D 20000, - }, - [ID_HMC792] =3D { - .gain_min =3D -15750, - .gain_max =3D 0, - }, - [ID_HMC1119] =3D { - .gain_min =3D -31750, - .gain_max =3D 0, - }, +static size_t ad8366_pack_code(struct ad8366_state *st) +{ + u8 ch_a =3D bitrev8(st->ch[0] & 0x3F); + u8 ch_b =3D bitrev8(st->ch[1] & 0x3F); + + st->data[0] =3D ch_b >> 4; + st->data[1] =3D (ch_b << 4) | (ch_a >> 2); + return 2; +} + +static size_t simple_pack_code(struct ad8366_state *st) +{ + st->data[0] =3D st->ch[0]; + return 1; +} + +static const struct ad8366_info ad8366_chip_info =3D { + .gain_min =3D 4500, + .gain_max =3D 20500, + .gain_step =3D 253, + .num_channels =3D 2, + .pack_code =3D ad8366_pack_code, }; =20 -static int ad8366_write(struct iio_dev *indio_dev, - unsigned char ch_a, unsigned char ch_b) +static const struct ad8366_info ada4961_chip_info =3D { + .gain_min =3D -6000, + .gain_max =3D 15000, + .gain_step =3D -1000, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, +}; + +static const struct ad8366_info adl5240_chip_info =3D { + .gain_min =3D -11500, + .gain_max =3D 20000, + .gain_step =3D 500, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, +}; + +static const struct ad8366_info hmc792_chip_info =3D { + .gain_min =3D -15750, + .gain_max =3D 0, + .gain_step =3D 250, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, +}; + +static const struct ad8366_info hmc1119_chip_info =3D { + .gain_min =3D -31750, + .gain_max =3D 0, + .gain_step =3D -250, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, +}; + +static int ad8366_write_code(struct ad8366_state *st) { - struct ad8366_state *st =3D iio_priv(indio_dev); - int ret; + const struct ad8366_info *inf =3D st->info; =20 - switch (st->type) { - case ID_AD8366: - ch_a =3D bitrev8(ch_a & 0x3F); - ch_b =3D bitrev8(ch_b & 0x3F); - - st->data[0] =3D ch_b >> 4; - st->data[1] =3D (ch_b << 4) | (ch_a >> 2); - break; - case ID_ADA4961: - st->data[0] =3D ch_a & 0x1F; - break; - case ID_ADL5240: - st->data[0] =3D (ch_a & 0x3F); - break; - case ID_HMC792: - case ID_HMC1119: - st->data[0] =3D ch_a; - break; - } - - ret =3D spi_write(st->spi, st->data, indio_dev->num_channels); - if (ret < 0) - dev_err(&indio_dev->dev, "write failed (%d)", ret); - - return ret; + return spi_write(st->spi, st->data, inf->pack_code(st)); } =20 static int ad8366_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, - long m) + long mask) { struct ad8366_state *st =3D iio_priv(indio_dev); - int ret; - int code, gain =3D 0; + const struct ad8366_info *inf =3D st->info; + int gain =3D inf->gain_step > 0 ? inf->gain_min : inf->gain_max; =20 - mutex_lock(&st->lock); - switch (m) { + guard(mutex)(&st->lock); + + switch (mask) { case IIO_CHAN_INFO_HARDWAREGAIN: - code =3D st->ch[chan->channel]; - - switch (st->type) { - case ID_AD8366: - gain =3D code * 253 + 4500; - break; - case ID_ADA4961: - gain =3D 15000 - code * 1000; - break; - case ID_ADL5240: - gain =3D 20000 - 31500 + code * 500; - break; - case ID_HMC792: - gain =3D -1 * code * 500; - break; - case ID_HMC1119: - gain =3D -1 * code * 250; - break; - } - - /* Values in dB */ + gain +=3D inf->gain_step * st->ch[chan->channel]; *val =3D gain / 1000; *val2 =3D (gain % 1000) * 1000; - - ret =3D IIO_VAL_INT_PLUS_MICRO_DB; - break; + return IIO_VAL_INT_PLUS_MICRO_DB; default: - ret =3D -EINVAL; + return -EINVAL; } - mutex_unlock(&st->lock); - - return ret; -}; +} =20 static int ad8366_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, @@ -163,10 +144,8 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, { struct ad8366_state *st =3D iio_priv(indio_dev); const struct ad8366_info *inf =3D st->info; - int code =3D 0, gain; - int ret; + int code, gain, gain_base; =20 - /* Values in dB */ if (val < 0) gain =3D (val * 1000) - (val2 / 1000); else @@ -175,36 +154,18 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, if (gain > inf->gain_max || gain < inf->gain_min) return -EINVAL; =20 - switch (st->type) { - case ID_AD8366: - code =3D (gain - 4500) / 253; - break; - case ID_ADA4961: - code =3D (15000 - gain) / 1000; - break; - case ID_ADL5240: - code =3D ((gain - 500 - 20000) / 500) & 0x3F; - break; - case ID_HMC792: - code =3D (abs(gain) / 500) & 0x3F; - break; - case ID_HMC1119: - code =3D (abs(gain) / 250) & 0x7F; - break; - } + gain_base =3D inf->gain_step > 0 ? inf->gain_min : inf->gain_max; + code =3D DIV_ROUND_CLOSEST(gain - gain_base, inf->gain_step); + + guard(mutex)(&st->lock); =20 - mutex_lock(&st->lock); switch (mask) { case IIO_CHAN_INFO_HARDWAREGAIN: st->ch[chan->channel] =3D code; - ret =3D ad8366_write(indio_dev, st->ch[0], st->ch[1]); - break; + return ad8366_write_code(st); default: - ret =3D -EINVAL; + return -EINVAL; } - mutex_unlock(&st->lock); - - return ret; } =20 static int ad8366_write_raw_get_fmt(struct iio_dev *indio_dev, @@ -238,10 +199,6 @@ static const struct iio_chan_spec ad8366_channels[] = =3D { AD8366_CHAN(1), }; =20 -static const struct iio_chan_spec ada4961_channels[] =3D { - AD8366_CHAN(0), -}; - static int ad8366_probe(struct spi_device *spi) { struct device *dev =3D &spi->dev; @@ -264,35 +221,22 @@ static int ad8366_probe(struct spi_device *spi) return ret; =20 st->spi =3D spi; - st->type =3D spi_get_device_id(spi)->driver_data; + st->info =3D spi_get_device_match_data(spi); + if (!st->info) + return dev_err_probe(dev, -EINVAL, "Invalid device info\n"); =20 - switch (st->type) { - case ID_AD8366: - indio_dev->channels =3D ad8366_channels; - indio_dev->num_channels =3D ARRAY_SIZE(ad8366_channels); - break; - case ID_ADA4961: - case ID_ADL5240: - case ID_HMC792: - case ID_HMC1119: - st->reset_gpio =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); - if (IS_ERR(st->reset_gpio)) - return dev_err_probe(dev, PTR_ERR(st->reset_gpio), - "Failed to get reset GPIO\n"); + st->reset_gpio =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(st->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(st->reset_gpio), + "Failed to get reset GPIO\n"); =20 - indio_dev->channels =3D ada4961_channels; - indio_dev->num_channels =3D ARRAY_SIZE(ada4961_channels); - break; - default: - return dev_err_probe(dev, -EINVAL, "Invalid device ID\n"); - } - - st->info =3D &ad8366_infos[st->type]; indio_dev->name =3D spi_get_device_id(spi)->name; indio_dev->info =3D &ad8366_info; indio_dev->modes =3D INDIO_DIRECT_MODE; + indio_dev->channels =3D ad8366_channels; + indio_dev->num_channels =3D st->info->num_channels; =20 - ret =3D ad8366_write(indio_dev, 0, 0); + ret =3D ad8366_write_code(st); if (ret < 0) return dev_err_probe(dev, ret, "failed to write initial gain\n"); =20 @@ -300,18 +244,29 @@ static int ad8366_probe(struct spi_device *spi) } =20 static const struct spi_device_id ad8366_id[] =3D { - {"ad8366", ID_AD8366}, - {"ada4961", ID_ADA4961}, - {"adl5240", ID_ADL5240}, - {"hmc792a", ID_HMC792}, - {"hmc1119", ID_HMC1119}, + {"ad8366", (kernel_ulong_t)&ad8366_chip_info}, + {"ada4961", (kernel_ulong_t)&ada4961_chip_info}, + {"adl5240", (kernel_ulong_t)&adl5240_chip_info}, + {"hmc792a", (kernel_ulong_t)&hmc792_chip_info}, + {"hmc1119", (kernel_ulong_t)&hmc1119_chip_info}, { } }; MODULE_DEVICE_TABLE(spi, ad8366_id); =20 +static const struct of_device_id ad8366_of_match[] =3D { + { .compatible =3D "adi,ad8366", .data =3D &ad8366_chip_info }, + { .compatible =3D "adi,ada4961", .data =3D &ada4961_chip_info }, + { .compatible =3D "adi,adl5240", .data =3D &adl5240_chip_info }, + { .compatible =3D "adi,hmc792a", .data =3D &hmc792_chip_info }, + { .compatible =3D "adi,hmc1119", .data =3D &hmc1119_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(of, ad8366_of_match); + static struct spi_driver ad8366_driver =3D { .driver =3D { - .name =3D KBUILD_MODNAME, + .name =3D KBUILD_MODNAME, + .of_match_table =3D ad8366_of_match, }, .probe =3D ad8366_probe, .id_table =3D ad8366_id, --=20 2.43.0 From nobody Sun Feb 8 15:53:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3F3633BBC6; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; cv=none; b=ghTrx5UfhU8V4d/9m5Mib9Rt2O9g4fsyOoWuQ6+IrJTUktoVhSoqim70Ho13P9kJBNOUY/KGMwZbLwQ/n5CIivXjjBSzqe4yVFNNzIvpSJWQ8GXLRHbiEFObk311WCfZV6twVrBNu3jAHwvnaLXosJBz+ezQwrPJsADk+DzdP0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; c=relaxed/simple; bh=nTkWrIvUUzvgq/OPnvUxlYx4rVHLhmAGhazBXvRvIR4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DBqp/jrfGz4nl29xFQChrN7q2t7FjT1zpD2vHwdebbKUwE7he2KRdaFNsTlyfZH0CTmuVn1255kb1msqsgm38RwW8xCPmEaKL5qMmfz81lcblr9hYxk1JvLp4bn3h2KJVjmStcnzfO5dBqoyznsYS8qffsGlR9XpffMl/3Uh4E8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X6vasYAz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X6vasYAz" Received: by smtp.kernel.org (Postfix) with ESMTPS id A9902C2BCB2; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769436113; bh=nTkWrIvUUzvgq/OPnvUxlYx4rVHLhmAGhazBXvRvIR4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=X6vasYAzT8NAwmlHOMEYYbpRzBVpMtGOaC8jtB9aptlRpExSsetoWJS5l1qnR9sgA 9kpwhhAkQV14Qf7jjM4P2LWRg/fIS/voZrQbGoNdmdw1nH3hmEX0rqsonofOmz5HmK JQYFgCq0tmyB3lEzGx+aVHaPFFilP5WfPNYRmmL9rfxvCemk72VoPUiHhlK8BWQvgR ZyVT/sdgm+3O8hc/uviO1mR85b5k1FquLHzjjI+wlpxLK4yy0yLtQaExiL0Whn8kQA Ri//prfGiQFOFFeXmONOoH55JLcZ7iUrZOqq6fYoswLwmtOuICYP7EobAjbt8F+g/x 7EmvMomJO9NEA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0A74D13C1E; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 26 Jan 2026 13:51:06 +0000 Subject: [PATCH v2 5/6] iio: amplifiers: ad8366: consume enable gpio Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-iio-ad8366-update-v2-5-c9a4d31aeb01@analog.com> References: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> In-Reply-To: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769436111; l=1405; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=hjO3AF8SajGaQsSNLm/TNA2Z1sFEVvdZwYSoYv5HFf0=; b=j0iEMbB69a495oPjVHQreEuRT6rLV60FdpY1TMMc9fs/WRw6oCZPCUz+Q+4AkqDn5FdECcaxD Z2bZqDHFNV4DudgdsrwluMu8FCMsOWQ2L5f22sR+Cl+pfU6YpaXdL6K X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Some parts may consume enable GPIO to enable serial mode (HMC1119's and HMC792A P/S pin) or powerup the device (e.g. ADA4961's PWUP pin). Co-developed-by: Michael Hennerich Signed-off-by: Michael Hennerich Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/ad8366.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 134188db2e15..9ad6a628376c 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -41,6 +41,7 @@ struct ad8366_state { struct spi_device *spi; struct mutex lock; /* protect sensor state */ struct gpio_desc *reset_gpio; + struct gpio_desc *enable_gpio; unsigned char ch[2]; const struct ad8366_info *info; /* @@ -230,6 +231,11 @@ static int ad8366_probe(struct spi_device *spi) return dev_err_probe(dev, PTR_ERR(st->reset_gpio), "Failed to get reset GPIO\n"); =20 + st->enable_gpio =3D devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH= ); + if (IS_ERR(st->enable_gpio)) + return dev_err_probe(dev, PTR_ERR(st->enable_gpio), + "Failed to get enable GPIO\n"); + indio_dev->name =3D spi_get_device_id(spi)->name; indio_dev->info =3D &ad8366_info; indio_dev->modes =3D INDIO_DIRECT_MODE; --=20 2.43.0 From nobody Sun Feb 8 15:53:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCC7B33BBD4; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; cv=none; b=U7hccjcIMjOH0+pfEcseP9DPpPaM7GQh8YgPWARfZkNidvl06ZEi4zLPU7+eYxEbxsJbLxYYlpP4kYvH92BvB+Mv4jVenN/UOjc2OhZ7AV/wWHIfjjGp771UjXuF+g86tpnLuGpWSuFetX4z0HhjaPVngWEQLwOLayIvuu23lPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769436113; c=relaxed/simple; bh=6k8S+MVNujf8CVpBP7rvF3wH3BSWx2N/cmllMQPGJvM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E2D8UKi9val93EceR5fZmkDNIsE5seAFrHy/5iFC63mJka25GhSyhAbQ77Wi7KIHG4NYDYqaHjkvG9OsiFDdg/yYkJZPZ+AzqDe6UzAyIeTf8nQACFYtsBdHjsVTGsEe8YZCOBo97oWl4h4wkESCi4Er7yY81Heo3Ce1xmQZ8TI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lWQ12rSP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lWQ12rSP" Received: by smtp.kernel.org (Postfix) with ESMTPS id B994BC2BCC6; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769436113; bh=6k8S+MVNujf8CVpBP7rvF3wH3BSWx2N/cmllMQPGJvM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=lWQ12rSPOpzry418IlryCyJTXH/2BwDmZ0DADtsmYG3nc4l+rW5Mqbm6meTp8ZnLK m44Q9z3CY7HA7fAVM5xu8NliBPZWO+sY4i+rEf+wCJD5uVVWZJD9bdmuEC+RjL3V54 xsUZNhzEU+GSihNVye+fvaJGXexjOYWBJHw6Pvddx/JkCrpV8UlNHsrEDVJKgwdcIh wPpEjqSl+mJ40Mo9NO1+S1ou4A4MAg6DPSmEvJlPR+5vrERLb4t2wD3hG6xfUfwVpm d9Iy+GD7gpgUryuSYmCQ+JF6EK1NxswSk33lm/DQQNA03Zu2ea7PoZL5cxQRfhx5R8 YD7wGz9TC0PIg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFCABD13C1C; Mon, 26 Jan 2026 14:01:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Mon, 26 Jan 2026 13:51:07 +0000 Subject: [PATCH v2 6/6] iio: amplifiers: ad8366: Update device support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-iio-ad8366-update-v2-6-c9a4d31aeb01@analog.com> References: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> In-Reply-To: <20260126-iio-ad8366-update-v2-0-c9a4d31aeb01@analog.com> To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Michael Hennerich , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rodrigo Alencar , Alexandru Ardelean X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769436111; l=6385; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=cYZYdo1jsI63Nd/LYcxtiA2+53D0PuyoRYFvGABoZxk=; b=SG+43gvAVWKTS6faC3C6oXN1k3mQauE2++W11lrAB95N0ok4XS+bI1yg7gdSuedBdk0KwYt0Z Wym/czysWfcBZwnUpgqJSqgYCMXAkUvEKI5JhzKKzEZyjWM59ZYgNI1 X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar Add support for the following digital step attenuators: - HMC271A: 1dB LSB 5-Bit Digital Attenuator SMT, 0.7 - 3.7 GHz - ADRF5720: 0.5 dB LSB, 6-Bit, Digital Attenuator, 9 kHz to 40 GHz - ADRF5730: 0.5 dB LSB, 6-Bit, Digital Attenuator, 100 MHz to 40 GHz - ADRF5731: 2 dB LSB, 4-Bit, Digital Attenuator, 100 MHz to 40 GHz - HMC1018A: 1.0 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz - HMC1019A: 0.5 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz Additionally, copyright notice was updated with current year. Co-developed-by: Alexandru Ardelean Signed-off-by: Alexandru Ardelean Co-developed-by: Michael Hennerich Signed-off-by: Michael Hennerich Signed-off-by: Rodrigo Alencar --- drivers/iio/amplifiers/Kconfig | 6 ++++ drivers/iio/amplifiers/ad8366.c | 72 +++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/drivers/iio/amplifiers/Kconfig b/drivers/iio/amplifiers/Kconfig index a8a604863eed..39d280d4d437 100644 --- a/drivers/iio/amplifiers/Kconfig +++ b/drivers/iio/amplifiers/Kconfig @@ -18,7 +18,13 @@ config AD8366 AD8366 Dual-Digital Variable Gain Amplifier (VGA) ADA4961 BiCMOS RF Digital Gain Amplifier (DGA) ADL5240 Digitally controlled variable gain amplifier (VGA) + ADRF5720: 0.5 dB LSB, 6-Bit, Silicon Digital Attenuator + ADRF5730: 0.5 dB LSB, 6-Bit, Silicon Digital Attenuator + ADRF5731: 2 dB LSB, 4-Bit, Silicon Digital Attenuator + HMC271A: 1dB LSB 5-Bit Digital Attenuator SMT HMC792A 0.25 dB LSB GaAs MMIC 6-Bit Digital Attenuator + HMC1018A: 1.0 dB LSB GaAs MMIC 5-BIT Digital Attenuator + HMC1019A: 0.5 dB LSB GaAs MMIC 5-BIT Digital Attenuator HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator =20 To compile this driver as a module, choose M here: the diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad836= 6.c index 9ad6a628376c..14de0418a234 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -5,10 +5,16 @@ * AD8366 Dual-Digital Variable Gain Amplifier (VGA) * ADA4961 BiCMOS RF Digital Gain Amplifier (DGA) * ADL5240 Digitally controlled variable gain amplifier (VGA) + * ADRF5720: 0.5 dB LSB, 6-Bit, Silicon Digital Attenuator, 9 kHz to 40 = GHz + * ADRF5730: 0.5 dB LSB, 6-Bit, Silicon Digital Attenuator, 100 MHz to 4= 0 GHz + * ADRF5731: 2 dB LSB, 4-Bit, Silicon Digital Attenuator, 100 MHz to 40 = GHz + * HMC271A: 1dB LSB 5-Bit Digital Attenuator SMT, 0.7 - 3.7 GHz * HMC792A 0.25 dB LSB GaAs MMIC 6-Bit Digital Attenuator + * HMC1018A: 1.0 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz + * HMC1019A: 0.5 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz * HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator * - * Copyright 2012-2019 Analog Devices Inc. + * Copyright 2012-2026 Analog Devices Inc. */ =20 #include @@ -67,6 +73,18 @@ static size_t simple_pack_code(struct ad8366_state *st) return 1; } =20 +static size_t adrf5731_pack_code(struct ad8366_state *st) +{ + st->data[0] =3D st->ch[0] << 2; + return 1; +} + +static size_t hmc271_pack_code(struct ad8366_state *st) +{ + st->data[0] =3D bitrev8(st->ch[0] & 0x1F) >> 3; + return 1; +} + static const struct ad8366_info ad8366_chip_info =3D { .gain_min =3D 4500, .gain_max =3D 20500, @@ -91,6 +109,30 @@ static const struct ad8366_info adl5240_chip_info =3D { .pack_code =3D simple_pack_code, }; =20 +static const struct ad8366_info adrf57x0_chip_info =3D { + .gain_min =3D -31500, + .gain_max =3D 0, + .gain_step =3D -500, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, +}; + +static const struct ad8366_info adrf5731_chip_info =3D { + .gain_min =3D -30000, + .gain_max =3D 0, + .gain_step =3D -2000, + .num_channels =3D 1, + .pack_code =3D adrf5731_pack_code, +}; + +static const struct ad8366_info hmc271_chip_info =3D { + .gain_min =3D -31000, + .gain_max =3D 0, + .gain_step =3D 1000, + .num_channels =3D 1, + .pack_code =3D hmc271_pack_code, +}; + static const struct ad8366_info hmc792_chip_info =3D { .gain_min =3D -15750, .gain_max =3D 0, @@ -99,6 +141,22 @@ static const struct ad8366_info hmc792_chip_info =3D { .pack_code =3D simple_pack_code, }; =20 +static const struct ad8366_info hmc1018_chip_info =3D { + .gain_min =3D -31000, + .gain_max =3D 0, + .gain_step =3D 1000, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, +}; + +static const struct ad8366_info hmc1019_chip_info =3D { + .gain_min =3D -15500, + .gain_max =3D 0, + .gain_step =3D 500, + .num_channels =3D 1, + .pack_code =3D simple_pack_code, +}; + static const struct ad8366_info hmc1119_chip_info =3D { .gain_min =3D -31750, .gain_max =3D 0, @@ -253,7 +311,13 @@ static const struct spi_device_id ad8366_id[] =3D { {"ad8366", (kernel_ulong_t)&ad8366_chip_info}, {"ada4961", (kernel_ulong_t)&ada4961_chip_info}, {"adl5240", (kernel_ulong_t)&adl5240_chip_info}, + {"adrf5720", (kernel_ulong_t)&adrf57x0_chip_info}, + {"adrf5730", (kernel_ulong_t)&adrf57x0_chip_info}, + {"adrf5731", (kernel_ulong_t)&adrf5731_chip_info}, + {"hmc271a", (kernel_ulong_t)&hmc271_chip_info}, {"hmc792a", (kernel_ulong_t)&hmc792_chip_info}, + {"hmc1018a", (kernel_ulong_t)&hmc1018_chip_info}, + {"hmc1019a", (kernel_ulong_t)&hmc1019_chip_info}, {"hmc1119", (kernel_ulong_t)&hmc1119_chip_info}, { } }; @@ -263,7 +327,13 @@ static const struct of_device_id ad8366_of_match[] =3D= { { .compatible =3D "adi,ad8366", .data =3D &ad8366_chip_info }, { .compatible =3D "adi,ada4961", .data =3D &ada4961_chip_info }, { .compatible =3D "adi,adl5240", .data =3D &adl5240_chip_info }, + { .compatible =3D "adi,adrf5720", .data =3D &adrf57x0_chip_info }, + { .compatible =3D "adi,adrf5730", .data =3D &adrf57x0_chip_info }, + { .compatible =3D "adi,adrf5731", .data =3D &adrf5731_chip_info }, + { .compatible =3D "adi,hmc271a", .data =3D &hmc271_chip_info }, { .compatible =3D "adi,hmc792a", .data =3D &hmc792_chip_info }, + { .compatible =3D "adi,hmc1018a", .data =3D &hmc1018_chip_info }, + { .compatible =3D "adi,hmc1019a", .data =3D &hmc1019_chip_info }, { .compatible =3D "adi,hmc1119", .data =3D &hmc1119_chip_info }, { } }; --=20 2.43.0