From nobody Mon Jun 8 04:25:47 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 9F8E2368D73; Tue, 2 Jun 2026 16:33:52 +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=1780418032; cv=none; b=fGHIJ03knnAEIHzrE6czw7VWN2nRGVdRFmtQMKmdqLFStLUbSdzjsZKKNjj9KT8lx1my4BmAEvirLpJT0Gbi2KLqGqQDkchDe31J5k4+YbIjfyPApuwXKkgixZYxRE5IKHVDPEfrYz/vVf8nMmULKg70soQFk/TZpOiEZ3jj+y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418032; c=relaxed/simple; bh=VpyNWKEpUs6kC87Yh1bsIzN7Mc90ZiqU1b0YvNZszkg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CxJEITYLr9WlmvKYFzXH31b6n+cTCsn3Ii2iZnCpB1W7CqHf/dMo5H7lzRi4emzDI5CmPYWWuawZV1QwZTgUym+FrHPB4vwn687DMW87lnG4hChlII9HXkpAjx+hVfOuWNcIcQDygWdUkU7BhEjmeUqqW9L2obNkGIXtM4WviW8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m4A8WTO6; 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="m4A8WTO6" Received: by smtp.kernel.org (Postfix) with ESMTPS id 55DBEC4AF09; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418032; bh=VpyNWKEpUs6kC87Yh1bsIzN7Mc90ZiqU1b0YvNZszkg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=m4A8WTO64VeeJ3TqsUjnYWR0xS6wRskPkdnwSeKazoHd086a1ZQcwLsOAENmUpAzQ mgTGpwMxfeNx9tmYkkTWWJcQQphXJ8ipbB1yC7MVA6RtlPdOyLB0Llwjf10L8SYe1/ GjFWrDoTl9i6zuvLwOoYFjjqOCpKPdmKGUk/1zeanc6grLd6EF9pblB/lJ+qK2B09Y pkPqzm9FQYLe/w6+Dv5iWszm8jMwlDy626Ie2ThHZQc/AYgoaPNjvJSAIGWnwJ8Kxo zRSsWYbQflmruNAwKMZkQrr/S2FGN4uyKyTOoUejw05wH1nqNgYYmZ8U1duKHFGSxJ 6J+wF0qTIXX3w== 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 3F238CD6E57; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:48 +0100 Subject: [PATCH 01/12] 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: <20260602-ad5686-new-features-v1-1-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar , Conor Dooley X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=2173; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Uodwb5bj6wApJ0FYWPX0bGa/9JMjqxNyEKnyBWSUBgI=; b=/cO5cMmyoPmYi5A6C4aj/zj3Qe3VDU/ZaYzlWkznciljoLVbTLa8DvCAk1Wf6Y+DvJQLXY6/x nE99fKAPayACWfSUqog5pWO2jaAC/o+EvlfIIMtSa1U8c7XAc0hDBeO 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. Acked-by: Conor Dooley Signed-off-by: Rodrigo Alencar --- .../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 b5a88b03dc2f..2dcc049f30e9 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml @@ -37,14 +37,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>; @@ -53,6 +84,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 Mon Jun 8 04:25:47 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 A39BA36C592; Tue, 2 Jun 2026 16:33:52 +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=1780418032; cv=none; b=YV7yFJT/4FcGDfBjcKqya1x4aZuL8z8jShhJEmhUEX4N7wn3cetuq3pcvnwpW6AWDx7/ZQBCMAQVtCetCW5UsROziIwPLG4KBGB9szp07nvjz+Pb8BXjDN47MI7M+jCLus2ldaTsPFx/CGaVa64ygHWF9vkLONW+gyJafmubRfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418032; c=relaxed/simple; bh=xMKqcbaROw6imR2IrvvgY6v8Sd1HK13DJfnlNymxGhc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HlERApwukXERvXb/yT2kfJbcd69WHpfuAAFpZ724MF0gf0OBGiuT+9D20mMG7hPQgKOShxeEUv6g4PEGlJWoWSpy58G74OB3gVX2BBIudH9IAKR0AX7oyoaQoq5O/bFTe35YoAyTTbHfDYi7utRuR9/u/26PTo+9DZ88YWPQVCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WRnwiEmN; 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="WRnwiEmN" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6D469C2BCB4; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418032; bh=xMKqcbaROw6imR2IrvvgY6v8Sd1HK13DJfnlNymxGhc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=WRnwiEmNr+qUWFQcp3HprvWQAtBy9kszDayZ2v0Tq1FwTsOvu6Czea9hcM7ghwn2y Jhb5fvOSFzt2PatRkYF1nVjVdmYHDAWufg91zVsXQjpKLqszt9NrkDOX9+WJPdCp8V nQ2KF4I5YZDpyWUWRWwOKvYMOVnis+RGh3ZJisNpssSH+SvTvSJuTUTcN5NhzWdQGw 72qq7r+h+7h8jJYCDUGlFHOu3qaeWlgs/Rf8Y7PHsZveLTn63y9Fk8SDJPMtf1G/uJ 6Y78d7wHKSfAW8EmvnMA6gBLc9VzhlU1dsi3I+En3IRPF6fiRGelwaZP9uHzmIjYDt nLnp+LyFTOiQA== 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 5A3C0CD6E61; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:49 +0100 Subject: [PATCH 02/12] 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: <20260602-ad5686-new-features-v1-2-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=2331; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=VM8uU+sbzNkXZ9pYeXkANlRpKN8chnD0VXo09VsEx34=; b=WAqADsMtZ1/nb+nA5zkqFvMUOU2PtbfmgiZ+e3KQRlY2u9nYhbgMvyPGTIcECefCyLnZkYBoo /6ob1a8iUUqA2IkrPSt/qKHdSO7evo7u3zPD/7AXiYKzsC0V7UExKJn 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, once it does not really exist as none of the devices describe any power input with that name. VCC is also misleading as it sounds like the input power supply, but it is being used as an external voltage reference, which should be called VREF. Certain devices require vref-supply to be available once an internal reference voltage is absent. For correct operation vdd and vlogic supplies are required. Signed-off-by: Rodrigo Alencar Acked-by: Conor Dooley --- .../devicetree/bindings/iio/dac/adi,ad5696.yaml | 31 ++++++++++++++++++= +--- 1 file changed, 28 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 2dcc049f30e9..e5fbaec4adf7 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5696.yaml @@ -33,9 +33,19 @@ properties: reg: maxItems: 1 =20 + vdd-supply: + description: Input power supply. + + vlogic-supply: + description: Digital power supply. + + 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. @@ -55,8 +65,21 @@ properties: required: - compatible - reg + - vdd-supply + - vlogic-supply =20 allOf: + - if: + properties: + compatible: + contains: + anyOf: + - const: adi,ad5693 + - const: adi,ad5694 + - const: adi,ad5696 + then: + required: + - vref-supply - if: properties: compatible: @@ -83,7 +106,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 Mon Jun 8 04:25:47 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 B073836C9D5; Tue, 2 Jun 2026 16:33:52 +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=1780418032; cv=none; b=c57jE13y3UPB46Q7nHQ6FvNkB91SFc39TSV45UutYe1Wv5oRyFkQO0sJ5qRnw42zyy7cSMpM07T8HPzP0+o/SYcUdAdRVyf2EcQx7LsjqPx7Im36ijJesHIlSu/lRor6AqOcbeY2a9NM+GMP+FtnQ0bhRwwcvSYyWhSEMMxKWPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418032; c=relaxed/simple; bh=PfzvH81Ajnwxo8skiVPyd2mjdF+LjWFrsS2NC+DT7Uc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TLRUk++1CIB1aaU/C6iVcZMsNusz81prde0jBzt364bbwOqH2sjiDFNAHJCxn8gzCUnKgAH38Rwob28yNl9dYLwjZwX9abbAn4iMAwvwiMafpWdOJVmbyQoBsfmtbaj/sisBIzORMctxDf80DxmU3WBewE94xVYWBNlEIY5mecY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KiHyJqOc; 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="KiHyJqOc" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8F0ABC2BCF7; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418032; bh=PfzvH81Ajnwxo8skiVPyd2mjdF+LjWFrsS2NC+DT7Uc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=KiHyJqOcpNFcjSTwTHVkbBmV+eaEGIftN8RmkOi2IYEysrFp5dZVgdKf2labGTnKz voOouCbEvoJsCoHmJExsZyCl17tH8jHJCdCC4H+YSmvCqyMq3trPCXEbJVrlwzciQp 5IPWoF15+Qfk4H/N/X+ivlAM5uCB+1k3F0cEPXcFBCTeKQhl2QpXQWGwOz5W3pFh6W Kfd6wbr0B8P9zGEoRUS2yIZLNV8VflWywU0hqmlgEf0y8Fy6DJQ1xV0h2WK6dhUfvv 9qGmP+KWzi4xQhz52yBPMmD3jzNzVQBcNqlHbVYb/NqOJEfxIGF4UtGF9nLzwI9D+q 32DkMFk1hqdig== 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 83EAACD5BD1; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:50 +0100 Subject: [PATCH 03/12] 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: <20260602-ad5686-new-features-v1-3-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar , Conor Dooley X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=2266; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Rs2rqZGq7IiMu22sP4N1aq9P+WM2P1YWJFniol3eG0I=; b=g9HsgRhRUnmTzrnIT90IvsmYM4Rshem3UP6734kmkKTxEjCFjJczlM6h6olnVcedmBQttgWlT Hi2f5hKpD63D3R/wKqsGhM3GYYJ7Rde3690U0QFzko5WIk2QF3PYd3I 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. Acked-by: Conor Dooley Signed-off-by: Rodrigo Alencar --- .../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 713f535bb33a..4680d4753dd4 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml @@ -35,17 +35,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>; @@ -53,6 +82,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 Mon Jun 8 04:25:47 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 CBD0A36F439; Tue, 2 Jun 2026 16:33:52 +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=1780418032; cv=none; b=VX9TAVIN8/21SYFxG9OsQXuyKNHpqmpPRDwX1khNe4Pc8CIN2JGPgprKiwNCt6yhFZNwpR1lQFxkXCgmOQcfBZWZYaZQjF1z28sDmNzT+HWeVZ9Zkk6tqcQiNjWjsS15HDp0ObDaEzbr8kumd7ZcchjuxoTzCbsKgCHkkGxv54Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418032; c=relaxed/simple; bh=MjM22zJK0gok/1JHSadsu38lb17Xjio+GrUTcGYaAHA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XE+jwexVIm8Q6oomqcGRbsb0O0+dSUz7aYpm7foPE13bf5Qsp3ZOVzZCwEHQzaVswnFatzEh5/eQ2OLE0NfKquaScI3LHtpdha+XPXPU2UIQvTt2HyXntSabdkTmimw/8uceKgbGT3l6GQ2/VL3zHzE5b7Vp1VOQ8ant/i/ifXo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m9BZLtdf; 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="m9BZLtdf" Received: by smtp.kernel.org (Postfix) with ESMTPS id A6414C2BCC9; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418032; bh=MjM22zJK0gok/1JHSadsu38lb17Xjio+GrUTcGYaAHA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=m9BZLtdf/SZh0uxsXW4Cm7j5FoPflF63oiP07vETJVw5riAeyNN1qKvtzcQZ3Xyif WaQGCHNiuesHrQ4JwkkkKakJtsU81w6BeANk2r16wFTsfK9JXQxsKyE6OG8cDO8oi5 GkkSHHnu2RSgXI8gurL6rSLalGkiU9Yat/YGDXj5D/jHasjh7P8uHBqZBiga2rxTZH n7MsV93Rq8nvJx8A8CBS6DXctO23QWiPuhE6OlsltoNihojUFp5ZywHyTdDXJRAv/9 nhwiKYvdaiHkHDuB2tOi1GZnmAAMV/ER/6l/SXZO8RnTG2w9+AbgnIkfiRQajNaiYr Mzo9afqKv+3Tg== 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 9BD7CCD6E57; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:51 +0100 Subject: [PATCH 04/12] 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: <20260602-ad5686-new-features-v1-4-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=2482; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=SZ+4+Wyz9VHuj/4IF6ruPdi67TJbJTwam23OqhjqJG4=; b=Pd05U39JY446ke6lGgbOgMTMy07LDnyKYr0NO97Syn2+SXjbWvi709evDDHpV5NCnDNLlK01I yFftrufzlC2CF+RHkBzkwXdAHUTWK39iQtPr3bbilgZ4aBUazyyDeQX 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, once it does not really exist as none of the devices describe any power input with that name. VCC is also misleading as it sounds like the input power supply, but it is being used as an external voltage reference, which should be called VREF. Certain devices require vref-supply to be available once an internal reference voltage is absent. For correct operation vdd and vlogic supplies are required. Signed-off-by: Rodrigo Alencar Acked-by: Conor Dooley --- .../devicetree/bindings/iio/dac/adi,ad5686.yaml | 31 ++++++++++++++++++= ++-- 1 file changed, 29 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 4680d4753dd4..2abdbf325392 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml @@ -32,8 +32,19 @@ properties: reg: maxItems: 1 =20 + vdd-supply: + description: Input power supply. + + vlogic-supply: + description: Digital power supply. + + 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. @@ -53,9 +64,23 @@ properties: required: - compatible - reg + - vdd-supply + - vlogic-supply =20 allOf: - $ref: /schemas/spi/spi-peripheral-props.yaml# + - if: + properties: + compatible: + contains: + anyOf: + - const: adi,ad5676 + - const: adi,ad5683 + - const: adi,ad5684 + - const: adi,ad5686 + then: + required: + - vref-supply - if: properties: compatible: @@ -81,7 +106,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 Mon Jun 8 04:25:47 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 E36D436F917; Tue, 2 Jun 2026 16:33:52 +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=1780418033; cv=none; b=qHLex8QNJ159iDI+FTgtYZtnf8tFPsMOWBEYSW9hnp4t/9jJLbes2eAvPSGqreuHv8qW8btmilXvtyCAGs/BeouF8HcgXkS9gpoxwJ6ruJqIqI1eC2Ea/UtcTHIcxvPyWzZ9yAtmkAbDvvcDV4G1FJGaKCXiWiWC8dGGbLl9aok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; c=relaxed/simple; bh=8NE1uXIvhRUv3/hjg7SnAjiwZfCxC9pPFDcg0Z34Ru8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UvKmfRw6cGjzXC+vdExvi5e46B+eUTq3Ez/gY/yptzcDKsYtLxcd2OgJG+81xEFgFsG3wLRcasWyLwY/lNaoZcpzKb9wpJR23CDU0PS5jgKnRmyKm3PH/votyT8Egs6yhwouIrxIRs8c4rPd+feWvNy+CDOjNmsM9pyJYyg27c8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NgNDLvQn; 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="NgNDLvQn" Received: by smtp.kernel.org (Postfix) with ESMTPS id C0565C2BCF5; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418032; bh=8NE1uXIvhRUv3/hjg7SnAjiwZfCxC9pPFDcg0Z34Ru8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=NgNDLvQn1alIRp7WvqfsmkJ+b8HtanLCos0yJW8b1AuAGFoRBX1N15aLSQJGi4kVw jq8FdEFzM2MiEDdTs5leB4cvOiKYbTEbii1lRhDdZRWybY3zedkkcSjGuOGxEifyww K1cjahrPSr1/BEC1hosm9TD22qr6zN92GVecJyYlMS9i4Be/HHNzVczCgb2W30fGaO e5aVLILR1wWuiQ4iObIuOE9WmcxPodPBqbpD6SuS0xFlsS7X8ab7k9t7+d8uMKMY52 H0ynl8kgdcdA8xR31SW+sO0Q4b4NcASYJhsAzKZIOUf21//ByPy1SYVoK23NuM618g V6FuGUyK+bkMg== 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 B5E7ECD6E61; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:52 +0100 Subject: [PATCH 05/12] 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: <20260602-ad5686-new-features-v1-5-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=2269; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=f/SVtqpON4GK4wHV3s6GhGXHVZxtYozoTOlTjmn+Yy8=; b=uWeDrdqU+kZ4O7T4U9kQChYAQ5HNPchDVuXfQjwbwh5sWuvTvVbiCr5i7NDLsvDMz7rAxrPg8 n0J9uTbMUhjBcT6CDIte4gJtRVXOAr8seSWKobjIEFr+V6kKzyIqozd 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 and enable 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. For correct operation, vdd and vlogic are required, then devm_regulator_get_enable() is used so the driver can still work without them by using the stub/dummy regulators. 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 5840fda4b011..4a8c587ff116 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -484,13 +485,27 @@ int ad5686_probe(struct device *dev, st->ops =3D ops; st->chip_info =3D chip_info; =20 - ret =3D devm_regulator_get_enable_read_voltage(dev, "vcc"); + ret =3D devm_regulator_get_enable(dev, "vdd"); + if (ret) + return dev_err_probe(dev, ret, "failed to enable vdd supply\n"); + + ret =3D devm_regulator_get_enable(dev, "vlogic"); + if (ret) + 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"); + /* Initialize masks to all ones */ st->pwr_down_mask =3D ~0; st->pwr_down_mode =3D ~0; --=20 2.43.0 From nobody Mon Jun 8 04:25:47 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 486A3373C00; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; cv=none; b=IUXzF1NrXRGz0/oXnINodzij9sNPeyCHyXC4pI4wsmyrHBgg9fXtKsMU4Rk9TEh7pJ+bAK6y3m+K1EEsBdURazCwFClmTgSQJ2Z/V1VIqFt2VQ1HZbUR6PKViYskLSjVij3yef0N6tZixP/JY4c/1IgQRQwA/K/EE/A8+OVdU3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; c=relaxed/simple; bh=1uhLpa5yyTgy0PQcnwcLD7pAKtgmq5gMx2kxNzRb//Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mj99lzZmYSKO59H8AyCcnoV4afbYNH+eu7br+lR14aVGjxrX67Jzd0vLaHgnFJDtULgwT2mWPWDeXmHi/1MtqK0LsC58mfy0vYxk1+nW2xIbJ+CFWU6CDv6eHofIUqvrI9EtPmjKYtCmNHf/iDMZ6Ecv7AuSZ+1pcGOMEKUgqjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MDKjc+ZR; 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="MDKjc+ZR" Received: by smtp.kernel.org (Postfix) with ESMTPS id EB3A6C2BCC7; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418033; bh=1uhLpa5yyTgy0PQcnwcLD7pAKtgmq5gMx2kxNzRb//Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MDKjc+ZRGSanL6Rvke0+5qlArvw+zAc6qzfN4vkiBpC6la2fVWVn+2I1VXsXNwP2Q WeocpdBecYvZxfI2n0ieOMvFrsuipJokWSCtjt0kmwq81LAZ7c7JktQmIrE2COJL47 P/TeM/rJJaEGKn1y7yqEYoIdvXkNoZPnimcllYLpyoPrdmZcVA/fUFw3H2vanBXTVy aUkUsudPyxInHbYRT7r3TT/KuZNuLeJOnOJcabEU2lSwlIzIjT6kKgx6M+/Fwuyg33 9llAsDAAs17cxhPyf/Pr5ifTmqWu44KshoNMyH3VfUNuC8r0FJmhrj45BIu2S9iYP3 4tGhVXp5dPG7g== 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 D42B7CD5BD1; Tue, 2 Jun 2026 16:33:52 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:53 +0100 Subject: [PATCH 06/12] 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: <20260602-ad5686-new-features-v1-6-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=1771; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=vXNN1mglGgjf48pZPy8eNX8aBxzrQUf3QPxVDN45sSE=; b=W4TrsPcJ/Kxj21ft0cLAe96AbCbgBo5ZD5cs9uFqRZEOoIMDfhQOWbJrjUIWclDq+xhJRSqFt VEOavaFWZ4hBj7Pw5UGrHuEbSj9sXaykfzXh7KLbp3iRgLxkmjx2daS 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 control, which is local to the probe function. Also, include delays for power-up time and reset pulse width. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 4a8c587ff116..345ca2436332 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -8,12 +8,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include =20 @@ -471,6 +473,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 ad5686_state *st; struct iio_dev *indio_dev; int ret, i; @@ -506,6 +509,16 @@ 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(dev, NULL); + if (IS_ERR(rstc)) + return dev_err_probe(dev, PTR_ERR(rstc), + "Failed to get reset control\n"); + + udelay(5); /* power-up time */ + reset_control_assert(rstc); + udelay(1); /* reset pulse: comfortably bigger than the spec */ + reset_control_deassert(rstc); + /* Initialize masks to all ones */ st->pwr_down_mask =3D ~0; st->pwr_down_mode =3D ~0; --=20 2.43.0 From nobody Mon Jun 8 04:25:47 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 5CAA8374185; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; cv=none; b=KKDOueNG01BUKwRvrsATVEPftVb3y9JD7hQ/pB9sJ6dLIWBoaP5AaXFTU1g3fdPWstSlQ/uyllsTMyQyTCkXtfsf05IJ/j6FfzAFNNdcZ/M+pEbPBnvnzux3n5eGs9GTpniiMPwy0Rdp7O6dnci3IY1PPd6O3rLH4pin7NgtHF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; c=relaxed/simple; bh=Ex1nmMpcn3Pxn2Oc8203/m1TcpdVIjGVQfv879Sx2BM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ikae0ImwjOhWIcWUtKoQzAPwihsH3Ab7BxjPWj5wBTUN9WQ0z1gYOpyL5MnoFkVKCh8Y8rFSQI5bimRfJX4/VjS5HbKqZ4mC7rzYXWQ6Ut/4MTLEGRU8N0icvaUzhSl2zQfvd7ufqWjgJJriRCesqPTlwhrLc/yDY5UK8bwJYvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BnJ66FAD; 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="BnJ66FAD" Received: by smtp.kernel.org (Postfix) with ESMTPS id 13849C4AF10; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418033; bh=Ex1nmMpcn3Pxn2Oc8203/m1TcpdVIjGVQfv879Sx2BM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BnJ66FADHhehXKU//VRsBDpypNSEuVl50NFWIGHhqdsKDBMnl4nBy5cNYn92J+pGA TojyFP4Lbqfu/YDxoxk9LwY4u0T/RrYeMbeGJ1jXdba5Y36OG8W2X1J6KfGXwd2hVa YHY7VmArUDL00ZRQuUOgnizZRLZ/bXSMujL6VdkP2hWjnlE4Njo6PDBmvsr61weIaL 93hg8We2a3rsMW1pmHzltqOVFGlE08bvewk9gaponvi7KB5Y+qi23t2K/p3N/ftzBp UZcNct5ThMMIwB17u4t9mo3HKssaY6lsCPylMy2D+TlK0j7PLUngbNFKhTcbiKtohk aXx5HrqBrJtaA== 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 0334ECD6E57; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:54 +0100 Subject: [PATCH 07/12] 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: <20260602-ad5686-new-features-v1-7-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=2056; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=pQX+cKvJ4ibMApwzGdCAG2JhxzWSWbPGxwsmPRVd0Ks=; b=0fBdx4J+O+ZGJpTFZA1nz9YeD0BAqPDKODvAx1L3d+H0nwIMntPim294gNjuEYIHiWjCHzZJQ qW2BMeXTfF1CGmsMX/iMPgJIQR1RGVa/xQoaiWw1MrvGBNha5pYe6Ic 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 LDAC, 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 345ca2436332..8f91838c5b53 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -514,6 +514,11 @@ int ad5686_probe(struct device *dev, return dev_err_probe(dev, PTR_ERR(rstc), "Failed to get reset control\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"); + udelay(5); /* power-up time */ reset_control_assert(rstc); udelay(1); /* reset pulse: comfortably bigger than the spec */ diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index a06fe7d89305..498d05ab12ee 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 @@ -119,6 +120,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 @@ -131,6 +133,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 Mon Jun 8 04:25:47 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 6F92637473A; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; cv=none; b=QA51D00zIZzmusDOWPGXDm9c6o2x+/Ksubqpvd+su+7yCeRyEzLfSKUapJ4Dl65ygmHsquAAVqXePX112DaShCZtOZ3LzfDVB2VJOkkSPh+PqGLNEMylCXTZbMjwJ1dF+eiSqU7/lmYTBz+gkXPZP8dDgmw0FcfRBnXWMnKRq2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; c=relaxed/simple; bh=4Olsc02gqukpHfg1z1h766Y4hOa+FcPXE68xTPMwQqo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H6boPIZQUzpplWU0VML0aQMplU4wuigxSANM54VYyHxVzOYcRMC6363KiCWFhz5fRvkjgLX7AXGYG/C5n0c//4iKXXEuzfIpESJVQ/GNNn6XokKlHBPh7MfjSZkoh3Wh4reZXgWHX/tmPpseqHlL1qqPcyxFt7pJqJGHzSVFJTs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YQ7c/U+b; 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="YQ7c/U+b" Received: by smtp.kernel.org (Postfix) with ESMTPS id 36F4DC2BCFB; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418033; bh=4Olsc02gqukpHfg1z1h766Y4hOa+FcPXE68xTPMwQqo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YQ7c/U+bXdT5thgZ6/dBwOdSHHoB6NUzRsXdwXEjDNjvujJ9EN/pdYWQKd9sbls8d 2ndU1eFvXEJe5egVt3JMsugIsCQ8sBMkj6o6++wjxNniKiTUKRJmDucDmjSZB0bZSf FHDnruI2iSgi7EhkKuwwx3mZ2VLyTJY9KHxMA8MAbPS5L5kLOxq+ILHxxmYvozrK4D K+XkZtkcQ+pg+nsG7qM44f1yZlNQ09iW5W9S8/YXGPtWeVrShEZ6Y3Y5m+2qEQ+0mq Ip2yRhMOI+st9U89ypdVFsm4N7Bh/LM6bZbkiR3tAT6zRgrrkfQQ70IVQ7Dn/vjsb7 wn83Ytq5kG8sA== 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 20117CD6E68; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:55 +0100 Subject: [PATCH 08/12] iio: dac: ad5686: introduce sync operation 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: <20260602-ad5686-new-features-v1-8-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=1436; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=5dYkJ2OZkHyAKxl2jNuORfMox/fLJ07hRjAKClskDvk=; b=fE08Oihthsp9HKS+Qe5GTjSDrJ+BfaalpgM/JL8G189wPX747TK8mdStR0bvoNh2qUxc/jbW+ TyP5o4N16D5Akal256r4ppDrRhFiK0IAxKpGZCOfOwk3yOHxkfRXuOz 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 sync() to operation to ad5686_bus_ops, which can be used to flush multiple pending data transfers at once. This is going to be used when implementing triggered buffer support. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 498d05ab12ee..414d39863004 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -67,10 +67,12 @@ struct ad5686_state; * struct 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 /** @@ -159,7 +161,13 @@ int ad5686_probe(struct device *dev, =20 static inline int ad5686_write(struct ad5686_state *st, u8 cmd, u8 addr, u= 16 val) { - return st->ops->write(st, cmd, addr, 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; } =20 static inline int ad5686_read(struct ad5686_state *st, u8 addr) --=20 2.43.0 From nobody Mon Jun 8 04:25:47 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 87C48374E66; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; cv=none; b=QRgoC1QStlC3v1cN2SznujGDmkrZv7MD9/7HwXnaT5iTbhJf/aBAEwwXESB3CUN8K02XUL3DoDNwdKYb4bxmtd4aWQ6PWsr8CgGIrpImMzNAV+b1ij6+oyDKHvf1xPNQiil/j7aeOuGqvJQtpdoEOXwqY7pcQ7JkA21gYzRgIn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; c=relaxed/simple; bh=8sFPddshvZdOm/9w4tg/dK2EGR2jW/B410oVDAQ+i74=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cRh71i/kkW2Wk6Quh7w/HC6j6upBjsmM1O5fafeVfKbXH46I3Ww7OwuFv4HM1xyXUJdq+wCyzOBY7HnnkrmoyAHFm5YTjxbF5fmEH3QxVqxTPVKTTgPk0oBdG2BMApgNRd0KLrUZkeUNOpKyd3zrsMAUq0s6pXPVqOQohHnMNhY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VWAdZiWi; 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="VWAdZiWi" Received: by smtp.kernel.org (Postfix) with ESMTPS id 51B00C4AF0C; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418033; bh=8sFPddshvZdOm/9w4tg/dK2EGR2jW/B410oVDAQ+i74=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=VWAdZiWivH1JGLmA2jv5deBrKHzpUE/iikgQG00ttyyVdROa9rtwtLs/xe2yxcns2 4ImLozS65yTFFuuEUSiRCpHXa9GoZMLYZFWOL5NTYjx2ygKPo9XbVIZY+93G3bpy40 1bW3/QSCPEb8XzPVnpYbHismtWqJe5Hje6ofoY7Sx3q2wQu2Iv+Tdz1hubIY+AWlCB tzVu7f7oFk4pmbxyFQwDidVrTEp9AipjjqcMmFR/m7ZvClJnzXg2dZJe2/HqzmTldb fN476q0zVcLaUrPA8aBz7PxWX81f74bLtqKhVaf0hUJNFS4iCL62z1NAOA57lii4bh JRQ4Lkfb33KWg== 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 3D991CD5BD1; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:56 +0100 Subject: [PATCH 09/12] 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: <20260602-ad5686-new-features-v1-9-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=8065; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Z8oMTCWL4U4nO4nS3fEClgyePNDnBDhn6Gad89yOGuA=; b=zBB3zuhYVqJhpWK8HvQTfqYdIcnwDg1KIhoay/aouKxELaFzrVSgccH/b1delBBVpQ5fMIOVh q04IalC2mXdD8Us7BS8sM8L93v+sBDiqD68hn6o2a+3uMz43ilnRAJH 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 | 109 +++++++++++++++++++++++++++++++--------= ---- drivers/iio/dac/ad5686.c | 4 +- drivers/iio/dac/ad5686.h | 8 +++- drivers/iio/dac/ad5696-i2c.c | 2 +- 4 files changed, 88 insertions(+), 35 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index 6b6ef1d7071f..66a5a2164395 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -12,59 +12,81 @@ #include #include #include +#include #include =20 #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 @@ -85,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); @@ -95,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 8f91838c5b53..a4cc0f86ea54 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -471,7 +471,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 ad5686_state *st; @@ -486,6 +487,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(dev, "vdd"); diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 414d39863004..bc793179db09 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 @@ -129,6 +130,7 @@ extern const struct ad5686_chip_info ad5679r_chip_info; * @use_internal_vref: set to true if the internal reference voltage is us= ed * @lock: lock to protect access to state fields, which includes * the data buffer during regmap ops + * @bus_data: bus specific data * @data: transfer buffers */ struct ad5686_state { @@ -141,6 +143,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 @@ -151,13 +154,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 279309329b64..28c97ded43ce 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 Mon Jun 8 04:25:47 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 9AC263750DB; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; cv=none; b=Yi4OQxhN6tHqKYTndiwU8513HGWRkQjfxyrsIkftVDBXzfbBSEKXB0R+dr90W6CEp7I5viQkDqk0iDYghR7yntApmPrNe2iTdKYuFYgh/svJCeucOr1TNK8AmBigxYC+Y61WC7X/H8kr/KwUBfa1PARK7C3O9/y2Rf3TWmvMX0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; c=relaxed/simple; bh=xoxiNijWqkSxyRa+DL1gBCKIDk4MEnYqXu1H4fCap5I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c3BPIuf5OwDdRoJE10opA04eL80txSmEul03MqHxDIsiAXGOPToMgvQxJ1pgHYRfaP9KMUkPP+a9MAJIlZSIyvYVkJdwAxHzH8wLN8wEZ2DTUn5DgX4rbCKQ99hIzHywcIMp+U3VXV/lJagMiDJDtwrmH3fp1sWTjOxdWOOKkIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eAJc0Yd1; 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="eAJc0Yd1" Received: by smtp.kernel.org (Postfix) with ESMTPS id 71FD5C2BCF7; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418033; bh=xoxiNijWqkSxyRa+DL1gBCKIDk4MEnYqXu1H4fCap5I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=eAJc0Yd1Fv9N62++nxvw4bAwtoM3QMnjAvuQHOFZpF+7HrtrdwU7kHmnlq1odaEGV aQbDMK5vD9P0Jtvk0geNJlO5IhfiPVILKDBEdKqEqunKBeylGBP+D0l8Py24zg7x3p kpQMxPqsyIZ6GNU27lkA+5KDFuwnTIyUP/VOmepmh/KGSIb1tRQvVib4bpKO0k3orR EcwdkI/Uo4LronpQ8U6J/BrzYnUgZKKrXYVrkmx1MgccQuHOuWqaMNuHO2ZxHQVwO+ qerNQ+EVOd/DZE2HsJoCXT4yOqncZvr/q411fyN/wsuiiMQAz5lCf/rEu0Brk2fc6y G4ULB1Xv5OXRA== 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 5A363CD6E57; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:57 +0100 Subject: [PATCH 10/12] 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: <20260602-ad5686-new-features-v1-10-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=3523; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=NkwPSM/HeIv2TIXju9nekbHoT2W+fYgNfc8kUZ545qg=; b=c/nRUD3meAVZeSmZCksdOe5Y+XPs5RMMtGVq3bhKB6U/r/WExqoXDiFZYMYRhSNZKSB2PiLob lqaS1TYWJGUABQNb/sQIU7bEnSC2fJoTMClJCzBNu3xY6/B0463pXPZ 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 Implement trigger handler by leveraging the LDAC gpio to update all DAC channels at once when it is available. Also, the 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 | 59 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 61 insertions(+) diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index 657c68e75542..5f14fcd780e2 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -240,6 +240,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 a4cc0f86ea54..5052df44ab1c 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -19,7 +19,11 @@ #include #include =20 +#include #include +#include +#include +#include =20 #include "ad5686.h" =20 @@ -245,6 +249,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), \ @@ -469,6 +474,53 @@ 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); + u16 val[AD5686_MAX_CHANNELS] =3D { }; + 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) { + ret =3D st->ops->write(st, cmd, indio_dev->channels[ch].address, val[i++= ]); + if (ret) + goto cleanup; + } + + if (st->ops->sync) + ret =3D st->ops->sync(st); /* flush all pending transfers */ + +cleanup: + 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, @@ -569,6 +621,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 Mon Jun 8 04:25:47 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 B05A037646E; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; cv=none; b=Yj7jLauI+4ALoFj+15ypsyyrZz3OeWEJRkoy0OvMnW0rTseWaLKZ0AM0sG58giKWLSQ5OOaV9G745Ofjs59Xce018YFNr1yaGTySKnYLVrDQuv0ZS0uqfCn3xweZ5IwMTFoKvDSN8zEYDANueDuEJ5BLUcdVMc7kftpK8uh+0nY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; c=relaxed/simple; bh=QE+/x50PUWPgUMng+TCd6vpNljqfCkNnE/cAuToKq/M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aMeHyG1nupoOwcfxH1Ej7rVdci9M3uuKG76OvsjmZHKXlnli3rrYIOADT/bjDdgzQ0mgpmy5oRTz2dnbXoQeGNPVP6EKdpzdjUFn5Ej8Va1o1CnquKedJZFIc3emQFmO3Qcy/lhg/NxvMRJY+cJw0Sx75AsDBM7inrsFBl9bYEw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z037idkp; 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="Z037idkp" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8ED00C2BD01; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418033; bh=QE+/x50PUWPgUMng+TCd6vpNljqfCkNnE/cAuToKq/M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Z037idkpLKdH7+sgn7WQEv6RNj4koW7SMkxDN3JTDtILEjVBUwkOSktaDTZtay9mr SiILa1b4I0Nvl7YePRzPZ9wVbAS0Qwvm63TT3K7lLoACA4yF2wKVW2+c/n4Zk8I/x+ mnINTxiNBfM3S8C5cWMUEVf4i1njanTR5u+XHdUhv5BXZA8RXGSIJHo2+LPqgvak7J pdefOQKtyr+pQaPuh0QjQhZZ3upHZCZ4+FAJmDtZAVuamFf2yduM5yIuafBldxK8Ug 8ZUkmRT1MTgp0bVKpRge8KvDRHpEoClaNX0KwqM3HaxJFQrRHxuxqnZ1lN8UQrmGpb WZQsTKZ79y9qA== 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 82D9ACD6E60; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:58 +0100 Subject: [PATCH 11/12] iio: dac: ad5686: write_raw: use guard(mutex)() 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: <20260602-ad5686-new-features-v1-11-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=1337; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=Dsy9fOpmU3g/1YFf/mAz4rjj8yKEcDVwiot3KZLm8lo=; b=Z++v0ifycOhzyxjvxvLeFAeSaxTfoRkG8LMACbMzeuYcqTqw65mZ+E2ow4UJgaT+YzxnNwsSX LVlg0xlP/VuCspodmAggEavmNlboJdT6mbyfbOdkv1eOU7/q9/x30D7 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 guarded mutex lock to facilitate code review when adding new attributes. This will allow for early returns, avoiding error-prone locking and unlocking in error paths. Gain-control support will add the scale attribute. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 5052df44ab1c..54b953018cfa 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -205,23 +205,19 @@ 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 (val >=3D (1 << chan->scan_type.realbits) || val < 0) 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; + return ad5686_write(st, AD5686_CMD_WRITE_INPUT_N_UPDATE_N, + chan->address, val << chan->scan_type.shift); default: - ret =3D -EINVAL; + return -EINVAL; } - - return ret; } =20 static const struct iio_info ad5686_info =3D { --=20 2.43.0 From nobody Mon Jun 8 04:25:47 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 D1A3B377553; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; cv=none; b=iF11LuneOVHulDA+OXcANVCrBofhf59/JmZ7nwdmMjOmbmkfGpLiFuEISG4Wkp99iSgUxfYTNKUdDZ2JzZ+7/4n3wjsFspo1iKUMt/fZP7O8klVIB2Y0GztowiXqPxG/u9eVjqFyGpKKzVbaHmeLLHUmqg0MmaTedU+WueSBu70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418033; c=relaxed/simple; bh=qsMK8Q2HM6jTGoQPEbrRSvbyVLrZlkP5fRZbE+xOgYQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HUJfTu/j5OoWnofXD6f938iA7DP7NEOwX4pYbfeUc1WbwHIJMN33cAjk381jvdYF9v9giMhN84PAn8biqjwfPEn7T6/nxDJWbgyMOCifPr1+KBbaCjbbT74lLtJDU/w9WHeR86NwwRjfN4MB4TmBVdYScBXEOGkR3huCuJdOH7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=twLLZfCL; 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="twLLZfCL" Received: by smtp.kernel.org (Postfix) with ESMTPS id ABA96C2BCC7; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1780418033; bh=qsMK8Q2HM6jTGoQPEbrRSvbyVLrZlkP5fRZbE+xOgYQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=twLLZfCLW3M5hjfRLntb9hJiCNy/XPY9HzvKMWljRpaRh1kyDzCOOsIOHg4TGgsPL vidx1qtU4sAa1bislzL5vImsKqSEsjrmGTqAp//mF9sQmLmRl9sT32Qt3OGXCY4FDA uigfXaZRkeP/M+/VpIKH6twiP1mUGL9SQ0L5x7w0f9L8QljAYhHrFzoVrOKgJuX7VP q5WnerDOK1DpNwuo8G5HeBy2NArRp2C3pYSB1kWIOXZXBJv5qv5GDDGLYOIjbviuGV qdnIQBgajWNhqGnycdMe6mhnikL2GNpgnrX40HvXCDHWaUYuaEs9m1wg7p2CD4RDsx 1ntPYKgrOtb+w== 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 A03BDCD5BD1; Tue, 2 Jun 2026 16:33:53 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 02 Jun 2026 17:33:59 +0100 Subject: [PATCH 12/12] 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: <20260602-ad5686-new-features-v1-12-691e01883d27@analog.com> References: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> In-Reply-To: <20260602-ad5686-new-features-v1-0-691e01883d27@analog.com> To: Michael Auchter , linux@analog.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Kees Cook , "Gustavo A. R. Silva" , Rodrigo Alencar X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780418030; l=7911; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=vqAOSWmQzVBmJ7L7sOnIK3s3iVYpw9YgEy4GB79ktSg=; b=dbzjSv28Hz9cjn/9A2b1SXPj75QVaExCRn6xGJq1sKrP1p5R7gOYRQtQWr5aFmy7siCN9juIk LFAio8o6v/8C2SFAFUn87XkJRLRndVNbMkFcOdJ4oO3rmN8n8KyZY8X 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. Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 96 ++++++++++++++++++++++++++++++++++++++++++++= +--- drivers/iio/dac/ad5686.h | 8 ++++ 2 files changed, 99 insertions(+), 5 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 54b953018cfa..fabe967c5225 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -13,10 +13,12 @@ #include #include #include +#include #include #include #include #include +#include #include =20 #include @@ -39,7 +41,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 & AD5686_PD_MSK) | - FIELD_PREP(AD5310_REF_BIT_MSK, st->use_internal_vref ? 0 : 1)); + FIELD_PREP(AD5310_REF_BIT_MSK, st->use_internal_vref ? 0 : 1) | + FIELD_PREP(AD5310_GAIN_BIT_MSK, st->double_scale ? 1 : 0)); } =20 static int ad5683_control_sync(struct ad5686_state *st) @@ -48,7 +51,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 & AD5686_PD_MSK) | - FIELD_PREP(AD5683_REF_BIT_MSK, st->use_internal_vref ? 0 : 1)); + FIELD_PREP(AD5683_REF_BIT_MSK, st->use_internal_vref ? 0 : 1) | + FIELD_PREP(AD5683_GAIN_BIT_MSK, st->double_scale ? 1 : 0)); } =20 static inline unsigned int ad5686_pd_mask_shift(const struct iio_chan_spec= *chan) @@ -191,9 +195,14 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, 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; } @@ -215,6 +224,63 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, =20 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; + + 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: + /* + * even if the gain pin is hardwired on the board, the + * user is able to control the scale such that it + * matches the actual gain setting. + */ + gpiod_set_value_cansleep(st->gain_gpio, + st->double_scale ? 1 : 0); + 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; } @@ -223,6 +289,8 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, 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 { @@ -244,6 +312,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 { \ @@ -470,6 +539,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; @@ -569,6 +648,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); + udelay(5); /* power-up time */ reset_control_assert(rstc); udelay(1); /* reset pulse: comfortably bigger than the spec */ diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index bc793179db09..455d6bbefdfe 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -40,9 +40,11 @@ #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) =20 +#define AD5683_GAIN_BIT_MSK BIT(11) #define AD5683_REF_BIT_MSK BIT(12) #define AD5683_PD_MSK GENMASK(14, 13) =20 @@ -124,9 +126,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 access to state fields, which includes * the data buffer during regmap ops @@ -138,9 +143,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