* [PATCH 00/22] Extend device support for AD5686 driver
@ 2026-04-22 14:45 Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 01/22] dt-bindings: iio: dac: ad5696: extend device support Rodrigo Alencar via B4 Relay
` (22 more replies)
0 siblings, 23 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
This series adds support for multiple nanoDAC parts, adding triggered
buffer and gain control support to the ad5686 DAC driver family, along
with a number of driver cleanups and fixes.
Initial patches update the device-tree bindings:
- Add compatible entries for missing and new parts;
- Add GPIO properties for RESET, GAIN and LDAC pins;
- Add missing power supplies properties.
Driver cleanups and fixes:
- Refactor include headers (IWYU);
- Switch to device managed mutex initialization;
- Drop enum chip id in favor of per-device chip_info structs;
- Fix voltage reference control on single-channel devices;
- Fix powerdown control on dual-channel devices;
- Introduce bus ops struct with a sync() operation for batching
bus transfers.
New functionality:
- Device support for: AD5316R, AD5675, AD5697R, AD5313R, AD5317R,
AD5674, AD5679, AD5687, AD5687R, AD5689 and AD5689R;
- Consume optional reset and new power supplies;
- LDAC GPIO handling (active-low, held low when unused);
- SPI bus sync() implementation for batching multiple transfers;
- Triggered buffer support, leveraging LDAC and sync() to flush
all channel writes atomically;
- Gain control support through the scale property.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
Rodrigo Alencar (22):
dt-bindings: iio: dac: ad5696: extend device support
dt-bindings: iio: dac: ad5696: add reset/ldac/gain gpio support
dt-bindings: iio: dac: ad5696: rework on power supplies
dt-bindings: iio: dac: ad5686: extend device support
dt-bindings: iio: dac: ad5686: add reset/ldac/gain gpio support
dt-bindings: iio: dac: ad5686: rework on power supplies
iio: dac: ad5686: refactor include headers
iio: dac: ad5686: remove redundant register definition
iio: dac: ad5686: drop enum id
iio: dac: ad5686: add of_match table to the spi driver
iio: dac: ad5686: fix ref bit initialization for single-channel parts
iio: dac: ad5686: fix powerdown control
iio: dac: ad5686: fix input raw value check
iio: dac: ad5686: add support for missing power supplies
iio: dac: ad5686: create bus ops struct
iio: dac: ad5686: extend device support with new parts
iio: dac: ad5686: update device list description
iio: dac: ad5686: consume optional reset signal
iio: dac: ad5686: add ldac gpio
iio: dac: ad5686: implement new sync() op for the spi bus
iio: dac: ad5686: add triggered buffer support
iio: dac: ad5686: add gain control support
.../devicetree/bindings/iio/dac/adi,ad5686.yaml | 61 +-
.../devicetree/bindings/iio/dac/adi,ad5696.yaml | 60 +-
drivers/iio/dac/Kconfig | 18 +-
drivers/iio/dac/ad5686-spi.c | 200 ++++--
drivers/iio/dac/ad5686.c | 775 +++++++++++++--------
drivers/iio/dac/ad5686.h | 144 ++--
drivers/iio/dac/ad5696-i2c.c | 94 +--
7 files changed, 906 insertions(+), 446 deletions(-)
---
base-commit: eade2b843d9b1f668fc1775f15611bb0a1999cd9
change-id: 20260325-ad5313r-iio-support-882ad39356e1
Best regards,
--
Rodrigo Alencar <rodrigo.alencar@analog.com>
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 01/22] dt-bindings: iio: dac: ad5696: extend device support
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 02/22] dt-bindings: iio: dac: ad5696: add reset/ldac/gain gpio support Rodrigo Alencar via B4 Relay
` (21 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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/Documentation/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
reg:
maxItems: 1
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 02/22] dt-bindings: iio: dac: ad5696: add reset/ldac/gain gpio support
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 01/22] dt-bindings: iio: dac: ad5696: extend device support Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 03/22] dt-bindings: iio: dac: ad5696: rework on power supplies Rodrigo Alencar via B4 Relay
` (20 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
.../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/Documentation/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.
+ 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 high,
+ the DAC output voltage is multiplied by 2, otherwise it is unchanged.
+ maxItems: 1
+
required:
- compatible
- reg
-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
examples:
- |
+ #include <dt-bindings/gpio/gpio.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
@@ -58,6 +89,7 @@ examples:
compatible = "adi,ad5696";
reg = <0>;
vcc-supply = <&dac_vref>;
+ ldac-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
};
};
...
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 03/22] dt-bindings: iio: dac: ad5696: rework on power supplies
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 01/22] dt-bindings: iio: dac: ad5696: extend device support Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 02/22] dt-bindings: iio: dac: ad5696: add reset/ldac/gain gpio support Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 04/22] dt-bindings: iio: dac: ad5686: extend device support Rodrigo Alencar via B4 Relay
` (19 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
.../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/Documentation/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
+ 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.
reset-gpios:
description: Active-low RESET pin to reset the device.
@@ -88,7 +101,9 @@ examples:
ad5696: dac@0 {
compatible = "adi,ad5696";
reg = <0>;
- vcc-supply = <&dac_vref>;
+ vdd-supply = <&dac_vdd>;
+ vlogic-supply = <&dac_vlogic>;
+ vref-supply = <&dac_vref>;
ldac-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
};
};
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 04/22] dt-bindings: iio: dac: ad5686: extend device support
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (2 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 03/22] dt-bindings: iio: dac: ad5696: rework on power supplies Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 05/22] dt-bindings: iio: dac: ad5686: add reset/ldac/gain gpio support Rodrigo Alencar via B4 Relay
` (18 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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/Documentation/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#
-title: Analog Devices AD5360 and similar SPI DACs
+title: Analog Devices AD5686 and similar SPI DACs
maintainers:
- Michael Hennerich <michael.hennerich@analog.com>
@@ -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
reg:
maxItems: 1
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 05/22] dt-bindings: iio: dac: ad5686: add reset/ldac/gain gpio support
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (3 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 04/22] dt-bindings: iio: dac: ad5686: extend device support Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 06/22] dt-bindings: iio: dac: ad5686: rework on power supplies Rodrigo Alencar via B4 Relay
` (17 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
.../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/Documentation/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.
+ 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 high,
+ the DAC output voltage is multiplied by 2, otherwise it is unchanged.
+ maxItems: 1
+
required:
- compatible
- reg
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
unevaluatedProperties: false
examples:
- |
+ #include <dt-bindings/gpio/gpio.h>
spi {
#address-cells = <1>;
#size-cells = <0>;
@@ -61,6 +90,8 @@ examples:
reg = <0>;
compatible = "adi,ad5310r";
vcc-supply = <&dac_vref0>;
+ reset-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
+ ldac-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
};
};
...
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 06/22] dt-bindings: iio: dac: ad5686: rework on power supplies
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (4 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 05/22] dt-bindings: iio: dac: ad5686: add reset/ldac/gain gpio support Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 07/22] iio: dac: ad5686: refactor include headers Rodrigo Alencar via B4 Relay
` (16 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
.../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/Documentation/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
+ 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.
reset-gpios:
description: Active-low RESET pin to reset the device.
@@ -89,7 +103,9 @@ examples:
dac@0 {
reg = <0>;
compatible = "adi,ad5310r";
- vcc-supply = <&dac_vref0>;
+ vdd-supply = <&dac_vdd>;
+ vlogic-supply = <&dac_vlogic>;
+ vref-supply = <&dac_vref>;
reset-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
ldac-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
};
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 07/22] iio: dac: ad5686: refactor include headers
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (5 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 06/22] dt-bindings: iio: dac: ad5686: rework on power supplies Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 19:43 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 08/22] iio: dac: ad5686: remove redundant register definition Rodrigo Alencar via B4 Relay
` (15 subsequent siblings)
22 siblings, 1 reply; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Apply IWYU principle, replacing unused/generic headers for
specific/missing headers. The resulting include directive list is sorted
accordingly.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
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.
*/
-#include "ad5686.h"
-
+#include <asm/byteorder.h>
+#include <linux/array_size.h>
+#include <linux/err.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/spi/spi.h>
+#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.
*/
-#include <linux/interrupt.h>
-#include <linux/fs.h>
-#include <linux/device.h>
+#include <linux/array_size.h>
+#include <linux/err.h>
+#include <linux/export.h>
#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
#include <linux/regulator/consumer.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
+#include <linux/sysfs.h>
#include "ad5686.h"
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__
-#include <linux/types.h>
-#include <linux/cache.h>
+#include <linux/bits.h>
#include <linux/mutex.h>
-#include <linux/kernel.h>
+#include <linux/types.h>
#include <linux/iio/iio.h>
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.
*/
-#include "ad5686.h"
-
-#include <linux/module.h>
+#include <asm/byteorder.h>
+#include <linux/err.h>
#include <linux/i2c.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+
+#include "ad5686.h"
static int ad5686_i2c_read(struct ad5686_state *st, u8 addr)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 08/22] iio: dac: ad5686: remove redundant register definition
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (6 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 07/22] iio: dac: ad5686: refactor include headers Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 19:47 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 09/22] iio: dac: ad5686: drop enum id Rodrigo Alencar via B4 Relay
` (14 subsequent siblings)
22 siblings, 1 reply; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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 = 0x8;
break;
- case AD5693_REGMAP:
- shift = 13;
- ref_bit_msk = AD5693_REF_BIT_MSK;
- break;
default:
return -EINVAL;
}
@@ -277,7 +273,7 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
.channels = ad5311r_channels,
.int_vref_mv = 2500,
.num_channels = 1,
- .regmap_type = AD5693_REGMAP,
+ .regmap_type = AD5683_REGMAP,
},
[ID_AD5337R] = {
.channels = ad5337r_channels,
@@ -399,24 +395,24 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
.channels = ad5691r_channels,
.int_vref_mv = 2500,
.num_channels = 1,
- .regmap_type = AD5693_REGMAP,
+ .regmap_type = AD5683_REGMAP,
},
[ID_AD5692R] = {
.channels = ad5692r_channels,
.int_vref_mv = 2500,
.num_channels = 1,
- .regmap_type = AD5693_REGMAP,
+ .regmap_type = AD5683_REGMAP,
},
[ID_AD5693] = {
.channels = ad5693_channels,
.num_channels = 1,
- .regmap_type = AD5693_REGMAP,
+ .regmap_type = AD5683_REGMAP,
},
[ID_AD5693R] = {
.channels = ad5693_channels,
.int_vref_mv = 2500,
.num_channels = 1,
- .regmap_type = AD5693_REGMAP,
+ .regmap_type = AD5683_REGMAP,
},
[ID_AD5694] = {
.channels = ad5684_channels,
@@ -508,11 +504,6 @@ int ad5686_probe(struct device *dev,
cmd = AD5686_CMD_INTERNAL_REFER_SETUP;
ref_bit_msk = 0;
break;
- case AD5693_REGMAP:
- cmd = AD5686_CMD_CONTROL_REG;
- ref_bit_msk = AD5693_REF_BIT_MSK;
- st->use_internal_vref = !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 @@
#define AD5310_REF_BIT_MSK BIT(8)
#define AD5683_REF_BIT_MSK BIT(12)
-#define AD5693_REF_BIT_MSK BIT(12)
/**
* ad5686_supported_device_ids:
@@ -88,7 +87,6 @@ enum ad5686_regmap_type {
AD5310_REGMAP,
AD5683_REGMAP,
AD5686_REGMAP,
- AD5693_REGMAP
};
struct ad5686_state;
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 09/22] iio: dac: ad5686: drop enum id
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (7 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 08/22] iio: dac: ad5686: remove redundant register definition Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 10/22] iio: dac: ad5686: add of_match table to the spi driver Rodrigo Alencar via B4 Relay
` (13 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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)
static int ad5686_spi_probe(struct spi_device *spi)
{
- const struct spi_device_id *id = 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);
}
static const struct spi_device_id ad5686_spi_id[] = {
- {"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_info[] = {
.ext_info = ad5686_ext_info, \
}
-#define DECLARE_AD5693_CHANNELS(name, bits, _shift) \
+#define DECLARE_AD5683_CHANNELS(name, bits, _shift) \
static const struct iio_chan_spec name[] = { \
AD5868_CHANNEL(0, 0, bits, _shift), \
}
@@ -247,205 +247,172 @@ static const struct iio_chan_spec name[] = { \
AD5868_CHANNEL(15, 15, bits, _shift), \
}
-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);
-static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
- [ID_AD5310R] = {
- .channels = ad5310r_channels,
- .int_vref_mv = 2500,
- .num_channels = 1,
- .regmap_type = AD5310_REGMAP,
- },
- [ID_AD5311R] = {
- .channels = ad5311r_channels,
- .int_vref_mv = 2500,
- .num_channels = 1,
- .regmap_type = AD5683_REGMAP,
- },
- [ID_AD5337R] = {
- .channels = ad5337r_channels,
- .int_vref_mv = 2500,
- .num_channels = 2,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5338R] = {
- .channels = ad5338r_channels,
- .int_vref_mv = 2500,
- .num_channels = 2,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5671R] = {
- .channels = ad5672_channels,
- .int_vref_mv = 2500,
- .num_channels = 8,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5672R] = {
- .channels = ad5672_channels,
- .int_vref_mv = 2500,
- .num_channels = 8,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5673R] = {
- .channels = ad5674r_channels,
- .int_vref_mv = 2500,
- .num_channels = 16,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5674R] = {
- .channels = ad5674r_channels,
- .int_vref_mv = 2500,
- .num_channels = 16,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5675R] = {
- .channels = ad5676_channels,
- .int_vref_mv = 2500,
- .num_channels = 8,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5676] = {
- .channels = ad5676_channels,
- .num_channels = 8,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5676R] = {
- .channels = ad5676_channels,
- .int_vref_mv = 2500,
- .num_channels = 8,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5677R] = {
- .channels = ad5679r_channels,
- .int_vref_mv = 2500,
- .num_channels = 16,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5679R] = {
- .channels = ad5679r_channels,
- .int_vref_mv = 2500,
- .num_channels = 16,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5681R] = {
- .channels = ad5691r_channels,
- .int_vref_mv = 2500,
- .num_channels = 1,
- .regmap_type = AD5683_REGMAP,
- },
- [ID_AD5682R] = {
- .channels = ad5692r_channels,
- .int_vref_mv = 2500,
- .num_channels = 1,
- .regmap_type = AD5683_REGMAP,
- },
- [ID_AD5683] = {
- .channels = ad5693_channels,
- .num_channels = 1,
- .regmap_type = AD5683_REGMAP,
- },
- [ID_AD5683R] = {
- .channels = ad5693_channels,
- .int_vref_mv = 2500,
- .num_channels = 1,
- .regmap_type = AD5683_REGMAP,
- },
- [ID_AD5684] = {
- .channels = ad5684_channels,
- .num_channels = 4,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5684R] = {
- .channels = ad5684_channels,
- .int_vref_mv = 2500,
- .num_channels = 4,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5685R] = {
- .channels = ad5685r_channels,
- .int_vref_mv = 2500,
- .num_channels = 4,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5686] = {
- .channels = ad5686_channels,
- .num_channels = 4,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5686R] = {
- .channels = ad5686_channels,
- .int_vref_mv = 2500,
- .num_channels = 4,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5691R] = {
- .channels = ad5691r_channels,
- .int_vref_mv = 2500,
- .num_channels = 1,
- .regmap_type = AD5683_REGMAP,
- },
- [ID_AD5692R] = {
- .channels = ad5692r_channels,
- .int_vref_mv = 2500,
- .num_channels = 1,
- .regmap_type = AD5683_REGMAP,
- },
- [ID_AD5693] = {
- .channels = ad5693_channels,
- .num_channels = 1,
- .regmap_type = AD5683_REGMAP,
- },
- [ID_AD5693R] = {
- .channels = ad5693_channels,
- .int_vref_mv = 2500,
- .num_channels = 1,
- .regmap_type = AD5683_REGMAP,
- },
- [ID_AD5694] = {
- .channels = ad5684_channels,
- .num_channels = 4,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5694R] = {
- .channels = ad5684_channels,
- .int_vref_mv = 2500,
- .num_channels = 4,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5695R] = {
- .channels = ad5685r_channels,
- .int_vref_mv = 2500,
- .num_channels = 4,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5696] = {
- .channels = ad5686_channels,
- .num_channels = 4,
- .regmap_type = AD5686_REGMAP,
- },
- [ID_AD5696R] = {
- .channels = ad5686_channels,
- .int_vref_mv = 2500,
- .num_channels = 4,
- .regmap_type = 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 = {
+ .channels = ad5310r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5310_REGMAP,
};
+EXPORT_SYMBOL_NS_GPL(ad5310r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5311r_chip_info = {
+ .channels = ad5311r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5683_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5311r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5681r_chip_info = {
+ .channels = ad5681r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5683_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5681r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5682r_chip_info = {
+ .channels = ad5682r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5683_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5682r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5683_chip_info = {
+ .channels = ad5683r_channels,
+ .num_channels = 1,
+ .regmap_type = AD5683_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5683_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5683r_chip_info = {
+ .channels = ad5683r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 1,
+ .regmap_type = AD5683_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5683r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5337r_chip_info = {
+ .channels = ad5337r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 2,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5337r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5338r_chip_info = {
+ .channels = ad5338r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 2,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5338r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5684_chip_info = {
+ .channels = ad5684r_channels,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5684_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5684r_chip_info = {
+ .channels = ad5684r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5684r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5685r_chip_info = {
+ .channels = ad5685r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5685r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5686_chip_info = {
+ .channels = ad5686r_channels,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5686_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5686r_chip_info = {
+ .channels = ad5686r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5686r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5672r_chip_info = {
+ .channels = ad5672r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 8,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5672r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5676_chip_info = {
+ .channels = ad5676r_channels,
+ .num_channels = 8,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5676_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5676r_chip_info = {
+ .channels = ad5676r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 8,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5676r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5674r_chip_info = {
+ .channels = ad5674r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 16,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5674r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5679r_chip_info = {
+ .channels = ad5679r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 16,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686");
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 = dev;
st->write = write;
st->read = read;
-
- st->chip_info = &ad5686_chip_info_tbl[chip_type];
+ st->chip_info = chip_info;
ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
if (ret < 0 && ret != -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)
-/**
- * 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,
-};
enum ad5686_regmap_type {
AD5310_REGMAP,
@@ -111,6 +75,34 @@ struct ad5686_chip_info {
enum ad5686_regmap_type regmap_type;
};
+/* 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 {
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);
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,
static int ad5686_i2c_probe(struct i2c_client *i2c)
{
- const struct i2c_device_id *id = 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);
}
static const struct i2c_device_id ad5686_i2c_id[] = {
- {"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);
static const struct of_device_id ad5686_of_match[] = {
- { .compatible = "adi,ad5311r" },
- { .compatible = "adi,ad5337r" },
- { .compatible = "adi,ad5338r" },
- { .compatible = "adi,ad5671r" },
- { .compatible = "adi,ad5675r" },
- { .compatible = "adi,ad5691r" },
- { .compatible = "adi,ad5692r" },
- { .compatible = "adi,ad5693" },
- { .compatible = "adi,ad5693r" },
- { .compatible = "adi,ad5694" },
- { .compatible = "adi,ad5694r" },
- { .compatible = "adi,ad5695r" },
- { .compatible = "adi,ad5696" },
- { .compatible = "adi,ad5696r" },
+ { .compatible = "adi,ad5311r", .data = &ad5311r_chip_info },
+ { .compatible = "adi,ad5337r", .data = &ad5337r_chip_info },
+ { .compatible = "adi,ad5338r", .data = &ad5338r_chip_info },
+ { .compatible = "adi,ad5671r", .data = &ad5672r_chip_info },
+ { .compatible = "adi,ad5673r", .data = &ad5674r_chip_info },
+ { .compatible = "adi,ad5675r", .data = &ad5676r_chip_info },
+ { .compatible = "adi,ad5677r", .data = &ad5679r_chip_info },
+ { .compatible = "adi,ad5691r", .data = &ad5681r_chip_info },
+ { .compatible = "adi,ad5692r", .data = &ad5682r_chip_info },
+ { .compatible = "adi,ad5693", .data = &ad5683_chip_info },
+ { .compatible = "adi,ad5693r", .data = &ad5683r_chip_info },
+ { .compatible = "adi,ad5694", .data = &ad5684_chip_info },
+ { .compatible = "adi,ad5694r", .data = &ad5684r_chip_info },
+ { .compatible = "adi,ad5695r", .data = &ad5685r_chip_info },
+ { .compatible = "adi,ad5696", .data = &ad5686_chip_info },
+ { .compatible = "adi,ad5696r", .data = &ad5686r_chip_info },
{ }
};
MODULE_DEVICE_TABLE(of, ad5686_of_match);
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 10/22] iio: dac: ad5686: add of_match table to the spi driver
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (8 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 09/22] iio: dac: ad5686: drop enum id Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 11/22] iio: dac: ad5686: fix ref bit initialization for single-channel parts Rodrigo Alencar via B4 Relay
` (12 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
Add of_match table for the SPI device variants to be consistent with the
AD5696 I2C driver.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
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[] = {
};
MODULE_DEVICE_TABLE(spi, ad5686_spi_id);
+static const struct of_device_id ad5686_of_match[] = {
+ { .compatible = "adi,ad5310r", .data = &ad5310r_chip_info },
+ { .compatible = "adi,ad5672r", .data = &ad5672r_chip_info },
+ { .compatible = "adi,ad5674r", .data = &ad5674r_chip_info },
+ { .compatible = "adi,ad5676", .data = &ad5676_chip_info },
+ { .compatible = "adi,ad5676r", .data = &ad5676r_chip_info },
+ { .compatible = "adi,ad5679r", .data = &ad5679r_chip_info },
+ { .compatible = "adi,ad5681r", .data = &ad5681r_chip_info },
+ { .compatible = "adi,ad5682r", .data = &ad5682r_chip_info },
+ { .compatible = "adi,ad5683", .data = &ad5683_chip_info },
+ { .compatible = "adi,ad5683r", .data = &ad5683r_chip_info },
+ { .compatible = "adi,ad5684", .data = &ad5684_chip_info },
+ { .compatible = "adi,ad5684r", .data = &ad5684r_chip_info },
+ { .compatible = "adi,ad5685r", .data = &ad5685r_chip_info },
+ { .compatible = "adi,ad5686", .data = &ad5686_chip_info },
+ { .compatible = "adi,ad5686r", .data = &ad5686r_chip_info },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ad5686_of_match);
+
static struct spi_driver ad5686_spi_driver = {
.driver = {
.name = "ad5686",
+ .of_match_table = ad5686_of_match,
},
.probe = ad5686_spi_probe,
.id_table = ad5686_spi_id,
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 11/22] iio: dac: ad5686: fix ref bit initialization for single-channel parts
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (9 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 10/22] iio: dac: ad5686: add of_match table to the spi driver Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 19:58 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 12/22] iio: dac: ad5686: fix powerdown control Rodrigo Alencar via B4 Relay
` (11 subsequent siblings)
22 siblings, 1 reply; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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 @@
*/
#include <linux/array_size.h>
+#include <linux/bitfield.h>
#include <linux/err.h>
#include <linux/export.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>
#include <linux/sysfs.h>
+#include <linux/wordpart.h>
#include "ad5686.h"
@@ -20,6 +22,24 @@ static const char * const ad5686_powerdown_modes[] = {
"three_state"
};
+static int ad5310_control_sync(struct ad5686_state *st)
+{
+ unsigned int pd_val = 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 = 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 = iio_priv(indio_dev);
- unsigned int val, ref_bit_msk;
- u8 shift, address = 0;
+ unsigned int val;
+ u8 address = 0;
ret = kstrtobool(buf, &readin);
if (ret)
@@ -79,30 +99,26 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
switch (st->chip_info->regmap_type) {
case AD5310_REGMAP:
- shift = 9;
- ref_bit_msk = AD5310_REF_BIT_MSK;
+ ret = ad5310_control_sync(st);
break;
case AD5683_REGMAP:
- shift = 13;
- ref_bit_msk = AD5683_REF_BIT_MSK;
+ ret = ad5683_control_sync(st);
break;
case AD5686_REGMAP:
- shift = 0;
- ref_bit_msk = 0;
/* AD5674R/AD5679R have 16 channels and 2 powerdown registers */
- if (chan->channel > 0x7)
+ val = st->pwr_down_mask & st->pwr_down_mode;
+ if (chan->channel > 0x7) {
address = 0x8;
+ val = upper_16_bits(val);
+ } else {
+ val = lower_16_bits(val);
+ }
+ ret = st->write(st, AD5686_CMD_POWERDOWN_DAC, address, val);
break;
default:
return -EINVAL;
}
- val = ((st->pwr_down_mask & st->pwr_down_mode) << shift);
- if (!st->use_internal_vref)
- val |= ref_bit_msk;
-
- ret = st->write(st, AD5686_CMD_POWERDOWN_DAC,
- address, val >> (address * 2));
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;
indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
@@ -438,8 +451,8 @@ int ad5686_probe(struct device *dev,
if (ret < 0 && ret != -ENODEV)
return ret;
- has_external_vref = ret != -ENODEV;
- st->vref_mv = has_external_vref ? ret / 1000 : st->chip_info->int_vref_mv;
+ st->use_internal_vref = ret == -ENODEV;
+ st->vref_mv = st->use_internal_vref ? st->chip_info->int_vref_mv : ret / 1000;
/* Set all the power down mode for all channels to 1K pulldown */
for (i = 0; i < st->chip_info->num_channels; i++)
@@ -457,29 +470,25 @@ int ad5686_probe(struct device *dev,
switch (st->chip_info->regmap_type) {
case AD5310_REGMAP:
- cmd = AD5686_CMD_CONTROL_REG;
- ref_bit_msk = AD5310_REF_BIT_MSK;
- st->use_internal_vref = !has_external_vref;
+ ret = ad5310_control_sync(st);
+ if (ret)
+ return ret;
break;
case AD5683_REGMAP:
- cmd = AD5686_CMD_CONTROL_REG;
- ref_bit_msk = AD5683_REF_BIT_MSK;
- st->use_internal_vref = !has_external_vref;
+ ret = ad5683_control_sync(st);
+ if (ret)
+ return ret;
break;
case AD5686_REGMAP:
- cmd = AD5686_CMD_INTERNAL_REFER_SETUP;
- ref_bit_msk = 0;
+ ret = st->write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0,
+ !st->use_internal_vref);
+ if (ret)
+ return ret;
break;
default:
return -EINVAL;
}
- val = (has_external_vref | ref_bit_msk);
-
- ret = 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
#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)
enum ad5686_regmap_type {
AD5310_REGMAP,
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 12/22] iio: dac: ad5686: fix powerdown control
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (10 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 11/22] iio: dac: ad5686: fix ref bit initialization for single-channel parts Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 20:25 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 13/22] iio: dac: ad5686: fix input raw value check Rodrigo Alencar via B4 Relay
` (10 subsequent siblings)
22 siblings, 1 reply; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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));
}
+static inline int ad5686_pd_mask_shift(const struct iio_chan_spec *chan)
+{
+ if (chan->channel == 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 = iio_priv(indio_dev);
+ int mode, shift = ad5686_pd_mask_shift(chan);
- return ((st->pwr_down_mode >> (chan->channel * 2)) & 0x3) - 1;
+ mutex_lock(&st->lock);
+ mode = ((st->pwr_down_mode >> shift) & 0x3) - 1;
+ mutex_unlock(&st->lock);
+
+ return mode;
}
static int ad5686_set_powerdown_mode(struct iio_dev *indio_dev,
@@ -53,9 +67,12 @@ static int ad5686_set_powerdown_mode(struct iio_dev *indio_dev,
unsigned int mode)
{
struct ad5686_state *st = iio_priv(indio_dev);
+ int shift = ad5686_pd_mask_shift(chan);
- st->pwr_down_mode &= ~(0x3 << (chan->channel * 2));
- st->pwr_down_mode |= ((mode + 1) << (chan->channel * 2));
+ mutex_lock(&st->lock);
+ st->pwr_down_mode &= ~(0x3 << shift);
+ st->pwr_down_mode |= ((mode + 1) << shift);
+ mutex_unlock(&st->lock);
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 = iio_priv(indio_dev);
+ int val, shift = ad5686_pd_mask_shift(chan);
- return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask &
- (0x3 << (chan->channel * 2))));
+ mutex_lock(&st->lock);
+ val = !!(st->pwr_down_mask & (0x3 << shift));
+ mutex_unlock(&st->lock);
+
+ return sysfs_emit(buf, "%d\n", val);
}
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 = ad5686_pd_mask_shift(chan);
struct ad5686_state *st = iio_priv(indio_dev);
unsigned int val;
u8 address = 0;
@@ -92,10 +113,12 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
if (ret)
return ret;
+ mutex_lock(&st->lock);
+
if (readin)
- st->pwr_down_mask |= (0x3 << (chan->channel * 2));
+ st->pwr_down_mask |= (0x3 << shift);
else
- st->pwr_down_mask &= ~(0x3 << (chan->channel * 2));
+ st->pwr_down_mask &= ~(0x3 << shift);
switch (st->chip_info->regmap_type) {
case AD5310_REGMAP:
@@ -116,9 +139,10 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
ret = st->write(st, AD5686_CMD_POWERDOWN_DAC, address, val);
break;
default:
- return -EINVAL;
+ ret = -EINVAL;
}
+ mutex_unlock(&st->lock);
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;
indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (indio_dev == NULL)
@@ -455,8 +479,14 @@ int ad5686_probe(struct device *dev,
st->vref_mv = st->use_internal_vref ? st->chip_info->int_vref_mv : ret / 1000;
/* Set all the power down mode for all channels to 1K pulldown */
- for (i = 0; i < st->chip_info->num_channels; i++)
- st->pwr_down_mode |= (0x01 << (i * 2));
+ st->pwr_down_mode = ~0U;
+ st->pwr_down_mask = ~0U;
+ for (i = 0; i < st->chip_info->num_channels; i++) {
+ shift = ad5686_pd_mask_shift(&st->chip_info->channels[i]);
+ st->pwr_down_mask &= ~(0x3 << shift); /* powered up state */
+ st->pwr_down_mode &= ~(0x3 << shift);
+ st->pwr_down_mode |= (0x01 << shift);
+ }
indio_dev->name = name;
indio_dev->info = &ad5686_info;
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 13/22] iio: dac: ad5686: fix input raw value check
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (11 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 12/22] iio: dac: ad5686: fix powerdown control Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 14/22] iio: dac: ad5686: add support for missing power supplies Rodrigo Alencar via B4 Relay
` (9 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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,
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;
mutex_lock(&st->lock);
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 14/22] iio: dac: ad5686: add support for missing power supplies
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (12 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 13/22] iio: dac: ad5686: fix input raw value check Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 15/22] iio: dac: ad5686: create bus ops struct Rodrigo Alencar via B4 Relay
` (8 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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 @@
#include <linux/array_size.h>
#include <linux/bitfield.h>
+#include <linux/dev_printk.h>
#include <linux/err.h>
#include <linux/export.h>
#include <linux/module.h>
@@ -471,13 +472,27 @@ int ad5686_probe(struct device *dev,
st->read = read;
st->chip_info = chip_info;
- ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
+ ret = devm_regulator_get_enable_optional(dev, "vdd");
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(dev, ret, "failed to enable vdd supply\n");
+
+ ret = devm_regulator_get_enable_optional(dev, "vlogic");
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(dev, ret, "failed to enable vlogic supply\n");
+
+ ret = devm_regulator_get_enable_read_voltage(dev, "vref");
+ if (ret == -ENODEV) /* vcc-supply is deprecated, but supported still */
+ ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
if (ret < 0 && ret != -ENODEV)
- return ret;
+ return dev_err_probe(dev, ret, "failed to read vref voltage\n");
st->use_internal_vref = ret == -ENODEV;
st->vref_mv = st->use_internal_vref ? st->chip_info->int_vref_mv : ret / 1000;
+ 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 = ~0U;
st->pwr_down_mask = ~0U;
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 15/22] iio: dac: ad5686: create bus ops struct
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (13 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 14/22] iio: dac: ad5686: add support for missing power supplies Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 16/22] iio: dac: ad5686: extend device support with new parts Rodrigo Alencar via B4 Relay
` (7 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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);
}
+static const struct ad5686_bus_ops ad5686_spi_ops = {
+ .write = ad5686_spi_write,
+ .read = 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);
}
static const struct spi_device_id ad5686_spi_id[] = {
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 = 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));
+ 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));
}
static int ad5683_control_sync(struct ad5686_state *st)
{
unsigned int pd_val = 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));
+ 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));
}
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_dev *indio_dev,
} else {
val = lower_16_bits(val);
}
- ret = st->write(st, AD5686_CMD_POWERDOWN_DAC, address, val);
+ ret = ad5686_write(st, AD5686_CMD_POWERDOWN_DAC, address, val);
break;
default:
ret = -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 = st->read(st, chan->address);
+ ret = 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;
mutex_lock(&st->lock);
- ret = st->write(st,
- AD5686_CMD_WRITE_INPUT_N_UPDATE_N,
- chan->address,
- val << chan->scan_type.shift);
+ ret = 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");
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 = iio_priv(indio_dev);
st->dev = dev;
- st->write = write;
- st->read = read;
+ st->ops = ops;
st->chip_info = chip_info;
ret = devm_regulator_get_enable_optional(dev, "vdd");
@@ -525,8 +521,8 @@ int ad5686_probe(struct device *dev,
return ret;
break;
case AD5686_REGMAP:
- ret = st->write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0,
- !st->use_internal_vref);
+ ret = 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 {
struct ad5686_state;
-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);
+};
/**
* struct ad5686_chip_info - chip specific information
@@ -106,24 +113,23 @@ extern const struct ad5686_chip_info ad5679r_chip_info;
/**
* 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 used
- * @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;
@@ -142,8 +148,22 @@ struct ad5686_state {
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);
+static inline int ad5686_write(struct ad5686_state *st, u8 cmd, u8 addr, u16 val)
+{
+ int ret;
+
+ ret = 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);
+}
#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 != 3) ? -EIO : 0;
}
+static const struct ad5686_bus_ops ad5686_i2c_ops = {
+ .write = ad5686_i2c_write,
+ .read = 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);
}
static const struct i2c_device_id ad5686_i2c_id[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 16/22] iio: dac: ad5686: extend device support with new parts
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (14 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 15/22] iio: dac: ad5686: create bus ops struct Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 17/22] iio: dac: ad5686: update device list description Rodrigo Alencar via B4 Relay
` (6 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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)
static const struct spi_device_id ad5686_spi_id[] = {
{ "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[] = {
{ "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);
static const struct of_device_id ad5686_of_match[] = {
{ .compatible = "adi,ad5310r", .data = &ad5310r_chip_info },
+ { .compatible = "adi,ad5313r", .data = &ad5338r_chip_info },
+ { .compatible = "adi,ad5317r", .data = &ad5317r_chip_info },
{ .compatible = "adi,ad5672r", .data = &ad5672r_chip_info },
+ { .compatible = "adi,ad5674", .data = &ad5674_chip_info },
{ .compatible = "adi,ad5674r", .data = &ad5674r_chip_info },
{ .compatible = "adi,ad5676", .data = &ad5676_chip_info },
{ .compatible = "adi,ad5676r", .data = &ad5676r_chip_info },
+ { .compatible = "adi,ad5679", .data = &ad5679_chip_info },
{ .compatible = "adi,ad5679r", .data = &ad5679r_chip_info },
{ .compatible = "adi,ad5681r", .data = &ad5681r_chip_info },
{ .compatible = "adi,ad5682r", .data = &ad5682r_chip_info },
@@ -139,6 +151,10 @@ static const struct of_device_id ad5686_of_match[] = {
{ .compatible = "adi,ad5685r", .data = &ad5685r_chip_info },
{ .compatible = "adi,ad5686", .data = &ad5686_chip_info },
{ .compatible = "adi,ad5686r", .data = &ad5686r_chip_info },
+ { .compatible = "adi,ad5687", .data = &ad5687_chip_info },
+ { .compatible = "adi,ad5687r", .data = &ad5687r_chip_info },
+ { .compatible = "adi,ad5689", .data = &ad5689_chip_info },
+ { .compatible = "adi,ad5689r", .data = &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);
/* 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 = {
};
EXPORT_SYMBOL_NS_GPL(ad5338r_chip_info, "IIO_AD5686");
+const struct ad5686_chip_info ad5687_chip_info = {
+ .channels = ad5687r_channels,
+ .num_channels = 2,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5687_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5687r_chip_info = {
+ .channels = ad5687r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 2,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5687r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5689_chip_info = {
+ .channels = ad5689r_channels,
+ .num_channels = 2,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5689_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5689r_chip_info = {
+ .channels = ad5689r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 2,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5689r_chip_info, "IIO_AD5686");
+
+const struct ad5686_chip_info ad5317r_chip_info = {
+ .channels = ad5317r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 4,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5317r_chip_info, "IIO_AD5686");
+
const struct ad5686_chip_info ad5684_chip_info = {
.channels = ad5684r_channels,
.num_channels = 4,
@@ -434,6 +475,13 @@ const struct ad5686_chip_info ad5676r_chip_info = {
};
EXPORT_SYMBOL_NS_GPL(ad5676r_chip_info, "IIO_AD5686");
+const struct ad5686_chip_info ad5674_chip_info = {
+ .channels = ad5674r_channels,
+ .num_channels = 16,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5674_chip_info, "IIO_AD5686");
+
const struct ad5686_chip_info ad5674r_chip_info = {
.channels = ad5674r_channels,
.int_vref_mv = 2500,
@@ -442,6 +490,13 @@ const struct ad5686_chip_info ad5674r_chip_info = {
};
EXPORT_SYMBOL_NS_GPL(ad5674r_chip_info, "IIO_AD5686");
+const struct ad5686_chip_info ad5679_chip_info = {
+ .channels = ad5679r_channels,
+ .num_channels = 16,
+ .regmap_type = AD5686_REGMAP,
+};
+EXPORT_SYMBOL_NS_GPL(ad5679_chip_info, "IIO_AD5686");
+
const struct ad5686_chip_info ad5679r_chip_info = {
.channels = ad5679r_channels,
.int_vref_mv = 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;
/* 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;
/* 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;
/**
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)
static const struct i2c_device_id ad5686_i2c_id[] = {
{ "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[] = {
{ "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);
static const struct of_device_id ad5686_of_match[] = {
{ .compatible = "adi,ad5311r", .data = &ad5311r_chip_info },
+ { .compatible = "adi,ad5316r", .data = &ad5317r_chip_info },
{ .compatible = "adi,ad5337r", .data = &ad5337r_chip_info },
{ .compatible = "adi,ad5338r", .data = &ad5338r_chip_info },
{ .compatible = "adi,ad5671r", .data = &ad5672r_chip_info },
{ .compatible = "adi,ad5673r", .data = &ad5674r_chip_info },
+ { .compatible = "adi,ad5675", .data = &ad5676_chip_info },
{ .compatible = "adi,ad5675r", .data = &ad5676r_chip_info },
{ .compatible = "adi,ad5677r", .data = &ad5679r_chip_info },
{ .compatible = "adi,ad5691r", .data = &ad5681r_chip_info },
@@ -110,6 +115,7 @@ static const struct of_device_id ad5686_of_match[] = {
{ .compatible = "adi,ad5695r", .data = &ad5685r_chip_info },
{ .compatible = "adi,ad5696", .data = &ad5686_chip_info },
{ .compatible = "adi,ad5696r", .data = &ad5686r_chip_info },
+ { .compatible = "adi,ad5697r", .data = &ad5687r_chip_info },
{ }
};
MODULE_DEVICE_TABLE(of, ad5686_of_match);
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 17/22] iio: dac: ad5686: update device list description
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (15 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 16/22] iio: dac: ad5686: extend device support with new parts Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 20:06 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 18/22] iio: dac: ad5686: consume optional reset signal Rodrigo Alencar via B4 Relay
` (5 subsequent siblings)
22 siblings, 1 reply; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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.
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.
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.
*/
#include <asm/byteorder.h>
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.
*/
#include <linux/array_size.h>
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.
*/
#include <asm/byteorder.h>
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 18/22] iio: dac: ad5686: consume optional reset signal
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (16 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 17/22] iio: dac: ad5686: update device list description Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 19/22] iio: dac: ad5686: add ldac gpio Rodrigo Alencar via B4 Relay
` (4 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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 <linux/export.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>
+#include <linux/reset.h>
#include <linux/sysfs.h>
#include <linux/wordpart.h>
@@ -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");
+ rstc = 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 = ~0U;
st->pwr_down_mask = ~0U;
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 19/22] iio: dac: ad5686: add ldac gpio
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (17 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 18/22] iio: dac: ad5686: consume optional reset signal Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 20/22] iio: dac: ad5686: implement new sync() op for the spi bus Rodrigo Alencar via B4 Relay
` (3 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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");
+ st->ldac_gpio = 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 = ~0U;
st->pwr_down_mask = ~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__
#include <linux/bits.h>
+#include <linux/gpio/consumer.h>
#include <linux/mutex.h>
#include <linux/types.h>
@@ -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;
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 20/22] iio: dac: ad5686: implement new sync() op for the spi bus
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (18 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 19/22] iio: dac: ad5686: add ldac gpio Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 21/22] iio: dac: ad5686: add triggered buffer support Rodrigo Alencar via B4 Relay
` (2 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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 <linux/err.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/overflow.h>
#include <linux/spi/spi.h>
#include "ad5686.h"
+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 = to_spi_device(st->dev);
- u8 tx_len, *buf;
+ struct ad5686_spi_data *bus_data = st->bus_data;
+ struct spi_transfer *xfer;
+
+ if (bus_data->size >= bus_data->capacity)
+ return -E2BIG;
+
+ if (bus_data->size)
+ bus_data->xfers[bus_data->size - 1].cs_change = 1;
+ else
+ spi_message_init(&bus_data->msg);
+
+ xfer = &bus_data->xfers[bus_data->size];
+ xfer->rx_buf = NULL;
+ xfer->cs_change = 0;
switch (st->chip_info->regmap_type) {
case AD5310_REGMAP:
- st->data[0].d16 = cpu_to_be16(AD5310_CMD(cmd) |
- val);
- buf = &st->data[0].d8[0];
- tx_len = 2;
+ st->data[bus_data->size].d16 = cpu_to_be16(AD5310_CMD(cmd) |
+ val);
+ xfer->tx_buf = &st->data[bus_data->size].d8[0];
+ xfer->len = 2;
break;
case AD5683_REGMAP:
- st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) |
- AD5683_DATA(val));
- buf = &st->data[0].d8[1];
- tx_len = 3;
+ st->data[bus_data->size].d32 = cpu_to_be32(AD5686_CMD(cmd) |
+ AD5683_DATA(val));
+ xfer->tx_buf = &st->data[bus_data->size].d8[1];
+ xfer->len = 3;
break;
case AD5686_REGMAP:
- st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) |
- AD5686_ADDR(addr) |
- val);
- buf = &st->data[0].d8[1];
- tx_len = 3;
+ st->data[bus_data->size].d32 = cpu_to_be32(AD5686_CMD(cmd) |
+ AD5686_ADDR(addr) |
+ val);
+ xfer->tx_buf = &st->data[bus_data->size].d8[1];
+ xfer->len = 3;
break;
default:
return -EINVAL;
}
- 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 = to_spi_device(st->dev);
+ struct ad5686_spi_data *bus_data = st->bus_data;
+
+ bus_data->size = 0; /* always reset, even on sync failure */
+ return spi_sync(spi, &bus_data->msg);
}
static int ad5686_spi_read(struct ad5686_state *st, u8 addr)
{
- struct spi_transfer t[] = {
- {
- .tx_buf = &st->data[0].d8[1],
- .len = 3,
- .cs_change = 1,
- }, {
- .tx_buf = &st->data[1].d8[1],
- .rx_buf = &st->data[2].d8[1],
- .len = 3,
- },
- };
struct spi_device *spi = to_spi_device(st->dev);
+ struct ad5686_spi_data *bus_data = st->bus_data;
+ struct spi_transfer *xfer = &bus_data->xfers[0];
u8 cmd = 0;
int ret;
@@ -84,8 +107,18 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 addr)
AD5686_ADDR(addr));
st->data[1].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP));
- ret = spi_sync_transfer(spi, t, ARRAY_SIZE(t));
- if (ret < 0)
+ xfer[0].tx_buf = &st->data[0].d8[1];
+ xfer[0].len = 3;
+ xfer[0].cs_change = 1;
+ xfer[1].tx_buf = &st->data[1].d8[1];
+ xfer[1].rx_buf = &st->data[2].d8[1];
+ xfer[1].len = 3;
+ xfer[1].cs_change = 0;
+
+ spi_message_init_with_transfers(&bus_data->msg, xfer, 2);
+
+ ret = spi_sync(spi, &bus_data->msg);
+ if (ret)
return ret;
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 = {
.write = ad5686_spi_write,
.read = ad5686_spi_read,
+ .sync = ad5686_spi_sync,
};
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 = spi_get_device_match_data(spi);
+ struct ad5686_spi_data *bus_data;
+ unsigned int capacity;
+
+ /* read operation requires at least 2 transfers */
+ capacity = max(info->num_channels, 2);
+ bus_data = devm_kzalloc(&spi->dev,
+ struct_size(bus_data, xfers, capacity),
+ GFP_KERNEL);
+ if (!bus_data)
+ return -ENOMEM;
+
+ bus_data->capacity = capacity;
+
+ return ad5686_probe(&spi->dev, info, spi->modalias, &ad5686_spi_ops,
+ bus_data);
}
static const struct spi_device_id ad5686_spi_id[] = {
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");
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,
st->dev = dev;
st->ops = ops;
+ st->bus_data = bus_data;
st->chip_info = chip_info;
ret = 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 @@
#define AD5686_ADDR_DAC(chan) (0x1 << (chan))
#define AD5686_ADDR_ALL_DAC 0xF
+#define AD5686_MAX_CHANNELS 16
#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 used
* @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;
/*
* 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);
};
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);
static inline int ad5686_write(struct ad5686_state *st, u8 cmd, u8 addr, u16 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 = {
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);
}
static const struct i2c_device_id ad5686_i2c_id[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 21/22] iio: dac: ad5686: add triggered buffer support
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (19 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 20/22] iio: dac: ad5686: implement new sync() op for the spi bus Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 22/22] iio: dac: ad5686: add gain control support Rodrigo Alencar via B4 Relay
2026-04-22 20:28 ` [PATCH 00/22] Extend device support for AD5686 driver Andy Shevchenko
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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
config AD5686
tristate
+ select IIO_BUFFER
+ select IIO_TRIGGERED_BUFFER
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 <linux/sysfs.h>
#include <linux/wordpart.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
+
#include "ad5686.h"
static const char * const ad5686_powerdown_modes[] = {
@@ -227,6 +232,7 @@ static const struct iio_chan_spec_ext_info ad5686_ext_info[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),\
.address = addr, \
+ .scan_index = chan, \
.scan_type = { \
.sign = 'u', \
.realbits = (bits), \
@@ -506,6 +512,55 @@ const struct ad5686_chip_info ad5679r_chip_info = {
};
EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686");
+static irqreturn_t ad5686_trigger_handler(int irq, void *p)
+{
+ struct iio_poll_func *pf = p;
+ struct iio_dev *indio_dev = pf->indio_dev;
+ struct iio_buffer *buffer = indio_dev->buffer;
+ struct ad5686_state *st = iio_priv(indio_dev);
+ const struct iio_chan_spec *chan;
+ u16 val[AD5686_MAX_CHANNELS];
+ int ret, ch, i = 0;
+ bool async_update;
+ u8 cmd;
+
+ ret = iio_pop_from_buffer(buffer, val);
+ if (ret)
+ goto out;
+
+ mutex_lock(&st->lock);
+
+ async_update = st->ldac_gpio && bitmap_weight(indio_dev->active_scan_mask,
+ iio_get_masklength(indio_dev)) > 1;
+ if (async_update) {
+ /* use ldac to update all channels simultaneously */
+ cmd = AD5686_CMD_WRITE_INPUT_N;
+ gpiod_set_value_cansleep(st->ldac_gpio, 0);
+ } else {
+ cmd = AD5686_CMD_WRITE_INPUT_N_UPDATE_N;
+ }
+
+ iio_for_each_active_channel(indio_dev, ch) {
+ chan = &indio_dev->channels[ch];
+ ret = st->ops->write(st, cmd, chan->address,
+ val[i++] << chan->scan_type.shift);
+ if (ret)
+ break;
+ }
+
+ if (!ret && st->ops->sync)
+ ret = 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;
}
+ ret = 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");
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 22/22] iio: dac: ad5686: add gain control support
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (20 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 21/22] iio: dac: ad5686: add triggered buffer support Rodrigo Alencar via B4 Relay
@ 2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 20:28 ` [PATCH 00/22] Extend device support for AD5686 driver Andy Shevchenko
22 siblings, 0 replies; 30+ messages in thread
From: Rodrigo Alencar via B4 Relay @ 2026-04-22 14:45 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening
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
From: Rodrigo Alencar <rodrigo.alencar@analog.com>
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 <rodrigo.alencar@analog.com>
---
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 <linux/dev_printk.h>
#include <linux/err.h>
#include <linux/export.h>
+#include <linux/math64.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>
#include <linux/reset.h>
#include <linux/sysfs.h>
+#include <linux/units.h>
#include <linux/wordpart.h>
#include <linux/iio/buffer.h>
@@ -35,7 +37,8 @@ static int ad5310_control_sync(struct ad5686_state *st)
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));
}
static int ad5683_control_sync(struct ad5686_state *st)
@@ -44,7 +47,8 @@ static int ad5683_control_sync(struct ad5686_state *st)
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));
}
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 = iio_priv(indio_dev);
int ret;
+ guard(mutex)(&st->lock);
+
switch (m) {
case IIO_CHAN_INFO_RAW:
- mutex_lock(&st->lock);
ret = ad5686_read(st, chan->address);
- mutex_unlock(&st->lock);
if (ret < 0)
return ret;
*val = (ret >> chan->scan_type.shift) &
GENMASK(chan->scan_type.realbits - 1, 0);
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
- *val = st->vref_mv;
- *val2 = chan->scan_type.realbits;
- return IIO_VAL_FRACTIONAL_LOG2;
+ if (st->double_scale) {
+ *val = st->scale_avail[2];
+ *val2 = st->scale_avail[3];
+ } else {
+ *val = st->scale_avail[0];
+ *val2 = 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 = iio_priv(indio_dev);
- int ret;
+
+ guard(mutex)(&st->lock);
switch (mask) {
case IIO_CHAN_INFO_RAW:
if (!in_range(val, 0, 1 << chan->scan_type.realbits))
return -EINVAL;
- mutex_lock(&st->lock);
- ret = ad5686_write(st, AD5686_CMD_WRITE_INPUT_N_UPDATE_N,
- chan->address, val << chan->scan_type.shift);
- mutex_unlock(&st->lock);
- break;
- default:
- ret = -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 == st->scale_avail[0] && val2 == st->scale_avail[1])
+ st->double_scale = false;
+ else if (val == st->scale_avail[2] && val2 == st->scale_avail[3])
+ st->double_scale = true;
+ else
+ return -EINVAL;
- 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 = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SCALE:
+ *type = IIO_VAL_INT_PLUS_NANO;
+ *vals = st->scale_avail;
+ *length = ARRAY_SIZE(st->scale_avail);
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
}
static const struct iio_info ad5686_info = {
.read_raw = ad5686_read_raw,
.write_raw = ad5686_write_raw,
+ .write_raw_get_fmt = ad5686_write_raw_get_fmt,
+ .read_avail = ad5686_read_avail,
};
static const struct iio_chan_spec_ext_info ad5686_ext_info[] = {
@@ -231,6 +289,7 @@ static const struct iio_chan_spec_ext_info ad5686_ext_info[] = {
.channel = chan, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),\
+ .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE),\
.address = addr, \
.scan_index = chan, \
.scan_type = { \
@@ -512,6 +571,16 @@ const struct ad5686_chip_info ad5679r_chip_info = {
};
EXPORT_SYMBOL_NS_GPL(ad5679r_chip_info, "IIO_AD5686");
+static void ad5686_init_scale_avail(struct ad5686_state *st)
+{
+ int realbits = st->chip_info->channels[0].scan_type.realbits;
+ s64 tmp;
+
+ tmp = 2ULL * st->vref_mv * NANO >> realbits;
+ st->scale_avail[2] = div_s64_rem(tmp, NANO, &st->scale_avail[3]);
+ st->scale_avail[0] = 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 = 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");
+ st->gain_gpio = 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 = ~0U;
st->pwr_down_mask = ~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
+#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)
@@ -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 used
* @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;
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH 07/22] iio: dac: ad5686: refactor include headers
2026-04-22 14:45 ` [PATCH 07/22] iio: dac: ad5686: refactor include headers Rodrigo Alencar via B4 Relay
@ 2026-04-22 19:43 ` Andy Shevchenko
0 siblings, 0 replies; 30+ messages in thread
From: Andy Shevchenko @ 2026-04-22 19:43 UTC (permalink / raw)
To: rodrigo.alencar
Cc: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening, Lars-Peter Clausen,
Michael Hennerich, David Lechner, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Kees Cook, Gustavo A. R. Silva,
Philipp Zabel
On Wed, Apr 22, 2026 at 03:45:41PM +0100, Rodrigo Alencar via B4 Relay wrote:
> Apply IWYU principle, replacing unused/generic headers for
> specific/missing headers. The resulting include directive list is sorted
> accordingly.
...
> -#include "ad5686.h"
> -
> +#include <asm/byteorder.h>
asm/* is another group and goes after linux/* generic ones.
> +#include <linux/array_size.h>
> +#include <linux/err.h>
> +#include <linux/mod_devicetable.h>
> #include <linux/module.h>
> #include <linux/spi/spi.h>
>
> +#include "ad5686.h"
> -#include <linux/interrupt.h>
> -#include <linux/fs.h>
> -#include <linux/device.h>
> +#include <linux/array_size.h>
> +#include <linux/err.h>
> +#include <linux/export.h>
> #include <linux/module.h>
> -#include <linux/kernel.h>
> -#include <linux/slab.h>
> -#include <linux/sysfs.h>
> #include <linux/regulator/consumer.h>
> -
> -#include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
Leave linux/iio/* group separated.
> +#include <linux/sysfs.h>
>
> #include "ad5686.h"
It should be something like this at the end:
linux/* generic headers
blank line
asm/* generic headers
blank line
linux/iio/*
blank line
"private headers"
...
Same applies to the rest of the patch.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 08/22] iio: dac: ad5686: remove redundant register definition
2026-04-22 14:45 ` [PATCH 08/22] iio: dac: ad5686: remove redundant register definition Rodrigo Alencar via B4 Relay
@ 2026-04-22 19:47 ` Andy Shevchenko
0 siblings, 0 replies; 30+ messages in thread
From: Andy Shevchenko @ 2026-04-22 19:47 UTC (permalink / raw)
To: rodrigo.alencar
Cc: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening, Lars-Peter Clausen,
Michael Hennerich, David Lechner, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Kees Cook, Gustavo A. R. Silva,
Philipp Zabel
On Wed, Apr 22, 2026 at 03:45:42PM +0100, Rodrigo Alencar via B4 Relay wrote:
> 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.
Not sure about naming, but LGTM, especially line that removed the trailing
entry without comma — kills two birds with one stone.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 11/22] iio: dac: ad5686: fix ref bit initialization for single-channel parts
2026-04-22 14:45 ` [PATCH 11/22] iio: dac: ad5686: fix ref bit initialization for single-channel parts Rodrigo Alencar via B4 Relay
@ 2026-04-22 19:58 ` Andy Shevchenko
0 siblings, 0 replies; 30+ messages in thread
From: Andy Shevchenko @ 2026-04-22 19:58 UTC (permalink / raw)
To: rodrigo.alencar
Cc: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening, Lars-Peter Clausen,
Michael Hennerich, David Lechner, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Kees Cook, Gustavo A. R. Silva,
Philipp Zabel
On Wed, Apr 22, 2026 at 03:45:45PM +0100, Rodrigo Alencar via B4 Relay wrote:
> 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.
...
> +static int ad5310_control_sync(struct ad5686_state *st)
> +{
> + unsigned int pd_val = 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));
I prefer to see explicit integers in use instead of implicit boolean promotions
in FIELD_*() that might lead to subtle mistakes.
st_use_internal_vref ? 0 : 1
In the code compiler will optimise this to the current state anyway.
> +}
...
> switch (st->chip_info->regmap_type) {
> case AD5310_REGMAP:
> - shift = 9;
> - ref_bit_msk = AD5310_REF_BIT_MSK;
> + ret = ad5310_control_sync(st);
> break;
> case AD5683_REGMAP:
> - shift = 13;
> - ref_bit_msk = AD5683_REF_BIT_MSK;
> + ret = ad5683_control_sync(st);
> break;
> case AD5686_REGMAP:
> - shift = 0;
> - ref_bit_msk = 0;
> /* AD5674R/AD5679R have 16 channels and 2 powerdown registers */
> - if (chan->channel > 0x7)
> + val = st->pwr_down_mask & st->pwr_down_mode;
> + if (chan->channel > 0x7) {
> address = 0x8;
> + val = upper_16_bits(val);
> + } else {
Would be nice to see address to be assigned here explicitly if it's a constant.
> + val = lower_16_bits(val);
> + }
> + ret = st->write(st, AD5686_CMD_POWERDOWN_DAC, address, val);
> break;
> default:
> return -EINVAL;
> }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 17/22] iio: dac: ad5686: update device list description
2026-04-22 14:45 ` [PATCH 17/22] iio: dac: ad5686: update device list description Rodrigo Alencar via B4 Relay
@ 2026-04-22 20:06 ` Andy Shevchenko
2026-04-22 20:07 ` Andy Shevchenko
0 siblings, 1 reply; 30+ messages in thread
From: Andy Shevchenko @ 2026-04-22 20:06 UTC (permalink / raw)
To: rodrigo.alencar
Cc: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening, Lars-Peter Clausen,
Michael Hennerich, David Lechner, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Kees Cook, Gustavo A. R. Silva,
Philipp Zabel
On Wed, Apr 22, 2026 at 03:45:51PM +0100, Rodrigo Alencar via B4 Relay wrote:
> 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.
...
> - 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.
Still unscalable and not much readable.
Can we rather make it groups like by channels, or just by a few numbers?
(Like the below example, but I am pretty much sure it's still far from the
better alternatives)
- AD5310R, AD5313R, AD5317R
- AD5672R, AD5674, AD5674R, AD5676, AD5676R, AD5679, AD5679R
- AD5681R, AD5682R, AD5683, AD5683R, AD5684, AD5684R, AD5685R
- AD5686
...
> /*
> - * 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
In the same way.
> * Digital to analog converters driver
> *
> - * Copyright 2018 Analog Devices Inc.
> + * Copyright 2018-2026 Analog Devices Inc.
> */
...
> /*
> - * 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.
> */
...
> /*
> - * 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
Looking at the core description it let me think that that has to be in i2c and
spi cases as well. One may deduct the list of supported devices from the ID
table(s). This also increases a lot readability — instead of searaching in the
monolithic list, the ID tables are ordered and one per line. Much easier to
find if user's device is supported or not.
> *
> - * Copyright 2018 Analog Devices Inc.
> + * Copyright 2018-2026 Analog Devices Inc.
> */
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 17/22] iio: dac: ad5686: update device list description
2026-04-22 20:06 ` Andy Shevchenko
@ 2026-04-22 20:07 ` Andy Shevchenko
0 siblings, 0 replies; 30+ messages in thread
From: Andy Shevchenko @ 2026-04-22 20:07 UTC (permalink / raw)
To: rodrigo.alencar
Cc: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening, Lars-Peter Clausen,
Michael Hennerich, David Lechner, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Kees Cook, Gustavo A. R. Silva,
Philipp Zabel
On Wed, Apr 22, 2026 at 11:06:47PM +0300, Andy Shevchenko wrote:
> On Wed, Apr 22, 2026 at 03:45:51PM +0100, Rodrigo Alencar via B4 Relay wrote:
...
> Looking at the core description it let me think that that has to be in i2c and
> spi cases as well. One may deduct the list of supported devices from the ID
> table(s). This also increases a lot readability — instead of searaching in the
> monolithic list, the ID tables are ordered and one per line. Much easier to
> find if user's device is supported or not.
Also make sure the MODULE_DESCRIPTION() text is aligned with this.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 12/22] iio: dac: ad5686: fix powerdown control
2026-04-22 14:45 ` [PATCH 12/22] iio: dac: ad5686: fix powerdown control Rodrigo Alencar via B4 Relay
@ 2026-04-22 20:25 ` Andy Shevchenko
0 siblings, 0 replies; 30+ messages in thread
From: Andy Shevchenko @ 2026-04-22 20:25 UTC (permalink / raw)
To: rodrigo.alencar
Cc: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening, Lars-Peter Clausen,
Michael Hennerich, David Lechner, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Kees Cook, Gustavo A. R. Silva,
Philipp Zabel
On Wed, Apr 22, 2026 at 03:45:46PM +0100, Rodrigo Alencar via B4 Relay wrote:
> This patch fixes powerdown control issues by protecting the cached
Please, read Submitting Patches documentation. It clearly says to use
imperative mood.
> 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.
When I see a word "fix" and no Fixes tag I got confused. Please, align commit
message and tags (either make it just refactor, or a real fix, or explain at
bare minimum in the comments block why there is "fix" w/o Fixes tag).
...
> {
> struct ad5686_state *st = iio_priv(indio_dev);
> + int val, shift = ad5686_pd_mask_shift(chan);
>
> - return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask &
> - (0x3 << (chan->channel * 2))));
> + mutex_lock(&st->lock);
> + val = !!(st->pwr_down_mask & (0x3 << shift));
> + mutex_unlock(&st->lock);
> +
> + return sysfs_emit(buf, "%d\n", val);
> }
Why not use guard()() from day 1?
...
> struct ad5686_state *st;
> - int ret, i;
> + int ret, i, shift;
Do 'i' and 'shift' need to be signed?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 00/22] Extend device support for AD5686 driver
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
` (21 preceding siblings ...)
2026-04-22 14:45 ` [PATCH 22/22] iio: dac: ad5686: add gain control support Rodrigo Alencar via B4 Relay
@ 2026-04-22 20:28 ` Andy Shevchenko
22 siblings, 0 replies; 30+ messages in thread
From: Andy Shevchenko @ 2026-04-22 20:28 UTC (permalink / raw)
To: rodrigo.alencar
Cc: Jonathan Cameron, linux-iio, devicetree, linux-kernel,
Michael Auchter, linux-hardening, Lars-Peter Clausen,
Michael Hennerich, David Lechner, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Kees Cook, Gustavo A. R. Silva,
Philipp Zabel
On Wed, Apr 22, 2026 at 03:45:34PM +0100, Rodrigo Alencar via B4 Relay wrote:
> This series adds support for multiple nanoDAC parts, adding triggered
> buffer and gain control support to the ad5686 DAC driver family, along
> with a number of driver cleanups and fixes.
>
> Initial patches update the device-tree bindings:
> - Add compatible entries for missing and new parts;
> - Add GPIO properties for RESET, GAIN and LDAC pins;
> - Add missing power supplies properties.
> Driver cleanups and fixes:
> - Refactor include headers (IWYU);
> - Switch to device managed mutex initialization;
> - Drop enum chip id in favor of per-device chip_info structs;
> - Fix voltage reference control on single-channel devices;
> - Fix powerdown control on dual-channel devices;
> - Introduce bus ops struct with a sync() operation for batching
> bus transfers.
>
> New functionality:
> - Device support for: AD5316R, AD5675, AD5697R, AD5313R, AD5317R,
> AD5674, AD5679, AD5687, AD5687R, AD5689 and AD5689R;
> - Consume optional reset and new power supplies;
> - LDAC GPIO handling (active-low, held low when unused);
> - SPI bus sync() implementation for batching multiple transfers;
> - Triggered buffer support, leveraging LDAC and sync() to flush
> all channel writes atomically;
> - Gain control support through the scale property.
This is rather long series. Please, start from the fixes series first that is
independent on the features.
I see here ~3 sequential series. Can we rather do them this way?
Personally I stopped reviewing on patch 12 (without even opening DT stuff)
because it's exhaustive. Documentation usually suggests the series to be
limited by ~15 patches IIRC.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2026-04-22 20:28 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 01/22] dt-bindings: iio: dac: ad5696: extend device support Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 02/22] dt-bindings: iio: dac: ad5696: add reset/ldac/gain gpio support Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 03/22] dt-bindings: iio: dac: ad5696: rework on power supplies Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 04/22] dt-bindings: iio: dac: ad5686: extend device support Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 05/22] dt-bindings: iio: dac: ad5686: add reset/ldac/gain gpio support Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 06/22] dt-bindings: iio: dac: ad5686: rework on power supplies Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 07/22] iio: dac: ad5686: refactor include headers Rodrigo Alencar via B4 Relay
2026-04-22 19:43 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 08/22] iio: dac: ad5686: remove redundant register definition Rodrigo Alencar via B4 Relay
2026-04-22 19:47 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 09/22] iio: dac: ad5686: drop enum id Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 10/22] iio: dac: ad5686: add of_match table to the spi driver Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 11/22] iio: dac: ad5686: fix ref bit initialization for single-channel parts Rodrigo Alencar via B4 Relay
2026-04-22 19:58 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 12/22] iio: dac: ad5686: fix powerdown control Rodrigo Alencar via B4 Relay
2026-04-22 20:25 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 13/22] iio: dac: ad5686: fix input raw value check Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 14/22] iio: dac: ad5686: add support for missing power supplies Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 15/22] iio: dac: ad5686: create bus ops struct Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 16/22] iio: dac: ad5686: extend device support with new parts Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 17/22] iio: dac: ad5686: update device list description Rodrigo Alencar via B4 Relay
2026-04-22 20:06 ` Andy Shevchenko
2026-04-22 20:07 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 18/22] iio: dac: ad5686: consume optional reset signal Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 19/22] iio: dac: ad5686: add ldac gpio Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 20/22] iio: dac: ad5686: implement new sync() op for the spi bus Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 21/22] iio: dac: ad5686: add triggered buffer support Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 22/22] iio: dac: ad5686: add gain control support Rodrigo Alencar via B4 Relay
2026-04-22 20:28 ` [PATCH 00/22] Extend device support for AD5686 driver Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox