* [PATCH v7 1/7] spi: dt-bindings: Add spi-device-addr peripheral property
2026-07-22 7:54 [PATCH v7 0/7] iio: dac: Add support for AD5529R DAC Janani Sunil
@ 2026-07-22 7:54 ` Janani Sunil
2026-07-22 16:39 ` Conor Dooley
2026-07-22 7:54 ` [PATCH v7 2/7] dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr Janani Sunil
` (5 subsequent siblings)
6 siblings, 1 reply; 24+ messages in thread
From: Janani Sunil @ 2026-07-22 7:54 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Janani Sunil,
linux-spi, Kent Gustavsson, Janani Sunil
Some SPI devices support sharing a single chip select across multiple
physical chips by encoding a device address in the SPI frame itself.
Add the generic spi-device-addr property for describing these hardware
addresses. The property is placed on the SPI peripheral node and may
contain multiple addresses.
Signed-off-by: Janani Sunil <janani.sunil@analog.com>
---
Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml
index 880a9f624566..b59d047cf117 100644
--- a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml
+++ b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml
@@ -142,6 +142,13 @@ properties:
minItems: 2
maxItems: 4
+ spi-device-addr:
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ description:
+ Device addresses used when multiple peripherals share a single chip
+ select. The array allows one logical peripheral to comprise multiple
+ physical devices, with one address per device.
+
st,spi-midi-ns:
deprecated: true
description: |
--
2.43.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* Re: [PATCH v7 1/7] spi: dt-bindings: Add spi-device-addr peripheral property
2026-07-22 7:54 ` [PATCH v7 1/7] spi: dt-bindings: Add spi-device-addr peripheral property Janani Sunil
@ 2026-07-22 16:39 ` Conor Dooley
0 siblings, 0 replies; 24+ messages in thread
From: Conor Dooley @ 2026-07-22 16:39 UTC (permalink / raw)
To: Janani Sunil
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson, linux-iio, devicetree, linux-kernel, linux-doc,
Janani Sunil, linux-spi, Kent Gustavsson
[-- Attachment #1: Type: text/plain, Size: 1491 bytes --]
On Wed, Jul 22, 2026 at 09:54:13AM +0200, Janani Sunil wrote:
> Some SPI devices support sharing a single chip select across multiple
> physical chips by encoding a device address in the SPI frame itself.
> Add the generic spi-device-addr property for describing these hardware
> addresses. The property is placed on the SPI peripheral node and may
> contain multiple addresses.
>
> Signed-off-by: Janani Sunil <janani.sunil@analog.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
> ---
> Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml
> index 880a9f624566..b59d047cf117 100644
> --- a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml
> +++ b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml
> @@ -142,6 +142,13 @@ properties:
> minItems: 2
> maxItems: 4
>
> + spi-device-addr:
> + $ref: /schemas/types.yaml#/definitions/uint32-array
> + description:
> + Device addresses used when multiple peripherals share a single chip
> + select. The array allows one logical peripheral to comprise multiple
> + physical devices, with one address per device.
> +
> st,spi-midi-ns:
> deprecated: true
> description: |
>
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v7 2/7] dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr
2026-07-22 7:54 [PATCH v7 0/7] iio: dac: Add support for AD5529R DAC Janani Sunil
2026-07-22 7:54 ` [PATCH v7 1/7] spi: dt-bindings: Add spi-device-addr peripheral property Janani Sunil
@ 2026-07-22 7:54 ` Janani Sunil
2026-07-22 8:05 ` sashiko-bot
2026-07-22 16:40 ` Conor Dooley
2026-07-22 7:54 ` [PATCH v7 3/7] iio: adc: mcp3564: Add support for spi-device-addr Janani Sunil
` (4 subsequent siblings)
6 siblings, 2 replies; 24+ messages in thread
From: Janani Sunil @ 2026-07-22 7:54 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Janani Sunil,
linux-spi, Kent Gustavsson, Janani Sunil
Add the generic spi-device-addr property to the binding and deprecate
the existing vendor specific microchip,hw-device-address property.
Signed-off-by: Janani Sunil <janani.sunil@analog.com>
---
.../devicetree/bindings/iio/adc/microchip,mcp3564.yaml | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml
index 675319276197..de1ea289e7f5 100644
--- a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml
@@ -80,6 +80,7 @@ properties:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 0
maximum: 3
+ deprecated: true
description:
The address is set on a per-device basis by fuses in the factory,
configured on request. If not requested, the fuses are set for 0x1.
@@ -91,6 +92,12 @@ properties:
clocking of the device address (BITS[7:6] - top two bits of COMMAND BYTE
which is first one on the wire).
+ spi-device-addr:
+ maxItems: 1
+ items:
+ enum: [0, 1, 2, 3]
+ default: [1]
+
"#io-channel-cells":
const: 1
@@ -123,7 +130,6 @@ dependencies:
required:
- compatible
- reg
- - microchip,hw-device-address
- spi-max-frequency
allOf:
@@ -159,7 +165,7 @@ examples:
spi-cpha;
spi-cpol;
spi-max-frequency = <10000000>;
- microchip,hw-device-address = <1>;
+ spi-device-addr = <1>;
#address-cells = <1>;
#size-cells = <0>;
--
2.43.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* Re: [PATCH v7 2/7] dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr
2026-07-22 7:54 ` [PATCH v7 2/7] dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr Janani Sunil
@ 2026-07-22 8:05 ` sashiko-bot
2026-07-22 16:40 ` Conor Dooley
1 sibling, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-07-22 8:05 UTC (permalink / raw)
To: Janani Sunil; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The dt-binding introduces `spi-device-addr` to replace the deprecated `microchip,hw-device-address` and removes it from the required list, but the driver has not been updated to parse the new generic property.
--
--- Patch [2]: [PATCH v7 2/7] dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr ---
commit a3bb549053e31953c445885e8d6cb1988514c7b0
Author: Janani Sunil <janani.sunil@analog.com>
dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr
This commit introduces the generic spi-device-addr property to the mcp3564
binding. It also marks the existing vendor-specific
microchip,hw-device-address property as deprecated and removes it from the
required list.
> diff --git a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml
> index 6753192761971..de1ea289e7f52 100644
> --- a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml
[ ... ]
> @@ -91,6 +92,12 @@ properties:
> clocking of the device address (BITS[7:6] - top two bits of COMMAND BYTE
> which is first one on the wire).
>
> + spi-device-addr:
> + maxItems: 1
> + items:
> + enum: [0, 1, 2, 3]
> + default: [1]
> +
> "#io-channel-cells":
> const: 1
[ ... ]
> @@ -123,7 +130,6 @@ dependencies:
> required:
> - compatible
> - reg
> - - microchip,hw-device-address
> - spi-max-frequency
>
> allOf:
[Severity: High]
Since the old microchip,hw-device-address property is removed from the
required list here and replaced by spi-device-addr, does the mcp3564 driver
need an accompanying update to parse the new generic property?
Currently, if a device tree author updates their configuration to use the new
spi-device-addr property following this binding, mcp3564_config() still
explicitly checks only for the deprecated property and will silently fall
back to 0x1:
drivers/iio/adc/mcp3564.c:mcp3564_config() {
unsigned int tmp = 0x01;
...
device_property_read_u32(dev, "microchip,hw-device-address", &tmp);
...
}
Could this cause hardware state machine initialization and SPI communication
to fail for any device physically strapped to addresses 0, 2, or 3 if they
drop the old property?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-ad5529r-driver-v7-0-7781cd74ad75@analog.com?part=2
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [PATCH v7 2/7] dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr
2026-07-22 7:54 ` [PATCH v7 2/7] dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr Janani Sunil
2026-07-22 8:05 ` sashiko-bot
@ 2026-07-22 16:40 ` Conor Dooley
1 sibling, 0 replies; 24+ messages in thread
From: Conor Dooley @ 2026-07-22 16:40 UTC (permalink / raw)
To: Janani Sunil
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson, linux-iio, devicetree, linux-kernel, linux-doc,
Janani Sunil, linux-spi, Kent Gustavsson
[-- Attachment #1: Type: text/plain, Size: 1974 bytes --]
On Wed, Jul 22, 2026 at 09:54:14AM +0200, Janani Sunil wrote:
> Add the generic spi-device-addr property to the binding and deprecate
> the existing vendor specific microchip,hw-device-address property.
>
> Signed-off-by: Janani Sunil <janani.sunil@analog.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
> ---
> .../devicetree/bindings/iio/adc/microchip,mcp3564.yaml | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml
> index 675319276197..de1ea289e7f5 100644
> --- a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3564.yaml
> @@ -80,6 +80,7 @@ properties:
> $ref: /schemas/types.yaml#/definitions/uint32
> minimum: 0
> maximum: 3
> + deprecated: true
> description:
> The address is set on a per-device basis by fuses in the factory,
> configured on request. If not requested, the fuses are set for 0x1.
> @@ -91,6 +92,12 @@ properties:
> clocking of the device address (BITS[7:6] - top two bits of COMMAND BYTE
> which is first one on the wire).
>
> + spi-device-addr:
> + maxItems: 1
> + items:
> + enum: [0, 1, 2, 3]
> + default: [1]
> +
> "#io-channel-cells":
> const: 1
>
> @@ -123,7 +130,6 @@ dependencies:
> required:
> - compatible
> - reg
> - - microchip,hw-device-address
> - spi-max-frequency
>
> allOf:
> @@ -159,7 +165,7 @@ examples:
> spi-cpha;
> spi-cpol;
> spi-max-frequency = <10000000>;
> - microchip,hw-device-address = <1>;
> + spi-device-addr = <1>;
>
> #address-cells = <1>;
> #size-cells = <0>;
>
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v7 3/7] iio: adc: mcp3564: Add support for spi-device-addr
2026-07-22 7:54 [PATCH v7 0/7] iio: dac: Add support for AD5529R DAC Janani Sunil
2026-07-22 7:54 ` [PATCH v7 1/7] spi: dt-bindings: Add spi-device-addr peripheral property Janani Sunil
2026-07-22 7:54 ` [PATCH v7 2/7] dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr Janani Sunil
@ 2026-07-22 7:54 ` Janani Sunil
2026-07-22 16:45 ` Conor Dooley
2026-07-22 17:06 ` Marius.Cristea
2026-07-22 7:54 ` [PATCH v7 4/7] dt-bindings: iio: adc: microchip,mcp3911: Add spi-device-addr Janani Sunil
` (3 subsequent siblings)
6 siblings, 2 replies; 24+ messages in thread
From: Janani Sunil @ 2026-07-22 7:54 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Janani Sunil,
linux-spi, Kent Gustavsson, Janani Sunil
Read the generic spi-device-addr property when determining the hardware
device address. Fall back to the deprecated microchip,hw-device-address
property to preserve compatibility with existing device trees.
The device address remains 1 when neither property is present.
Signed-off-by: Janani Sunil <janani.sunil@analog.com>
---
drivers/iio/adc/mcp3564.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
index 36675563829e..71deb05e878e 100644
--- a/drivers/iio/adc/mcp3564.c
+++ b/drivers/iio/adc/mcp3564.c
@@ -1122,7 +1122,9 @@ static int mcp3564_config(struct iio_dev *indio_dev, bool *use_internal_vref_att
* addresses are available when multiple devices are present on the same
* SPI bus with only one Chip Select line for all devices.
*/
- device_property_read_u32(dev, "microchip,hw-device-address", &tmp);
+ ret = device_property_read_u32(dev, "spi-device-addr", &tmp);
+ if (ret)
+ device_property_read_u32(dev, "microchip,hw-device-address", &tmp);
if (tmp > 3) {
dev_err_probe(dev, tmp,
--
2.43.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* Re: [PATCH v7 3/7] iio: adc: mcp3564: Add support for spi-device-addr
2026-07-22 7:54 ` [PATCH v7 3/7] iio: adc: mcp3564: Add support for spi-device-addr Janani Sunil
@ 2026-07-22 16:45 ` Conor Dooley
2026-07-22 17:02 ` Marius.Cristea
2026-07-22 17:06 ` Marius.Cristea
1 sibling, 1 reply; 24+ messages in thread
From: Conor Dooley @ 2026-07-22 16:45 UTC (permalink / raw)
To: Janani Sunil
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson, linux-iio, devicetree, linux-kernel, linux-doc,
Janani Sunil, linux-spi, Kent Gustavsson
[-- Attachment #1: Type: text/plain, Size: 1404 bytes --]
On Wed, Jul 22, 2026 at 09:54:15AM +0200, Janani Sunil wrote:
> Read the generic spi-device-addr property when determining the hardware
> device address. Fall back to the deprecated microchip,hw-device-address
> property to preserve compatibility with existing device trees.
>
> The device address remains 1 when neither property is present.
>
> Signed-off-by: Janani Sunil <janani.sunil@analog.com>
> ---
> drivers/iio/adc/mcp3564.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
> index 36675563829e..71deb05e878e 100644
> --- a/drivers/iio/adc/mcp3564.c
> +++ b/drivers/iio/adc/mcp3564.c
> @@ -1122,7 +1122,9 @@ static int mcp3564_config(struct iio_dev *indio_dev, bool *use_internal_vref_att
> * addresses are available when multiple devices are present on the same
> * SPI bus with only one Chip Select line for all devices.
> */
> - device_property_read_u32(dev, "microchip,hw-device-address", &tmp);
> + ret = device_property_read_u32(dev, "spi-device-addr", &tmp);
> + if (ret)
> + device_property_read_u32(dev, "microchip,hw-device-address", &tmp);
Same on this one, shouldn't it check the return value so that the below
check of temp > 3 doesn't just pass with the default value of tmp?
>
> if (tmp > 3) {
> dev_err_probe(dev, tmp,
>
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [PATCH v7 3/7] iio: adc: mcp3564: Add support for spi-device-addr
2026-07-22 16:45 ` Conor Dooley
@ 2026-07-22 17:02 ` Marius.Cristea
2026-07-22 17:12 ` Conor Dooley
0 siblings, 1 reply; 24+ messages in thread
From: Marius.Cristea @ 2026-07-22 17:02 UTC (permalink / raw)
To: conor, janani.sunil
Cc: corbet, linux-doc, robh, andy, nedo80, kent, Michael.Hennerich,
jan.sun97, lars, conor+dt, linux-spi, linux-kernel, devicetree,
skhan, dlechner, nuno.sa, p.zabel, jic23, marcus.folkesson,
krzk+dt, linux-iio, broonie
On Wed, 2026-07-22 at 17:45 +0100, Conor Dooley wrote:
> On Wed, Jul 22, 2026 at 09:54:15AM +0200, Janani Sunil wrote:
> > Read the generic spi-device-addr property when determining the
> > hardware
> > device address. Fall back to the deprecated microchip,hw-device-
> > address
> > property to preserve compatibility with existing device trees.
> >
> > The device address remains 1 when neither property is present.
> >
> > Signed-off-by: Janani Sunil <janani.sunil@analog.com>
> > ---
> > drivers/iio/adc/mcp3564.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
> > index 36675563829e..71deb05e878e 100644
> > --- a/drivers/iio/adc/mcp3564.c
> > +++ b/drivers/iio/adc/mcp3564.c
> > @@ -1122,7 +1122,9 @@ static int mcp3564_config(struct iio_dev
> > *indio_dev, bool *use_internal_vref_att
> > * addresses are available when multiple devices are
> > present on the same
> > * SPI bus with only one Chip Select line for all devices.
> > */
> > - device_property_read_u32(dev, "microchip,hw-device-
> > address", &tmp);
> > + ret = device_property_read_u32(dev, "spi-device-addr",
> > &tmp);
> > + if (ret)
> > + device_property_read_u32(dev, "microchip,hw-
> > device-address", &tmp);
>
> Same on this one, shouldn't it check the return value so that the
> below
> check of temp > 3 doesn't just pass with the default value of tmp?
>
Default hardware address is 0x01, unless a special order with custom
hardware address is made. I think is safe to try to communicate with
the default HW address.
> >
> > if (tmp > 3) {
> > dev_err_probe(dev, tmp,
> >
> > --
> > 2.43.0
> >
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [PATCH v7 3/7] iio: adc: mcp3564: Add support for spi-device-addr
2026-07-22 17:02 ` Marius.Cristea
@ 2026-07-22 17:12 ` Conor Dooley
0 siblings, 0 replies; 24+ messages in thread
From: Conor Dooley @ 2026-07-22 17:12 UTC (permalink / raw)
To: Marius.Cristea
Cc: janani.sunil, corbet, linux-doc, robh, andy, nedo80, kent,
Michael.Hennerich, jan.sun97, lars, conor+dt, linux-spi,
linux-kernel, devicetree, skhan, dlechner, nuno.sa, p.zabel,
jic23, marcus.folkesson, krzk+dt, linux-iio, broonie
[-- Attachment #1: Type: text/plain, Size: 1886 bytes --]
On Wed, Jul 22, 2026 at 05:02:28PM +0000, Marius.Cristea@microchip.com wrote:
> On Wed, 2026-07-22 at 17:45 +0100, Conor Dooley wrote:
> > On Wed, Jul 22, 2026 at 09:54:15AM +0200, Janani Sunil wrote:
> > > Read the generic spi-device-addr property when determining the
> > > hardware
> > > device address. Fall back to the deprecated microchip,hw-device-
> > > address
> > > property to preserve compatibility with existing device trees.
> > >
> > > The device address remains 1 when neither property is present.
> > >
> > > Signed-off-by: Janani Sunil <janani.sunil@analog.com>
> > > ---
> > > drivers/iio/adc/mcp3564.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
> > > index 36675563829e..71deb05e878e 100644
> > > --- a/drivers/iio/adc/mcp3564.c
> > > +++ b/drivers/iio/adc/mcp3564.c
> > > @@ -1122,7 +1122,9 @@ static int mcp3564_config(struct iio_dev
> > > *indio_dev, bool *use_internal_vref_att
> > > * addresses are available when multiple devices are
> > > present on the same
> > > * SPI bus with only one Chip Select line for all devices.
> > > */
> > > - device_property_read_u32(dev, "microchip,hw-device-
> > > address", &tmp);
> > > + ret = device_property_read_u32(dev, "spi-device-addr",
> > > &tmp);
> > > + if (ret)
> > > + device_property_read_u32(dev, "microchip,hw-
> > > device-address", &tmp);
> >
> > Same on this one, shouldn't it check the return value so that the
> > below
> > check of temp > 3 doesn't just pass with the default value of tmp?
> >
>
> Default hardware address is 0x01, unless a special order with custom
> hardware address is made. I think is safe to try to communicate with
> the default HW address.
Ah, sounds good so.
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v7 3/7] iio: adc: mcp3564: Add support for spi-device-addr
2026-07-22 7:54 ` [PATCH v7 3/7] iio: adc: mcp3564: Add support for spi-device-addr Janani Sunil
2026-07-22 16:45 ` Conor Dooley
@ 2026-07-22 17:06 ` Marius.Cristea
1 sibling, 0 replies; 24+ messages in thread
From: Marius.Cristea @ 2026-07-22 17:06 UTC (permalink / raw)
To: corbet, robh, andy, kent, Michael.Hennerich, lars, conor+dt,
skhan, dlechner, nuno.sa, janani.sunil, krzk+dt, p.zabel, jic23,
marcus.folkesson, broonie
Cc: linux-spi, nedo80, devicetree, linux-kernel, linux-iio, linux-doc,
jan.sun97
On Wed, 2026-07-22 at 09:54 +0200, Janani Sunil wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> Read the generic spi-device-addr property when determining the
> hardware
> device address. Fall back to the deprecated microchip,hw-device-
> address
> property to preserve compatibility with existing device trees.
>
> The device address remains 1 when neither property is present.
>
> Signed-off-by: Janani Sunil <janani.sunil@analog.com>
> ---
> drivers/iio/adc/mcp3564.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
> index 36675563829e..71deb05e878e 100644
> --- a/drivers/iio/adc/mcp3564.c
> +++ b/drivers/iio/adc/mcp3564.c
> @@ -1122,7 +1122,9 @@ static int mcp3564_config(struct iio_dev
> *indio_dev, bool *use_internal_vref_att
> * addresses are available when multiple devices are present
> on the same
> * SPI bus with only one Chip Select line for all devices.
> */
> - device_property_read_u32(dev, "microchip,hw-device-address",
> &tmp);
> + ret = device_property_read_u32(dev, "spi-device-addr", &tmp);
> + if (ret)
> + device_property_read_u32(dev, "microchip,hw-device-
> address", &tmp);
>
> if (tmp > 3) {
> dev_err_probe(dev, tmp,
>
> --
> 2.43.0
Reviewed-by: Marius Cristea <marius.cristea@microchip.com>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v7 4/7] dt-bindings: iio: adc: microchip,mcp3911: Add spi-device-addr
2026-07-22 7:54 [PATCH v7 0/7] iio: dac: Add support for AD5529R DAC Janani Sunil
` (2 preceding siblings ...)
2026-07-22 7:54 ` [PATCH v7 3/7] iio: adc: mcp3564: Add support for spi-device-addr Janani Sunil
@ 2026-07-22 7:54 ` Janani Sunil
2026-07-22 8:05 ` sashiko-bot
2026-07-22 16:41 ` Conor Dooley
2026-07-22 7:54 ` [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr Janani Sunil
` (2 subsequent siblings)
6 siblings, 2 replies; 24+ messages in thread
From: Janani Sunil @ 2026-07-22 7:54 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Janani Sunil,
linux-spi, Kent Gustavsson, Janani Sunil
Add the generic spi-device-addr property to the binding and deprecate
the existing vendor specific microchip,device-addr property
Signed-off-by: Janani Sunil <janani.sunil@analog.com>
---
Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml
index 3a69ec60edb9..36da2bee1db2 100644
--- a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml
@@ -57,6 +57,13 @@ properties:
$ref: /schemas/types.yaml#/definitions/uint32
enum: [0, 1, 2, 3]
default: 0
+ deprecated: true
+
+ spi-device-addr:
+ maxItems: 1
+ items:
+ enum: [0, 1, 2, 3]
+ default: [0]
vref-supply:
description: |
@@ -86,7 +93,7 @@ examples:
interrupts = <15 2>;
reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
spi-max-frequency = <20000000>;
- microchip,device-addr = <0>;
+ spi-device-addr = <0>;
vref-supply = <&vref_reg>;
clocks = <&xtal>;
};
--
2.43.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* Re: [PATCH v7 4/7] dt-bindings: iio: adc: microchip,mcp3911: Add spi-device-addr
2026-07-22 7:54 ` [PATCH v7 4/7] dt-bindings: iio: adc: microchip,mcp3911: Add spi-device-addr Janani Sunil
@ 2026-07-22 8:05 ` sashiko-bot
2026-07-22 16:41 ` Conor Dooley
1 sibling, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-07-22 8:05 UTC (permalink / raw)
To: Janani Sunil; +Cc: robh, devicetree, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The dt-bindings update deprecates `microchip,device-addr` in favor of the new generic `spi-device-addr` property, but the `mcp3911` driver was not updated to parse it. If a device tree uses the newly recommended `spi-device-addr` property, the driver will fail to parse it, fall back to device address 0, and fail to communicate with hardware configured for other addresses.
--
--- Patch [4]: [PATCH v7 4/7] dt-bindings: iio: adc: microchip,mcp3911: Add spi-device-addr ---
commit 9e6e246369fd97fd7587432780e30a16297f1eb0
Author: Janani Sunil <janani.sunil@analog.com>
dt-bindings: iio: adc: microchip,mcp3911: Add spi-device-addr
This commit adds the generic spi-device-addr property to the binding.
It also deprecates the existing vendor-specific microchip,device-addr
property.
> diff --git a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml
> index 3a69ec60edb91..36da2bee1db28 100644
> --- a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml
> @@ -57,6 +57,13 @@ properties:
> $ref: /schemas/types.yaml#/definitions/uint32
> enum: [0, 1, 2, 3]
> default: 0
> + deprecated: true
> +
> + spi-device-addr:
> + maxItems: 1
> + items:
> + enum: [0, 1, 2, 3]
> + default: [0]
[Severity: High]
Is the driver updated to parse this new property?
Looking at mcp3911_probe() in drivers/iio/adc/mcp3911.c, the driver only
handles the deprecated properties:
ret = device_property_read_u32(dev, "microchip,device-addr", &adc->dev_addr);
if (ret)
device_property_read_u32(dev, "device-addr", &adc->dev_addr);
If a modernized device tree uses the newly recommended spi-device-addr
property instead of microchip,device-addr, will the driver fail to parse it
and leave adc->dev_addr at 0?
Could this cause communication failures with hardware configured for non-zero
addresses?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-ad5529r-driver-v7-0-7781cd74ad75@analog.com?part=4
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v7 4/7] dt-bindings: iio: adc: microchip,mcp3911: Add spi-device-addr
2026-07-22 7:54 ` [PATCH v7 4/7] dt-bindings: iio: adc: microchip,mcp3911: Add spi-device-addr Janani Sunil
2026-07-22 8:05 ` sashiko-bot
@ 2026-07-22 16:41 ` Conor Dooley
1 sibling, 0 replies; 24+ messages in thread
From: Conor Dooley @ 2026-07-22 16:41 UTC (permalink / raw)
To: Janani Sunil
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson, linux-iio, devicetree, linux-kernel, linux-doc,
Janani Sunil, linux-spi, Kent Gustavsson
[-- Attachment #1: Type: text/plain, Size: 1593 bytes --]
On Wed, Jul 22, 2026 at 09:54:16AM +0200, Janani Sunil wrote:
> Add the generic spi-device-addr property to the binding and deprecate
> the existing vendor specific microchip,device-addr property
>
> Signed-off-by: Janani Sunil <janani.sunil@analog.com>
> ---
> Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml
> index 3a69ec60edb9..36da2bee1db2 100644
> --- a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml
> @@ -57,6 +57,13 @@ properties:
> $ref: /schemas/types.yaml#/definitions/uint32
> enum: [0, 1, 2, 3]
> default: 0
> + deprecated: true
> +
> + spi-device-addr:
> + maxItems: 1
> + items:
> + enum: [0, 1, 2, 3]
> + default: [0]
On all patches with a default, the [] are not needed around it.
Only change that if you respin.
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
>
> vref-supply:
> description: |
> @@ -86,7 +93,7 @@ examples:
> interrupts = <15 2>;
> reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
> spi-max-frequency = <20000000>;
> - microchip,device-addr = <0>;
> + spi-device-addr = <0>;
> vref-supply = <&vref_reg>;
> clocks = <&xtal>;
> };
>
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr
2026-07-22 7:54 [PATCH v7 0/7] iio: dac: Add support for AD5529R DAC Janani Sunil
` (3 preceding siblings ...)
2026-07-22 7:54 ` [PATCH v7 4/7] dt-bindings: iio: adc: microchip,mcp3911: Add spi-device-addr Janani Sunil
@ 2026-07-22 7:54 ` Janani Sunil
2026-07-22 16:41 ` Conor Dooley
2026-07-22 17:19 ` Marius.Cristea
2026-07-22 7:54 ` [PATCH v7 6/7] dt-bindings: iio: dac: Add AD5529R Janani Sunil
2026-07-22 7:54 ` [PATCH v7 7/7] iio: dac: Add AD5529R DAC driver support Janani Sunil
6 siblings, 2 replies; 24+ messages in thread
From: Janani Sunil @ 2026-07-22 7:54 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Janani Sunil,
linux-spi, Kent Gustavsson, Janani Sunil
Read the generic spi-device-addr property when determining the hardware
device address. Fall back to the deprecated microchip,device-addr
property and then to the historical device-addr property to preserve
compatibility with existing devicetrees.
The device address remains 0 when none of the properties are present.
Signed-off-by: Janani Sunil <janani.sunil@analog.com>
---
drivers/iio/adc/mcp3911.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
index ddc3721f3f68..3919a326b4db 100644
--- a/drivers/iio/adc/mcp3911.c
+++ b/drivers/iio/adc/mcp3911.c
@@ -740,10 +740,13 @@ static int mcp3911_probe(struct spi_device *spi)
}
/*
- * Fallback to "device-addr" due to historical mismatch between
- * dt-bindings and implementation.
+ * Fall back to the vendor-specific property, then to "device-addr"
+ * due to a historical mismatch between the binding and implementation.
*/
- ret = device_property_read_u32(dev, "microchip,device-addr", &adc->dev_addr);
+ ret = device_property_read_u32(dev, "spi-device-addr", &adc->dev_addr);
+ if (ret)
+ ret = device_property_read_u32(dev, "microchip,device-addr",
+ &adc->dev_addr);
if (ret)
device_property_read_u32(dev, "device-addr", &adc->dev_addr);
if (adc->dev_addr > 3) {
--
2.43.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* Re: [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr
2026-07-22 7:54 ` [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr Janani Sunil
@ 2026-07-22 16:41 ` Conor Dooley
2026-07-22 16:43 ` Conor Dooley
2026-07-22 17:19 ` Marius.Cristea
1 sibling, 1 reply; 24+ messages in thread
From: Conor Dooley @ 2026-07-22 16:41 UTC (permalink / raw)
To: Janani Sunil
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson, linux-iio, devicetree, linux-kernel, linux-doc,
Janani Sunil, linux-spi, Kent Gustavsson
[-- Attachment #1: Type: text/plain, Size: 1613 bytes --]
On Wed, Jul 22, 2026 at 09:54:17AM +0200, Janani Sunil wrote:
> Read the generic spi-device-addr property when determining the hardware
> device address. Fall back to the deprecated microchip,device-addr
> property and then to the historical device-addr property to preserve
> compatibility with existing devicetrees.
>
> The device address remains 0 when none of the properties are present.
>
> Signed-off-by: Janani Sunil <janani.sunil@analog.com>
> ---
> drivers/iio/adc/mcp3911.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
> index ddc3721f3f68..3919a326b4db 100644
> --- a/drivers/iio/adc/mcp3911.c
> +++ b/drivers/iio/adc/mcp3911.c
> @@ -740,10 +740,13 @@ static int mcp3911_probe(struct spi_device *spi)
> }
>
> /*
> - * Fallback to "device-addr" due to historical mismatch between
> - * dt-bindings and implementation.
> + * Fall back to the vendor-specific property, then to "device-addr"
> + * due to a historical mismatch between the binding and implementation.
Jaysus, bit of a mess here.
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> */
> - ret = device_property_read_u32(dev, "microchip,device-addr", &adc->dev_addr);
> + ret = device_property_read_u32(dev, "spi-device-addr", &adc->dev_addr);
> + if (ret)
> + ret = device_property_read_u32(dev, "microchip,device-addr",
> + &adc->dev_addr);
> if (ret)
> device_property_read_u32(dev, "device-addr", &adc->dev_addr);
> if (adc->dev_addr > 3) {
>
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr
2026-07-22 16:41 ` Conor Dooley
@ 2026-07-22 16:43 ` Conor Dooley
2026-07-22 17:18 ` Marius.Cristea
0 siblings, 1 reply; 24+ messages in thread
From: Conor Dooley @ 2026-07-22 16:43 UTC (permalink / raw)
To: Janani Sunil
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson, linux-iio, devicetree, linux-kernel, linux-doc,
Janani Sunil, linux-spi, Kent Gustavsson
[-- Attachment #1: Type: text/plain, Size: 1822 bytes --]
On Wed, Jul 22, 2026 at 05:41:54PM +0100, Conor Dooley wrote:
> On Wed, Jul 22, 2026 at 09:54:17AM +0200, Janani Sunil wrote:
> > Read the generic spi-device-addr property when determining the hardware
> > device address. Fall back to the deprecated microchip,device-addr
> > property and then to the historical device-addr property to preserve
> > compatibility with existing devicetrees.
> >
> > The device address remains 0 when none of the properties are present.
> >
> > Signed-off-by: Janani Sunil <janani.sunil@analog.com>
> > ---
> > drivers/iio/adc/mcp3911.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
> > index ddc3721f3f68..3919a326b4db 100644
> > --- a/drivers/iio/adc/mcp3911.c
> > +++ b/drivers/iio/adc/mcp3911.c
> > @@ -740,10 +740,13 @@ static int mcp3911_probe(struct spi_device *spi)
> > }
> >
> > /*
> > - * Fallback to "device-addr" due to historical mismatch between
> > - * dt-bindings and implementation.
> > + * Fall back to the vendor-specific property, then to "device-addr"
> > + * due to a historical mismatch between the binding and implementation.
>
> Jaysus, bit of a mess here.
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
>
> > */
> > - ret = device_property_read_u32(dev, "microchip,device-addr", &adc->dev_addr);
> > + ret = device_property_read_u32(dev, "spi-device-addr", &adc->dev_addr);
> > + if (ret)
> > + ret = device_property_read_u32(dev, "microchip,device-addr",
> > + &adc->dev_addr);
> > if (ret)
> > device_property_read_u32(dev, "device-addr", &adc->dev_addr);
Actually, this should check the return value, right?
> > if (adc->dev_addr > 3) {
> >
> > --
> > 2.43.0
> >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr
2026-07-22 16:43 ` Conor Dooley
@ 2026-07-22 17:18 ` Marius.Cristea
0 siblings, 0 replies; 24+ messages in thread
From: Marius.Cristea @ 2026-07-22 17:18 UTC (permalink / raw)
To: conor, janani.sunil
Cc: corbet, linux-doc, robh, andy, nedo80, kent, Michael.Hennerich,
jan.sun97, lars, conor+dt, linux-spi, linux-kernel, devicetree,
skhan, dlechner, nuno.sa, p.zabel, jic23, marcus.folkesson,
krzk+dt, linux-iio, broonie
On Wed, 2026-07-22 at 17:43 +0100, Conor Dooley wrote:
> On Wed, Jul 22, 2026 at 05:41:54PM +0100, Conor Dooley wrote:
> > On Wed, Jul 22, 2026 at 09:54:17AM +0200, Janani Sunil wrote:
> > > Read the generic spi-device-addr property when determining the
> > > hardware
> > > device address. Fall back to the deprecated microchip,device-addr
> > > property and then to the historical device-addr property to
> > > preserve
> > > compatibility with existing devicetrees.
> > >
> > > The device address remains 0 when none of the properties are
> > > present.
> > >
> > > Signed-off-by: Janani Sunil <janani.sunil@analog.com>
> > > ---
> > > drivers/iio/adc/mcp3911.c | 9 ++++++---
> > > 1 file changed, 6 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/iio/adc/mcp3911.c
> > > b/drivers/iio/adc/mcp3911.c
> > > index ddc3721f3f68..3919a326b4db 100644
> > > --- a/drivers/iio/adc/mcp3911.c
> > > +++ b/drivers/iio/adc/mcp3911.c
> > > @@ -740,10 +740,13 @@ static int mcp3911_probe(struct spi_device
> > > *spi)
> > > }
> > >
> > > /*
> > > - * Fallback to "device-addr" due to historical mismatch
> > > between
> > > - * dt-bindings and implementation.
> > > + * Fall back to the vendor-specific property, then to
> > > "device-addr"
> > > + * due to a historical mismatch between the binding and
> > > implementation.
> >
> > Jaysus, bit of a mess here.
> > Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> >
> > > */
> > > - ret = device_property_read_u32(dev, "microchip,device-
> > > addr", &adc->dev_addr);
> > > + ret = device_property_read_u32(dev, "spi-device-addr",
> > > &adc->dev_addr);
> > > + if (ret)
> > > + ret = device_property_read_u32(dev,
> > > "microchip,device-addr",
> > > + &adc->dev_addr);
> > > if (ret)
> > > device_property_read_u32(dev, "device-addr",
> > > &adc->dev_addr);
>
> Actually, this should check the return value, right?
Default hardware address is 0x00, unless a special order with custom
hardware address is made. I think is safe to try to communicate with
the default HW address, regardless of the return value.
>
> > > if (adc->dev_addr > 3) {
> > >
> > > --
> > > 2.43.0
> > >
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr
2026-07-22 7:54 ` [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr Janani Sunil
2026-07-22 16:41 ` Conor Dooley
@ 2026-07-22 17:19 ` Marius.Cristea
1 sibling, 0 replies; 24+ messages in thread
From: Marius.Cristea @ 2026-07-22 17:19 UTC (permalink / raw)
To: corbet, robh, andy, kent, Michael.Hennerich, lars, conor+dt,
skhan, dlechner, nuno.sa, janani.sunil, krzk+dt, p.zabel, jic23,
marcus.folkesson, broonie
Cc: linux-spi, nedo80, devicetree, linux-kernel, linux-iio, linux-doc,
jan.sun97
On Wed, 2026-07-22 at 09:54 +0200, Janani Sunil wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> Read the generic spi-device-addr property when determining the
> hardware
> device address. Fall back to the deprecated microchip,device-addr
> property and then to the historical device-addr property to preserve
> compatibility with existing devicetrees.
>
> The device address remains 0 when none of the properties are present.
>
> Signed-off-by: Janani Sunil <janani.sunil@analog.com>
> ---
> drivers/iio/adc/mcp3911.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c
> index ddc3721f3f68..3919a326b4db 100644
> --- a/drivers/iio/adc/mcp3911.c
> +++ b/drivers/iio/adc/mcp3911.c
> @@ -740,10 +740,13 @@ static int mcp3911_probe(struct spi_device
> *spi)
> }
>
> /*
> - * Fallback to "device-addr" due to historical mismatch
> between
> - * dt-bindings and implementation.
> + * Fall back to the vendor-specific property, then to
> "device-addr"
> + * due to a historical mismatch between the binding and
> implementation.
> */
> - ret = device_property_read_u32(dev, "microchip,device-addr",
> &adc->dev_addr);
> + ret = device_property_read_u32(dev, "spi-device-addr", &adc-
> >dev_addr);
> + if (ret)
> + ret = device_property_read_u32(dev,
> "microchip,device-addr",
> + &adc->dev_addr);
> if (ret)
> device_property_read_u32(dev, "device-addr", &adc-
> >dev_addr);
> if (adc->dev_addr > 3) {
>
> --
> 2.43.0
Reviewed-by: Marius Cristea <marius.cristea@microchip.com>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v7 6/7] dt-bindings: iio: dac: Add AD5529R
2026-07-22 7:54 [PATCH v7 0/7] iio: dac: Add support for AD5529R DAC Janani Sunil
` (4 preceding siblings ...)
2026-07-22 7:54 ` [PATCH v7 5/7] iio: adc: mcp3911: Add support for spi-device-addr Janani Sunil
@ 2026-07-22 7:54 ` Janani Sunil
2026-07-22 8:11 ` sashiko-bot
2026-07-22 16:39 ` Conor Dooley
2026-07-22 7:54 ` [PATCH v7 7/7] iio: dac: Add AD5529R DAC driver support Janani Sunil
6 siblings, 2 replies; 24+ messages in thread
From: Janani Sunil @ 2026-07-22 7:54 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Janani Sunil,
linux-spi, Kent Gustavsson, Janani Sunil
Devicetree bindings for AD5529R 16 channel 12/16 bit high voltage,
buffered voltage output digital-to-analog converter (DAC) with an
integrated precision reference.
Signed-off-by: Janani Sunil <janani.sunil@analog.com>
---
.../devicetree/bindings/iio/dac/adi,ad5529r.yaml | 224 +++++++++++++++++++++
MAINTAINERS | 7 +
2 files changed, 231 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5529r.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5529r.yaml
new file mode 100644
index 000000000000..730206fd6eab
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5529r.yaml
@@ -0,0 +1,224 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/dac/adi,ad5529r.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices AD5529R 16-Channel 12/16-bit High Voltage DAC
+
+maintainers:
+ - Janani Sunil <janani.sunil@analog.com>
+
+description: |
+ The AD5529R is a 16-channel, 12-bit or 16-bit, high voltage, buffered voltage
+ output digital-to-analog converter (DAC) with an integrated precision reference.
+ The device operates from unipolar and bipolar supplies. It is guaranteed
+ monotonic and has built-in rail-to-rail output buffers that can source or
+ sink up to 25mA.
+
+ Specifications:
+ * 16 independent 12-bit or 16-bit DAC channels
+ * Independently programmable output ranges: 0V to 5V, 0V to 10V, 0V to 20V,
+ 0V to 40V, ±5V, ±10V, ±15V, and ±20V
+ * The device supports SPI communication with Mode 0 and Mode 3.
+ * 4.096V precision reference, 12ppm/°C maximum
+ * Built-in function generation: Toggle, Sinusoidal Dither, and Ramp waveforms
+ * Multiplexer for output voltage, load current sense and die temperature
+
+ Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ad5529r.pdf
+
+properties:
+ compatible:
+ enum:
+ - adi,ad5529r-16 # 16-bit variant
+ - adi,ad5529r-12 # 12-bit variant
+
+ reg:
+ maxItems: 1
+
+ spi-max-frequency:
+ maximum: 25000000
+ description:
+ Maximum SPI frequency. The device supports SPI Mode 0 and Mode 3.
+ Read operations are limited to 25MHz maximum.
+
+ reset-gpios:
+ maxItems: 1
+ description:
+ GPIO connected to the RESET pin. Active low. When asserted low,
+ performs a power-on reset and initializes the device to its default state.
+
+ clear-gpios:
+ maxItems: 1
+ description:
+ GPIO connected to the CLEAR pin. Active low. When asserted low,
+ clears all DAC data registers without affecting configuration settings.
+
+ interrupts:
+ maxItems: 1
+ description:
+ Interrupt connected to the ALARM pin. Active low interrupt output
+ for overtemperature conditions, SPI CRC errors, and function completion.
+
+ pwms:
+ minItems: 1
+ maxItems: 4
+ description:
+ PWM signals connected to the TG0-TG3 toggle pins. Pulsing these pins
+ based on trigger edge settings allows selected DACs to be updated
+ synchronously for digital function generation.
+
+ pwm-names:
+ minItems: 1
+ maxItems: 4
+ items:
+ enum: [ tg0, tg1, tg2, tg3 ]
+
+ io-channels:
+ maxItems: 1
+ description:
+ ADC channel connected to the MUXOUT pin for monitoring output voltage,
+ load current sense, and die temperature.
+
+ io-channel-names:
+ const: muxout
+
+ vdd-supply:
+ description: Digital power supply (1.08V to 1.98V)
+
+ avdd-supply:
+ description: Analog power supply (4.75V to 5.25V)
+
+ hvdd-supply:
+ description:
+ High voltage positive supply (7V to 45V). Supply voltage should be chosen
+ based on configured output ranges (see datasheet Table 9).
+
+ hvss-supply:
+ description:
+ High voltage negative supply (-22.5V to 0V). Required only when using
+ bipolar output ranges (±5V, ±10V, ±15V, ±20V). Supply voltage should be
+ chosen based on configured output ranges (see datasheet Table 9).
+
+ vref-supply:
+ description:
+ External voltage reference supply (4.056V to 4.136V, typically 4.096V).
+ When specified, the device uses external reference mode and the VREF pin
+ becomes an input. The device uses the internal 4.096V precision reference
+ otherwise.
+
+ spi-device-addr:
+ minItems: 1
+ maxItems: 4
+ items:
+ enum: [0, 1, 2, 3]
+ default: [0]
+ description:
+ Hardware address of each device, selected by the ID0 and ID1 pins.
+ Up to four AD5529R devices can share a single SPI chip select.
+
+ "#address-cells":
+ const: 1
+
+ "#size-cells":
+ const: 0
+
+patternProperties:
+ "^channel@([0-9a-f]{1,2})$":
+ $ref: dac.yaml
+ type: object
+ description: Child nodes for individual channel configuration
+
+ properties:
+ reg:
+ description:
+ Flattened channel number across all AD5529R devices sharing the chip
+ select. Within each 16-channel block, the physical channel number is reg % 16.
+ minimum: 0
+ maximum: 63
+
+ output-range-microvolt:
+ description:
+ Output voltage range for this channel as [min, max] in
+ microvolts.
+ oneOf:
+ - items:
+ - const: 0
+ default: 0
+ - enum: [5000000, 10000000, 20000000, 40000000]
+ default: 5000000
+ - items:
+ - const: -5000000
+ - const: 5000000
+ - items:
+ - const: -10000000
+ - const: 10000000
+ - items:
+ - const: -15000000
+ - const: 15000000
+ - items:
+ - const: -20000000
+ - const: 20000000
+
+ required:
+ - reg
+
+ additionalProperties: false
+
+required:
+ - compatible
+ - reg
+ - vdd-supply
+ - avdd-supply
+ - hvdd-supply
+
+dependencies:
+ spi-cpha: [ spi-cpol ]
+ spi-cpol: [ spi-cpha ]
+
+allOf:
+ - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+
+ spi {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ dac@0 {
+ compatible = "adi,ad5529r-16";
+ reg = <0>;
+ spi-max-frequency = <25000000>;
+ spi-device-addr = <0>;
+
+ vdd-supply = <&vdd_regulator>;
+ avdd-supply = <&avdd_regulator>;
+ hvdd-supply = <&hvdd_regulator>;
+ hvss-supply = <&hvss_regulator>;
+
+ reset-gpios = <&gpio0 87 GPIO_ACTIVE_LOW>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ channel@0 {
+ reg = <0>;
+ output-range-microvolt = <0 5000000>;
+ };
+
+ channel@1 {
+ reg = <1>;
+ output-range-microvolt = <(-10000000) 10000000>;
+ };
+
+ channel@2 {
+ reg = <2>;
+ output-range-microvolt = <0 40000000>;
+ };
+ };
+ };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index d6c3c7d22403..320e84765ce6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1507,6 +1507,13 @@ W: https://ez.analog.com/linux-software-drivers
F: Documentation/devicetree/bindings/iio/adc/adi,ad4851.yaml
F: drivers/iio/adc/ad4851.c
+ANALOG DEVICES INC AD5529R DRIVER
+M: Janani Sunil <janani.sunil@analog.com>
+L: linux-iio@vger.kernel.org
+S: Supported
+W: https://ez.analog.com/linux-software-drivers
+F: Documentation/devicetree/bindings/iio/dac/adi,ad5529r.yaml
+
ANALOG DEVICES INC AD5706R DRIVER
M: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
L: linux-iio@vger.kernel.org
--
2.43.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* Re: [PATCH v7 6/7] dt-bindings: iio: dac: Add AD5529R
2026-07-22 7:54 ` [PATCH v7 6/7] dt-bindings: iio: dac: Add AD5529R Janani Sunil
@ 2026-07-22 8:11 ` sashiko-bot
2026-07-22 16:39 ` Conor Dooley
1 sibling, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-07-22 8:11 UTC (permalink / raw)
To: Janani Sunil; +Cc: robh, conor+dt, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The child node schema uses `additionalProperties: false` alongside a `$ref`, which incorrectly blocks valid properties from the referenced schema.
--
--- Patch [6]: [PATCH v7 6/7] dt-bindings: iio: dac: Add AD5529R ---
commit 7d0649d467110abde25b98986887b22fbe5ea358
Author: Janani Sunil <janani.sunil@analog.com>
Subject: dt-bindings: iio: dac: Add AD5529R
This commit introduces device tree bindings for the Analog Devices AD5529R, a
16-channel, 12-bit or 16-bit high voltage DAC. The bindings specify power
supplies, SPI interface parameters, GPIOs for reset and clear, and individual
channel configurations.
> diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5529r.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5529r.yaml
> new file mode 100644
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5529r.yaml
[ ... ]
> +patternProperties:
> + "^channel@([0-9a-f]{1,2})$":
> + $ref: dac.yaml
> + type: object
> + description: Child nodes for individual channel configuration
[ ... ]
> + required:
> + - reg
> +
> + additionalProperties: false
[Severity: Low]
Will using additionalProperties: false here block properties evaluated by the
$ref to dac.yaml?
Standard DAC properties like label might fail validation during dtbs_check
when added to channel nodes.
Should this be changed to unevaluatedProperties: false instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-ad5529r-driver-v7-0-7781cd74ad75@analog.com?part=6
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [PATCH v7 6/7] dt-bindings: iio: dac: Add AD5529R
2026-07-22 7:54 ` [PATCH v7 6/7] dt-bindings: iio: dac: Add AD5529R Janani Sunil
2026-07-22 8:11 ` sashiko-bot
@ 2026-07-22 16:39 ` Conor Dooley
1 sibling, 0 replies; 24+ messages in thread
From: Conor Dooley @ 2026-07-22 16:39 UTC (permalink / raw)
To: Janani Sunil
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson, linux-iio, devicetree, linux-kernel, linux-doc,
Janani Sunil, linux-spi, Kent Gustavsson
[-- Attachment #1: Type: text/plain, Size: 380 bytes --]
On Wed, Jul 22, 2026 at 09:54:18AM +0200, Janani Sunil wrote:
> Devicetree bindings for AD5529R 16 channel 12/16 bit high voltage,
> buffered voltage output digital-to-analog converter (DAC) with an
> integrated precision reference.
>
> Signed-off-by: Janani Sunil <janani.sunil@analog.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v7 7/7] iio: dac: Add AD5529R DAC driver support
2026-07-22 7:54 [PATCH v7 0/7] iio: dac: Add support for AD5529R DAC Janani Sunil
` (5 preceding siblings ...)
2026-07-22 7:54 ` [PATCH v7 6/7] dt-bindings: iio: dac: Add AD5529R Janani Sunil
@ 2026-07-22 7:54 ` Janani Sunil
2026-07-22 8:14 ` sashiko-bot
6 siblings, 1 reply; 24+ messages in thread
From: Janani Sunil @ 2026-07-22 7:54 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, Jonathan Corbet,
Shuah Khan, Mark Brown, Marius Cristea, Marcus Folkesson,
Kent Gustavsson
Cc: linux-iio, devicetree, linux-kernel, linux-doc, Janani Sunil,
linux-spi, Kent Gustavsson, Janani Sunil
Add support for AD5529R 16-channel, 12/16 bit Digital to Analog Converter
from Analog Devices.
The device communicates over SPI and supports per-channel output range
configuration. An optional external 4.096V reference can be used in
place of the internal reference.
Signed-off-by: Janani Sunil <janani.sunil@analog.com>
---
MAINTAINERS | 1 +
drivers/iio/dac/Kconfig | 17 ++
drivers/iio/dac/Makefile | 1 +
drivers/iio/dac/ad5529r.c | 501 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 520 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 320e84765ce6..143714e27d51 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1513,6 +1513,7 @@ L: linux-iio@vger.kernel.org
S: Supported
W: https://ez.analog.com/linux-software-drivers
F: Documentation/devicetree/bindings/iio/dac/adi,ad5529r.yaml
+F: drivers/iio/dac/ad5529r.c
ANALOG DEVICES INC AD5706R DRIVER
M: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
index 657c68e75542..bb1d59889a2a 100644
--- a/drivers/iio/dac/Kconfig
+++ b/drivers/iio/dac/Kconfig
@@ -134,6 +134,23 @@ config AD5449
To compile this driver as a module, choose M here: the
module will be called ad5449.
+config AD5529R
+ tristate "Analog Devices AD5529R High Voltage DAC driver"
+ depends on SPI_MASTER
+ select REGMAP_SPI
+ help
+ Say yes here to build support for Analog Devices AD5529R
+ 16-Channel, 12-Bit/16-Bit, 40V High Voltage Precision Digital to Analog
+ Converter.
+
+ The device features multiple output voltage ranges from -20V to +20V,
+ built-in 4.096V voltage reference, and digital functions including
+ toggle, dither, and ramp modes. Supports both 12-bit and 16-bit
+ resolution variants.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ad5529r.
+
config AD5592R_BASE
tristate
diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile
index 003431798498..f35e060b3643 100644
--- a/drivers/iio/dac/Makefile
+++ b/drivers/iio/dac/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_AD5446) += ad5446.o
obj-$(CONFIG_AD5446_SPI) += ad5446-spi.o
obj-$(CONFIG_AD5446_I2C) += ad5446-i2c.o
obj-$(CONFIG_AD5449) += ad5449.o
+obj-$(CONFIG_AD5529R) += ad5529r.o
obj-$(CONFIG_AD5592R_BASE) += ad5592r-base.o
obj-$(CONFIG_AD5592R) += ad5592r.o
obj-$(CONFIG_AD5593R) += ad5593r.o
diff --git a/drivers/iio/dac/ad5529r.c b/drivers/iio/dac/ad5529r.c
new file mode 100644
index 000000000000..2fd1dd053da5
--- /dev/null
+++ b/drivers/iio/dac/ad5529r.c
@@ -0,0 +1,501 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * AD5529R Digital-to-Analog Converter Driver
+ * 16-Channel, 12/16-Bit, 40V High Voltage Precision DAC
+ *
+ * Copyright 2026 Analog Devices Inc.
+ * Author: Janani Sunil <janani.sunil@analog.com>
+ */
+
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/delay.h>
+#include <linux/dev_printk.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/iio/iio.h>
+#include <linux/module.h>
+#include <linux/property.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/reset.h>
+#include <linux/spi/spi.h>
+#include <linux/types.h>
+#include <linux/units.h>
+
+#define AD5529R_REG_INTERFACE_CONFIG_A 0x00
+#define AD5529R_INTERFACE_CONFIG_A_SW_RESET (BIT(7) | BIT(0))
+#define AD5529R_INTERFACE_CONFIG_A_ADDR_ASCENSION BIT(5)
+#define AD5529R_INTERFACE_CONFIG_A_SDO_ENABLE BIT(4)
+#define AD5529R_REG_DEVICE_CONFIG 0x02
+#define AD5529R_REG_CHIP_GRADE 0x06
+#define AD5529R_REG_SCRATCH_PAD 0x0A
+#define AD5529R_REG_SPI_REVISION 0x0B
+#define AD5529R_REG_VENDOR_H 0x0D
+#define AD5529R_REG_STREAM_MODE 0x0E
+#define AD5529R_REG_INTERFACE_STATUS_A 0x11
+#define AD5529R_REG_MULTI_DAC_CH_SEL 0x14
+#define AD5529R_REG_OUT_RANGE_BASE 0x3C
+#define AD5529R_REG_OUT_RANGE(ch) (AD5529R_REG_OUT_RANGE_BASE + (ch) * 2)
+#define AD5529R_REG_DAC_INPUT_A_BASE 0x148
+#define AD5529R_REG_DAC_INPUT_A(ch) (AD5529R_REG_DAC_INPUT_A_BASE + (ch) * 2)
+#define AD5529R_REG_DAC_DATA_READBACK_BASE 0x16A
+#define AD5529R_REG_TSENS_ALERT_FLAG 0x18C
+#define AD5529R_REG_TSENS_SHTD_FLAG 0x18E
+#define AD5529R_REG_FUNC_BUSY 0x1A0
+#define AD5529R_REG_REF_SEL 0x1A2
+#define AD5529R_REF_SEL_INTERNAL_REF BIT(0)
+#define AD5529R_REG_INIT_CRC_ERR_STAT 0x1A4
+#define AD5529R_REG_MULTI_DAC_HOTPATH_SW_LDAC 0x1A8
+
+#define AD5529R_MAX_REGISTER 0x232
+#define AD5529R_8BIT_REG_MAX 0x13
+#define AD5529R_SPI_READ_FLAG 0x80
+#define AD5529R_ADDR_SHIFT 12
+
+struct ad5529r_model_data {
+ const char *model_name;
+ unsigned int resolution;
+};
+
+#define AD5529R_DAC_CHANNEL(chan) ((struct iio_chan_spec) { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .output = 1, \
+ .channel = (chan), \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
+ BIT(IIO_CHAN_INFO_SCALE) | \
+ BIT(IIO_CHAN_INFO_OFFSET), \
+})
+
+static const char * const ad5529r_supply_names[] = {
+ "vdd",
+ "avdd",
+ "hvdd",
+};
+
+static const struct ad5529r_model_data ad5529r_16bit_model_data = {
+ .model_name = "ad5529r-16",
+ .resolution = 16,
+};
+
+static const struct ad5529r_model_data ad5529r_12bit_model_data = {
+ .model_name = "ad5529r-12",
+ .resolution = 12,
+};
+
+enum ad5529r_output_range {
+ AD5529R_RANGE_0V_5V,
+ AD5529R_RANGE_0V_10V,
+ AD5529R_RANGE_0V_20V,
+ AD5529R_RANGE_0V_40V,
+ AD5529R_RANGE_NEG5V_5V,
+ AD5529R_RANGE_NEG10V_10V,
+ AD5529R_RANGE_NEG15V_15V,
+ AD5529R_RANGE_NEG20V_20V,
+};
+
+static const s32 ad5529r_output_ranges_mV[8][2] = {
+ [AD5529R_RANGE_0V_5V] = { 0, 5000 },
+ [AD5529R_RANGE_0V_10V] = { 0, 10000 },
+ [AD5529R_RANGE_0V_20V] = { 0, 20000 },
+ [AD5529R_RANGE_0V_40V] = { 0, 40000 },
+ [AD5529R_RANGE_NEG5V_5V] = { -5000, 5000 },
+ [AD5529R_RANGE_NEG10V_10V] = { -10000, 10000 },
+ [AD5529R_RANGE_NEG15V_15V] = { -15000, 15000 },
+ [AD5529R_RANGE_NEG20V_20V] = { -20000, 20000 },
+};
+
+struct ad5529r_state {
+ struct spi_device *spi;
+ const struct ad5529r_model_data *model_data;
+ struct regmap *regmap_8bit;
+ struct regmap *regmap_16bit;
+ struct iio_chan_spec channels[16];
+ unsigned int num_channels;
+ enum ad5529r_output_range output_range_idx[16];
+};
+
+static const struct regmap_range ad5529r_8bit_readable_ranges[] = {
+ regmap_reg_range(AD5529R_REG_INTERFACE_CONFIG_A, AD5529R_REG_CHIP_GRADE),
+ regmap_reg_range(AD5529R_REG_SCRATCH_PAD, AD5529R_REG_VENDOR_H),
+ regmap_reg_range(AD5529R_REG_STREAM_MODE, AD5529R_REG_INTERFACE_STATUS_A),
+};
+
+static const struct regmap_range ad5529r_16bit_readable_ranges[] = {
+ regmap_reg_range(AD5529R_REG_MULTI_DAC_CH_SEL, AD5529R_REG_INIT_CRC_ERR_STAT),
+ regmap_reg_range(AD5529R_REG_MULTI_DAC_HOTPATH_SW_LDAC, AD5529R_MAX_REGISTER),
+};
+
+static const struct regmap_access_table ad5529r_8bit_readable_table = {
+ .yes_ranges = ad5529r_8bit_readable_ranges,
+ .n_yes_ranges = ARRAY_SIZE(ad5529r_8bit_readable_ranges),
+};
+
+static const struct regmap_access_table ad5529r_16bit_readable_table = {
+ .yes_ranges = ad5529r_16bit_readable_ranges,
+ .n_yes_ranges = ARRAY_SIZE(ad5529r_16bit_readable_ranges),
+};
+
+static const struct regmap_range ad5529r_8bit_read_only_ranges[] = {
+ regmap_reg_range(AD5529R_REG_DEVICE_CONFIG, AD5529R_REG_CHIP_GRADE),
+ regmap_reg_range(AD5529R_REG_SPI_REVISION, AD5529R_REG_VENDOR_H),
+};
+
+static const struct regmap_range ad5529r_16bit_read_only_ranges[] = {
+ regmap_reg_range(AD5529R_REG_DAC_DATA_READBACK_BASE,
+ AD5529R_REG_DAC_DATA_READBACK_BASE + 15 * 2),
+ regmap_reg_range(AD5529R_REG_TSENS_ALERT_FLAG, AD5529R_REG_TSENS_SHTD_FLAG),
+ regmap_reg_range(AD5529R_REG_FUNC_BUSY, AD5529R_REG_FUNC_BUSY),
+ regmap_reg_range(AD5529R_REG_INIT_CRC_ERR_STAT, AD5529R_REG_INIT_CRC_ERR_STAT),
+};
+
+static const struct regmap_access_table ad5529r_8bit_writeable_table = {
+ .no_ranges = ad5529r_8bit_read_only_ranges,
+ .n_no_ranges = ARRAY_SIZE(ad5529r_8bit_read_only_ranges),
+};
+
+static const struct regmap_access_table ad5529r_16bit_writeable_table = {
+ .no_ranges = ad5529r_16bit_read_only_ranges,
+ .n_no_ranges = ARRAY_SIZE(ad5529r_16bit_read_only_ranges),
+};
+
+static struct regmap *ad5529r_get_regmap(struct ad5529r_state *st,
+ unsigned int reg)
+{
+ if (reg <= AD5529R_8BIT_REG_MAX)
+ return st->regmap_8bit;
+
+ return st->regmap_16bit;
+}
+
+static int ad5529r_reset(struct ad5529r_state *st)
+{
+ struct reset_control *rst;
+ int ret;
+
+ rst = devm_reset_control_get_optional_exclusive(&st->spi->dev, NULL);
+ if (IS_ERR(rst))
+ return PTR_ERR(rst);
+
+ if (rst) {
+ ret = reset_control_assert(rst);
+ if (ret)
+ return ret;
+
+ /* Minimum reset low width (t_reset) is 20 ns per datasheet. */
+ ret = reset_control_deassert(rst);
+ if (ret)
+ return ret;
+ } else {
+ ret = regmap_write(st->regmap_8bit, AD5529R_REG_INTERFACE_CONFIG_A,
+ AD5529R_INTERFACE_CONFIG_A_SW_RESET);
+ if (ret)
+ return ret;
+ }
+
+ /*
+ * Wait 10 ms for digital initialization to complete.
+ * Per datasheet, Interface Status A register NOT_READY_ERR bit is
+ * set if SPI transactions are attempted before digital initialization
+ * completes.
+ */
+ fsleep(10 * USEC_PER_MSEC);
+
+ return regmap_write(st->regmap_8bit, AD5529R_REG_INTERFACE_CONFIG_A,
+ AD5529R_INTERFACE_CONFIG_A_SDO_ENABLE |
+ AD5529R_INTERFACE_CONFIG_A_ADDR_ASCENSION);
+}
+
+static int ad5529r_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
+ struct ad5529r_state *st = iio_priv(indio_dev);
+ unsigned int reg_addr, reg_val_h;
+ int ret, range_idx, span_mv;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ /*
+ * Read from DAC_INPUT_A register rather than DAC_DATA_READBACK.
+ * The DAC operates in transparent mode and directly reflects
+ * whatever value is written to the INPUT_A register.
+ */
+ reg_addr = AD5529R_REG_DAC_INPUT_A(chan->channel);
+ ret = regmap_read(st->regmap_16bit, reg_addr, ®_val_h);
+ if (ret)
+ return ret;
+
+ *val = reg_val_h;
+
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_SCALE:
+ range_idx = st->output_range_idx[chan->channel];
+
+ span_mv = ad5529r_output_ranges_mV[range_idx][1] -
+ ad5529r_output_ranges_mV[range_idx][0];
+ *val = span_mv;
+ *val2 = st->model_data->resolution;
+
+ return IIO_VAL_FRACTIONAL_LOG2;
+ case IIO_CHAN_INFO_OFFSET:
+ range_idx = st->output_range_idx[chan->channel];
+
+ if (ad5529r_output_ranges_mV[range_idx][0] < 0)
+ *val = -(1 << (st->model_data->resolution - 1));
+ else
+ *val = 0;
+
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int ad5529r_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
+ struct ad5529r_state *st = iio_priv(indio_dev);
+ unsigned int reg_addr;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ if (val < 0 || val > GENMASK(st->model_data->resolution - 1, 0))
+ return -EINVAL;
+
+ reg_addr = AD5529R_REG_DAC_INPUT_A(chan->channel);
+
+ return regmap_write(st->regmap_16bit, reg_addr, val);
+ default:
+ return -EINVAL;
+ }
+}
+
+static int ad5529r_find_output_range(const s32 *vals)
+{
+ for (unsigned int i = 0; i < ARRAY_SIZE(ad5529r_output_ranges_mV); i++) {
+ const s32 *range = ad5529r_output_ranges_mV[i];
+
+ if (vals[0] == range[0] * (MICRO / MILLI) &&
+ vals[1] == range[1] * (MICRO / MILLI))
+ return i;
+ }
+
+ return -EINVAL;
+}
+
+static int ad5529r_parse_channel_ranges(struct device *dev,
+ struct ad5529r_state *st)
+{
+ s32 vals[2];
+ int ret, range_idx;
+ u32 ch;
+
+ device_for_each_child_node_scoped(dev, child) {
+ ret = fwnode_property_read_u32(child, "reg", &ch);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Missing reg property in channel node\n");
+
+ if (ch >= 16)
+ return dev_err_probe(dev, -EINVAL,
+ "Channel %u exceeds maximum 15\n",
+ ch);
+
+ if (fwnode_property_present(child, "output-range-microvolt")) {
+ /*
+ * DT stores cells as raw 32-bit values; signed endpoints are
+ * encoded by dtc in two's-complement and then interpreted
+ * here as s32.
+ */
+ ret = fwnode_property_read_u32_array(child,
+ "output-range-microvolt",
+ (u32 *)vals, ARRAY_SIZE(vals));
+ if (ret < 0)
+ return dev_err_probe(dev, ret,
+ "Failed to read range for ch %u\n",
+ ch);
+
+ range_idx = ad5529r_find_output_range(vals);
+ if (range_idx < 0)
+ return dev_err_probe(dev, range_idx,
+ "Invalid range [%d %d] for ch %u\n",
+ vals[0], vals[1], ch);
+ } else {
+ range_idx = AD5529R_RANGE_0V_5V;
+ }
+
+ st->output_range_idx[ch] = range_idx;
+ ret = regmap_write(st->regmap_16bit,
+ AD5529R_REG_OUT_RANGE(ch), range_idx);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to configure range for ch %u\n",
+ ch);
+
+ st->channels[st->num_channels++] = AD5529R_DAC_CHANNEL(ch);
+ }
+
+ return 0;
+}
+
+static int ad5529r_reg_access(struct iio_dev *indio_dev,
+ unsigned int reg,
+ unsigned int writeval,
+ unsigned int *readval)
+{
+ struct ad5529r_state *st = iio_priv(indio_dev);
+
+ if (readval)
+ return regmap_read(ad5529r_get_regmap(st, reg), reg, readval);
+
+ return regmap_write(ad5529r_get_regmap(st, reg), reg, writeval);
+}
+
+static const struct iio_info ad5529r_info = {
+ .read_raw = ad5529r_read_raw,
+ .write_raw = ad5529r_write_raw,
+ .debugfs_reg_access = ad5529r_reg_access,
+};
+
+static int ad5529r_probe(struct spi_device *spi)
+{
+ struct device *dev = &spi->dev;
+ struct iio_dev *indio_dev;
+ struct ad5529r_state *st;
+ struct regmap_config regmap_8bit_cfg;
+ struct regmap_config regmap_16bit_cfg;
+ bool external_vref;
+ u32 dev_addr = 0;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ st = iio_priv(indio_dev);
+
+ st->spi = spi;
+
+ st->model_data = spi_get_device_match_data(spi);
+ if (!st->model_data)
+ return dev_err_probe(dev, -EINVAL,
+ "Failed to identify device variant\n");
+
+ device_property_read_u32(dev, "spi-device-addr", &dev_addr);
+ if (dev_addr > 3)
+ return dev_err_probe(dev, -EINVAL,
+ "spi-device-addr %u out of range [0, 3]\n",
+ dev_addr);
+
+ regmap_8bit_cfg = (struct regmap_config) {
+ .name = "ad5529r-8bit",
+ .reg_bits = 16,
+ .val_bits = 8,
+ .max_register = AD5529R_8BIT_REG_MAX,
+ .read_flag_mask = AD5529R_SPI_READ_FLAG,
+ .rd_table = &ad5529r_8bit_readable_table,
+ .wr_table = &ad5529r_8bit_writeable_table,
+ .reg_base = dev_addr << AD5529R_ADDR_SHIFT,
+ };
+ regmap_16bit_cfg = (struct regmap_config) {
+ .name = "ad5529r-16bit",
+ .reg_bits = 16,
+ .val_bits = 16,
+ .max_register = AD5529R_MAX_REGISTER,
+ .read_flag_mask = AD5529R_SPI_READ_FLAG,
+ .val_format_endian = REGMAP_ENDIAN_LITTLE,
+ .rd_table = &ad5529r_16bit_readable_table,
+ .wr_table = &ad5529r_16bit_writeable_table,
+ .reg_stride = 2,
+ .reg_base = dev_addr << AD5529R_ADDR_SHIFT,
+ };
+
+ ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(ad5529r_supply_names),
+ ad5529r_supply_names);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to get and enable regulators\n");
+
+ ret = devm_regulator_get_enable_optional(dev, "hvss");
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(dev, ret,
+ "Failed to get and enable hvss regulator\n");
+
+ ret = devm_regulator_get_enable_optional(dev, "vref");
+ if (ret == -ENODEV)
+ external_vref = false;
+ else if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to get and enable vref regulator\n");
+ else
+ external_vref = true;
+
+ st->regmap_8bit = devm_regmap_init_spi(spi, ®map_8bit_cfg);
+ if (IS_ERR(st->regmap_8bit))
+ return dev_err_probe(dev, PTR_ERR(st->regmap_8bit),
+ "Failed to initialize 8-bit regmap\n");
+
+ st->regmap_16bit = devm_regmap_init_spi(spi, ®map_16bit_cfg);
+ if (IS_ERR(st->regmap_16bit))
+ return dev_err_probe(dev, PTR_ERR(st->regmap_16bit),
+ "Failed to initialize 16-bit regmap\n");
+
+ ret = ad5529r_reset(st);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to reset device\n");
+
+ ret = regmap_assign_bits(st->regmap_16bit, AD5529R_REG_REF_SEL,
+ AD5529R_REF_SEL_INTERNAL_REF,
+ external_vref ? 0 : AD5529R_REF_SEL_INTERNAL_REF);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to configure reference\n");
+
+ ret = ad5529r_parse_channel_ranges(dev, st);
+ if (ret)
+ return ret;
+
+ indio_dev->name = st->model_data->model_name;
+ indio_dev->info = &ad5529r_info;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->channels = st->channels;
+ indio_dev->num_channels = st->num_channels;
+
+ return devm_iio_device_register(dev, indio_dev);
+}
+
+static const struct of_device_id ad5529r_of_match[] = {
+ { .compatible = "adi,ad5529r-16", .data = &ad5529r_16bit_model_data },
+ { .compatible = "adi,ad5529r-12", .data = &ad5529r_12bit_model_data },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ad5529r_of_match);
+
+static const struct spi_device_id ad5529r_id[] = {
+ {
+ .name = "ad5529r-16",
+ .driver_data = (kernel_ulong_t)&ad5529r_16bit_model_data,
+ },
+ {
+ .name = "ad5529r-12",
+ .driver_data = (kernel_ulong_t)&ad5529r_12bit_model_data,
+ },
+ { }
+};
+MODULE_DEVICE_TABLE(spi, ad5529r_id);
+
+static struct spi_driver ad5529r_driver = {
+ .driver = {
+ .name = "ad5529r",
+ .of_match_table = ad5529r_of_match,
+ },
+ .probe = ad5529r_probe,
+ .id_table = ad5529r_id,
+};
+module_spi_driver(ad5529r_driver);
+
+MODULE_AUTHOR("Janani Sunil <janani.sunil@analog.com>");
+MODULE_DESCRIPTION("Analog Devices AD5529R 12/16-bit DAC driver");
+MODULE_LICENSE("GPL");
--
2.43.0
^ permalink raw reply related [flat|nested] 24+ messages in thread* Re: [PATCH v7 7/7] iio: dac: Add AD5529R DAC driver support
2026-07-22 7:54 ` [PATCH v7 7/7] iio: dac: Add AD5529R DAC driver support Janani Sunil
@ 2026-07-22 8:14 ` sashiko-bot
0 siblings, 0 replies; 24+ messages in thread
From: sashiko-bot @ 2026-07-22 8:14 UTC (permalink / raw)
To: Janani Sunil; +Cc: devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Out-of-bounds array write in `ad5529r_parse_channel_ranges` due to missing bounds check on `st->num_channels`.
- [Medium] Missing required hardware delay between reset assertion and deassertion.
--
--- Patch [7]: [PATCH v7 7/7] iio: dac: Add AD5529R DAC driver support ---
commit 190cbf7d47fe0e91c8bbafb4dfea2a90c159fb6b
Author: Janani Sunil <janani.sunil@analog.com>
iio: dac: Add AD5529R DAC driver support
This commit adds support for the Analog Devices AD5529R 16-channel,
12/16 bit Digital to Analog Converter. The device communicates over SPI
and supports per-channel output range configuration.
> diff --git a/drivers/iio/dac/ad5529r.c b/drivers/iio/dac/ad5529r.c
> new file mode 100644
> index 0000000000000..2fd1dd053da58
> --- /dev/null
> +++ b/drivers/iio/dac/ad5529r.c
[ ... ]
> +static int ad5529r_reset(struct ad5529r_state *st)
> +{
> + struct reset_control *rst;
> + int ret;
> +
> + rst = devm_reset_control_get_optional_exclusive(&st->spi->dev, NULL);
> + if (IS_ERR(rst))
> + return PTR_ERR(rst);
> +
> + if (rst) {
> + ret = reset_control_assert(rst);
> + if (ret)
> + return ret;
> +
> + /* Minimum reset low width (t_reset) is 20 ns per datasheet. */
> + ret = reset_control_deassert(rst);
[Severity: Medium]
Since the datasheet requires a minimum reset low width of 20 ns, should there
be a delay like ndelay(20) before deasserting the reset?
Back-to-back MMIO writes on fast hardware might toggle the reset line faster
than the required 20 ns.
> + if (ret)
> + return ret;
> + } else {
[ ... ]
> +static int ad5529r_parse_channel_ranges(struct device *dev,
> + struct ad5529r_state *st)
> +{
> + s32 vals[2];
> + int ret, range_idx;
> + u32 ch;
> +
> + device_for_each_child_node_scoped(dev, child) {
> + ret = fwnode_property_read_u32(child, "reg", &ch);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "Missing reg property in channel node\n");
> +
> + if (ch >= 16)
> + return dev_err_probe(dev, -EINVAL,
> + "Channel %u exceeds maximum 15\n",
> + ch);
[ ... ]
> + st->output_range_idx[ch] = range_idx;
> + ret = regmap_write(st->regmap_16bit,
> + AD5529R_REG_OUT_RANGE(ch), range_idx);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "Failed to configure range for ch %u\n",
> + ch);
> +
> + st->channels[st->num_channels++] = AD5529R_DAC_CHANNEL(ch);
[Severity: High]
Does this code risk an out-of-bounds array write to st->channels[]?
While the code checks if the individual 'reg' property 'ch' is less than 16,
it does not verify the total number of child nodes. If a malformed Device Tree
contains more than 16 child nodes (for instance, due to duplicate 'reg'
values), st->num_channels will exceed the fixed size of st->channels[16] and
corrupt adjacent memory.
> + }
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-ad5529r-driver-v7-0-7781cd74ad75@analog.com?part=7
^ permalink raw reply [flat|nested] 24+ messages in thread