From nobody Wed Jun 17 04:15:33 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 1247823E33D; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=dly8RE9EQh+eGo8wLdDGK3fizcx9VZtNBcqpGmR+6ezN5P4cdq4IW0OOFSQIkDkksXKNR3WIlhGWHJCG2sWcvhnmC1Eilis5kvftqGAW6eZ6/RP4sif+FhM+FLdQtB5p3Ae1gGfKakEYaosJDEsv03D4ckObhCqqxN55VXJlEGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=KW9LBaKsAszNIdyDF3YPDVS0lfnwke+MlHzKoxh0iUQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ng4BGm+Y/75Y/lIv5GaM6GD/XD/pwFP7ARw/IKph/XDtY71qOnHNWu8kKjbj1aY5wtYEoOdGU38fYh311TpvN2S5WKkcxRqI0MT1GhotbZRcl8wp3sCUjUmXd9ZRqXdk7zXI2PzQ3vuNnmbKyoTNjsHtHrMoMZoCA340GCTqtU8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cyj2e+Rb; 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="cyj2e+Rb" Received: by smtp.kernel.org (Postfix) with ESMTPS id D178BC2BCB4; Wed, 22 Apr 2026 14:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869183; bh=KW9LBaKsAszNIdyDF3YPDVS0lfnwke+MlHzKoxh0iUQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cyj2e+RbqwoMiA+2LJiDv5GP6UPSc+ogjutnXbWbI5+Yu8BVAQHFr17rRsGbZ3h91 e2IWZdPwXG4Jm/joU9kr1bAn8eb7nKs65kO7SRxVPIBCuKLU7TW98SgkPuezAFE7n9 CweYB5X/bsnXCmcloC+W0oRJo2lOLnHhgs6aLcwtUB3FRHLeBSZUnEai1fsqzCO4v+ EMJ/yRqGnP/dyb0K4Jt/aIH0WvcYdgL/ohEzHJ3RH6nSr9resDCILLPPgr5FKhlweY DPkFmt5X+CUeYPdpTJ3d2+AD3xDAmPJkfMQSOFkmsOQLNM6fFI+LhFlkN9RKJ54UAu qPEVebzKfYB8Q== 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 C252AF9EDED; Wed, 22 Apr 2026 14:46:23 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:35 +0100 Subject: [PATCH 01/22] dt-bindings: iio: dac: ad5696: extend 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: <20260422-ad5313r-iio-support-v1-1-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=1192; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=El1N/55Vq+qsAn09ahJqnZZZn0tChOeJyXjS3wCOfPE=; b=TqIPGOd3GrgXveavFWj7EsXu+bwU+jXRUWXdLzoMfkv5QNMfFP/RyLpWWDPK69vcKt5oxlaMd TJ0F1yb86WPCVgYe+iZgoginWn4D0G+/X7jUkDBMvIjVPbbiV6PPja8 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 Support for AD5316R, AD5673R, AD5675, AD5677R and AD5697R missing from the device-tree bindings documentation. These devices have different bit resolutions or different number of channels so no fallback compatibles are used. Signed-off-by: Rodrigo Alencar Acked-by: Conor Dooley --- Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml b/Do= cumentation/devicetree/bindings/iio/dac/adi,ad5696.yaml index b5a88b03dc2f..ed79323bfc93 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml @@ -16,10 +16,14 @@ properties: compatible: enum: - adi,ad5311r + - adi,ad5316r - adi,ad5337r - adi,ad5338r - adi,ad5671r + - adi,ad5673r + - adi,ad5675 - adi,ad5675r + - adi,ad5677r - adi,ad5691r - adi,ad5692r - adi,ad5693 @@ -29,6 +33,7 @@ properties: - adi,ad5695r - adi,ad5696 - adi,ad5696r + - adi,ad5697r =20 reg: maxItems: 1 --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 28265223DD4; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=hi6T7M4o3YZKhQwwaQl65mMXv388+hLMX6lW1nWKMGVm7hikeJQE2jOhvLPAsYLGbJn0hgts3r6MBoGkRt9ekfo0UNtObZGdUJBCqHukBlxcQvHQJ+xYFojub3C5hDE9PHk99BsKHx3ZCr+rT+K62JnRtwzhW1esAXj82dvNL8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=VCcoVBaBR69QBcUMk0tddJq9B7HjYpfLaX+qiyL0bgk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E+LMLNGw5R/rsIaZubEYxJJn1IQj+nMVAB2ScWhkq6Shisk7fBDnZ/RHSkLR3EAfTmlnKXHE90gOGGB5rBsVjzwx9Rq2AVP7iCeraMY+E0LdTGnZuzra/iwoIqfai/IGPntfUlKDIEsX7ir5K6SFhQWWoB+YGBWR1A4LTCV8TLs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fdyn3cat; 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="fdyn3cat" Received: by smtp.kernel.org (Postfix) with ESMTPS id DEDD4C2BCB2; Wed, 22 Apr 2026 14:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869183; bh=VCcoVBaBR69QBcUMk0tddJq9B7HjYpfLaX+qiyL0bgk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fdyn3catM7NnM0+R5Pj0ZeLaAF4SMuTDRvM2o59G2P153xktP94tBwY5Rj/j58OLj NfArRsTqSrNHAh2zzB8KelZonVDRuLis4znGKdD+c/a/kQd6nrmEXgUV88zjkIBkN0 rtPSalW5cDRNmoEtWTG3zoBJ4MEOhNosSKEtbKHtIZN9NH8v8ihJ1KvEQ1cverIayn HhbA3TkcssirMTyTFUleccQZNsZadyyOVb74i5m6xjrvDXTe81zcrgYPJBfss+U7JY TZp4OXY/hSXTWGJtfYoJJCp+h8UQ+AeGmMEGha86usfTRmDVIa7e9S4iUYdOpPhLoD lgfB7H4dikAbg== 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 D2679F9EDF1; Wed, 22 Apr 2026 14:46:23 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:36 +0100 Subject: [PATCH 02/22] dt-bindings: iio: dac: ad5696: add reset/ldac/gain gpio 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: <20260422-ad5313r-iio-support-v1-2-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=2120; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=qDXGr5kPMnSg1mp9xsUjZzi2MmbbEF4H1bMQgp9WLN8=; b=bpuElbtlIoGVy8C+o2ClPMb+s+UJ3cemjXyCpnj2XRDCW4ClPHKJlJog5ww0mtC+E1UVG/NMZ 15N6u890yWbCYrReNGIe6UVcomjnaI5bbRVqNvKEQAdzNTbSIT0Jx/y 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 GPIO property for RESET, LDAC and GAIN pin. RESET is active-low, LDAC is used to load DAC channels with values from input registers and GAIN can double the voltage in output channels. The gain-gpios property is not available to all supported parts. Signed-off-by: Rodrigo Alencar Acked-by: Conor Dooley --- .../devicetree/bindings/iio/dac/adi,ad5696.yaml | 34 ++++++++++++++++++= +++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml b/Do= cumentation/devicetree/bindings/iio/dac/adi,ad5696.yaml index ed79323bfc93..f286e5072abc 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml @@ -42,14 +42,45 @@ properties: description: | The regulator supply for DAC reference voltage. =20 + reset-gpios: + description: Active-low RESET pin to reset the device. + maxItems: 1 + + ldac-gpios: + description: + Active-low LDAC pin used to asynchronously update the DAC channels. + maxItems: 1 + + gain-gpios: + description: + GAIN pin that sets a multiplier for the DAC output voltage. When hig= h, + the DAC output voltage is multiplied by 2, otherwise it is unchanged. + maxItems: 1 + required: - compatible - reg =20 -additionalProperties: false +allOf: + - if: + properties: + compatible: + contains: + anyOf: + - const: adi,ad5311r + - const: adi,ad5691r + - const: adi,ad5692r + - const: adi,ad5693 + - const: adi,ad5693r + then: + properties: + gain-gpios: false + +unevaluatedProperties: false =20 examples: - | + #include i2c { #address-cells =3D <1>; #size-cells =3D <0>; @@ -58,6 +89,7 @@ examples: compatible =3D "adi,ad5696"; reg =3D <0>; vcc-supply =3D <&dac_vref>; + ldac-gpios =3D <&gpio0 1 GPIO_ACTIVE_LOW>; }; }; ... --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 39116318EE7; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=pobvrBLo7Rnl/ZboRiJPiibI8wJW/dmis4W6wwdv1VMdLzUAZRhXDjT/qXQRYCUHyDXhCUIsYwZW8C1tj6on0oOWxSUSKV7cogw5/eiBri5JsGij6sQF/gsVS9QA6iniD7nq69EHKE/Og2v4dlVwtXOL9B23K/malCBjPAsDKj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=xxutEXxm9rgHXUJpYjoukNdmX7/D20P+XlqLd31i94k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jZwzMDYoPlu1SwL0pZWf51fjGHjLnkMmY1pBJLDpGNAhyTEKlnva7L6IUeZ6ONr3Kayg+IWaJlycPixlgr/28UQAOLiqepCaC3cObIwuel21Ggslh1L1rm3qSeOj1AolPK65fwmGyX0fSp5/yXKZ2HdmyBA+7CdmKrc2is5goRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KS7ICVYv; 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="KS7ICVYv" Received: by smtp.kernel.org (Postfix) with ESMTPS id EA1C0C2BCB7; Wed, 22 Apr 2026 14:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=xxutEXxm9rgHXUJpYjoukNdmX7/D20P+XlqLd31i94k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=KS7ICVYv223/Y3P/49WzwpIcP9xt0kLANc8PHrQHxt5TrNaNNPgqBkC6vkdBR/H7a ylPCWbK6N/UawP7TqTwCT2SIXIhg4Hi/kPW+63EiiRHqTiJhox65mOsoM4Z1MIOfph N6WTcGLFc8Bgi3oL8wLwegXOAwgUdiwe5JkY4ouXfyPQ4SDXBSClIxo1vOGf2rmyBB tKNrba6QVhnBQPRazxQ+dQ3DEhbsvSg25qkKCP9BFsK8vnrAhXtRBiAJOy4JjSNDZO AwFn/9mHXkVBsmeABKwCXqH0MgATmeSEWSSseZmytwpg2AHLIYYw91rK1o7a1thB6c w3XlBozi6BDUg== 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 E26B7F9EDEB; Wed, 22 Apr 2026 14:46:23 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:37 +0100 Subject: [PATCH 03/22] dt-bindings: iio: dac: ad5696: rework on power supplies 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: <20260422-ad5313r-iio-support-v1-3-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=1859; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=1236hzCkqKqmziCwLICDAiFEWcH70pEVjQM4fWoD3cE=; b=KGaW/CCBXk2IGuhChc+a7r9Q3nj3yr2KhBU0eKijuxjA+L0wfzFYJc+djA7P8NGETkdonjbZ6 EzDN00+ByOBBXSxflMJZMnLaGqwfgI+8OjTA5rYHYD2D0rMqfM3c3fw 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 supplies for VDD, VLOGIC and VREF input voltage pins. The vcc-supply property is deprecated. Certain devices require vref-supply to be available once an internal reference voltage is absent. Still, this patch does not add those as 'required' so that the ABI is not broken. Signed-off-by: Rodrigo Alencar --- .../devicetree/bindings/iio/dac/adi,ad5696.yaml | 21 +++++++++++++++++= +--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml b/Do= cumentation/devicetree/bindings/iio/dac/adi,ad5696.yaml index f286e5072abc..21b80fe597d1 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml @@ -38,9 +38,22 @@ properties: reg: maxItems: 1 =20 + vdd-supply: + description: Input power supply. + + vlogic-supply: + description: + Digital power supply. If not supplied, it is assumed to be the same = as + vdd-supply. VLOGIC may be hardwired to VDD in some board designs or + internally connected in small packages. + + vref-supply: + description: + Reference voltage supply. If not supplied the internal reference is = used. + vcc-supply: - description: | - The regulator supply for DAC reference voltage. + deprecated: true + description: Use vref-supply instead. =20 reset-gpios: description: Active-low RESET pin to reset the device. @@ -88,7 +101,9 @@ examples: ad5696: dac@0 { compatible =3D "adi,ad5696"; reg =3D <0>; - vcc-supply =3D <&dac_vref>; + vdd-supply =3D <&dac_vdd>; + vlogic-supply =3D <&dac_vlogic>; + vref-supply =3D <&dac_vref>; ldac-gpios =3D <&gpio0 1 GPIO_ACTIVE_LOW>; }; }; --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 5551432143D; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=AGkvvvU1d56UTTWEVGGqS9nQE2LjOvvEqTapawtWolqTDtS+o0tvbIUu9YXJmnqnH62/rK5VL9cWhsR/IHTBmCuPp/oGAG13uZY9OKx09qXTZ/UVgTR9H/A3ODpIMyWypGJOHTE+Q41eyuRARasbVMUzt1Dnw5pk4WJrzeJvQ2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=wYMJ0asaxMRDeWv5Nx7Q3Fd4tXlmnv2sQIesKgmiuEg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fzbf4W6pVDYIyJkKGMpgps8s215aRjc4gp9XM22TMnWibVO764sbkMZfdRvmb4L/9t5QEAquTNZc3uKU/r+WzzXlcHUWC3b4GwiYyHbFV3cgbs6/IZq6eU7bnXclSBaCwpEDNWj+ulUTFM6MjJCV4do1xuhjMwrTbaykmwxRUj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eoANxEWj; 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="eoANxEWj" Received: by smtp.kernel.org (Postfix) with ESMTPS id 05F89C2BCB8; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=wYMJ0asaxMRDeWv5Nx7Q3Fd4tXlmnv2sQIesKgmiuEg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=eoANxEWjqfFkPmW2yZ2lyTpaYGwKtMXzIhbjwf6iKaxs3tJtqdl3GJ7B7JOaAfug2 E5EnPMMidvs3q4v47cx723fyPzisFd9+qGkw5PXmYDnwt2x3T3Qg0clIj3CmzjUkGX UEur+Ad6eb5pzEyrMbm3btPCaPrheTpmIKCSL2vsSZ7SA5yHugX7xhEdk/OOxnBV4M 70dR3hrm6Rpw9emMnPVAUJcHiIC6z3ReIXfZwrLtttfFvG7bvf6LXBQi+ovyc+GRx3 oVn9jizaoAxrEmsv9mhFBLouIjh5NDa2vIb8xdEBlZSa8GIHNEN+QHMhXvnQF4fjlM mSXjzaqhSUx1A== 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 F24CFF9EDC9; Wed, 22 Apr 2026 14:46:23 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:38 +0100 Subject: [PATCH 04/22] dt-bindings: iio: dac: ad5686: extend 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: <20260422-ad5313r-iio-support-v1-4-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=1669; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=HqOQ9v1hLDh+jrtLmYJHNFXNPvRsvM+6yK2HXF19r28=; b=cHWHdVPDJIqbj+S6F/eVxycOYC4pyjly5Gl0bzbdm6grFkRPv+GWsRvR7XhXvPovUjPQJb425 wZlCBBDGyifByfTkcEZSY/J6BLPzkhBCoxOYItNNwAj4iDYjErdaUJU 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 compatible entries for AD5313R, AD5317R, AD5674, AD5679, AD5687, AD5687R, AD5689, AD5689R. These devices have unique combination of channel count, bit resolution and supported command set, so that fallback compatibles are not used. Also, a small copy-and-paste error is fixed to the title field. Signed-off-by: Rodrigo Alencar Acked-by: Conor Dooley --- Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml b/Do= cumentation/devicetree/bindings/iio/dac/adi,ad5686.yaml index 713f535bb33a..cb035741529f 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/iio/dac/adi,ad5686.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: Analog Devices AD5360 and similar SPI DACs +title: Analog Devices AD5686 and similar SPI DACs =20 maintainers: - Michael Hennerich @@ -14,10 +14,14 @@ properties: compatible: enum: - adi,ad5310r + - adi,ad5313r + - adi,ad5317r - adi,ad5672r + - adi,ad5674 - adi,ad5674r - adi,ad5676 - adi,ad5676r + - adi,ad5679 - adi,ad5679r - adi,ad5681r - adi,ad5682r @@ -28,6 +32,10 @@ properties: - adi,ad5685r - adi,ad5686 - adi,ad5686r + - adi,ad5687 + - adi,ad5687r + - adi,ad5689 + - adi,ad5689r =20 reg: maxItems: 1 --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 5B41832143F; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=kbNa1KrDsT9AW5y7CwrgK/a1iUIPXHe5lf7pKEKY2HqKYDhLDC7vFC9XE+ilVoLC2AmcZNwaZSKozssujfk8Bp5YYv1RNPWWiLKpN8+f7bnMBiDjzk/0hJKZJP+S5fc9o5d5rihWCRgdE8fUTJU/s7D0P0jfOdddggKW1PNWO4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=LjIJCXNKBloKa8J7crgRBq9nzi+vvSVTBMwFFcTVU3Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dHe/7IpJY0KhKqaN2ZVMctUeJvy0C1mjI6Pwqo436Xh843/l/iE3Wzvz6oti9+iYETOZLFaBN1BW9fKa+P1zSUiOBnJLSAfdeZZcaT9xhvp++9cHAF4VlAm+MnQbUP7qrZKe/KvkceK9TCR43c9KxTeP4tplfa1jITBw0XwQnj4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M4Ak0ppw; 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="M4Ak0ppw" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1784AC2BCC6; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=LjIJCXNKBloKa8J7crgRBq9nzi+vvSVTBMwFFcTVU3Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=M4Ak0ppwPn/Z8mNaj8sU+/hW6nC7NMZzbx/41OSyyg4HWxbmqRadtBXX5PpKitQJE 5JHHXeaNHLepAXALXOurmRd7OLpvq/It3t2tmwVg/jUixH8ghHlpMaD9Lqqv8xDIFT ISg0PLPpSAhRpv78kv6iCBLo7ILPVDsW420FYRGYTP++RiEJoKH9MD2T6GCzUBY+KA PrwASQBp+/SpPfb3qDRRwRqO49+Ed0OHgeExFRR2Ht3Pm+FAKhDv/e0ZP3T91kTTcU U4c5XmiLtbRhSyCjrBcNkT5PC26sdvJ1oRoFUv5wt8hceiE0sHzyE38GaTYHTNmXYm GrfoX88IcUx0A== 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 0E6B5F9EDF3; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:39 +0100 Subject: [PATCH 05/22] dt-bindings: iio: dac: ad5686: add reset/ldac/gain gpio 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: <20260422-ad5313r-iio-support-v1-5-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=2213; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=wOaYAWpRRj1O+OF2FPPEqrEtz1565nfRtvyzOVFlG90=; b=8BI4DkEzHrNYUf9/2froJpEW7mtscJs2/ss1S4CEv0HHqsIy+jobBQCH1Ys6i943nVdznkW3i gUUCqqdMXqrDkB2KzeudibwdxyW5MQI3eKaFwcGYnwRYI0pyuBgTTYw 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 GPIO property for RESET, LDAC and GAIN pin. RESET is active-low, LDAC is used to load DAC channels with values from input registers and GAIN can double the voltage in output channels. The gain-gpios property is not available to all supported parts. Signed-off-by: Rodrigo Alencar Acked-by: Conor Dooley --- .../devicetree/bindings/iio/dac/adi,ad5686.yaml | 31 ++++++++++++++++++= ++++ 1 file changed, 31 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml b/Do= cumentation/devicetree/bindings/iio/dac/adi,ad5686.yaml index cb035741529f..543ee181f7b3 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml @@ -43,17 +43,46 @@ properties: vcc-supply: description: If not supplied the internal reference is used. =20 + reset-gpios: + description: Active-low RESET pin to reset the device. + maxItems: 1 + + ldac-gpios: + description: + Active-low LDAC pin used to asynchronously update the DAC channels. + maxItems: 1 + + gain-gpios: + description: + GAIN pin that sets a multiplier for the DAC output voltage. When hig= h, + the DAC output voltage is multiplied by 2, otherwise it is unchanged. + maxItems: 1 + required: - compatible - reg =20 allOf: - $ref: /schemas/spi/spi-peripheral-props.yaml# + - if: + properties: + compatible: + contains: + anyOf: + - const: adi,ad5310r + - const: adi,ad5681r + - const: adi,ad5682r + - const: adi,ad5683 + - const: adi,ad5683r + then: + properties: + gain-gpios: false =20 unevaluatedProperties: false =20 examples: - | + #include spi { #address-cells =3D <1>; #size-cells =3D <0>; @@ -61,6 +90,8 @@ examples: reg =3D <0>; compatible =3D "adi,ad5310r"; vcc-supply =3D <&dac_vref0>; + reset-gpios =3D <&gpio0 0 GPIO_ACTIVE_LOW>; + ldac-gpios =3D <&gpio0 1 GPIO_ACTIVE_LOW>; }; }; ... --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 68FBF30CDAE; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=XbXDkz5ZB79FD41e/pAKwYMEB2sBHkiBIVpLTLrqmDBUVx37uL7Rr7EXx+uBQNxXPPlYbEl1J5kOz5UtoEUSHcoiwfcy441sP0G6xjBTpq0DNQ+gOPLRtlqOAx8PKRz+sZM8DJvUF98pfxIxbjalM3v8Yj5oByAkUJd06sXWR70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=DzIZnucRYUqqamp1ggNd1WrAaNj54va5kduJMehc5ps=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WlteKhS2loYvS3Oqf487ua+0G1r+shdHQglin6EcnNqwy1TGsBPGD89LL04+3St4BtHYHCHLTsK16YUFcmYjOpAEL+LaxwZ4JholYKny58nvFOse5gyH5Yr8U255iZR25dRzOY3Ha2EqIfb37Ma5gutUx/7SH/BsDSTVjDqbDQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FNxQtq3P; 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="FNxQtq3P" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2A36FC2BCC4; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=DzIZnucRYUqqamp1ggNd1WrAaNj54va5kduJMehc5ps=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=FNxQtq3PZadoEV09tdAaNUUp+S7PABEoZiP3AtgXD+QjfoR6lk4XHHgcxojC8B+r6 M4r3ppVNhasJlpfh6FvkkiZ/CPkiDgtlm3iFpbRk5+YqOX+KaEu+JEme6rIeyqqSvS Hw91A2bALLB3Cwy/OJxTjfA49gz6M+/FcIabPcnx9RprZmZGgaYbxChWqRTOMO4oPK w3Koh/ScH2d5HPHbTWVSc6uYBNC3aJcLk9IsrtH65V4vUIe2Quikok5B03ZfZm/htG 08fSKb7JpgX/98zRWacFQY7N1NzrMyGKEMNMpRqCg1Ob8/zIammuhgyD9mUaFGqMt+ sUEVINONQseuw== 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 20ABDF9EDF1; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:40 +0100 Subject: [PATCH 06/22] dt-bindings: iio: dac: ad5686: rework on power supplies 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: <20260422-ad5313r-iio-support-v1-6-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=1922; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=9yk2gkX45ghKrgYSGht1grG7IvZtcYAKJWf3zLMMNP4=; b=dcBqGtLLVkbxf4wEq7VPlN9iVaG0HiLPdYiiUkS9NeZGHpveLr/vt4Lbdz7p1ltswxjyeDR3G nAN4LC5D/vfCmOzorRCWQNWxC15iFdmcs6icw4r37pUpeBeCcHf1FLk 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 supplies for VDD, VLOGIC and VREF input voltage pins. The vcc-supply property is deprecated. Certain devices require vref-supply to be available once an internal reference voltage is absent. Still, this patch does not add those as 'required' so that the ABI is not broken. Signed-off-by: Rodrigo Alencar --- .../devicetree/bindings/iio/dac/adi,ad5686.yaml | 20 ++++++++++++++++= ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml b/Do= cumentation/devicetree/bindings/iio/dac/adi,ad5686.yaml index 543ee181f7b3..3292d5190b70 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml @@ -40,8 +40,22 @@ properties: reg: maxItems: 1 =20 + vdd-supply: + description: Input power supply. + + vlogic-supply: + description: + Digital power supply. If not supplied, it is assumed to be the same = as + vdd-supply. VLOGIC may be hardwired to VDD in some board designs or + internally connected in small packages. + + vref-supply: + description: + Reference voltage supply. If not supplied the internal reference is = used. + vcc-supply: - description: If not supplied the internal reference is used. + deprecated: true + description: Use vref-supply instead. =20 reset-gpios: description: Active-low RESET pin to reset the device. @@ -89,7 +103,9 @@ examples: dac@0 { reg =3D <0>; compatible =3D "adi,ad5310r"; - vcc-supply =3D <&dac_vref0>; + vdd-supply =3D <&dac_vdd>; + vlogic-supply =3D <&dac_vlogic>; + vref-supply =3D <&dac_vref>; reset-gpios =3D <&gpio0 0 GPIO_ACTIVE_LOW>; ldac-gpios =3D <&gpio0 1 GPIO_ACTIVE_LOW>; }; --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 7860D32C924; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=GHl1/IIoD6XVhbccXOZnkdDvRvsdJAiMnKxAPmajm40k9AlC/kciV43mU0ZaYm9e0Vlz+YKT2PSLrx2ge4xS7GZWiRg5bjZbiH9ovZyd+Uxu0GO8Y3dMSjnhoHIdymSBU2qa1yfprGtEygwis+OWfXgDHX6oFf5drUH7MG7xENk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=l+N2eTpdCf7SDD+ccsaQ4RMwN1LY4hOleoPt5R0zvgM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NmEJ6vipMo50TLp4C5exC6dz3Vj3v/fsdsrGqJH6OY/64uYlhQJ8vtU0VkUy9wXWWQrmGMsm6QCgtb+ezdO/XUvGlUESgNc2fCDgOl3ZgXpua4x3/o8fhaQLuN/Uq5C/VJLAQCra+d++o8XqB/0yMxdD8+4X6rTE7FXuL4aPMHQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cPctFswy; 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="cPctFswy" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3D810C2BCFA; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=l+N2eTpdCf7SDD+ccsaQ4RMwN1LY4hOleoPt5R0zvgM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cPctFswya3Op/IZD7IAmz9WIGDkgsI9sYsbmcSppfgRucoYVGLJqrpkTlqHwoE7om rdlzSiRsZG6BU6RAXtrY68xz1HYXtltQD2QFzLY/l6Di5egJ2Tfneg8NDXnnEgioIO ZccikrhILe194ELbu3Rji/MIAr35AMPrT/BcH/GcY9Z3SXGE9FzUea2ypmuwVlbayG U+um1habYfIX+bJkHt7e/fEZSUktY5GqGOT7C8uV42K5HcUs4PsdUNlBa8qf6RCAiK 7mfHfzmPxoyIkiBdFdcTFEvsDnPZrX3GvMy+wSh05u0Y0paIuO8px+IFYxW2jeSAb8 n3WKBq2R729Jg== 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 3497CF9EDEB; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:41 +0100 Subject: [PATCH 07/22] iio: dac: ad5686: refactor include headers 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: <20260422-ad5313r-iio-support-v1-7-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=2739; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=6tt5M1kuQh7zLk0nCE7kXKPrQzBvjK2aZ4Ndo8TiE2w=; b=Du8u4IVD/tTMb/rLnXhyQEMXCVQy6QWhra+qgP4VdWZW/2KoscdYbVaYt+bNLzhpFVcYZL0jI 8xPhOzMl9R7Bf3qxi4jxXrJAqCu1keF/YgBQSmxTFnYcCyiecRJCECO 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 Apply IWYU principle, replacing unused/generic headers for specific/missing headers. The resulting include directive list is sorted accordingly. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686-spi.c | 8 ++++++-- drivers/iio/dac/ad5686.c | 13 ++++--------- drivers/iio/dac/ad5686.h | 5 ++--- drivers/iio/dac/ad5696-i2c.c | 9 ++++++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index df8619e0c092..b4df06f6bf02 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -8,11 +8,15 @@ * Copyright 2018 Analog Devices Inc. */ =20 -#include "ad5686.h" - +#include +#include +#include +#include #include #include =20 +#include "ad5686.h" + static int ad5686_spi_write(struct ad5686_state *st, u8 cmd, u8 addr, u16 val) { diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 9a384c50929b..1a6eb3832f22 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -5,17 +5,12 @@ * Copyright 2011 Analog Devices Inc. */ =20 -#include -#include -#include +#include +#include +#include #include -#include -#include -#include #include - -#include -#include +#include =20 #include "ad5686.h" =20 diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index e7d36bae3e59..3fcc792ea656 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -8,10 +8,9 @@ #ifndef __DRIVERS_IIO_DAC_AD5686_H__ #define __DRIVERS_IIO_DAC_AD5686_H__ =20 -#include -#include +#include #include -#include +#include =20 #include =20 diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index d3327bca0e07..587f53228bae 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -7,10 +7,13 @@ * Copyright 2018 Analog Devices Inc. */ =20 -#include "ad5686.h" - -#include +#include +#include #include +#include +#include + +#include "ad5686.h" =20 static int ad5686_i2c_read(struct ad5686_state *st, u8 addr) { --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 8093D32F764; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=POsDXNchSG8LTv51YSmwf34IIUlwRHcaXX5/nmoarL38TYCDnhppWSJ/7wrULT6cofBC6OM+R340I82tViYatYuXAACI4I44nzliSGPVWsWOaXDDenra3h0y+S6KNriOTd1TaeiUSo8PfkxFfxZn+B2rRRJmtBvJ0gWPrAMozoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=F9Nr0dL97FhuwgP6JQ6EOPNw/sgLvryAOIT0llXjf58=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UFWqXwmrl/8+V5e1i0ARZibmEFrOQVdprJwpBRR+Byppl8yxDpbdMfVKThxnA6fDHdcM6yEsXlPovc36Y5ff8Cry+xJoNpAQtJ534efovMeoQ40f/On7CY0kDQSao3Ns5KASd859l+PgeByxYnwW7Y6LExYcUfXAFv9yIGk2h38= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dM+Lo0kC; 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="dM+Lo0kC" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4F381C4AF15; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=F9Nr0dL97FhuwgP6JQ6EOPNw/sgLvryAOIT0llXjf58=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=dM+Lo0kCsHbMM0ajj1yIvZuM1pWf2bv2iPI09Y2Yb0XwlVfw5bHcZtWQTAfh4MimO pjkc/gji4Bmo1e7bL9Rbsr8ZawULAILJkEZs7oMU/gb05m8YBvzPph1zXBaDlaj/ww zPOcYpC12V5wd076aLM618VoGHSwi191zmTe/cX+l78u3P3RLH6MgajjAhe1c9i3ro DVcXPCWsWXcBrfIJ2Tsu7H1bZdZ+E0fvXxblrD2RhiSKRQbOQbO1ObMzgTFDNpVGAC eD0G9gaBONWwHAN9OHLbQ5X6ND2Ng6oZDyFXlgVO67GSvOpCR75aY0UgbpaUf8/QMC awv6X6pJqyHKw== 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 46136F9EDC9; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:42 +0100 Subject: [PATCH 08/22] iio: dac: ad5686: remove redundant register definition 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: <20260422-ad5313r-iio-support-v1-8-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=2846; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=ohjQW1AWDwRd84EWTvh6fCxsW2xwkyxLY5jzdH+7/fM=; b=qxDCy61RCTrZvVxcG8tC7f+4uoyo/zcsS/ec1eJJ3Wa2EkE8J9O1RVCm/uwwJGf8S9kyw9ZZP T/TaWDBqmogAa7fr38zUKzWEft2UIXBAMh459R2VgNLjOvH8CMuzdGV 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 AD5683_REGMAP and AD5693_REGMAP behave the same way in the common code, and that is because they target single channel devices from the same sub-family. There is no reason to separate them and it will make things simpler when refactoring the chip info table. Signed-off-by: Rodrigo Alencar Reviewed-by: Andy Shevchenko --- drivers/iio/dac/ad5686.c | 19 +++++-------------- drivers/iio/dac/ad5686.h | 2 -- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 1a6eb3832f22..0bc925bd827e 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -93,10 +93,6 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev= *indio_dev, if (chan->channel > 0x7) address =3D 0x8; break; - case AD5693_REGMAP: - shift =3D 13; - ref_bit_msk =3D AD5693_REF_BIT_MSK; - break; default: return -EINVAL; } @@ -277,7 +273,7 @@ static const struct ad5686_chip_info ad5686_chip_info_t= bl[] =3D { .channels =3D ad5311r_channels, .int_vref_mv =3D 2500, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5337R] =3D { .channels =3D ad5337r_channels, @@ -399,24 +395,24 @@ static const struct ad5686_chip_info ad5686_chip_info= _tbl[] =3D { .channels =3D ad5691r_channels, .int_vref_mv =3D 2500, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5692R] =3D { .channels =3D ad5692r_channels, .int_vref_mv =3D 2500, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5693] =3D { .channels =3D ad5693_channels, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5693R] =3D { .channels =3D ad5693_channels, .int_vref_mv =3D 2500, .num_channels =3D 1, - .regmap_type =3D AD5693_REGMAP, + .regmap_type =3D AD5683_REGMAP, }, [ID_AD5694] =3D { .channels =3D ad5684_channels, @@ -508,11 +504,6 @@ int ad5686_probe(struct device *dev, cmd =3D AD5686_CMD_INTERNAL_REFER_SETUP; ref_bit_msk =3D 0; break; - case AD5693_REGMAP: - cmd =3D AD5686_CMD_CONTROL_REG; - ref_bit_msk =3D AD5693_REF_BIT_MSK; - st->use_internal_vref =3D !has_external_vref; - break; default: return -EINVAL; } diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 3fcc792ea656..fe6482e84178 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -45,7 +45,6 @@ =20 #define AD5310_REF_BIT_MSK BIT(8) #define AD5683_REF_BIT_MSK BIT(12) -#define AD5693_REF_BIT_MSK BIT(12) =20 /** * ad5686_supported_device_ids: @@ -88,7 +87,6 @@ enum ad5686_regmap_type { AD5310_REGMAP, AD5683_REGMAP, AD5686_REGMAP, - AD5693_REGMAP }; =20 struct ad5686_state; --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 9629533ADAD; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=N7TxG5OyUTmOVm1BOh9q3jEyollDOWafcpo/KFQIaoBuTssWHIrjnWxc9UWCq75XyGPXCdcA8LsDbq3lKWpY5jsFGHk0J+IJ58ZKIE6nETwP0ZhQjmA5Mo8JoB3dME9Gw01+yvh2t3r780awCGzX/R/vznzA5wHvgrdfGXQY3Qg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=4GFXjrZ13nu1WsSOK02rS+Z79FNPGZTIDaWFlCEt14w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z3Z4tzAMCa5dR2Upcgg9gh4aLqYhqPOCZZY649vMT7Y91mqjnWjXh58ZSJo/Z7oKaots1NsL/xYhQrgyHbCHhY29+UpOx2V0EnFvX5hPZ+FmryxeQRoRU1L75AV1zLweyVHGAAmlM3FscCdc7jH+SqZGDWepMpkta91ycpwoRWQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tg5Q8j7g; 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="Tg5Q8j7g" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6403EC2BCFB; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=4GFXjrZ13nu1WsSOK02rS+Z79FNPGZTIDaWFlCEt14w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Tg5Q8j7gZuzkRxHyuJCSsUe2yx4l84gT0567YNEoBwHqU7rLuQAfGnlQ2RXC1wOtB wMbnqsuRCZL07NstrdRGXN3KWwv9gmNWNuFZ7KSl3ArIMGwTtlQfwwCEIUdmErl0fh cGU+5e2xHAoAwHnNOiAiiWTZiudq+PZgUv9aV/KIcqJdp1aOjgSrfK5i4D6CrloR1N Ns+mEU3AOufY/uRpfL9ty3pVQwBnfnSfyotq9LIzyONPR4ffpAx5OOQjP9rMD4PQEh bgySAX/ubWOxGN3CWvYSm6b891RbHYAj7fYjeGpXfc9lX+c3kHrilm3SNd30WG20zM 83POYpamvZ79w== 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 59516F9EDF3; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:43 +0100 Subject: [PATCH 09/22] iio: dac: ad5686: drop enum id 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: <20260422-ad5313r-iio-support-v1-9-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=20318; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=XrF41Ufu/0tckD+P4OPMujl2SpU30LUqjAgjpY1nkFI=; b=+xPaf4PtH1Ty6zvhKUjkR2Wn6uOlFiy6OPX7iJ4Jm1E8V4a+c/jrDa27qtqDfaTVvOh6/IGoy 4K1u0bcKRt4DSLapbKuIBi/eX0ALMGIVYnpzvNqNwL29mf9CsDUDuoc 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 Split chip info table into separate structs and expose them to the spi i2c drivers. That is the preferrable approach and allows for the drivers to have knowledge of the device info before the common probe function gets called. Those chip info structs may be shared by SPI and I2C driver variants. Channel declaration definitions are grouped according to channel count and DECLARE_AD5693_CHANNELS() macro is renamed to DECLARE_AD5683_CHANNELS() to match the regmap_type enum. Use spi_get_device_match_data() and i2c_get_match_data() to get chip info struct reference, passing it as parameter to the common probe function. Also, missing entries (AD5673R/AD5677R) are added to the i2c of_match table. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686-spi.c | 38 +++-- drivers/iio/dac/ad5686.c | 358 ++++++++++++++++++++-------------------= ---- drivers/iio/dac/ad5686.h | 66 ++++---- drivers/iio/dac/ad5696-i2c.c | 67 ++++---- 4 files changed, 243 insertions(+), 286 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index b4df06f6bf02..7a7a19a01b56 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -93,29 +93,27 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 = addr) =20 static int ad5686_spi_probe(struct spi_device *spi) { - const struct spi_device_id *id =3D spi_get_device_id(spi); - - return ad5686_probe(&spi->dev, id->driver_data, id->name, - ad5686_spi_write, ad5686_spi_read); + return ad5686_probe(&spi->dev, spi_get_device_match_data(spi), + spi->modalias, ad5686_spi_write, ad5686_spi_read); } =20 static const struct spi_device_id ad5686_spi_id[] =3D { - {"ad5310r", ID_AD5310R}, - {"ad5672r", ID_AD5672R}, - {"ad5674r", ID_AD5674R}, - {"ad5676", ID_AD5676}, - {"ad5676r", ID_AD5676R}, - {"ad5679r", ID_AD5679R}, - {"ad5681r", ID_AD5681R}, - {"ad5682r", ID_AD5682R}, - {"ad5683", ID_AD5683}, - {"ad5683r", ID_AD5683R}, - {"ad5684", ID_AD5684}, - {"ad5684r", ID_AD5684R}, - {"ad5685", ID_AD5685R}, /* Does not exist */ - {"ad5685r", ID_AD5685R}, - {"ad5686", ID_AD5686}, - {"ad5686r", ID_AD5686R}, + { "ad5310r", (kernel_ulong_t)&ad5310r_chip_info }, + { "ad5672r", (kernel_ulong_t)&ad5672r_chip_info }, + { "ad5674r", (kernel_ulong_t)&ad5674r_chip_info }, + { "ad5676", (kernel_ulong_t)&ad5676_chip_info }, + { "ad5676r", (kernel_ulong_t)&ad5676r_chip_info }, + { "ad5679r", (kernel_ulong_t)&ad5679r_chip_info }, + { "ad5681r", (kernel_ulong_t)&ad5681r_chip_info }, + { "ad5682r", (kernel_ulong_t)&ad5682r_chip_info }, + { "ad5683", (kernel_ulong_t)&ad5683_chip_info }, + { "ad5683r", (kernel_ulong_t)&ad5683r_chip_info }, + { "ad5684", (kernel_ulong_t)&ad5684_chip_info }, + { "ad5684r", (kernel_ulong_t)&ad5684r_chip_info }, + { "ad5685", (kernel_ulong_t)&ad5685r_chip_info }, /* Does not exist */ + { "ad5685r", (kernel_ulong_t)&ad5685r_chip_info }, + { "ad5686", (kernel_ulong_t)&ad5686_chip_info }, + { "ad5686r", (kernel_ulong_t)&ad5686r_chip_info }, { } }; MODULE_DEVICE_TABLE(spi, ad5686_spi_id); diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 0bc925bd827e..e67faef91164 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -196,7 +196,7 @@ static const struct iio_chan_spec_ext_info ad5686_ext_i= nfo[] =3D { .ext_info =3D ad5686_ext_info, \ } =20 -#define DECLARE_AD5693_CHANNELS(name, bits, _shift) \ +#define DECLARE_AD5683_CHANNELS(name, bits, _shift) \ static const struct iio_chan_spec name[] =3D { \ AD5868_CHANNEL(0, 0, bits, _shift), \ } @@ -247,205 +247,172 @@ static const struct iio_chan_spec name[] =3D { \ AD5868_CHANNEL(15, 15, bits, _shift), \ } =20 -DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2); -DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6); +/* single-channel */ +DECLARE_AD5683_CHANNELS(ad5310r_channels, 10, 2); +DECLARE_AD5683_CHANNELS(ad5311r_channels, 10, 6); +DECLARE_AD5683_CHANNELS(ad5681r_channels, 12, 4); +DECLARE_AD5683_CHANNELS(ad5682r_channels, 14, 2); +DECLARE_AD5683_CHANNELS(ad5683r_channels, 16, 0); + +/* dual-channel */ DECLARE_AD5338_CHANNELS(ad5337r_channels, 8, 8); DECLARE_AD5338_CHANNELS(ad5338r_channels, 10, 6); -DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4); -DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4); -DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0); -DECLARE_AD5679_CHANNELS(ad5679r_channels, 16, 0); -DECLARE_AD5686_CHANNELS(ad5684_channels, 12, 4); -DECLARE_AD5686_CHANNELS(ad5685r_channels, 14, 2); -DECLARE_AD5686_CHANNELS(ad5686_channels, 16, 0); -DECLARE_AD5693_CHANNELS(ad5693_channels, 16, 0); -DECLARE_AD5693_CHANNELS(ad5692r_channels, 14, 2); -DECLARE_AD5693_CHANNELS(ad5691r_channels, 12, 4); =20 -static const struct ad5686_chip_info ad5686_chip_info_tbl[] =3D { - [ID_AD5310R] =3D { - .channels =3D ad5310r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5310_REGMAP, - }, - [ID_AD5311R] =3D { - .channels =3D ad5311r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5337R] =3D { - .channels =3D ad5337r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 2, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5338R] =3D { - .channels =3D ad5338r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 2, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5671R] =3D { - .channels =3D ad5672_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5672R] =3D { - .channels =3D ad5672_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5673R] =3D { - .channels =3D ad5674r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 16, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5674R] =3D { - .channels =3D ad5674r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 16, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5675R] =3D { - .channels =3D ad5676_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5676] =3D { - .channels =3D ad5676_channels, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5676R] =3D { - .channels =3D ad5676_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 8, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5677R] =3D { - .channels =3D ad5679r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 16, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5679R] =3D { - .channels =3D ad5679r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 16, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5681R] =3D { - .channels =3D ad5691r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5682R] =3D { - .channels =3D ad5692r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5683] =3D { - .channels =3D ad5693_channels, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5683R] =3D { - .channels =3D ad5693_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5684] =3D { - .channels =3D ad5684_channels, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5684R] =3D { - .channels =3D ad5684_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5685R] =3D { - .channels =3D ad5685r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5686] =3D { - .channels =3D ad5686_channels, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5686R] =3D { - .channels =3D ad5686_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5691R] =3D { - .channels =3D ad5691r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5692R] =3D { - .channels =3D ad5692r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5693] =3D { - .channels =3D ad5693_channels, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5693R] =3D { - .channels =3D ad5693_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 1, - .regmap_type =3D AD5683_REGMAP, - }, - [ID_AD5694] =3D { - .channels =3D ad5684_channels, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5694R] =3D { - .channels =3D ad5684_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5695R] =3D { - .channels =3D ad5685r_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5696] =3D { - .channels =3D ad5686_channels, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, - [ID_AD5696R] =3D { - .channels =3D ad5686_channels, - .int_vref_mv =3D 2500, - .num_channels =3D 4, - .regmap_type =3D AD5686_REGMAP, - }, +/* quad-channel */ +DECLARE_AD5686_CHANNELS(ad5684r_channels, 12, 4); +DECLARE_AD5686_CHANNELS(ad5685r_channels, 14, 2); +DECLARE_AD5686_CHANNELS(ad5686r_channels, 16, 0); + +/* 8-channel */ +DECLARE_AD5676_CHANNELS(ad5672r_channels, 12, 4); +DECLARE_AD5676_CHANNELS(ad5676r_channels, 16, 0); + +/* 16-channel */ +DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4); +DECLARE_AD5679_CHANNELS(ad5679r_channels, 16, 0); + +const struct ad5686_chip_info ad5310r_chip_info =3D { + .channels =3D ad5310r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5310_REGMAP, }; +EXPORT_SYMBOL_NS_GPL(ad5310r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5311r_chip_info =3D { + .channels =3D ad5311r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5311r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5681r_chip_info =3D { + .channels =3D ad5681r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5681r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5682r_chip_info =3D { + .channels =3D ad5682r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5682r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5683_chip_info =3D { + .channels =3D ad5683r_channels, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5683_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5683r_chip_info =3D { + .channels =3D ad5683r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 1, + .regmap_type =3D AD5683_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5683r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5337r_chip_info =3D { + .channels =3D ad5337r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 2, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5337r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5338r_chip_info =3D { + .channels =3D ad5338r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 2, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5338r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5684_chip_info =3D { + .channels =3D ad5684r_channels, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5684_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5684r_chip_info =3D { + .channels =3D ad5684r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5684r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5685r_chip_info =3D { + .channels =3D ad5685r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5685r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5686_chip_info =3D { + .channels =3D ad5686r_channels, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5686_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5686r_chip_info =3D { + .channels =3D ad5686r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5686r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5672r_chip_info =3D { + .channels =3D ad5672r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 8, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5672r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5676_chip_info =3D { + .channels =3D ad5676r_channels, + .num_channels =3D 8, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5676_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5676r_chip_info =3D { + .channels =3D ad5676r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 8, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5676r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5674r_chip_info =3D { + .channels =3D ad5674r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 16, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5674r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5679r_chip_info =3D { + .channels =3D ad5679r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 16, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686"); =20 int ad5686_probe(struct device *dev, - enum ad5686_supported_device_ids chip_type, + const struct ad5686_chip_info *chip_info, const char *name, ad5686_write_func write, ad5686_read_func read) { @@ -465,8 +432,7 @@ int ad5686_probe(struct device *dev, st->dev =3D dev; st->write =3D write; st->read =3D read; - - st->chip_info =3D &ad5686_chip_info_tbl[chip_type]; + st->chip_info =3D chip_info; =20 ret =3D devm_regulator_get_enable_read_voltage(dev, "vcc"); if (ret < 0 && ret !=3D -ENODEV) diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index fe6482e84178..6e3552c92e4b 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -46,42 +46,6 @@ #define AD5310_REF_BIT_MSK BIT(8) #define AD5683_REF_BIT_MSK BIT(12) =20 -/** - * ad5686_supported_device_ids: - */ -enum ad5686_supported_device_ids { - ID_AD5310R, - ID_AD5311R, - ID_AD5337R, - ID_AD5338R, - ID_AD5671R, - ID_AD5672R, - ID_AD5673R, - ID_AD5674R, - ID_AD5675R, - ID_AD5676, - ID_AD5676R, - ID_AD5677R, - ID_AD5679R, - ID_AD5681R, - ID_AD5682R, - ID_AD5683, - ID_AD5683R, - ID_AD5684, - ID_AD5684R, - ID_AD5685R, - ID_AD5686, - ID_AD5686R, - ID_AD5691R, - ID_AD5692R, - ID_AD5693, - ID_AD5693R, - ID_AD5694, - ID_AD5694R, - ID_AD5695R, - ID_AD5696, - ID_AD5696R, -}; =20 enum ad5686_regmap_type { AD5310_REGMAP, @@ -111,6 +75,34 @@ struct ad5686_chip_info { enum ad5686_regmap_type regmap_type; }; =20 +/* single-channel instances */ +extern const struct ad5686_chip_info ad5310r_chip_info; +extern const struct ad5686_chip_info ad5311r_chip_info; +extern const struct ad5686_chip_info ad5681r_chip_info; +extern const struct ad5686_chip_info ad5682r_chip_info; +extern const struct ad5686_chip_info ad5683_chip_info; +extern const struct ad5686_chip_info ad5683r_chip_info; + +/* dual-channel instances */ +extern const struct ad5686_chip_info ad5337r_chip_info; +extern const struct ad5686_chip_info ad5338r_chip_info; + +/* quad-channel instances */ +extern const struct ad5686_chip_info ad5684_chip_info; +extern const struct ad5686_chip_info ad5684r_chip_info; +extern const struct ad5686_chip_info ad5685r_chip_info; +extern const struct ad5686_chip_info ad5686_chip_info; +extern const struct ad5686_chip_info ad5686r_chip_info; + +/* 8-channel instances */ +extern const struct ad5686_chip_info ad5672r_chip_info; +extern const struct ad5686_chip_info ad5676_chip_info; +extern const struct ad5686_chip_info ad5676r_chip_info; + +/* 16-channel instances */ +extern const struct ad5686_chip_info ad5674r_chip_info; +extern const struct ad5686_chip_info ad5679r_chip_info; + /** * struct ad5686_state - driver instance specific data * @spi: spi_device @@ -148,7 +140,7 @@ struct ad5686_state { =20 =20 int ad5686_probe(struct device *dev, - enum ad5686_supported_device_ids chip_type, + const struct ad5686_chip_info *chip_info, const char *name, ad5686_write_func write, ad5686_read_func read); =20 diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index 587f53228bae..237f4b5df021 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -63,47 +63,48 @@ static int ad5686_i2c_write(struct ad5686_state *st, =20 static int ad5686_i2c_probe(struct i2c_client *i2c) { - const struct i2c_device_id *id =3D i2c_client_get_device_id(i2c); - return ad5686_probe(&i2c->dev, id->driver_data, id->name, - ad5686_i2c_write, ad5686_i2c_read); + return ad5686_probe(&i2c->dev, i2c_get_match_data(i2c), + i2c->name, ad5686_i2c_write, ad5686_i2c_read); } =20 static const struct i2c_device_id ad5686_i2c_id[] =3D { - {"ad5311r", ID_AD5311R}, - {"ad5337r", ID_AD5337R}, - {"ad5338r", ID_AD5338R}, - {"ad5671r", ID_AD5671R}, - {"ad5673r", ID_AD5673R}, - {"ad5675r", ID_AD5675R}, - {"ad5677r", ID_AD5677R}, - {"ad5691r", ID_AD5691R}, - {"ad5692r", ID_AD5692R}, - {"ad5693", ID_AD5693}, - {"ad5693r", ID_AD5693R}, - {"ad5694", ID_AD5694}, - {"ad5694r", ID_AD5694R}, - {"ad5695r", ID_AD5695R}, - {"ad5696", ID_AD5696}, - {"ad5696r", ID_AD5696R}, + { "ad5311r", (kernel_ulong_t)&ad5311r_chip_info }, + { "ad5337r", (kernel_ulong_t)&ad5337r_chip_info }, + { "ad5338r", (kernel_ulong_t)&ad5338r_chip_info }, + { "ad5671r", (kernel_ulong_t)&ad5672r_chip_info }, + { "ad5673r", (kernel_ulong_t)&ad5674r_chip_info }, + { "ad5675r", (kernel_ulong_t)&ad5676r_chip_info }, + { "ad5677r", (kernel_ulong_t)&ad5679r_chip_info }, + { "ad5691r", (kernel_ulong_t)&ad5681r_chip_info }, + { "ad5692r", (kernel_ulong_t)&ad5682r_chip_info }, + { "ad5693", (kernel_ulong_t)&ad5683_chip_info }, + { "ad5693r", (kernel_ulong_t)&ad5683r_chip_info }, + { "ad5694", (kernel_ulong_t)&ad5684_chip_info }, + { "ad5694r", (kernel_ulong_t)&ad5684r_chip_info }, + { "ad5695r", (kernel_ulong_t)&ad5685r_chip_info }, + { "ad5696", (kernel_ulong_t)&ad5686_chip_info }, + { "ad5696r", (kernel_ulong_t)&ad5686r_chip_info }, { } }; MODULE_DEVICE_TABLE(i2c, ad5686_i2c_id); =20 static const struct of_device_id ad5686_of_match[] =3D { - { .compatible =3D "adi,ad5311r" }, - { .compatible =3D "adi,ad5337r" }, - { .compatible =3D "adi,ad5338r" }, - { .compatible =3D "adi,ad5671r" }, - { .compatible =3D "adi,ad5675r" }, - { .compatible =3D "adi,ad5691r" }, - { .compatible =3D "adi,ad5692r" }, - { .compatible =3D "adi,ad5693" }, - { .compatible =3D "adi,ad5693r" }, - { .compatible =3D "adi,ad5694" }, - { .compatible =3D "adi,ad5694r" }, - { .compatible =3D "adi,ad5695r" }, - { .compatible =3D "adi,ad5696" }, - { .compatible =3D "adi,ad5696r" }, + { .compatible =3D "adi,ad5311r", .data =3D &ad5311r_chip_info }, + { .compatible =3D "adi,ad5337r", .data =3D &ad5337r_chip_info }, + { .compatible =3D "adi,ad5338r", .data =3D &ad5338r_chip_info }, + { .compatible =3D "adi,ad5671r", .data =3D &ad5672r_chip_info }, + { .compatible =3D "adi,ad5673r", .data =3D &ad5674r_chip_info }, + { .compatible =3D "adi,ad5675r", .data =3D &ad5676r_chip_info }, + { .compatible =3D "adi,ad5677r", .data =3D &ad5679r_chip_info }, + { .compatible =3D "adi,ad5691r", .data =3D &ad5681r_chip_info }, + { .compatible =3D "adi,ad5692r", .data =3D &ad5682r_chip_info }, + { .compatible =3D "adi,ad5693", .data =3D &ad5683_chip_info }, + { .compatible =3D "adi,ad5693r", .data =3D &ad5683r_chip_info }, + { .compatible =3D "adi,ad5694", .data =3D &ad5684_chip_info }, + { .compatible =3D "adi,ad5694r", .data =3D &ad5684r_chip_info }, + { .compatible =3D "adi,ad5695r", .data =3D &ad5685r_chip_info }, + { .compatible =3D "adi,ad5696", .data =3D &ad5686_chip_info }, + { .compatible =3D "adi,ad5696r", .data =3D &ad5686r_chip_info }, { } }; MODULE_DEVICE_TABLE(of, ad5686_of_match); --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 A84AD33D4E2; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=ANQlugPvlNvg5Q6I66io8sR4aWT/BTKQWswIoSCYezAvH9SdczROWAo2FMPsJ4hXGefp8QEeW6D14yl1QG4F2pvhIZkOSJKYq+kXP+YYOlfWt68QhdfStGpDyMj5rktftDMxVmQwKLJZ93m5yUNve7uPBxAwJhTylfloqXb5eVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=K+xFdI3qumlz2bfGS97Hrd7C3kyFTVbwY0YIscqxoxY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eUg8CrMg/cfpTInw0iLye8kBtTGXg1TMCpI3d0wzkgU6coqZtEu47f4g4RLEGp/ntA5JB/30WAXv9U/fL+neAvhqsj6tAlBXi238V+w4s3sxFeOcmmTINcnP+fzXdTcw1Q2TOoUUqpJ6E40m8IUi1VOxhYwObOLSrVmO7K4r17g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RjhUJK/+; 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="RjhUJK/+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 81293C4AF11; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=K+xFdI3qumlz2bfGS97Hrd7C3kyFTVbwY0YIscqxoxY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RjhUJK/+sveXbGxjLKrSndX4MqsHeBteXGR42YDhdtTMYLbbmm0IZzZ/B4V+cXuoO fw6JX0O3EhMXdlZpg8fmhUq1W+ZL0PY76EXd6K0zW1b1RjdVS0di5ppKZcDccTa1/e J5IiCCvsRNj+4WTKgywALBwVDo5oPKGUg7vLbiT/kZl+cufmO36HsQ/4GbizuzmwWf sCRifK+Mi0gzmkr3keAADsIf4qCUOTcMprbllqul1XK3c/KA4CcDd8WdHr3kbRfIN5 4T4YjUJlZkhQMEoSnCn8gVz0p5gJdZvlRNzOjwAO2NJ6T/4uwLicJTv2JnY4251hHf LfEKTmw9G+z1g== 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 6E7F7F9EDF5; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:44 +0100 Subject: [PATCH 10/22] iio: dac: ad5686: add of_match table to the spi 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: <20260422-ad5313r-iio-support-v1-10-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=1849; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=C7y+tv8tl9vSOd2HafCCTEPh7cdjuxKwc/v91PQUx9E=; b=WY9x4RgC1GHSTS1QD9/Q94sNL6zKsziziM763el98x+DfBvcFe4tmyKCLisSjkDIxK4C0CE7f UFWhFLHkHdxCMUuvCbOkbiY2GZCQSHCfY1qW6qpYQ0RtOBDl8Jk3GUg 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 of_match table for the SPI device variants to be consistent with the AD5696 I2C driver. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686-spi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index 7a7a19a01b56..6c9b70880da9 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -118,9 +118,30 @@ static const struct spi_device_id ad5686_spi_id[] =3D { }; MODULE_DEVICE_TABLE(spi, ad5686_spi_id); =20 +static const struct of_device_id ad5686_of_match[] =3D { + { .compatible =3D "adi,ad5310r", .data =3D &ad5310r_chip_info }, + { .compatible =3D "adi,ad5672r", .data =3D &ad5672r_chip_info }, + { .compatible =3D "adi,ad5674r", .data =3D &ad5674r_chip_info }, + { .compatible =3D "adi,ad5676", .data =3D &ad5676_chip_info }, + { .compatible =3D "adi,ad5676r", .data =3D &ad5676r_chip_info }, + { .compatible =3D "adi,ad5679r", .data =3D &ad5679r_chip_info }, + { .compatible =3D "adi,ad5681r", .data =3D &ad5681r_chip_info }, + { .compatible =3D "adi,ad5682r", .data =3D &ad5682r_chip_info }, + { .compatible =3D "adi,ad5683", .data =3D &ad5683_chip_info }, + { .compatible =3D "adi,ad5683r", .data =3D &ad5683r_chip_info }, + { .compatible =3D "adi,ad5684", .data =3D &ad5684_chip_info }, + { .compatible =3D "adi,ad5684r", .data =3D &ad5684r_chip_info }, + { .compatible =3D "adi,ad5685r", .data =3D &ad5685r_chip_info }, + { .compatible =3D "adi,ad5686", .data =3D &ad5686_chip_info }, + { .compatible =3D "adi,ad5686r", .data =3D &ad5686r_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(of, ad5686_of_match); + static struct spi_driver ad5686_spi_driver =3D { .driver =3D { .name =3D "ad5686", + .of_match_table =3D ad5686_of_match, }, .probe =3D ad5686_spi_probe, .id_table =3D ad5686_spi_id, --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 BED13344044; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=XWLklfX+ZaWTJc8OoEak+MKQZ6wl/hhyac7fbapr6k2ijjv5IUPXiSY6NfCBDe7tzbjPt1JQKCb7QaNvdVxuWRXrYf1SvM4on4WxeW2N/t8DMzwQwcmJrKpcJ1ERjYz97e1G5zirwSvsVC6xKJI7EPG/hSgN2EE2TOySFycGVoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=sQoCI/ekQ1NhAv+hxshxm+zS5jKkGMxUF4Dn9I85syI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wdhp0yiDX6LkSmy7ItNfSVPT0ckqjuBojAB9j44oTxHBVQ7L8jSxhlUsEG0j7q3MzE5Bubucqnt2KgMnGTEwaPmvzTcWV1iZ4lldVjoimWt7RjvNTQZ6i11hVBskc6n4s42xOxalZ0U1F0XrsCJa3oAdAhmhp0Fqgqejuw+hAaw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fTwSmo4q; 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="fTwSmo4q" Received: by smtp.kernel.org (Postfix) with ESMTPS id 99CADC2BCC9; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=sQoCI/ekQ1NhAv+hxshxm+zS5jKkGMxUF4Dn9I85syI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fTwSmo4q13rkhU7191MEdjGEw8afI06L12DJ3NgCPYXqIRaQS9n/QdN00kzyfq7f4 LK794F+B9xwdHv4tY6EnSibA24kQNo6dD8kgxH7eBsGvF02YIJQZzxLp8jeOqR5PjM DDHQUPvLD2WiKJr++wazEQKsBLhNHIdG+HaHiV6q1Oj9bx8/iAHZh8U7C8wJHyWPsQ ymD7W0jQ1kxMrRI1KtMP939GprQjGTtEEsyQcQ3KDOsKfevu+/BRoGmE6X0ti1wUBc yWLsZzMXjb+huIQw5yBCPJJesqB3MV2Xq1rOsHzDgvnKJAkFqIPOd//UruChpnio46 KP23SnuAk8blA== 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 7F2E3F9EDF6; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:45 +0100 Subject: [PATCH 11/22] iio: dac: ad5686: fix ref bit initialization for single-channel parts 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: <20260422-ad5313r-iio-support-v1-11-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=5789; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Ph++WbScG/7DVMcdVEOFz61aSBSuj4HHept6UKwK5DA=; b=YOonYJNp/Q5LUaeNFisr7IUNPZxcGhUJyk42pDA0ba8tNHdDyJKKfukjB9eLUXyhjjfCTSpdE NhbCCzr8FaKApAc2JTAJaZC+ok2BJbGC5o7CQgjlApvT6nqwtYMxlLA 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 For single-channel parts the control register is used to enable the internal voltage reference and perform powerdown control. The reference enable bit position was ignored when writing the register at the probe function. This patch adds a control_sync() function that properly consumes the mask definitions with FIELD_PREP(). As further cleanup, the created functions and definitions are also used in ad5686_write_dac_powerdown(). Some local variables ended up being unused (so removed) and st->use_internal_vref is initialized earlier in probe. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 79 +++++++++++++++++++++++++++-----------------= ---- drivers/iio/dac/ad5686.h | 3 +- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index e67faef91164..4ca9cd5b6e38 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -6,11 +6,13 @@ */ =20 #include +#include #include #include #include #include #include +#include =20 #include "ad5686.h" =20 @@ -20,6 +22,24 @@ static const char * const ad5686_powerdown_modes[] =3D { "three_state" }; =20 +static int ad5310_control_sync(struct ad5686_state *st) +{ + unsigned int pd_val =3D st->pwr_down_mask & st->pwr_down_mode; + + return st->write(st, AD5686_CMD_CONTROL_REG, 0, + FIELD_PREP(AD5310_PD_MSK, pd_val) | + FIELD_PREP(AD5310_REF_BIT_MSK, !st->use_internal_vref)); +} + +static int ad5683_control_sync(struct ad5686_state *st) +{ + unsigned int pd_val =3D st->pwr_down_mask & st->pwr_down_mode; + + return st->write(st, AD5686_CMD_CONTROL_REG, 0, + FIELD_PREP(AD5683_PD_MSK, pd_val) | + FIELD_PREP(AD5683_REF_BIT_MSK, !st->use_internal_vref)); +} + static int ad5686_get_powerdown_mode(struct iio_dev *indio_dev, const struct iio_chan_spec *chan) { @@ -65,8 +85,8 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev = *indio_dev, bool readin; int ret; struct ad5686_state *st =3D iio_priv(indio_dev); - unsigned int val, ref_bit_msk; - u8 shift, address =3D 0; + unsigned int val; + u8 address =3D 0; =20 ret =3D kstrtobool(buf, &readin); if (ret) @@ -79,30 +99,26 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_de= v *indio_dev, =20 switch (st->chip_info->regmap_type) { case AD5310_REGMAP: - shift =3D 9; - ref_bit_msk =3D AD5310_REF_BIT_MSK; + ret =3D ad5310_control_sync(st); break; case AD5683_REGMAP: - shift =3D 13; - ref_bit_msk =3D AD5683_REF_BIT_MSK; + ret =3D ad5683_control_sync(st); break; case AD5686_REGMAP: - shift =3D 0; - ref_bit_msk =3D 0; /* AD5674R/AD5679R have 16 channels and 2 powerdown registers */ - if (chan->channel > 0x7) + val =3D st->pwr_down_mask & st->pwr_down_mode; + if (chan->channel > 0x7) { address =3D 0x8; + val =3D upper_16_bits(val); + } else { + val =3D lower_16_bits(val); + } + ret =3D st->write(st, AD5686_CMD_POWERDOWN_DAC, address, val); break; default: return -EINVAL; } =20 - val =3D ((st->pwr_down_mask & st->pwr_down_mode) << shift); - if (!st->use_internal_vref) - val |=3D ref_bit_msk; - - ret =3D st->write(st, AD5686_CMD_POWERDOWN_DAC, - address, val >> (address * 2)); =20 return ret ? ret : len; } @@ -416,11 +432,8 @@ int ad5686_probe(struct device *dev, const char *name, ad5686_write_func write, ad5686_read_func read) { - struct ad5686_state *st; struct iio_dev *indio_dev; - unsigned int val, ref_bit_msk; - bool has_external_vref; - u8 cmd; + struct ad5686_state *st; int ret, i; =20 indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); @@ -438,8 +451,8 @@ int ad5686_probe(struct device *dev, if (ret < 0 && ret !=3D -ENODEV) return ret; =20 - has_external_vref =3D ret !=3D -ENODEV; - st->vref_mv =3D has_external_vref ? ret / 1000 : st->chip_info->int_vref_= mv; + st->use_internal_vref =3D ret =3D=3D -ENODEV; + st->vref_mv =3D st->use_internal_vref ? st->chip_info->int_vref_mv : ret = / 1000; =20 /* Set all the power down mode for all channels to 1K pulldown */ for (i =3D 0; i < st->chip_info->num_channels; i++) @@ -457,29 +470,25 @@ int ad5686_probe(struct device *dev, =20 switch (st->chip_info->regmap_type) { case AD5310_REGMAP: - cmd =3D AD5686_CMD_CONTROL_REG; - ref_bit_msk =3D AD5310_REF_BIT_MSK; - st->use_internal_vref =3D !has_external_vref; + ret =3D ad5310_control_sync(st); + if (ret) + return ret; break; case AD5683_REGMAP: - cmd =3D AD5686_CMD_CONTROL_REG; - ref_bit_msk =3D AD5683_REF_BIT_MSK; - st->use_internal_vref =3D !has_external_vref; + ret =3D ad5683_control_sync(st); + if (ret) + return ret; break; case AD5686_REGMAP: - cmd =3D AD5686_CMD_INTERNAL_REFER_SETUP; - ref_bit_msk =3D 0; + ret =3D st->write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0, + !st->use_internal_vref); + if (ret) + return ret; break; default: return -EINVAL; } =20 - val =3D (has_external_vref | ref_bit_msk); - - ret =3D st->write(st, cmd, 0, !!val); - if (ret) - return ret; - return devm_iio_device_register(dev, indio_dev); } EXPORT_SYMBOL_NS_GPL(ad5686_probe, "IIO_AD5686"); diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 6e3552c92e4b..7004d0d1d97a 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -44,8 +44,9 @@ #define AD5686_CMD_READBACK_ENABLE_V2 0x5 =20 #define AD5310_REF_BIT_MSK BIT(8) +#define AD5310_PD_MSK GENMASK(10, 9) #define AD5683_REF_BIT_MSK BIT(12) - +#define AD5683_PD_MSK GENMASK(14, 13) =20 enum ad5686_regmap_type { AD5310_REGMAP, --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 C5E343451BA; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=jzL0YEHRNLdFf0qivsuYlyNjLdHrHOU2r12Tgbb6+jMGgcA+hY+EfT+ObRVtAZgvFKqAWLqDbGCXGtRDU0EtDIOEFAPYjwpNmQN6taSzScH6a+xGCHEqK8ORDpkQZ4+HZX600k6Ybdi29Lr4tMa0rYdoCIZucTy4N3SmkCm4tSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=caKHGwBXpvbftS2vPlXjZT9VlXoo2hKGDiksKcobEM8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uZzi1/dOUKIAIodyUhZl5Jm4/rduJEEep5pxuG8WU/8bKBHcsOh+j+ztALcUqs+PbRRmbE3GlesZmdVDcdw838BUUaiB2TyPSemWlCxNTUcvraB4DIB4+J4PWeDcskYDipllalRog/L8a4zqDcFuldNuP224y3FAHtPcDtFnWtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V85yRJ2C; 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="V85yRJ2C" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9941BC4AF09; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=caKHGwBXpvbftS2vPlXjZT9VlXoo2hKGDiksKcobEM8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=V85yRJ2CHF8qG8TmbGhqcrSIAYBKQtNySVKtlRRXWkoxG2PieVZOaTRuqRk4M+Xc7 gOD/1vNgv4BknvYzy8bxJdYFJQ/L9CMMrYYGsYV06PgoaA3938gfSFguOd9Q8c++gN jzn82r9/QKvuDktpQ7H5KN0Mq7vEj+53l5DiwpDJlpbgy3NEfkP1aILahA8t/I3lss EqZH1df665DuJlC4RfkYhdvHobklZpDE6X1p3OYB43TwJQmpmt21XG7Ugjf85HNuUd RD9rpLzfoMEzz50LYffMyeYy5CRFp8GmsXp6WUN97JgaSnBx2lRJYEI17HVC++ojxz WNksbc+1sgkdw== 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 902BCF9EDF4; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:46 +0100 Subject: [PATCH 12/22] iio: dac: ad5686: fix powerdown control 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: <20260422-ad5313r-iio-support-v1-12-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=4907; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=N4j8DVJg39SZkt7C9VDNtfzdCSPJ1WG7gWhxuqNFEEE=; b=7ua9qLj9VhnIQ0A0hvD9Fvf4rqTmvWh/iU/Z+jQi9ssuYVydqBRbxnq8QN0SC76Z1CKIACV/8 PUQMqFH16eaCCadgg6ykK/feD6HMjaESOscoTs4G42QjGqQSChhT+Z7 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 This patch fixes powerdown control issues by protecting the cached powerdown states with mutex access, and by using a proper bit shift for the powerdown mask values. During initialization, powerdown bits are initialized so that unused bits are set to 1 and the correct bit shift is used. Dual-channel devices use one-hot encondig in the address and that reflects on the position of the powerdown bits, which are not channel-index based for that case. Quad-channel devices also use one-hot encondig for the channel address but the result of log2(address) coincides with the channel index value. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 54 +++++++++++++++++++++++++++++++++++++-------= ---- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 4ca9cd5b6e38..19d791c655b7 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -40,12 +40,26 @@ static int ad5683_control_sync(struct ad5686_state *st) FIELD_PREP(AD5683_REF_BIT_MSK, !st->use_internal_vref)); } =20 +static inline int ad5686_pd_mask_shift(const struct iio_chan_spec *chan) +{ + if (chan->channel =3D=3D chan->address) + return chan->channel * 2; + + /* one-hot encoding is used in dual/quad channel devices */ + return __ffs(chan->address) * 2; +} + static int ad5686_get_powerdown_mode(struct iio_dev *indio_dev, const struct iio_chan_spec *chan) { struct ad5686_state *st =3D iio_priv(indio_dev); + int mode, shift =3D ad5686_pd_mask_shift(chan); =20 - return ((st->pwr_down_mode >> (chan->channel * 2)) & 0x3) - 1; + mutex_lock(&st->lock); + mode =3D ((st->pwr_down_mode >> shift) & 0x3) - 1; + mutex_unlock(&st->lock); + + return mode; } =20 static int ad5686_set_powerdown_mode(struct iio_dev *indio_dev, @@ -53,9 +67,12 @@ static int ad5686_set_powerdown_mode(struct iio_dev *ind= io_dev, unsigned int mode) { struct ad5686_state *st =3D iio_priv(indio_dev); + int shift =3D ad5686_pd_mask_shift(chan); =20 - st->pwr_down_mode &=3D ~(0x3 << (chan->channel * 2)); - st->pwr_down_mode |=3D ((mode + 1) << (chan->channel * 2)); + mutex_lock(&st->lock); + st->pwr_down_mode &=3D ~(0x3 << shift); + st->pwr_down_mode |=3D ((mode + 1) << shift); + mutex_unlock(&st->lock); =20 return 0; } @@ -71,9 +88,13 @@ static ssize_t ad5686_read_dac_powerdown(struct iio_dev = *indio_dev, uintptr_t private, const struct iio_chan_spec *chan, char *buf) { struct ad5686_state *st =3D iio_priv(indio_dev); + int val, shift =3D ad5686_pd_mask_shift(chan); =20 - return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask & - (0x3 << (chan->channel * 2)))); + mutex_lock(&st->lock); + val =3D !!(st->pwr_down_mask & (0x3 << shift)); + mutex_unlock(&st->lock); + + return sysfs_emit(buf, "%d\n", val); } =20 static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, @@ -83,7 +104,7 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev= *indio_dev, size_t len) { bool readin; - int ret; + int ret, shift =3D ad5686_pd_mask_shift(chan); struct ad5686_state *st =3D iio_priv(indio_dev); unsigned int val; u8 address =3D 0; @@ -92,10 +113,12 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_d= ev *indio_dev, if (ret) return ret; =20 + mutex_lock(&st->lock); + if (readin) - st->pwr_down_mask |=3D (0x3 << (chan->channel * 2)); + st->pwr_down_mask |=3D (0x3 << shift); else - st->pwr_down_mask &=3D ~(0x3 << (chan->channel * 2)); + st->pwr_down_mask &=3D ~(0x3 << shift); =20 switch (st->chip_info->regmap_type) { case AD5310_REGMAP: @@ -116,9 +139,10 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_d= ev *indio_dev, ret =3D st->write(st, AD5686_CMD_POWERDOWN_DAC, address, val); break; default: - return -EINVAL; + ret =3D -EINVAL; } =20 + mutex_unlock(&st->lock); =20 return ret ? ret : len; } @@ -434,7 +458,7 @@ int ad5686_probe(struct device *dev, { struct iio_dev *indio_dev; struct ad5686_state *st; - int ret, i; + int ret, i, shift; =20 indio_dev =3D devm_iio_device_alloc(dev, sizeof(*st)); if (indio_dev =3D=3D NULL) @@ -455,8 +479,14 @@ int ad5686_probe(struct device *dev, st->vref_mv =3D st->use_internal_vref ? st->chip_info->int_vref_mv : ret = / 1000; =20 /* Set all the power down mode for all channels to 1K pulldown */ - for (i =3D 0; i < st->chip_info->num_channels; i++) - st->pwr_down_mode |=3D (0x01 << (i * 2)); + st->pwr_down_mode =3D ~0U; + st->pwr_down_mask =3D ~0U; + for (i =3D 0; i < st->chip_info->num_channels; i++) { + shift =3D ad5686_pd_mask_shift(&st->chip_info->channels[i]); + st->pwr_down_mask &=3D ~(0x3 << shift); /* powered up state */ + st->pwr_down_mode &=3D ~(0x3 << shift); + st->pwr_down_mode |=3D (0x01 << shift); + } =20 indio_dev->name =3D name; indio_dev->info =3D &ad5686_info; --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 D05E7345CDC; Wed, 22 Apr 2026 14:46:24 +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=1776869184; cv=none; b=RxbYVm9J6WUfdfhFjQjtB+68ffXhBhfD7nFcmCaV+q9o7Seci3WomDy7w/Nhq096372k7EwzwazzJeL4d3St6s7ScXGdXw2ZRKPksDF9vK2Ta6jWynUxqLNL8uWFId0/Ga2PYdfO29zutBSzv12G4gG9Mrn8aWdVndtVp4wU3jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869184; c=relaxed/simple; bh=fxSwh5YZV0lJwNqSnII1QOTZVKAjsKtIukTH30xl2OE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V7VBHRaSY1hqniefppe9Zc0IQusdRUH4OezTayjmHf/ObKCX85Nr4l9dakcqu7OFNN3VpTxJbe2y3l2PO/xDJFeKhTWBWKcwEdFid6AU5nadF1bw/UiSYmiy5Ai0wJc3ve2eJpzNRM+4Kqi+hsTYfk9j9oHy0IwmQ49Va9C8iFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VKbhA42z; 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="VKbhA42z" Received: by smtp.kernel.org (Postfix) with ESMTPS id A9A04C4AF19; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=fxSwh5YZV0lJwNqSnII1QOTZVKAjsKtIukTH30xl2OE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=VKbhA42z5pTeKTR83QwZzXsi2Iu6DfE0gCqqcGxTV3K321c0xo77BioKtZV7VC0qv XGjJ6s2sZg9zO2ixuOJ4eERaAzfQd3Kfmi3Mf7HLbQhxUcz+1owB8RfS+OA34Tt00Y 8iOwpQJ1iWQwme46oZIgPnNAvCJEqxMaRzjuu12lCj9pGfjqkQACovG3TB51D2b35C wdSdJWanvXqIRoEq2ls9kUzfqagKpEFLNHgoTkOIHnVSnXMWxV6hwA3lwOO8fnRkdV v0uJtE3eV6ke7+Rw2fiP/LqiC0vGBfJdGBTQUkoumAjDNWaTAGgAsr25JDVlOokGex LYbfnv+77bKPw== 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 9FEA8F9EDF7; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:47 +0100 Subject: [PATCH 13/22] iio: dac: ad5686: fix input raw value check 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: <20260422-ad5313r-iio-support-v1-13-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=852; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=f6PzyqSsWxOZZP4d7ht2aA8eC0y4w+JduFiMQSa6zy8=; b=2zDSyBy3PiTZVEfheySnluorFvGYtbMC503N7GbMqpmFI4Jm1nUdvB3I0thMUFSWM83HzqcPR NgfzkzxSvc8Bm+dugDpgBA2e98CPjy2VtBOwH6QPUNsVoKE+kSQZMgm 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 Use in_range() to fix range check for input raw value, which is off by one, i.e., for a 10-bit DAC the max valid value is 1023, but 1 << 10 equals 1024, which passes the previous check, allowing an out-of-range write. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 19d791c655b7..07a944311f0e 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -185,7 +185,7 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, =20 switch (mask) { case IIO_CHAN_INFO_RAW: - if (val > (1 << chan->scan_type.realbits) || val < 0) + if (!in_range(val, 0, 1 << chan->scan_type.realbits)) return -EINVAL; =20 mutex_lock(&st->lock); --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 E4DC534846E; Wed, 22 Apr 2026 14:46:24 +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=1776869185; cv=none; b=XZk0MoL3Ix2qZ1m+0LtQpz0aNIXldngoAYIO+Dmb9QJlov4eVDdgftapMJcR2ZkDFtGMElpZEEceQ2tiJw5KZ/2UDbC3Okyi+1sRGbRl/4SEwSbrffGUEegsM5yPnLwOvWPmTuXVHJpCHHViVWGe8tAqedTVvaz+Atg8ZNX1iw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869185; c=relaxed/simple; bh=3hESn832CfVD1qGqLh7+GlKm0U4NhAxkZ7Jm+PmxZfo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A9214TDxYpR+HJdktt15gis06C+jA7s8aOXixjRLwdE8aOmoP24CyCSTTNYv1S0Bp33U+yQC/nkztfuavD2JM3vpfabU8mbzpkcvLP3X4bKeSfb9XjDA3lGeWE9Ql25uz6ee+JcyagmhlFRqx029Xasv6bkVrfXlAHyhq6ClcQk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JNg2yGLo; 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="JNg2yGLo" Received: by smtp.kernel.org (Postfix) with ESMTPS id BEA9FC2BCC7; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=3hESn832CfVD1qGqLh7+GlKm0U4NhAxkZ7Jm+PmxZfo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=JNg2yGLoFpsOWkyeVaMnv1zbEpzRsezV66/C8WGBGgsm2VvANZqIPn0dDWk0jbKyL +UzscNWQaohkZ6AcjfVj+0X0CJTC1FVuH5O52ktcH8Abcc6ofiYzFzLUZT8AcfpPXD nF2kA4rvzsp3fh0q16HHSY+wrZovUsCzmdZTc6vLFhGF3h/njlkmD8m+VKMy/2OGEw F9wtNYFup3iHzODgdGCr+IXprswlYnCxLxoktxukhQ3h4QprAmMz+WjUeTnQa+1DOg p0iYGmJDr9VTej+nxnoHp4AmXp9gg7yPlBy3ShcZ+vVhJJiaIURgEpEG0Q6qgxET7b Ts6/bkrMUw1XQ== 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 B259DF9EDF8; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:48 +0100 Subject: [PATCH 14/22] iio: dac: ad5686: add support for missing power supplies 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: <20260422-ad5313r-iio-support-v1-14-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=2155; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Z/GezyWiY80ZBSqa1VITaQKZTnq4hO/6275dv+f3m1U=; b=3RNNPvTq3x/z9VtYoeaK53SU6Z31sVadzXzmfwmHfmiQ1pvHV4I33R/F4W2EhjmkTg99iK7pz +l2nVz2SAebAnHLN9tvaJdY1s4MrN+OLbB61Auk/w6PfQPM1Z66ZzZm 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 Get optional regulators for vdd, vlogic and vref input power pins. vdd is the input power supply, while vlogic powers the digital side. vref is replacing vcc, which is being deprecated, but still supported. The value of vref_mv is checked so that a device without internal voltage reference cannot proceed without an explicit supply. Error report uses dev_err_probe(), which helps debugging an init issue. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 07a944311f0e..4989404a7b6e 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -7,6 +7,7 @@ =20 #include #include +#include #include #include #include @@ -471,13 +472,27 @@ int ad5686_probe(struct device *dev, st->read =3D read; st->chip_info =3D chip_info; =20 - ret =3D devm_regulator_get_enable_read_voltage(dev, "vcc"); + ret =3D devm_regulator_get_enable_optional(dev, "vdd"); + if (ret && ret !=3D -ENODEV) + return dev_err_probe(dev, ret, "failed to enable vdd supply\n"); + + ret =3D devm_regulator_get_enable_optional(dev, "vlogic"); + if (ret && ret !=3D -ENODEV) + return dev_err_probe(dev, ret, "failed to enable vlogic supply\n"); + + ret =3D devm_regulator_get_enable_read_voltage(dev, "vref"); + if (ret =3D=3D -ENODEV) /* vcc-supply is deprecated, but supported still = */ + ret =3D devm_regulator_get_enable_read_voltage(dev, "vcc"); if (ret < 0 && ret !=3D -ENODEV) - return ret; + return dev_err_probe(dev, ret, "failed to read vref voltage\n"); =20 st->use_internal_vref =3D ret =3D=3D -ENODEV; st->vref_mv =3D st->use_internal_vref ? st->chip_info->int_vref_mv : ret = / 1000; =20 + if (!st->vref_mv) + return dev_err_probe(dev, -EINVAL, + "invalid or not provided vref voltage\n"); + /* Set all the power down mode for all channels to 1K pulldown */ st->pwr_down_mode =3D ~0U; st->pwr_down_mask =3D ~0U; --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 F2D7A34D389; Wed, 22 Apr 2026 14:46:24 +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=1776869185; cv=none; b=odqt/SVSYGd55psnGGFOHFiYoz13tsS/r7uxKiWCv9NVao117onPm4ARmpjBOOGXNUyVsI5RTJdlO50U+FcW/YC0Tg7lzGLy6G8fCAjpGBgqdNh2KGHDJqzpIGPRIUc3/7R9vSER/jl5dMV6XATsVb6Z7p0DuoRvi40Fp8bE/z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869185; c=relaxed/simple; bh=pxNfPBV9abv2iiYKCM3CIOnVBpKtnMS17H+Wr7KVeQc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PfcS9Qzgq8xIXdjP+Qz3iu65IYBfSk7bBnrNBb6/2wGnjP66vtUuSueYoJfcMNin9NnEFqVKYozBLy7lGAHNR/mCs5IdoMZbEROCnVuvkglIgYlrPyX+5ZXvWJFXKTqQXwCcxW2mG7UBSb2GwjSzTEUv4vJNyEOPyyiPFfPNvqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=htWpR2/K; 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="htWpR2/K" Received: by smtp.kernel.org (Postfix) with ESMTPS id D2D35C4AF16; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=pxNfPBV9abv2iiYKCM3CIOnVBpKtnMS17H+Wr7KVeQc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=htWpR2/KEpwQAhd1AsDroXpwocx294Gt1L+ik3SXfGEafb1tYb25Z4gBZfyU+FaCW AhDRzKxbVsJpqjj37AzOVDo+t+3n9sTM1Wq39iVjd+aGz/QAjhU8JvO6Qf8Oxf75LV MO+uN858fsUbliIUOS50p0yUJ5PHlQ1rNiHuRVYjoHe2zcFYmay+cH7eyxXDgdmXtp XIAiPzqXVvbDyvAXubfmhTmKNicpIIDGEXV6kuOnnw4DV+WCwNmVNXL4WuJHbs1QU7 Amuu9/eYrw7Ms5KohDIPA9bMyJO+sv0kQ8v+9LNAUcT9d51YghwpHE/19/VbonOcXT FMGGV0nRoUoRw== 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 C6470F9EDF3; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:49 +0100 Subject: [PATCH 15/22] iio: dac: ad5686: create bus ops struct 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: <20260422-ad5313r-iio-support-v1-15-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=7997; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=uPClgrlUPxOW/10rckm79pZao0inPAAnozDn4pnLyIU=; b=wZDih8DVfYFcM/5Tu4xEMM01KygTMLWVe4b+INQfC1gIa4k9Y1xC9UjpG3DexSddC1IFJycdr lnakbLON2f3DpUuCjrKW/SvDFXXG2EiF6b1jMI9it90DJJCYE8k+TtV 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 Create struct with bus operations, including a sync() operation that will be used to flush multiple channel writes at once. Auxiliary functions ad5686_write() and ad5686_read() are created and ad5686_probe() now receives an ops struct pointer rather than individual read and write functions. Documentation header of ad5686_state struct is updated accordingly (adjusting renamed fields and formatting). Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686-spi.c | 7 ++++++- drivers/iio/dac/ad5686.c | 32 ++++++++++++++------------------ drivers/iio/dac/ad5686.h | 44 ++++++++++++++++++++++++++++++++--------= ---- drivers/iio/dac/ad5696-i2c.c | 7 ++++++- 4 files changed, 58 insertions(+), 32 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index 6c9b70880da9..9c00e016e67c 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -91,10 +91,15 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 = addr) return be32_to_cpu(st->data[2].d32); } =20 +static const struct ad5686_bus_ops ad5686_spi_ops =3D { + .write =3D ad5686_spi_write, + .read =3D ad5686_spi_read, +}; + static int ad5686_spi_probe(struct spi_device *spi) { return ad5686_probe(&spi->dev, spi_get_device_match_data(spi), - spi->modalias, ad5686_spi_write, ad5686_spi_read); + spi->modalias, &ad5686_spi_ops); } =20 static const struct spi_device_id ad5686_spi_id[] =3D { diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 4989404a7b6e..fddcc77ab794 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -27,18 +27,18 @@ static int ad5310_control_sync(struct ad5686_state *st) { unsigned int pd_val =3D st->pwr_down_mask & st->pwr_down_mode; =20 - return st->write(st, AD5686_CMD_CONTROL_REG, 0, - FIELD_PREP(AD5310_PD_MSK, pd_val) | - FIELD_PREP(AD5310_REF_BIT_MSK, !st->use_internal_vref)); + return ad5686_write(st, AD5686_CMD_CONTROL_REG, 0, + FIELD_PREP(AD5310_PD_MSK, pd_val) | + FIELD_PREP(AD5310_REF_BIT_MSK, !st->use_internal_vref)); } =20 static int ad5683_control_sync(struct ad5686_state *st) { unsigned int pd_val =3D st->pwr_down_mask & st->pwr_down_mode; =20 - return st->write(st, AD5686_CMD_CONTROL_REG, 0, - FIELD_PREP(AD5683_PD_MSK, pd_val) | - FIELD_PREP(AD5683_REF_BIT_MSK, !st->use_internal_vref)); + return ad5686_write(st, AD5686_CMD_CONTROL_REG, 0, + FIELD_PREP(AD5683_PD_MSK, pd_val) | + FIELD_PREP(AD5683_REF_BIT_MSK, !st->use_internal_vref)); } =20 static inline int ad5686_pd_mask_shift(const struct iio_chan_spec *chan) @@ -137,7 +137,7 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_de= v *indio_dev, } else { val =3D lower_16_bits(val); } - ret =3D st->write(st, AD5686_CMD_POWERDOWN_DAC, address, val); + ret =3D ad5686_write(st, AD5686_CMD_POWERDOWN_DAC, address, val); break; default: ret =3D -EINVAL; @@ -160,7 +160,7 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: mutex_lock(&st->lock); - ret =3D st->read(st, chan->address); + ret =3D ad5686_read(st, chan->address); mutex_unlock(&st->lock); if (ret < 0) return ret; @@ -190,10 +190,8 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, return -EINVAL; =20 mutex_lock(&st->lock); - ret =3D st->write(st, - AD5686_CMD_WRITE_INPUT_N_UPDATE_N, - chan->address, - val << chan->scan_type.shift); + ret =3D ad5686_write(st, AD5686_CMD_WRITE_INPUT_N_UPDATE_N, + chan->address, val << chan->scan_type.shift); mutex_unlock(&st->lock); break; default: @@ -454,8 +452,7 @@ EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686"); =20 int ad5686_probe(struct device *dev, const struct ad5686_chip_info *chip_info, - const char *name, ad5686_write_func write, - ad5686_read_func read) + const char *name, const struct ad5686_bus_ops *ops) { struct iio_dev *indio_dev; struct ad5686_state *st; @@ -468,8 +465,7 @@ int ad5686_probe(struct device *dev, st =3D iio_priv(indio_dev); =20 st->dev =3D dev; - st->write =3D write; - st->read =3D read; + st->ops =3D ops; st->chip_info =3D chip_info; =20 ret =3D devm_regulator_get_enable_optional(dev, "vdd"); @@ -525,8 +521,8 @@ int ad5686_probe(struct device *dev, return ret; break; case AD5686_REGMAP: - ret =3D st->write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0, - !st->use_internal_vref); + ret =3D ad5686_write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0, + !st->use_internal_vref); if (ret) return ret; break; diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 7004d0d1d97a..55f49dbbbd39 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -56,10 +56,17 @@ enum ad5686_regmap_type { =20 struct ad5686_state; =20 -typedef int (*ad5686_write_func)(struct ad5686_state *st, - u8 cmd, u8 addr, u16 val); - -typedef int (*ad5686_read_func)(struct ad5686_state *st, u8 addr); +/** + * ad5686_bus_ops - bus specific read/write operations + * @read: read a register value at the given address + * @write: write a command, address and value to the device + * @sync: ensure the completion of the write operation (optional) + */ +struct ad5686_bus_ops { + int (*read)(struct ad5686_state *st, u8 addr); + int (*write)(struct ad5686_state *st, u8 cmd, u8 addr, u16 val); + int (*sync)(struct ad5686_state *st); +}; =20 /** * struct ad5686_chip_info - chip specific information @@ -106,24 +113,23 @@ extern const struct ad5686_chip_info ad5679r_chip_inf= o; =20 /** * struct ad5686_state - driver instance specific data - * @spi: spi_device + * @dev: device instance * @chip_info: chip model specific constants, available modes etc + * @ops: bus specific operations * @vref_mv: actual reference voltage used * @pwr_down_mask: power down mask * @pwr_down_mode: current power down mode * @use_internal_vref: set to true if the internal reference voltage is us= ed - * @lock lock to protect the data buffer during regmap ops - * @data: spi transfer buffers + * @lock: lock to protect the data buffer during regmap ops + * @data: transfer buffers */ - struct ad5686_state { struct device *dev; const struct ad5686_chip_info *chip_info; + const struct ad5686_bus_ops *ops; unsigned short vref_mv; unsigned int pwr_down_mask; unsigned int pwr_down_mode; - ad5686_write_func write; - ad5686_read_func read; bool use_internal_vref; struct mutex lock; =20 @@ -142,8 +148,22 @@ struct ad5686_state { =20 int ad5686_probe(struct device *dev, const struct ad5686_chip_info *chip_info, - const char *name, ad5686_write_func write, - ad5686_read_func read); + const char *name, const struct ad5686_bus_ops *ops); =20 +static inline int ad5686_write(struct ad5686_state *st, u8 cmd, u8 addr, u= 16 val) +{ + int ret; + + ret =3D st->ops->write(st, cmd, addr, val); + if (ret) + return ret; + + return st->ops->sync ? st->ops->sync(st) : 0; +} + +static inline int ad5686_read(struct ad5686_state *st, u8 addr) +{ + return st->ops->read(st, addr); +} =20 #endif /* __DRIVERS_IIO_DAC_AD5686_H__ */ diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index 237f4b5df021..51cd765d80f3 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -61,10 +61,15 @@ static int ad5686_i2c_write(struct ad5686_state *st, return (ret !=3D 3) ? -EIO : 0; } =20 +static const struct ad5686_bus_ops ad5686_i2c_ops =3D { + .write =3D ad5686_i2c_write, + .read =3D ad5686_i2c_read, +}; + static int ad5686_i2c_probe(struct i2c_client *i2c) { return ad5686_probe(&i2c->dev, i2c_get_match_data(i2c), - i2c->name, ad5686_i2c_write, ad5686_i2c_read); + i2c->name, &ad5686_i2c_ops); } =20 static const struct i2c_device_id ad5686_i2c_id[] =3D { --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 1047F352F88; Wed, 22 Apr 2026 14:46:25 +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=1776869185; cv=none; b=IUQkiYhVF5c/WpFNvWdAp30ukdiujlAZM3/c3r6zB3rCM4PYBJDyutkyw6jaxuKb7+VfwJ3jWgFZfCw5V+oJPq82S8GCYc38Fna5xmNBNFjUbtAemMC8xxprJ8Y3ZxoeuGgbacWO3QqUMthDV1WxJ9ByVdNIlEmR9iV6O9fbEA8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869185; c=relaxed/simple; bh=f8VcwkTRlYpjFKy1P9T3fyn8hxX6zRLwXAQcqJzAAn8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=paJX+cr5VBS3zkwLAyuzgwXVIxM7IlaQX09uJhLPm8B2lfpUPH5o/1EgtSobKM4HHAzgPYQ34YWrqBnGj4mvmRAcYDoAPPHbTkSsqvv7nmx58Z9uFDfkFS+96Aa5gfKweohrilZkZdE00bGfhdh6xpKtZ7FQjAwdzgxr1ZNvsjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JgXgygeR; 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="JgXgygeR" Received: by smtp.kernel.org (Postfix) with ESMTPS id DFFCAC19425; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869184; bh=f8VcwkTRlYpjFKy1P9T3fyn8hxX6zRLwXAQcqJzAAn8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=JgXgygeRlEruOHRGEuYl1oLDIKsAIWoTF4AkTB4fRj2cRTIn+Ymfe0ZtrqPfIouAb QkRBLcjsGlIgUfNvmn9iXLRnHCfGAjOeQUjjPrV8pFqyo/H8af6ft7RyX7/v7e3YZ4 oMDfbPFtWDpTqa7b0O/0hfRV19KDWLZ7dyIQKRGLHhTNxOCz1UqYu7SCHdDM1ELswD pOyzOsXkZGBNgr+SWY3dfOWkZRvHct2rl0d0Dfq2T2ue5IhG970aqT+BhORPDzu+BR slwZexcFXsq6oZnzq1CNEYSkJUCQGhenzyFB4T14MsG1wRhaLVxXyELuohE5a5dCqI 0b0z/C1i0xVBg== 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 D822DF9EDF4; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:50 +0100 Subject: [PATCH 16/22] iio: dac: ad5686: extend device support with new parts 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: <20260422-ad5313r-iio-support-v1-16-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=10073; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=ZOoAgr93kAfD2sJxGQv6hN2qubBX9RO2hW6A/Wbys+I=; b=mm8eqFL3aj9kOMry+45BTtlgSfv3slwm9xkvid8FQAuu6+EzNTPoRyuwT5Eysh18Ni/jPYpvk 7geHzON7rIqCOHNCE+buuZUvbGQsg5iJ9V/ycxiuhEnMMrvQZx9L1So 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 AD5313R, AD5317R, AD5674, AD5679, AD5687, AD5687R, AD5689, AD5689R to the AD5686 SPI driver. Also adding support for AD5316R, AD5675, AD5697R to the AD5696 I2C driver. This includes the creation of seven chip info struct instances and reuse of existing ones. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686-spi.c | 16 +++++++++++++ drivers/iio/dac/ad5686.c | 55 ++++++++++++++++++++++++++++++++++++++++= ++++ drivers/iio/dac/ad5686.h | 7 ++++++ drivers/iio/dac/ad5696-i2c.c | 6 +++++ 4 files changed, 84 insertions(+) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index 9c00e016e67c..b57dc88eb953 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -104,10 +104,14 @@ static int ad5686_spi_probe(struct spi_device *spi) =20 static const struct spi_device_id ad5686_spi_id[] =3D { { "ad5310r", (kernel_ulong_t)&ad5310r_chip_info }, + { "ad5313r", (kernel_ulong_t)&ad5338r_chip_info }, + { "ad5317r", (kernel_ulong_t)&ad5317r_chip_info }, { "ad5672r", (kernel_ulong_t)&ad5672r_chip_info }, + { "ad5674", (kernel_ulong_t)&ad5674_chip_info }, { "ad5674r", (kernel_ulong_t)&ad5674r_chip_info }, { "ad5676", (kernel_ulong_t)&ad5676_chip_info }, { "ad5676r", (kernel_ulong_t)&ad5676r_chip_info }, + { "ad5679", (kernel_ulong_t)&ad5679_chip_info }, { "ad5679r", (kernel_ulong_t)&ad5679r_chip_info }, { "ad5681r", (kernel_ulong_t)&ad5681r_chip_info }, { "ad5682r", (kernel_ulong_t)&ad5682r_chip_info }, @@ -119,16 +123,24 @@ static const struct spi_device_id ad5686_spi_id[] =3D= { { "ad5685r", (kernel_ulong_t)&ad5685r_chip_info }, { "ad5686", (kernel_ulong_t)&ad5686_chip_info }, { "ad5686r", (kernel_ulong_t)&ad5686r_chip_info }, + { "ad5687", (kernel_ulong_t)&ad5687_chip_info }, + { "ad5687r", (kernel_ulong_t)&ad5687r_chip_info }, + { "ad5689", (kernel_ulong_t)&ad5689_chip_info }, + { "ad5689r", (kernel_ulong_t)&ad5689r_chip_info }, { } }; MODULE_DEVICE_TABLE(spi, ad5686_spi_id); =20 static const struct of_device_id ad5686_of_match[] =3D { { .compatible =3D "adi,ad5310r", .data =3D &ad5310r_chip_info }, + { .compatible =3D "adi,ad5313r", .data =3D &ad5338r_chip_info }, + { .compatible =3D "adi,ad5317r", .data =3D &ad5317r_chip_info }, { .compatible =3D "adi,ad5672r", .data =3D &ad5672r_chip_info }, + { .compatible =3D "adi,ad5674", .data =3D &ad5674_chip_info }, { .compatible =3D "adi,ad5674r", .data =3D &ad5674r_chip_info }, { .compatible =3D "adi,ad5676", .data =3D &ad5676_chip_info }, { .compatible =3D "adi,ad5676r", .data =3D &ad5676r_chip_info }, + { .compatible =3D "adi,ad5679", .data =3D &ad5679_chip_info }, { .compatible =3D "adi,ad5679r", .data =3D &ad5679r_chip_info }, { .compatible =3D "adi,ad5681r", .data =3D &ad5681r_chip_info }, { .compatible =3D "adi,ad5682r", .data =3D &ad5682r_chip_info }, @@ -139,6 +151,10 @@ static const struct of_device_id ad5686_of_match[] =3D= { { .compatible =3D "adi,ad5685r", .data =3D &ad5685r_chip_info }, { .compatible =3D "adi,ad5686", .data =3D &ad5686_chip_info }, { .compatible =3D "adi,ad5686r", .data =3D &ad5686r_chip_info }, + { .compatible =3D "adi,ad5687", .data =3D &ad5687_chip_info }, + { .compatible =3D "adi,ad5687r", .data =3D &ad5687r_chip_info }, + { .compatible =3D "adi,ad5689", .data =3D &ad5689_chip_info }, + { .compatible =3D "adi,ad5689r", .data =3D &ad5689r_chip_info }, { } }; MODULE_DEVICE_TABLE(of, ad5686_of_match); diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index fddcc77ab794..bb661d985626 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -296,8 +296,11 @@ DECLARE_AD5683_CHANNELS(ad5683r_channels, 16, 0); /* dual-channel */ DECLARE_AD5338_CHANNELS(ad5337r_channels, 8, 8); DECLARE_AD5338_CHANNELS(ad5338r_channels, 10, 6); +DECLARE_AD5338_CHANNELS(ad5687r_channels, 12, 4); +DECLARE_AD5338_CHANNELS(ad5689r_channels, 16, 0); =20 /* quad-channel */ +DECLARE_AD5686_CHANNELS(ad5317r_channels, 10, 6); DECLARE_AD5686_CHANNELS(ad5684r_channels, 12, 4); DECLARE_AD5686_CHANNELS(ad5685r_channels, 14, 2); DECLARE_AD5686_CHANNELS(ad5686r_channels, 16, 0); @@ -373,6 +376,44 @@ const struct ad5686_chip_info ad5338r_chip_info =3D { }; EXPORT_SYMBOL_NS_GPL(ad5338r_chip_info, "IIO_AD5686"); =20 +const struct ad5686_chip_info ad5687_chip_info =3D { + .channels =3D ad5687r_channels, + .num_channels =3D 2, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5687_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5687r_chip_info =3D { + .channels =3D ad5687r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 2, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5687r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5689_chip_info =3D { + .channels =3D ad5689r_channels, + .num_channels =3D 2, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5689_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5689r_chip_info =3D { + .channels =3D ad5689r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 2, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5689r_chip_info, "IIO_AD5686"); + +const struct ad5686_chip_info ad5317r_chip_info =3D { + .channels =3D ad5317r_channels, + .int_vref_mv =3D 2500, + .num_channels =3D 4, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5317r_chip_info, "IIO_AD5686"); + const struct ad5686_chip_info ad5684_chip_info =3D { .channels =3D ad5684r_channels, .num_channels =3D 4, @@ -434,6 +475,13 @@ const struct ad5686_chip_info ad5676r_chip_info =3D { }; EXPORT_SYMBOL_NS_GPL(ad5676r_chip_info, "IIO_AD5686"); =20 +const struct ad5686_chip_info ad5674_chip_info =3D { + .channels =3D ad5674r_channels, + .num_channels =3D 16, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5674_chip_info, "IIO_AD5686"); + const struct ad5686_chip_info ad5674r_chip_info =3D { .channels =3D ad5674r_channels, .int_vref_mv =3D 2500, @@ -442,6 +490,13 @@ const struct ad5686_chip_info ad5674r_chip_info =3D { }; EXPORT_SYMBOL_NS_GPL(ad5674r_chip_info, "IIO_AD5686"); =20 +const struct ad5686_chip_info ad5679_chip_info =3D { + .channels =3D ad5679r_channels, + .num_channels =3D 16, + .regmap_type =3D AD5686_REGMAP, +}; +EXPORT_SYMBOL_NS_GPL(ad5679_chip_info, "IIO_AD5686"); + const struct ad5686_chip_info ad5679r_chip_info =3D { .channels =3D ad5679r_channels, .int_vref_mv =3D 2500, diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 55f49dbbbd39..e2ed0a2a8ac9 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -94,8 +94,13 @@ extern const struct ad5686_chip_info ad5683r_chip_info; /* dual-channel instances */ extern const struct ad5686_chip_info ad5337r_chip_info; extern const struct ad5686_chip_info ad5338r_chip_info; +extern const struct ad5686_chip_info ad5687_chip_info; +extern const struct ad5686_chip_info ad5687r_chip_info; +extern const struct ad5686_chip_info ad5689_chip_info; +extern const struct ad5686_chip_info ad5689r_chip_info; =20 /* quad-channel instances */ +extern const struct ad5686_chip_info ad5317r_chip_info; extern const struct ad5686_chip_info ad5684_chip_info; extern const struct ad5686_chip_info ad5684r_chip_info; extern const struct ad5686_chip_info ad5685r_chip_info; @@ -108,7 +113,9 @@ extern const struct ad5686_chip_info ad5676_chip_info; extern const struct ad5686_chip_info ad5676r_chip_info; =20 /* 16-channel instances */ +extern const struct ad5686_chip_info ad5674_chip_info; extern const struct ad5686_chip_info ad5674r_chip_info; +extern const struct ad5686_chip_info ad5679_chip_info; extern const struct ad5686_chip_info ad5679r_chip_info; =20 /** diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index 51cd765d80f3..8fb9da7fde1f 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -74,10 +74,12 @@ static int ad5686_i2c_probe(struct i2c_client *i2c) =20 static const struct i2c_device_id ad5686_i2c_id[] =3D { { "ad5311r", (kernel_ulong_t)&ad5311r_chip_info }, + { "ad5316r", (kernel_ulong_t)&ad5317r_chip_info }, { "ad5337r", (kernel_ulong_t)&ad5337r_chip_info }, { "ad5338r", (kernel_ulong_t)&ad5338r_chip_info }, { "ad5671r", (kernel_ulong_t)&ad5672r_chip_info }, { "ad5673r", (kernel_ulong_t)&ad5674r_chip_info }, + { "ad5675", (kernel_ulong_t)&ad5676_chip_info }, { "ad5675r", (kernel_ulong_t)&ad5676r_chip_info }, { "ad5677r", (kernel_ulong_t)&ad5679r_chip_info }, { "ad5691r", (kernel_ulong_t)&ad5681r_chip_info }, @@ -89,16 +91,19 @@ static const struct i2c_device_id ad5686_i2c_id[] =3D { { "ad5695r", (kernel_ulong_t)&ad5685r_chip_info }, { "ad5696", (kernel_ulong_t)&ad5686_chip_info }, { "ad5696r", (kernel_ulong_t)&ad5686r_chip_info }, + { "ad5697r", (kernel_ulong_t)&ad5687r_chip_info }, { } }; MODULE_DEVICE_TABLE(i2c, ad5686_i2c_id); =20 static const struct of_device_id ad5686_of_match[] =3D { { .compatible =3D "adi,ad5311r", .data =3D &ad5311r_chip_info }, + { .compatible =3D "adi,ad5316r", .data =3D &ad5317r_chip_info }, { .compatible =3D "adi,ad5337r", .data =3D &ad5337r_chip_info }, { .compatible =3D "adi,ad5338r", .data =3D &ad5338r_chip_info }, { .compatible =3D "adi,ad5671r", .data =3D &ad5672r_chip_info }, { .compatible =3D "adi,ad5673r", .data =3D &ad5674r_chip_info }, + { .compatible =3D "adi,ad5675", .data =3D &ad5676_chip_info }, { .compatible =3D "adi,ad5675r", .data =3D &ad5676r_chip_info }, { .compatible =3D "adi,ad5677r", .data =3D &ad5679r_chip_info }, { .compatible =3D "adi,ad5691r", .data =3D &ad5681r_chip_info }, @@ -110,6 +115,7 @@ static const struct of_device_id ad5686_of_match[] =3D { { .compatible =3D "adi,ad5695r", .data =3D &ad5685r_chip_info }, { .compatible =3D "adi,ad5696", .data =3D &ad5686_chip_info }, { .compatible =3D "adi,ad5696r", .data =3D &ad5686r_chip_info }, + { .compatible =3D "adi,ad5697r", .data =3D &ad5687r_chip_info }, { } }; MODULE_DEVICE_TABLE(of, ad5686_of_match); --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 27B853563EB; Wed, 22 Apr 2026 14:46:25 +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=1776869185; cv=none; b=H8zvalvHYWxl5kgb5oBUjgOexClds1BUtk4sCRpbxwFSkTQJjPrw8eVMjWrfQI0SETMRYy/bNEMFuGJCCmW14bra2enXnOO25CoKkny3BNscVMyZxggKO+YwGS3HOp6n5aP/FahXU4pNhV1PIebUWVZhRQ+c2PnUxb1BdmF7sqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869185; c=relaxed/simple; bh=FJG8SonoGio8LwT7T00CqDcGH3iQXLHfoc+nen1ZNoI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FeMV/NI/g/4zGm2sSKCJgBBjA+upAVWIfNm1PoM6BNMyQP0qmqRSfavFLo/iaHLWpzEQNInuE1Rsp7Y3gWt+7/wIJEHuWc/ZqNuEyJS6R5Ncyd3JbL8MwC5U/bmaJm2Euwc5IXDC5DPlEWhVkZtNGv4uiMdc57uk2xrKySK7Ji4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=agJb0hBH; 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="agJb0hBH" Received: by smtp.kernel.org (Postfix) with ESMTPS id EF471C2BCC9; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869185; bh=FJG8SonoGio8LwT7T00CqDcGH3iQXLHfoc+nen1ZNoI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=agJb0hBHb4yZM6SunUBHX9Siw2o5lKeBUALbfUHtJO2xQsgV+iHqS9MxiwzhBKVBQ WwEoc4DamrQ4hpa7dsuF/XcwDZjoF3Lx51WwnbSLiCjZKvlFmyvlL3ye2zyXSs2G5n FiuiAu3kZdQOFK5moBQm+soenu7s15j0VvP+Ga+JBxLcyDy5fFU1wt+rdLpCnzXZsb XF8opm0B2ZqmLwgSTOGNLAn62iYmjgPEqxUgUuhIKy33/tUb1yK0WhgcYlN2cAGjoQ FffKhsY6fQHyUxwFEK3BbHZRMIgvU5Gpnl0qpaaPD1HUS+1Wry2UpHGy0etklMC6pP le6elE0Zzf3zA== 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 E78BAF9EDF7; Wed, 22 Apr 2026 14:46:24 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:51 +0100 Subject: [PATCH 17/22] iio: dac: ad5686: update device list description 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: <20260422-ad5313r-iio-support-v1-17-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=4131; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=6Itx5hy1mvB2bOEpnWldN5TFmPMjDDFuSdP09yLPaJw=; b=hx77HXvPzwJU7vo8vGaU4D/eefLuopDVNxdnxF3JVkfTFkGsTVywbh8Xp8uYFrTbzaB2/rr7v d2Rwkvie3wDCLMi4Nl5mTdltNknMmQ26qLWEGmsIHnjBOZ8nT7U3I1S 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 Update device list entries from comment headers for both SPI and I2C driver files and under Kconfig help text. Adjust comment header for the core file as supported devices are listed elsewhere. Also update Copyright notice in comment file headers with the current year. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/Kconfig | 16 +++++++++------- drivers/iio/dac/ad5686-spi.c | 8 ++++---- drivers/iio/dac/ad5686.c | 4 ++-- drivers/iio/dac/ad5696-i2c.c | 7 ++++--- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index cd4870b65415..8ef4a87d6d6a 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -235,9 +235,11 @@ config AD5686_SPI depends on SPI select AD5686 help - Say yes here to build support for Analog Devices AD5672R, AD5674R, - AD5676, AD5676R, AD5679R, AD5684, AD5684R, AD5684R, AD5685R, AD5686, - AD5686R Voltage Output Digital to Analog Converter. + Say yes here to build support for Analog Devices AD5310R, AD5313R, + AD5317R, AD5672R, AD5674, AD5674R, AD5676, AD5676R, AD5679, AD5679R, + AD5681R, AD5682R, AD5683, AD5683R, AD5684, AD5684R, AD5685R, AD5686, + AD5686R, AD5687, AD5687R, AD5689, AD5689R Voltage Output + Digital to Analog Converter. =20 To compile this driver as a module, choose M here: the module will be called ad5686. @@ -247,10 +249,10 @@ config AD5696_I2C depends on I2C select AD5686 help - Say yes here to build support for Analog Devices AD5311R, AD5337, - AD5338R, AD5671R, AD5673R, AD5675R, AD5677R, AD5691R, AD5692R, AD5693, - AD5693R, AD5694, AD5694R, AD5695R, AD5696, and AD5696R Digital to - Analog converters. + Say yes here to build support for Analog Devices AD5311R, AD5316R, + AD5338R, AD5671R, AD5673R, AD5675, AD5675R, AD5677R, AD5691R, AD5692R, + AD5693, AD5693R, AD5694, AD5694R, AD5695R, AD5696, AD5696R, AD5697R + Digital to Analog converters. =20 To compile this driver as a module, choose M here: the module will be called ad5696. diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index b57dc88eb953..ebfc40efa679 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -1,11 +1,11 @@ // SPDX-License-Identifier: GPL-2.0 /* - * AD5672R, AD5674R, AD5676, AD5676R, AD5679R, - * AD5681R, AD5682R, AD5683, AD5683R, AD5684, - * AD5684R, AD5685R, AD5686, AD5686R + * AD5310R, AD5313R, AD5317R, AD5672R, AD5674, AD5674R, AD5676, AD5676R, + * AD5679, AD5679R, AD5681R, AD5682R, AD5683, AD5683R, AD5684, AD5684R, + * AD5685R, AD5686, AD5686R, AD5687, AD5687R, AD5689, AD5689R * Digital to analog converters driver * - * Copyright 2018 Analog Devices Inc. + * Copyright 2018-2026 Analog Devices Inc. */ =20 #include diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index bb661d985626..cfbc1624e01c 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 /* - * AD5686R, AD5685R, AD5684R Digital to analog converters driver + * Core driver for AD5686R and similar Digital to analog converters * - * Copyright 2011 Analog Devices Inc. + * Copyright 2011-2026 Analog Devices Inc. */ =20 #include diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index 8fb9da7fde1f..e75c5f8c65aa 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -1,10 +1,11 @@ // SPDX-License-Identifier: GPL-2.0 /* - * AD5338R, AD5671R, AD5673R, AD5675R, AD5677R, AD5691R, AD5692R, AD5693, - * AD5693R, AD5694, AD5694R, AD5695R, AD5696, AD5696R + * AD5311R, AD5316R, AD5338R, AD5671R, AD5673R, AD5675, AD5675R, AD5677R, + * AD5691R, AD5692R, AD5693, AD5693R, AD5694, AD5694R, AD5695R, AD5696, + * AD5696R, AD5697R * Digital to analog converters driver * - * Copyright 2018 Analog Devices Inc. + * Copyright 2018-2026 Analog Devices Inc. */ =20 #include --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 381ED35CB6A; Wed, 22 Apr 2026 14:46:25 +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=1776869185; cv=none; b=byS4NGP5WhHfUAy80lvJIv3cmoe85iK4J2xOKaPeyg1yPk0fEXamMHsO71OOcRQzes7nCtonZHFFuO4YpDqG5fFPpf9b2L7HnARXzyYmc4P4c5VwObP0CCvqiBtCskHis+3uAOWnqKYHmdRiL6ONbraiUMDnQHMr7MTH9slufn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869185; c=relaxed/simple; bh=9Ry/xie9bws+jjU+HLl640jFV5VQErKM0NyN1y9kc5k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bg/Xr/gGoq/5c7y42zM/erUEr9W9DcwqJaI7WuffL56EVD/o/DmXobSG/yQD1xFqYqWj7SqhXNoyYA0XUyfQGb5BduQwhYZhFB3ZCtSIEsZ2LPL2Qjx1hNbhRSoSQzDoH+btR42LIOiK/DcAT8UaKqXqFqEf40djQifJjGjnnZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kpswZKMH; 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="kpswZKMH" Received: by smtp.kernel.org (Postfix) with ESMTPS id 100CAC2BCAF; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869185; bh=9Ry/xie9bws+jjU+HLl640jFV5VQErKM0NyN1y9kc5k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=kpswZKMHXzMyc3QudZhPA4SKi6jQFJQe4fH0R1ZjYGVyq/F2+8ZcE2Jbf+iG91LD2 YIbDonabJIAAfT3x1ZyNN9qCqBZCcL8BxVP4r3mW/cPIePLiFe1YFOOsRDVZq5V0fW aF3mv71qXKj+Sq9lVkpsM5mEuWFBqyDDUBXvFuGuep+FAISp5dfGQ0R/YXQ46eKIOR G6OJEfYIsesHe7pLvqW+aX8CW4IbBlqKh3PqCZSFjYCdp5+Ko9xJgI1anB09LQJeYg yqMvPUP1yBnYs7QtWMRIjKNDcJkKiBReHp175XfmsG/JjoQEjfQB2b1r5PKvuBD4yA LZrALXKwiyA5w== 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 036E2F9EDF8; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:52 +0100 Subject: [PATCH 18/22] iio: dac: ad5686: consume optional reset signal 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: <20260422-ad5313r-iio-support-v1-18-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=1411; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=3UgEqXCA/XRsf04HaUrlAwYpFQa0MfcYtNAzXdyAGX4=; b=IrB3+7OY+DElqxbbkxVqr6FxOrgkYRuwuEkx2P+glAx8X/YLBvxBifOwljdzkK3GBkpKVuK4c 3NflE0CYXbXDzFg2ZDC+rR88edxwgomPcJZ6CJd6CGELeEg0vwCOkZ9 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 RESET pin GPIO support through an optional reset controller, which is local to the probe function and deasserted by default. Signed-off-by: Rodrigo Alencar Reviewed-by: Philipp Zabel --- drivers/iio/dac/ad5686.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index cfbc1624e01c..f239880d1cc7 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include =20 @@ -509,6 +510,7 @@ int ad5686_probe(struct device *dev, const struct ad5686_chip_info *chip_info, const char *name, const struct ad5686_bus_ops *ops) { + struct reset_control *rstc; struct iio_dev *indio_dev; struct ad5686_state *st; int ret, i, shift; @@ -544,6 +546,11 @@ int ad5686_probe(struct device *dev, return dev_err_probe(dev, -EINVAL, "invalid or not provided vref voltage\n"); =20 + rstc =3D devm_reset_control_get_optional_exclusive_deasserted(dev, NULL); + if (IS_ERR(rstc)) + return dev_err_probe(dev, PTR_ERR(rstc), + "Failed to get reset controller\n"); + /* Set all the power down mode for all channels to 1K pulldown */ st->pwr_down_mode =3D ~0U; st->pwr_down_mask =3D ~0U; --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 3C3C135DA77; Wed, 22 Apr 2026 14:46:25 +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=1776869185; cv=none; b=bc5IbFIk+R0pH+Jf9HOnEzgczVV7MVyeTKM6EsJ75KaOoihN1ZGmZx3FjHjtLxdOk/b/qxqeS4HTFrsn/uviz3Ko9QlmeO/jKgjskzUHiVnEe/nGvJt/Uem+3vws3yE/Ycpkkr479O09Yt/Rc55omx4DwtOpduSimG5DMROab80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869185; c=relaxed/simple; bh=3kb2rSZ83unoM8iTQf9eNEvk87lDtXl/5M1lwDciVh4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y0dSZiDSLTUYZUwTE3K8btEsiinynOY5B0vDjEKB3HwDv1Pjto+rl+newC6I7oYHzMwZTYhKHjMpKLCI+k0DYIfVVt4CPpo5t1tZiOVjE/h+6YTSPFd6HfTBDbYIVeQ22ufqmy8i/Lv/QteeYQEJgNdTOz2g7EOel9/y88yiG6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UJdM1q+A; 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="UJdM1q+A" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1DBF7C2BCB2; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869185; bh=3kb2rSZ83unoM8iTQf9eNEvk87lDtXl/5M1lwDciVh4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=UJdM1q+AX5BvquMTtsBnq23ksbbqqUGaYrL+GAQHi6HjNalOduINcLI9884ptc+KL yJcmbwxisO3IqsIAm+mtWlPSkjwnV1F1ZUfTnGpafQWekdei8JNFP/XawgxAAI2B+3 mzJRCHgiePpLH5CFD0ELCHHmqAx3vgzArOJXPvWO05MwhcoDixactYtVbTZKkr/GIP epBupXQBmFDvsiJVTVOc0xdtwWfHeAromTF3yeZo41zqyjNBrUoCHDuMALWPq5NDTL X9yI3sroAl7ibghGrGCDV5DasWKjcctqwCd7IlLog4xRFUwvQpV6VnFxFJuN3nj6ma 7B5xfMZBnfaAQ== 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 16420F9EDF3; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:53 +0100 Subject: [PATCH 19/22] iio: dac: ad5686: add ldac 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: <20260422-ad5313r-iio-support-v1-19-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=2053; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=378jN4/xaZA344iqhUUHGi9nfoBwWVzEp0C0waS1ZBY=; b=v96yvtPdGymCJ/tIcXH8we6BOqphHO7HhCQzxs7gkP2o/us62Q007vZYxb1jpbsl9PIw04U+N GjA4UCaS4OMANNvWUvOMYWk4NXFK6ysv/0pzyTJziY9Yb3zEs01mkv1 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 If wired LADC, should be held low when unused (pin is active-low), which allows for synchronous DAC updates. This will be used to update all the channels at the same time when adding buffer support. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 5 +++++ drivers/iio/dac/ad5686.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index f239880d1cc7..d37b4902766f 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -551,6 +551,11 @@ int ad5686_probe(struct device *dev, return dev_err_probe(dev, PTR_ERR(rstc), "Failed to get reset controller\n"); =20 + st->ldac_gpio =3D devm_gpiod_get_optional(dev, "ldac", GPIOD_OUT_HIGH); + if (IS_ERR(st->ldac_gpio)) + return dev_err_probe(dev, PTR_ERR(st->ldac_gpio), + "Failed to get LDAC GPIO\n"); + /* Set all the power down mode for all channels to 1K pulldown */ st->pwr_down_mode =3D ~0U; st->pwr_down_mask =3D ~0U; diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index e2ed0a2a8ac9..3b7460178632 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -9,6 +9,7 @@ #define __DRIVERS_IIO_DAC_AD5686_H__ =20 #include +#include #include #include =20 @@ -123,6 +124,7 @@ extern const struct ad5686_chip_info ad5679r_chip_info; * @dev: device instance * @chip_info: chip model specific constants, available modes etc * @ops: bus specific operations + * @ldac_gpio: LDAC pin GPIO descriptor * @vref_mv: actual reference voltage used * @pwr_down_mask: power down mask * @pwr_down_mode: current power down mode @@ -134,6 +136,7 @@ struct ad5686_state { struct device *dev; const struct ad5686_chip_info *chip_info; const struct ad5686_bus_ops *ops; + struct gpio_desc *ldac_gpio; unsigned short vref_mv; unsigned int pwr_down_mask; unsigned int pwr_down_mode; --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 570CD35F19D; Wed, 22 Apr 2026 14:46:25 +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=1776869185; cv=none; b=PgxDGz64cIX/4ngx6ZUXWuf6uHk7ABbqwZ311FhjuBEs5SKmAVRkKldUm8imcI2ZtqtCX+eZNoWhC2y88MdhzXkP93FYQKTF7gQVkxuPp5DdayBohq0OY3/TMSk3UK7BDl5CYbC6MA0vwW/n/s9gHv+gkdsjFbej2XFW3ZN1IK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869185; c=relaxed/simple; bh=HGcbT32nNh84iYmZUhGVRdfg3yoExBseX8EJ16yXRFY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eUsKxh9sfnEDvoMFJtZIQGP5HbcA4yYwHpodZVR4fO/p4QG/PF6IsdFww455EW70HtdCDuYvJMNfI1MWFrPvxiy7WbTePWHxmtciS+KURSPLHJMqKxX9wefrOAwK91wEjY2CQW5w5e3OEvnyqv44HFBroiE/y6OJlUzBKTPAurM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X6Me3c56; 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="X6Me3c56" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2F9C9C2BCF5; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869185; bh=HGcbT32nNh84iYmZUhGVRdfg3yoExBseX8EJ16yXRFY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=X6Me3c56vJsqV4BIFESreWbPuz3klvdYVSrZARJIF5ltA5eLXZX0/l6bBKFBrzGSh SkVMVUNXZ9BKxNZmqLNmEAATTOhO0w6j6ejXuZCi3MuZGydzyqxQlBIBJ2lF+xWIeG S4LmJxEYIyKgwyZguYRVQG9jK4avG4phkTWiIJNVXvoeZz/RWrstB9JhMLoDBo8r33 kJr6TxazPFGAhzqJYkzeDfZp1vN8Q2d2RqEpEG++hFTAr0W1QaxYxK8P7VOsONKLZ3 vvzh5U+Y+q+hBw7FFPMmb8Lti3rB9JmGvy1SdK6ZBFwsZhS2FFpNH8MM+zm43Olf7l ilEzgO6U5XiCA== 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 27858F9EDF9; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:54 +0100 Subject: [PATCH 20/22] iio: dac: ad5686: implement new sync() op for the spi bus 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: <20260422-ad5313r-iio-support-v1-20-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=8074; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=25qHTNPh69lU6r2wtccMyMUIekl87dfZK6NbWnQppHc=; b=qphIWVok7TmHf2La4HtYhXJDWfppAgGVjCLLMZDJgGxRjEynQm333kNAlOIv/ImHe7UdK2dl6 n694gf/A4VJB8XrMXI9uzrDpiWs8S6bQdRSQ3vmVsj7OxV7wqvnRx+8 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 Use of local SPI bus data to manage a collection of SPI transfers and flush them to the SPI platform driver with the sync() operation. This allows for faster handling of multiple channel DAC writes, avoiding kernel overhead per spi_sync() call, which will be helpful when enabling triggered buffer support. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686-spi.c | 110 +++++++++++++++++++++++++++++++--------= ---- drivers/iio/dac/ad5686.c | 4 +- drivers/iio/dac/ad5686.h | 8 +++- drivers/iio/dac/ad5696-i2c.c | 2 +- 4 files changed, 89 insertions(+), 35 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index ebfc40efa679..bacfb1deab31 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -13,57 +13,80 @@ #include #include #include +#include #include =20 #include "ad5686.h" =20 +struct ad5686_spi_data { + struct spi_message msg; + unsigned int size; + unsigned int capacity; + struct spi_transfer xfers[] __counted_by(capacity); +}; + static int ad5686_spi_write(struct ad5686_state *st, u8 cmd, u8 addr, u16 val) { - struct spi_device *spi =3D to_spi_device(st->dev); - u8 tx_len, *buf; + struct ad5686_spi_data *bus_data =3D st->bus_data; + struct spi_transfer *xfer; + + if (bus_data->size >=3D bus_data->capacity) + return -E2BIG; + + if (bus_data->size) + bus_data->xfers[bus_data->size - 1].cs_change =3D 1; + else + spi_message_init(&bus_data->msg); + + xfer =3D &bus_data->xfers[bus_data->size]; + xfer->rx_buf =3D NULL; + xfer->cs_change =3D 0; =20 switch (st->chip_info->regmap_type) { case AD5310_REGMAP: - st->data[0].d16 =3D cpu_to_be16(AD5310_CMD(cmd) | - val); - buf =3D &st->data[0].d8[0]; - tx_len =3D 2; + st->data[bus_data->size].d16 =3D cpu_to_be16(AD5310_CMD(cmd) | + val); + xfer->tx_buf =3D &st->data[bus_data->size].d8[0]; + xfer->len =3D 2; break; case AD5683_REGMAP: - st->data[0].d32 =3D cpu_to_be32(AD5686_CMD(cmd) | - AD5683_DATA(val)); - buf =3D &st->data[0].d8[1]; - tx_len =3D 3; + st->data[bus_data->size].d32 =3D cpu_to_be32(AD5686_CMD(cmd) | + AD5683_DATA(val)); + xfer->tx_buf =3D &st->data[bus_data->size].d8[1]; + xfer->len =3D 3; break; case AD5686_REGMAP: - st->data[0].d32 =3D cpu_to_be32(AD5686_CMD(cmd) | - AD5686_ADDR(addr) | - val); - buf =3D &st->data[0].d8[1]; - tx_len =3D 3; + st->data[bus_data->size].d32 =3D cpu_to_be32(AD5686_CMD(cmd) | + AD5686_ADDR(addr) | + val); + xfer->tx_buf =3D &st->data[bus_data->size].d8[1]; + xfer->len =3D 3; break; default: return -EINVAL; } =20 - return spi_write(spi, buf, tx_len); + spi_message_add_tail(xfer, &bus_data->msg); + bus_data->size++; + + return 0; +} + +static int ad5686_spi_sync(struct ad5686_state *st) +{ + struct spi_device *spi =3D to_spi_device(st->dev); + struct ad5686_spi_data *bus_data =3D st->bus_data; + + bus_data->size =3D 0; /* always reset, even on sync failure */ + return spi_sync(spi, &bus_data->msg); } =20 static int ad5686_spi_read(struct ad5686_state *st, u8 addr) { - struct spi_transfer t[] =3D { - { - .tx_buf =3D &st->data[0].d8[1], - .len =3D 3, - .cs_change =3D 1, - }, { - .tx_buf =3D &st->data[1].d8[1], - .rx_buf =3D &st->data[2].d8[1], - .len =3D 3, - }, - }; struct spi_device *spi =3D to_spi_device(st->dev); + struct ad5686_spi_data *bus_data =3D st->bus_data; + struct spi_transfer *xfer =3D &bus_data->xfers[0]; u8 cmd =3D 0; int ret; =20 @@ -84,8 +107,18 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 = addr) AD5686_ADDR(addr)); st->data[1].d32 =3D cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP)); =20 - ret =3D spi_sync_transfer(spi, t, ARRAY_SIZE(t)); - if (ret < 0) + xfer[0].tx_buf =3D &st->data[0].d8[1]; + xfer[0].len =3D 3; + xfer[0].cs_change =3D 1; + xfer[1].tx_buf =3D &st->data[1].d8[1]; + xfer[1].rx_buf =3D &st->data[2].d8[1]; + xfer[1].len =3D 3; + xfer[1].cs_change =3D 0; + + spi_message_init_with_transfers(&bus_data->msg, xfer, 2); + + ret =3D spi_sync(spi, &bus_data->msg); + if (ret) return ret; =20 return be32_to_cpu(st->data[2].d32); @@ -94,12 +127,27 @@ static int ad5686_spi_read(struct ad5686_state *st, u8= addr) static const struct ad5686_bus_ops ad5686_spi_ops =3D { .write =3D ad5686_spi_write, .read =3D ad5686_spi_read, + .sync =3D ad5686_spi_sync, }; =20 static int ad5686_spi_probe(struct spi_device *spi) { - return ad5686_probe(&spi->dev, spi_get_device_match_data(spi), - spi->modalias, &ad5686_spi_ops); + const struct ad5686_chip_info *info =3D spi_get_device_match_data(spi); + struct ad5686_spi_data *bus_data; + unsigned int capacity; + + /* read operation requires at least 2 transfers */ + capacity =3D max(info->num_channels, 2); + bus_data =3D devm_kzalloc(&spi->dev, + struct_size(bus_data, xfers, capacity), + GFP_KERNEL); + if (!bus_data) + return -ENOMEM; + + bus_data->capacity =3D capacity; + + return ad5686_probe(&spi->dev, info, spi->modalias, &ad5686_spi_ops, + bus_data); } =20 static const struct spi_device_id ad5686_spi_id[] =3D { diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index d37b4902766f..a065c614c874 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -508,7 +508,8 @@ EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686"); =20 int ad5686_probe(struct device *dev, const struct ad5686_chip_info *chip_info, - const char *name, const struct ad5686_bus_ops *ops) + const char *name, const struct ad5686_bus_ops *ops, + void *bus_data) { struct reset_control *rstc; struct iio_dev *indio_dev; @@ -523,6 +524,7 @@ int ad5686_probe(struct device *dev, =20 st->dev =3D dev; st->ops =3D ops; + st->bus_data =3D bus_data; st->chip_info =3D chip_info; =20 ret =3D devm_regulator_get_enable_optional(dev, "vdd"); diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 3b7460178632..ff30c96e1730 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -24,6 +24,7 @@ =20 #define AD5686_ADDR_DAC(chan) (0x1 << (chan)) #define AD5686_ADDR_ALL_DAC 0xF +#define AD5686_MAX_CHANNELS 16 =20 #define AD5686_CMD_NOOP 0x0 #define AD5686_CMD_WRITE_INPUT_N 0x1 @@ -130,6 +131,7 @@ extern const struct ad5686_chip_info ad5679r_chip_info; * @pwr_down_mode: current power down mode * @use_internal_vref: set to true if the internal reference voltage is us= ed * @lock: lock to protect the data buffer during regmap ops + * @bus_data: bus specific data * @data: transfer buffers */ struct ad5686_state { @@ -142,6 +144,7 @@ struct ad5686_state { unsigned int pwr_down_mode; bool use_internal_vref; struct mutex lock; + void *bus_data; =20 /* * DMA (thus cache coherency maintenance) may require the @@ -152,13 +155,14 @@ struct ad5686_state { __be32 d32; __be16 d16; u8 d8[4]; - } data[3] __aligned(IIO_DMA_MINALIGN); + } data[AD5686_MAX_CHANNELS] __aligned(IIO_DMA_MINALIGN); }; =20 =20 int ad5686_probe(struct device *dev, const struct ad5686_chip_info *chip_info, - const char *name, const struct ad5686_bus_ops *ops); + const char *name, const struct ad5686_bus_ops *ops, + void *bus_data); =20 static inline int ad5686_write(struct ad5686_state *st, u8 cmd, u8 addr, u= 16 val) { diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index e75c5f8c65aa..41dd4fe8054e 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -70,7 +70,7 @@ static const struct ad5686_bus_ops ad5686_i2c_ops =3D { static int ad5686_i2c_probe(struct i2c_client *i2c) { return ad5686_probe(&i2c->dev, i2c_get_match_data(i2c), - i2c->name, &ad5686_i2c_ops); + i2c->name, &ad5686_i2c_ops, NULL); } =20 static const struct i2c_device_id ad5686_i2c_id[] =3D { --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 5CBDD3603E1; Wed, 22 Apr 2026 14:46:25 +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=1776869185; cv=none; b=kVKIQgRgD2tvKfh3/4SKVXHg5yimHxr2hJOnArfB8R3j1mmWiVeSlujwyS5x3Ned4ZR+bCjJOkfPfRd8jaoWhBVzTKh9ktAqurqF8WPJ/lHKSetjC4vKJYdB0p11l/72TMNfVay3Vgez39FNcYWs8yFwYT0jGzfrt2/N16o349k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869185; c=relaxed/simple; bh=dV2Vf7Kj1xLGuXV3YDzzCt7K7isy1Z1mBtR4HJ/idCk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DVhE9JJgf7I1Rkg7ic2vQZ9Z04hYrQo4kHXAUeZ7K748+MV/dkJ9EPenIeXWVJv12kSRls5etUJksmlYO1cOa9dtXnsfiWEhjBMHifPfLomARLTSW+JDXEim9HbKP1BSXqqRW6fUI7WM8sjpV+Z44Swtx0HOr/hR/bEu13xJeS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PQJkw0ng; 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="PQJkw0ng" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3D663C2BCFA; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869185; bh=dV2Vf7Kj1xLGuXV3YDzzCt7K7isy1Z1mBtR4HJ/idCk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=PQJkw0ngmL1E0hQP+pNuvOhTLtZHjv4+zyv//sE8OaGwB8VSTQnucoBhVo06W9eBA SxHucZBnPft5GWqLhjkVz3z9SUSl5NfRqPGry5y5+c9Btnkd+1nDF4o2tG1KXKGINs loo58X7O0Rze/Mgo5e/243qD0ADPKU+WxVJmPAPJHBKl5kedr6mAZlrMXqVOM3mZ75 ZyPLRjvW1Z5aqzDbF4oBA5mh/VJGF7o3klhZPUluAqQc6XW3FmwROT5v+UUIRDNZoX qIZ4iz8dPMypPE8eBeSApnBb9nfnWsJJI6i/ZCeQNOm+mQITsq0zpp2xb8ZkJFoTbJ NemrPowidbueQ== 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 37527F9EDF6; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:55 +0100 Subject: [PATCH 21/22] iio: dac: ad5686: add triggered buffer 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: <20260422-ad5313r-iio-support-v1-21-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=3587; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=n/jQcRuYKzz2K1D7fdN2/Uolo6lmFJ6ohrN+/ywPH1A=; b=8goP76zj/wMm+SjuSmvAExMrATiZuEpHhx17kq6AfjB6Pb6MTqC2fmN1FtDaYzg8r9irxnzEG 1+gUKCYPOUJBQvcmyLuHUoshgO+k41cgOvWObU0vwb1ERh2qtM6Y3ro 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 Trigger handler is implemented by leveraging the LDAC gpio when it is available. Multiple channel writes can be flushed at once with the sync() operation. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/Kconfig | 2 ++ drivers/iio/dac/ad5686.c | 62 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 64 insertions(+) diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index 8ef4a87d6d6a..bb4d3bdabef2 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -229,6 +229,8 @@ config LTC2688 =20 config AD5686 tristate + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER =20 config AD5686_SPI tristate "Analog Devices AD5686 and similar multi-channel DACs (SPI)" diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index a065c614c874..bec951afe8d0 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -16,6 +16,11 @@ #include #include =20 +#include +#include +#include +#include + #include "ad5686.h" =20 static const char * const ad5686_powerdown_modes[] =3D { @@ -227,6 +232,7 @@ static const struct iio_chan_spec_ext_info ad5686_ext_i= nfo[] =3D { .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE),\ .address =3D addr, \ + .scan_index =3D chan, \ .scan_type =3D { \ .sign =3D 'u', \ .realbits =3D (bits), \ @@ -506,6 +512,55 @@ const struct ad5686_chip_info ad5679r_chip_info =3D { }; EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686"); =20 +static irqreturn_t ad5686_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf =3D p; + struct iio_dev *indio_dev =3D pf->indio_dev; + struct iio_buffer *buffer =3D indio_dev->buffer; + struct ad5686_state *st =3D iio_priv(indio_dev); + const struct iio_chan_spec *chan; + u16 val[AD5686_MAX_CHANNELS]; + int ret, ch, i =3D 0; + bool async_update; + u8 cmd; + + ret =3D iio_pop_from_buffer(buffer, val); + if (ret) + goto out; + + mutex_lock(&st->lock); + + async_update =3D st->ldac_gpio && bitmap_weight(indio_dev->active_scan_ma= sk, + iio_get_masklength(indio_dev)) > 1; + if (async_update) { + /* use ldac to update all channels simultaneously */ + cmd =3D AD5686_CMD_WRITE_INPUT_N; + gpiod_set_value_cansleep(st->ldac_gpio, 0); + } else { + cmd =3D AD5686_CMD_WRITE_INPUT_N_UPDATE_N; + } + + iio_for_each_active_channel(indio_dev, ch) { + chan =3D &indio_dev->channels[ch]; + ret =3D st->ops->write(st, cmd, chan->address, + val[i++] << chan->scan_type.shift); + if (ret) + break; + } + + if (!ret && st->ops->sync) + ret =3D st->ops->sync(st); /* flush all pending transfers */ + + if (async_update) + gpiod_set_value_cansleep(st->ldac_gpio, 1); + + mutex_unlock(&st->lock); +out: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + int ad5686_probe(struct device *dev, const struct ad5686_chip_info *chip_info, const char *name, const struct ad5686_bus_ops *ops, @@ -599,6 +654,13 @@ int ad5686_probe(struct device *dev, return -EINVAL; } =20 + ret =3D devm_iio_triggered_buffer_setup_ext(dev, indio_dev, NULL, + &ad5686_trigger_handler, + IIO_BUFFER_DIRECTION_OUT, + NULL, NULL); + if (ret) + return ret; + return devm_iio_device_register(dev, indio_dev); } EXPORT_SYMBOL_NS_GPL(ad5686_probe, "IIO_AD5686"); --=20 2.43.0 From nobody Wed Jun 17 04:15:33 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 6DD14362136; Wed, 22 Apr 2026 14:46:25 +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=1776869185; cv=none; b=MjX1XAkDqhg0VxZJFlf4whbRBaMLV5g6aN1ZAh6fIWwZa71CH/HsRbMTL7K7Fip8VknGjmsCm/moC5Ztrgf1woqTtvKVV3jctKmVwS/puISmajVMEovtm6UNwrQDB/d1v2/PLtuSoMwsjT9XkB1sfO1hJXK2+wFW7OwBIyusLMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776869185; c=relaxed/simple; bh=a1hoFBArNCRGOPxSOCT3KsKFGAF57mGdswh600GR89M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KNtMDFz7dXDopUSdtSHYjMS68nfJXuEj+rlz6woTJGSPBy9S8Sz+3xmBBXq8i+O6q46lwpRj0PNF4BZAuxRJ9AQzW6oaE4c8umBUknd8kOBwLXY6FxKAdoE83Na5h3iUiveUoxq4ls+anm2qtkB7nIgx38SC5u3Oz+Inc6ZuC+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nxj9vnoS; 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="nxj9vnoS" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4E369C19425; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776869185; bh=a1hoFBArNCRGOPxSOCT3KsKFGAF57mGdswh600GR89M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=nxj9vnoSTpzbQUkGSIcVDBMv3+6FmSr5O1GQtE6Omx4a04+LU3kz14ldUkQK33og4 W1eoIh9l5Gnvyz9JavI2nWEjPpJwxd6XbjqdC0ny9lMwf6YQR7XnijaXKk4a4aBeQ1 wPA8D5Hy40SaocbsgdN1tt0iBJOrnkPTirDbgmxLXu3HT5/R+jUjxzeTPbZBQtopGK wsO7Iee70dOg/rrqZEHEL00kRNqVs33MEUIXTqBBvltjp5xrwqWlACTqx5oTnkiE5X LzmLm5UWd2MRMiIh0GYPsXJwZ/5+N4uqv4IDLQIBFDX5u+h3pl8EzDM71/vzUa5AlE lrWiKA2Qtzekw== 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 475D0F9EDF8; Wed, 22 Apr 2026 14:46:25 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Wed, 22 Apr 2026 15:45:56 +0100 Subject: [PATCH 22/22] iio: dac: ad5686: add gain control 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: <20260422-ad5313r-iio-support-v1-22-ed7dca001d1b@analog.com> References: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> In-Reply-To: <20260422-ad5313r-iio-support-v1-0-ed7dca001d1b@analog.com> To: Jonathan Cameron , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Auchter , linux-hardening@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Philipp Zabel , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1776869181; l=8442; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=URbZ5TVRgr4bvYDvByD92jjaVJ7Ltjup1kD+2pY59yk=; b=Euh65UeH8BRPeQwqnDmHeDYANZUCIcpJ5FOLAxxbQH+xBIh68L/cVkMczbrWp6/smenkORqdr pNJgrMuFynkCkQR7ac7Po9xzZzdYZCfkWNZzkj2bqL9RZDzB1lmL2Qg 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 Most of the supported devices rely on a GAIN pin to control a 2x multiplier applied to the output voltage. Other devices, e.g. the single-channel ones, provides a gain control through a bit field in the control register. Some designs might have the GAIN pin hardwired to VDD/VLOGIC or GND, which would still be fine for this patch, that allows the scale property to be configurable with two available options. In read_raw() and write_raw() implementations mutex guards are used to allow early returns. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 110 +++++++++++++++++++++++++++++++++++++++----= ---- drivers/iio/dac/ad5686.h | 8 ++++ 2 files changed, 101 insertions(+), 17 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index bec951afe8d0..adbf62848697 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -10,10 +10,12 @@ #include #include #include +#include #include #include #include #include +#include #include =20 #include @@ -35,7 +37,8 @@ static int ad5310_control_sync(struct ad5686_state *st) =20 return ad5686_write(st, AD5686_CMD_CONTROL_REG, 0, FIELD_PREP(AD5310_PD_MSK, pd_val) | - FIELD_PREP(AD5310_REF_BIT_MSK, !st->use_internal_vref)); + FIELD_PREP(AD5310_REF_BIT_MSK, !st->use_internal_vref) | + FIELD_PREP(AD5310_GAIN_BIT_MSK, st->double_scale)); } =20 static int ad5683_control_sync(struct ad5686_state *st) @@ -44,7 +47,8 @@ static int ad5683_control_sync(struct ad5686_state *st) =20 return ad5686_write(st, AD5686_CMD_CONTROL_REG, 0, FIELD_PREP(AD5683_PD_MSK, pd_val) | - FIELD_PREP(AD5683_REF_BIT_MSK, !st->use_internal_vref)); + FIELD_PREP(AD5683_REF_BIT_MSK, !st->use_internal_vref) | + FIELD_PREP(AD5683_GAIN_BIT_MSK, st->double_scale)); } =20 static inline int ad5686_pd_mask_shift(const struct iio_chan_spec *chan) @@ -163,20 +167,25 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, struct ad5686_state *st =3D iio_priv(indio_dev); int ret; =20 + guard(mutex)(&st->lock); + switch (m) { case IIO_CHAN_INFO_RAW: - mutex_lock(&st->lock); ret =3D ad5686_read(st, chan->address); - mutex_unlock(&st->lock); if (ret < 0) return ret; *val =3D (ret >> chan->scan_type.shift) & GENMASK(chan->scan_type.realbits - 1, 0); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - *val =3D st->vref_mv; - *val2 =3D chan->scan_type.realbits; - return IIO_VAL_FRACTIONAL_LOG2; + if (st->double_scale) { + *val =3D st->scale_avail[2]; + *val2 =3D st->scale_avail[3]; + } else { + *val =3D st->scale_avail[0]; + *val2 =3D st->scale_avail[1]; + } + return IIO_VAL_INT_PLUS_NANO; } return -EINVAL; } @@ -188,28 +197,77 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, long mask) { struct ad5686_state *st =3D iio_priv(indio_dev); - int ret; + + guard(mutex)(&st->lock); =20 switch (mask) { case IIO_CHAN_INFO_RAW: if (!in_range(val, 0, 1 << chan->scan_type.realbits)) return -EINVAL; =20 - mutex_lock(&st->lock); - ret =3D ad5686_write(st, AD5686_CMD_WRITE_INPUT_N_UPDATE_N, - chan->address, val << chan->scan_type.shift); - mutex_unlock(&st->lock); - break; - default: - ret =3D -EINVAL; - } + return ad5686_write(st, AD5686_CMD_WRITE_INPUT_N_UPDATE_N, + chan->address, val << chan->scan_type.shift); + case IIO_CHAN_INFO_SCALE: + if (val =3D=3D st->scale_avail[0] && val2 =3D=3D st->scale_avail[1]) + st->double_scale =3D false; + else if (val =3D=3D st->scale_avail[2] && val2 =3D=3D st->scale_avail[3]) + st->double_scale =3D true; + else + return -EINVAL; =20 - return ret; + switch (st->chip_info->regmap_type) { + case AD5310_REGMAP: + return ad5310_control_sync(st); + case AD5683_REGMAP: + return ad5683_control_sync(st); + case AD5686_REGMAP: + gpiod_set_value_cansleep(st->gain_gpio, st->double_scale); + return 0; + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +static int ad5686_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_RAW: + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + return IIO_VAL_INT_PLUS_NANO; + default: + return -EINVAL; + } +} + +static int ad5686_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + struct ad5686_state *st =3D iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + *type =3D IIO_VAL_INT_PLUS_NANO; + *vals =3D st->scale_avail; + *length =3D ARRAY_SIZE(st->scale_avail); + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } } =20 static const struct iio_info ad5686_info =3D { .read_raw =3D ad5686_read_raw, .write_raw =3D ad5686_write_raw, + .write_raw_get_fmt =3D ad5686_write_raw_get_fmt, + .read_avail =3D ad5686_read_avail, }; =20 static const struct iio_chan_spec_ext_info ad5686_ext_info[] =3D { @@ -231,6 +289,7 @@ static const struct iio_chan_spec_ext_info ad5686_ext_i= nfo[] =3D { .channel =3D chan, \ .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE),\ + .info_mask_shared_by_type_available =3D BIT(IIO_CHAN_INFO_SCALE),\ .address =3D addr, \ .scan_index =3D chan, \ .scan_type =3D { \ @@ -512,6 +571,16 @@ const struct ad5686_chip_info ad5679r_chip_info =3D { }; EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686"); =20 +static void ad5686_init_scale_avail(struct ad5686_state *st) +{ + int realbits =3D st->chip_info->channels[0].scan_type.realbits; + s64 tmp; + + tmp =3D 2ULL * st->vref_mv * NANO >> realbits; + st->scale_avail[2] =3D div_s64_rem(tmp, NANO, &st->scale_avail[3]); + st->scale_avail[0] =3D div_s64_rem(tmp >> 1, NANO, &st->scale_avail[1]); +} + static irqreturn_t ad5686_trigger_handler(int irq, void *p) { struct iio_poll_func *pf =3D p; @@ -613,6 +682,13 @@ int ad5686_probe(struct device *dev, return dev_err_probe(dev, PTR_ERR(st->ldac_gpio), "Failed to get LDAC GPIO\n"); =20 + st->gain_gpio =3D devm_gpiod_get_optional(dev, "gain", GPIOD_OUT_LOW); + if (IS_ERR(st->gain_gpio)) + return dev_err_probe(dev, PTR_ERR(st->gain_gpio), + "Failed to get GAIN GPIO\n"); + + ad5686_init_scale_avail(st); + /* Set all the power down mode for all channels to 1K pulldown */ st->pwr_down_mode =3D ~0U; st->pwr_down_mask =3D ~0U; diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index ff30c96e1730..f2680cd1a057 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -45,8 +45,10 @@ #define AD5686_CMD_CONTROL_REG 0x4 #define AD5686_CMD_READBACK_ENABLE_V2 0x5 =20 +#define AD5310_GAIN_BIT_MSK BIT(7) #define AD5310_REF_BIT_MSK BIT(8) #define AD5310_PD_MSK GENMASK(10, 9) +#define AD5683_GAIN_BIT_MSK BIT(11) #define AD5683_REF_BIT_MSK BIT(12) #define AD5683_PD_MSK GENMASK(14, 13) =20 @@ -126,9 +128,12 @@ extern const struct ad5686_chip_info ad5679r_chip_info; * @chip_info: chip model specific constants, available modes etc * @ops: bus specific operations * @ldac_gpio: LDAC pin GPIO descriptor + * @gain_gpio: GAIN pin GPIO descriptor * @vref_mv: actual reference voltage used * @pwr_down_mask: power down mask * @pwr_down_mode: current power down mode + * @scale_avail: pre-calculated available scale values + * @double_scale: flag to indicate the gain multiplier is applied * @use_internal_vref: set to true if the internal reference voltage is us= ed * @lock: lock to protect the data buffer during regmap ops * @bus_data: bus specific data @@ -139,9 +144,12 @@ struct ad5686_state { const struct ad5686_chip_info *chip_info; const struct ad5686_bus_ops *ops; struct gpio_desc *ldac_gpio; + struct gpio_desc *gain_gpio; unsigned short vref_mv; unsigned int pwr_down_mask; unsigned int pwr_down_mode; + int scale_avail[4]; + bool double_scale; bool use_internal_vref; struct mutex lock; void *bus_data; --=20 2.43.0