dt-bindings: iio: dds: Add AD9832/AD9835 binding
Subsystems (3)
v2 cover dt-bindings: iio: dds: Add AD9832/AD9835 binding
v2:
- Add SPI peripheral schema reference
- Fix example by adding clock and regulator providers
- Fix SPDX license format
Hungyu Lin (1):
dt-bindings: iio: dds: Add AD9832/AD9835 binding
.../bindings/iio/dds/adi,ad9832.yaml | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dds/adi,ad9832.yaml
Signature · 1 line
2.34.1
PATCH v2 1/1 dt-bindings: iio: dds: Add AD9832/AD9835 binding
Add devicetree binding documentation for AD9832 and AD9835 DDS devices.
These devices are SPI-controlled direct digital synthesizers requiring AVDD, DVDD supplies and an external master clock.
--- .../bindings/iio/dds/adi,ad9832.yaml | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dds/adi,ad9832.yaml
Documentation/devicetree/bindings/iio/dds/adi,ad9832.yaml new file +87 -0
@@ -0,0 +1,87 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dds/adi,ad9832.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD9832 / AD9835 DDS + +maintainers: + - Hungyu Lin <[email protected]> + +description: | + Binding for Analog Devices AD9832 and AD9835 SPI-controlled direct + digital synthesizers (DDS). The devices use an external master clock + and are controlled over a serial SPI-compatible interface. + +properties: + compatible: + enum: + - adi,ad9832 + - adi,ad9835 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 20000000 + + clocks: + maxItems: 1 + description: + External master clock input. + + clock-names: + const: mclk + + avdd-supply: + description: + Analog power supply. + + dvdd-supply: + description: + Digital power supply. + +required: + - compatible + - reg + - clocks + - clock-names + - avdd-supply + - dvdd-supply + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples: + - | + mclk: clock { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <25000000>; + }; + + vdd_3v3: regulator { + compatible = "regulator-fixed"; + regulator-name = "vdd_3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + + spi { + #address-cells = <1>; + #size-cells = <0>; + + ad9832@0 { + compatible = "adi,ad9832"; + reg = <0>; + spi-max-frequency = <20000000>; + clocks = <&mclk>; + clock-names = "mclk"; + avdd-supply = <&vdd_3v3>; + dvdd-supply = <&vdd_3v3>; + }; + };
Signature · 1 line
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] The AD9832 and AD9835 require SPI Mode 2 (CPOL=1, CPHA=0), but the binding does not enforce…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The AD9832 and AD9835 require SPI Mode 2 (CPOL=1, CPHA=0), but the binding does not enforce spi-cpol and the example omits it.
- [High] The driver will unconditionally fail to probe when instantiated via Device Tree because it strictly requires platform_data.
- [Low] The example uses a specific part number for the node name (ad9832@0) rather than a generic functional name. --
commit 0760129b4a1ce54473ebad28ebda22535e9eedd6
Author: Hungyu Lin <[email protected]>
dt-bindings: iio: dds: Add AD9832/AD9835 binding
This commit adds device tree binding documentation for the Analog Devices AD9832 and AD9835 SPI-controlled direct digital synthesizers.
Since the binding introduces device tree support, does the driver need updates to actually probe successfully when instantiated this way?
Looking at ad9832_probe(), it unconditionally returns -ENODEV if dev_get_platdata() is NULL:
drivers/iio/dds/ad9832.c:ad9832_probe() {
struct ad9832_platform_data *pdata = dev_get_platdata(&spi->dev);
if (!pdata) {
dev_dbg(&spi->dev, "no platform data?\n");
return -ENODEV;
}
...
}When instantiated via device tree, platform data is typically NULL. Will the driver fail to probe without additional patches to handle missing platform data?
Quoted 4 lines
Documentation/devicetree/bindings/iio/dds/adi,ad9832.yaml new file +0
-0
[ ... ]
Quoted 11 lines
properties:
compatible:
enum:
- adi,ad9832
- adi,ad9835reg:
maxItems: 1spi-max-frequency:
maximum: 20000000
Does this binding need to specify spi-cpol?
The AD9832 hardware requires SPI Mode 2 (CPOL=1, CPHA=0) where the SPI clock idles high. Since the driver doesn't set spi->mode in code and relies on the device tree to configure polarity, omitting it might cause the controller to default to Mode 0, which would cause communication to fail.
Should spi-cpol: true be added to the properties and included in the example?
[ ... ]
Quoted 5 lines
spi {
#address-cells = <1>;
#size-cells = <0>;
ad9832@0 {This isn't a bug, but does this violate the device tree convention for generic node names? Usually, node names describe the hardware's function rather than the specific part number, such as generator@0 or frequency@0.
Quoted 3 lines
compatible = "adi,ad9832";
reg = <0>;
spi-max-frequency = <20000000>;Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1