Skip to contentSkip to conversation

iio:frequency:admv1014: add support for ADMV1014

PATCH Superseded Antoniu Miclaus 2 participants 8 messages Jan 19, 2022 – Jan 22, 2022

Subsystems (4)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Antoniu Miclaus

author maintainer
#0 lore raw

PATCH v3 1/4 iio:frequency:admv1014: add support for ADMV1014

The ADMV1014 is a silicon germanium (SiGe), wideband, microwave downconverter optimized for point to point microwave radio designs operating in the 24 GHz to 44 GHz frequency range.

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADMV1014.pdf

---
changes in v3:
- add line breaks where needed
- expose IIO channels/attributes based on the input mode
- remove comma after null terminator
- make VCC_X regulators optional and remove value checks
- use only unlocked versions of spi read/write inside init function
- move powerdown action to init function

 drivers/iio/frequency/Kconfig    |  10 +
 drivers/iio/frequency/Makefile   |   1 +
 drivers/iio/frequency/admv1014.c | 950 +++++++++++++++++++++++++++++++
 3 files changed, 961 insertions(+)
 create mode 100644 drivers/iio/frequency/admv1014.c
drivers/iio/frequency/Kconfig +10 -0
index 2c9e0559e8a4..493221f42077 100644
@@ -50,6 +50,16 @@ config ADF4371
 	  To compile this driver as a module, choose M here: the
 	  module will be called adf4371.
 
+config ADMV1014
+	tristate "Analog Devices ADMV1014 Microwave Downconverter"
+	depends on SPI && COMMON_CLK && 64BIT
+	help
+	  Say yes here to build support for Analog Devices ADMV1014
+	  24 GHz to 44 GHz, Wideband, Microwave Downconverter.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called admv1014.
+
 config ADRF6780
         tristate "Analog Devices ADRF6780 Microwave Upconverter"
         depends on SPI
drivers/iio/frequency/Makefile +1 -0
index ae3136c79202..5f0348e5eb53 100644
@@ -7,4 +7,5 @@
 obj-$(CONFIG_AD9523) += ad9523.o
 obj-$(CONFIG_ADF4350) += adf4350.o
 obj-$(CONFIG_ADF4371) += adf4371.o
+obj-$(CONFIG_ADMV1014) += admv1014.o
 obj-$(CONFIG_ADRF6780) += adrf6780.o
drivers/iio/frequency/admv1014.c new file +950 -0

950 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v3 2/4 dt-bindings:iio:frequency: add admv1014 binding

Add device tree bindings for the ADMV1014 Upconverter.

changes in v3:
- change clock description as suggested

---
 .../bindings/iio/frequency/adi,admv1014.yaml  | 129 ++++++++++++++++++
 1 file changed, 129 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml
Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml new file +129 -0
new file mode 100644
index 000000000000..864093f6a29a
@@ -0,0 +1,129 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/frequency/adi,admv1014.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ADMV1014 Microwave Downconverter
+
+maintainers:
+  - Antoniu Miclaus <[email protected]>
+
+description: |
+   Wideband, microwave downconverter optimized for point to point microwave
+   radio designs operating in the 24 GHz to 44 GHz frequency range.
+
+   https://www.analog.com/en/products/admv1014.html
+
+properties:
+  compatible:
+    enum:
+      - adi,admv1014
+
+  reg:
+    maxItems: 1
+
+  spi-max-frequency:
+    maximum: 1000000
+
+  clocks:
+    minItems: 1
+
+  clock-names:
+    items:
+      - const: lo_in
+    description:
+      External clock that provides the Local Oscilator input.
+
+  vcm-supply:
+    description:
+      Common-mode voltage regulator.
+
+  vcc-if-bb-supply:
+    description:
+      BB and IF supply voltage regulator.
+
+  vcc-vga-supply:
+    description:
+      RF Amplifier supply voltage regulator.
+
+  vcc-vva-supply:
+    description:
+      VVA Control Circuit supply voltage regulator.
+
+  vcc-lna-3p3-supply:
+    description:
+      Low Noise Amplifier 3.3V supply voltage regulator.
+
+  vcc-lna-1p5-supply:
+    description:
+      Low Noise Amplifier 1.5V supply voltage regulator.
+
+  vcc-bg-supply:
+    description:
+      Band Gap Circuit supply voltage regulator.
+
+  vcc-quad-supply:
+    description:
+      Quadruple supply voltage regulator.
+
+  vcc-mixer-supply:
+    description:
+      Mixer supply voltage regulator.
+
+  adi,input-mode:
+    description:
+      Select the input mode.
+      iq - in-phase quadrature (I/Q) input
+      if - complex intermediate frequency (IF) input
+    enum: [iq, if]
+
+  adi,detector-enable:
+    description:
+      Digital Rx Detector Enable. The Square Law Detector output is
+      available at output pin VDET.
+    type: boolean
+
+  adi,p1db-compensation-enable:
+    description:
+      Turn on bits to optimize P1dB.
+    type: boolean
+
+  adi,quad-se-mode:
+    description:
+      Switch the LO path from differential to single-ended operation.
+      se-neg - Single-Ended Mode, Negative Side Disabled.
+      se-pos - Single-Ended Mode, Positive Side Disabled.
+      diff - Differential Mode.
+    enum: [se-neg, se-pos, diff]
+
+  '#clock-cells':
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - vcm-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    spi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      admv1014@0{
+        compatible = "adi,admv1014";
+        reg = <0>;
+        spi-max-frequency = <1000000>;
+        clocks = <&admv1014_lo>;
+        clock-names = "lo_in";
+        vcm-supply = <&vcm>;
+        adi,quad-se-mode = "diff";
+        adi,detector-enable;
+        adi,p1db-compensation-enable;
+      };
+    };
+...
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [PATCH v3 2/4] dt-bindings:iio:frequency: add admv1014 binding

Quoted 6 lines · On Wed, 19 Jan 2022 10:18:36 +0200 Antoniu Miclaus…

Add device tree bindings for the ADMV1014 Upconverter.

changes in v3:
- change clock description as suggested
---

Change log below the ---

We don't want it in the permanent git history. There will be a link tag to this thread to allow anyone who happens to want to known more to find the version change log.

Given you got it right in the other 3 patches, I'm guessing you just missed here.

If that is all that turns up in review, I can fix it whilst applying.

Thanks,

Jonathan

Quoted 139 lines
 .../bindings/iio/frequency/adi,admv1014.yaml  | 129 ++++++++++++++++++
 1 file changed, 129 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml
Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml new file +129 -0
new file mode 100644
index 000000000000..864093f6a29a
@@ -0,0 +1,129 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/frequency/adi,admv1014.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ADMV1014 Microwave Downconverter
+
+maintainers:
+  - Antoniu Miclaus <[email protected]>
+
+description: |
+   Wideband, microwave downconverter optimized for point to point microwave
+   radio designs operating in the 24 GHz to 44 GHz frequency range.
+
+   https://www.analog.com/en/products/admv1014.html
+
+properties:
+  compatible:
+    enum:
+      - adi,admv1014
+
+  reg:
+    maxItems: 1
+
+  spi-max-frequency:
+    maximum: 1000000
+
+  clocks:
+    minItems: 1
+
+  clock-names:
+    items:
+      - const: lo_in
+    description:
+      External clock that provides the Local Oscilator input.
+
+  vcm-supply:
+    description:
+      Common-mode voltage regulator.
+
+  vcc-if-bb-supply:
+    description:
+      BB and IF supply voltage regulator.
+
+  vcc-vga-supply:
+    description:
+      RF Amplifier supply voltage regulator.
+
+  vcc-vva-supply:
+    description:
+      VVA Control Circuit supply voltage regulator.
+
+  vcc-lna-3p3-supply:
+    description:
+      Low Noise Amplifier 3.3V supply voltage regulator.
+
+  vcc-lna-1p5-supply:
+    description:
+      Low Noise Amplifier 1.5V supply voltage regulator.
+
+  vcc-bg-supply:
+    description:
+      Band Gap Circuit supply voltage regulator.
+
+  vcc-quad-supply:
+    description:
+      Quadruple supply voltage regulator.
+
+  vcc-mixer-supply:
+    description:
+      Mixer supply voltage regulator.
+
+  adi,input-mode:
+    description:
+      Select the input mode.
+      iq - in-phase quadrature (I/Q) input
+      if - complex intermediate frequency (IF) input
+    enum: [iq, if]
+
+  adi,detector-enable:
+    description:
+      Digital Rx Detector Enable. The Square Law Detector output is
+      available at output pin VDET.
+    type: boolean
+
+  adi,p1db-compensation-enable:
+    description:
+      Turn on bits to optimize P1dB.
+    type: boolean
+
+  adi,quad-se-mode:
+    description:
+      Switch the LO path from differential to single-ended operation.
+      se-neg - Single-Ended Mode, Negative Side Disabled.
+      se-pos - Single-Ended Mode, Positive Side Disabled.
+      diff - Differential Mode.
+    enum: [se-neg, se-pos, diff]
+
+  '#clock-cells':
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - vcm-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    spi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      admv1014@0{
+        compatible = "adi,admv1014";
+        reg = <0>;
+        spi-max-frequency = <1000000>;
+        clocks = <&admv1014_lo>;
+        clock-names = "lo_in";
+        vcm-supply = <&vcm>;
+        adi,quad-se-mode = "diff";
+        adi,detector-enable;
+        adi,p1db-compensation-enable;
+      };
+    };
+...
maintainer
#3 lore raw

Re: [PATCH v3 2/4] dt-bindings:iio:frequency: add admv1014 binding

In reply to Antoniu Miclaus
Quoted 104 lines · On Wed, 19 Jan 2022 10:18:36 +0200 Antoniu Miclaus…

Add device tree bindings for the ADMV1014 Upconverter.

changes in v3:
- change clock description as suggested

---
 .../bindings/iio/frequency/adi,admv1014.yaml  | 129 ++++++++++++++++++
 1 file changed, 129 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml
Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml new file +88 -0
new file mode 100644
index 000000000000..864093f6a29a
@@ -0,0 +1,129 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/frequency/adi,admv1014.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ADMV1014 Microwave Downconverter
+
+maintainers:
+  - Antoniu Miclaus <[email protected]>
+
+description: |
+   Wideband, microwave downconverter optimized for point to point microwave
+   radio designs operating in the 24 GHz to 44 GHz frequency range.
+
+   https://www.analog.com/en/products/admv1014.html
+
+properties:
+  compatible:
+    enum:
+      - adi,admv1014
+
+  reg:
+    maxItems: 1
+
+  spi-max-frequency:
+    maximum: 1000000
+
+  clocks:
+    minItems: 1
+
+  clock-names:
+    items:
+      - const: lo_in
+    description:
+      External clock that provides the Local Oscilator input.
+
+  vcm-supply:
+    description:
+      Common-mode voltage regulator.
+
+  vcc-if-bb-supply:
+    description:
+      BB and IF supply voltage regulator.
+
+  vcc-vga-supply:
+    description:
+      RF Amplifier supply voltage regulator.
+
+  vcc-vva-supply:
+    description:
+      VVA Control Circuit supply voltage regulator.
+
+  vcc-lna-3p3-supply:
+    description:
+      Low Noise Amplifier 3.3V supply voltage regulator.
+
+  vcc-lna-1p5-supply:
+    description:
+      Low Noise Amplifier 1.5V supply voltage regulator.
+
+  vcc-bg-supply:
+    description:
+      Band Gap Circuit supply voltage regulator.
+
+  vcc-quad-supply:
+    description:
+      Quadruple supply voltage regulator.
+
+  vcc-mixer-supply:
+    description:
+      Mixer supply voltage regulator.
+
+  adi,input-mode:
+    description:
+      Select the input mode.
+      iq - in-phase quadrature (I/Q) input
+      if - complex intermediate frequency (IF) input
+    enum: [iq, if]
+
+  adi,detector-enable:
+    description:
+      Digital Rx Detector Enable. The Square Law Detector output is
+      available at output pin VDET.
+    type: boolean
+
+  adi,p1db-compensation-enable:
+    description:

Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml line 98

Quoted 10 lines
Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml new file +10 -0
+      Turn on bits to optimize P1dB.
+    type: boolean
+
+  adi,quad-se-mode:
+    description:
+      Switch the LO path from differential to single-ended operation.
+      se-neg - Single-Ended Mode, Negative Side Disabled.
+      se-pos - Single-Ended Mode, Positive Side Disabled.
+      diff - Differential Mode.
+    enum: [se-neg, se-pos, diff]

Hi Antoniu

These elements need to specify a default for when they are not provided seeing as they are optional and the default is not obvious.

Thanks,

Jonathan

Quoted 31 lines
Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml new file +31 -0
+
+  '#clock-cells':
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - vcm-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    spi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      admv1014@0{
+        compatible = "adi,admv1014";
+        reg = <0>;
+        spi-max-frequency = <1000000>;
+        clocks = <&admv1014_lo>;
+        clock-names = "lo_in";
+        vcm-supply = <&vcm>;
+        adi,quad-se-mode = "diff";
+        adi,detector-enable;
+        adi,p1db-compensation-enable;
+      };
+    };
+...
author maintainer
#4 lore raw

PATCH v3 3/4 Documentation:ABI:testing:admv1014: add ABI docs

In reply to Antoniu Miclaus

Add documentation for the use of the Digital Attenuator gain.

---
changes in v3:
- add description for calibscale in I/Q mode

 .../testing/sysfs-bus-iio-frequency-admv1014  | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1014
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1014 new file +29 -0
new file mode 100644
index 000000000000..77c1691e6910
@@ -0,0 +1,29 @@
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage0_i_calibscale_coarse
+KernelVersion:
+Contact:	[email protected]
+Description:
+		Read/write value for the digital attenuator gain (IF_I) with coarse steps.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage0_q_calibscale_coarse
+KernelVersion:
+Contact:	[email protected]
+Description:
+		Read/write value for the digital attenuator gain (IF_Q) with coarse steps.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage0_i_calibscale_fine
+KernelVersion:
+Contact:	[email protected]
+Description:
+		Read/write value for the digital attenuator gain (IF_I) with fine steps.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage0_q_calibscale_fine
+KernelVersion:
+Contact:	[email protected]
+Description:
+		Read/write value for the digital attenuator gain (IF_Q) with fine steps.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage_calibscale
+KernelVersion:
+Contact:	[email protected]
+Description:
+		Read/write value for the digital attenuator gain (I/Q).
Signature · 1 line
2.34.1
maintainer
#5 lore raw

Re: [PATCH v3 3/4] Documentation:ABI:testing:admv1014: add ABI docs

Quoted 3 lines · On Wed, 19 Jan 2022 10:18:37 +0200 Antoniu Miclaus…

Add documentation for the use of the Digital Attenuator gain.

One entry that should be in the generic docs rather than here.

Given the documentation generation scripts don't support multiple entries for a given attribute name an that one is 'standard' we should just add it to the main file as otherwise the chances are very high of accidentally getting duplication when it turns up in another driver ABI doc.

We may need to move some of the others later if they turn out to occur in multiple drivers but they are obscure enough to be fine in this file for now.

Thanks,

Jonathan

Quoted 28 lines

---
changes in v3:
- add description for calibscale in I/Q mode

 .../testing/sysfs-bus-iio-frequency-admv1014  | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1014
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1014 new file +15 -0
new file mode 100644
index 000000000000..77c1691e6910
@@ -0,0 +1,29 @@
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage0_i_calibscale_coarse
+KernelVersion:
+Contact:	[email protected]
+Description:
+		Read/write value for the digital attenuator gain (IF_I) with coarse steps.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage0_q_calibscale_coarse
+KernelVersion:
+Contact:	[email protected]
+Description:
+		Read/write value for the digital attenuator gain (IF_Q) with coarse steps.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage0_i_calibscale_fine
+KernelVersion:
+Contact:	[email protected]

Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1014 line 25

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1014 new file +10 -0
+Description:
+		Read/write value for the digital attenuator gain (IF_I) with fine steps.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage0_q_calibscale_fine
+KernelVersion:
+Contact:	[email protected]
+Description:
+		Read/write value for the digital attenuator gain (IF_Q) with fine steps.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_altvoltage_calibscale

This particular one is normal ABI, so should just be added to the list in sysfs-bus-iio alongside all the other calibscale entries.

Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-iio-frequency-admv1014 new file +4 -0
+KernelVersion:
+Contact:	[email protected]
+Description:
+		Read/write value for the digital attenuator gain (I/Q).
author maintainer
#6 lore raw

PATCH v3 4/4 MAINTAINERS: add maintainer for ADMV1014 driver

In reply to Antoniu Miclaus

Add myself as maintainer for the ADMV1014 driver.

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index 170bbbeefc3f..b05148cfd4aa 100644
@@ -1119,6 +1119,14 @@ W:	http://ez.analog.com/community/linux-device-drivers
 F:	Documentation/devicetree/bindings/hwmon/adi,adm1177.yaml
 F:	drivers/hwmon/adm1177.c
 
+ANALOG DEVICES INC ADMV1014 DRIVER
+M:	Antoniu Miclaus <[email protected]>
+L:	[email protected]
+S:	Supported
+W:	https://ez.analog.com/linux-software-drivers
+F:	Documentation/devicetree/bindings/iio/frequency/adi,admv1014.yaml
+F:	drivers/iio/frequency/admv1014.c
+
 ANALOG DEVICES INC ADP5061 DRIVER
 M:	Michael Hennerich <[email protected]>
 L:	[email protected]
Signature · 1 line
2.34.1
maintainer
#7 lore raw
In reply to Antoniu Miclaus
Quoted 6 lines · On Wed, 19 Jan 2022 10:18:35 +0200 Antoniu Miclaus…

The ADMV1014 is a silicon germanium (SiGe), wideband, microwave downconverter optimized for point to point microwave radio designs operating in the 24 GHz to 44 GHz frequency range.

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADMV1014.pdf

Hi Antoniu,

This looks mostly fine to me, but I think you haven't quite understood the difference between a required regulator and an optional one. It's about whether there is power needed on the pin. E.g. sometimes for things like reference voltages we can use either an external voltage or an internally generated reference, thus making vref-supply optional. It's not about whether they 'need' to be specified in DT. The regulator core has a concept of a dummy regulator which is provided in some cases when we request a regulator and one is not specified. This is a simplification to allow for always on supplies without fully describing them. That fallback is what should be relied on, not optional regulators unless they really are.

Once you've made most (maybe all?) of the regulators in here non optional you can use the bulk get / enable regulator calls to cut down on repetition.

Thanks,

Jonathan

...

Quoted 19 lines
drivers/iio/frequency/admv1014.c new file +19 -0
+static int admv1014_init(struct admv1014_state *st)
+{
+	int ret;
+	unsigned int chip_id, enable_reg, enable_reg_msk;
+	struct spi_device *spi = st->spi;
+
+	ret = regulator_enable(st->vcm_reg);
+	if (ret) {
+		dev_err(&spi->dev, "Failed to enable Common-Mode Voltage!\n");
+		return ret;
+	}
+
+	ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->vcm_reg);
+	if (ret)
+		return ret;
+
+	if (st->vcc_if_bb_reg) {
+		ret = regulator_enable(st->vcc_if_bb_reg);
+		if (ret) {

drivers/iio/frequency/admv1014.c line 636

Quoted 10 lines
drivers/iio/frequency/admv1014.c new file +10 -0
+			dev_err(&spi->dev, "Failed to enable BB and IF Voltage!\n");
+			return ret;
+		}
+
+		ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->vcc_if_bb_reg);
+		if (ret)
+			return ret;
+	}
+
+	if (st->vcc_vga_reg) {

I'm fairly sure these should not be optional regs (they may be dummy ones provided by the regulator subsystem) so we should always enable them.

As below, you should be able to use bulk regulator handling for all of these.

Quoted 194 lines
drivers/iio/frequency/admv1014.c new file +194 -0
+		ret = regulator_enable(st->vcc_vga_reg);
+		if (ret) {
+			dev_err(&spi->dev, "Failed to enable RF Amplifier Voltage!\n");
+			return ret;
+		}
+
+		ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->vcc_vga_reg);
+		if (ret)
+			return ret;
+	}
+
+	if (st->vcc_vva_reg) {
+		ret = regulator_enable(st->vcc_vva_reg);
+		if (ret) {
+			dev_err(&spi->dev, "Failed to enable VVA Control Circuit Voltage!\n");
+			return ret;
+		}
+
+		ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->vcc_vva_reg);
+		if (ret)
+			return ret;
+	}
+
+	if (st->vcc_lna_3p3_reg) {
+		ret = regulator_enable(st->vcc_lna_3p3_reg);
+		if (ret) {
+			dev_err(&spi->dev, "Failed to enable Low Noise Amplifier 3.3V Voltage!\n");
+			return ret;
+		}
+
+		ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->vcc_lna_3p3_reg);
+		if (ret)
+			return ret;
+	}
+
+	if (st->vcc_lna_1p5_reg) {
+		ret = regulator_enable(st->vcc_lna_1p5_reg);
+		if (ret) {
+			dev_err(&spi->dev, "Failed to enable Low Noise Amplifier 1.5V Voltage!\n");
+			return ret;
+		}
+
+		ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->vcc_lna_1p5_reg);
+		if (ret)
+			return ret;
+	}
+
+	if (st->vcc_bg_reg) {
+		ret = regulator_enable(st->vcc_bg_reg);
+		if (ret) {
+			dev_err(&spi->dev, "Failed to enable Band Gap Circuit Voltage!\n");
+			return ret;
+		}
+
+		ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->vcc_bg_reg);
+		if (ret)
+			return ret;
+	}
+
+	if (st->vcc_quad_reg) {
+		ret = regulator_enable(st->vcc_quad_reg);
+		if (ret) {
+			dev_err(&spi->dev, "Failed to enable Quadruple Voltage!\n");
+			return ret;
+		}
+
+		ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->vcc_quad_reg);
+		if (ret)
+			return ret;
+	}
+
+	if (st->vcc_mixer_reg) {
+		ret = regulator_enable(st->vcc_mixer_reg);
+		if (ret) {
+			dev_err(&spi->dev, "Failed to enable Mixer Voltage!\n");
+			return ret;
+		}
+
+		ret = devm_add_action_or_reset(&spi->dev, admv1014_reg_disable, st->vcc_mixer_reg);
+		if (ret)
+			return ret;
+	}
+
+	ret = clk_prepare_enable(st->clkin);
+	if (ret)
+		return ret;
+
+	ret = devm_add_action_or_reset(&spi->dev, admv1014_clk_disable, st->clkin);
+	if (ret)
+		return ret;
+
+	st->nb.notifier_call = admv1014_freq_change;
+	ret = devm_clk_notifier_register(&spi->dev, st->clkin, &st->nb);
+	if (ret)
+		return ret;
+
+	ret = devm_add_action_or_reset(&spi->dev, admv1014_powerdown, st);
+	if (ret)
+		return ret;
+
+	/* Perform a software reset */
+	ret = __admv1014_spi_update_bits(st, ADMV1014_REG_SPI_CONTROL,
+					 ADMV1014_SPI_SOFT_RESET_MSK,
+					 FIELD_PREP(ADMV1014_SPI_SOFT_RESET_MSK, 1));
+	if (ret) {
+		dev_err(&spi->dev, "ADMV1014 SPI software reset failed.\n");
+		return ret;
+	}
+
+	ret = __admv1014_spi_update_bits(st, ADMV1014_REG_SPI_CONTROL,
+					 ADMV1014_SPI_SOFT_RESET_MSK,
+					 FIELD_PREP(ADMV1014_SPI_SOFT_RESET_MSK, 0));
+	if (ret) {
+		dev_err(&spi->dev, "ADMV1014 SPI software reset disable failed.\n");
+		return ret;
+	}
+
+	ret = __admv1014_spi_write(st, ADMV1014_REG_VVA_TEMP_COMP, 0x727C);
+	if (ret) {
+		dev_err(&spi->dev, "Writing default Temperature Compensation value failed.\n");
+		return ret;
+	}
+
+	ret = __admv1014_spi_read(st, ADMV1014_REG_SPI_CONTROL, &chip_id);
+	if (ret)
+		return ret;
+
+	chip_id = (chip_id & ADMV1014_CHIP_ID_MSK) >> 4;
+	if (chip_id != ADMV1014_CHIP_ID) {
+		dev_err(&spi->dev, "Invalid Chip ID.\n");
+		return -EINVAL;
+	}
+
+	ret = __admv1014_spi_update_bits(st, ADMV1014_REG_QUAD,
+					 ADMV1014_QUAD_SE_MODE_MSK,
+					 FIELD_PREP(ADMV1014_QUAD_SE_MODE_MSK,
+						    st->quad_se_mode));
+	if (ret) {
+		dev_err(&spi->dev, "Writing Quad SE Mode failed.\n");
+		return ret;
+	}
+
+	ret = admv1014_update_quad_filters(st);
+	if (ret) {
+		dev_err(&spi->dev, "Update Quad Filters failed.\n");
+		return ret;
+	}
+
+	ret = admv1014_update_vcm_settings(st);
+	if (ret) {
+		dev_err(&spi->dev, "Update VCM Settings failed.\n");
+		return ret;
+	}
+
+	enable_reg_msk = ADMV1014_P1DB_COMPENSATION_MSK |
+			 ADMV1014_IF_AMP_PD_MSK |
+			 ADMV1014_BB_AMP_PD_MSK |
+			 ADMV1014_DET_EN_MSK;
+
+	enable_reg = FIELD_PREP(ADMV1014_P1DB_COMPENSATION_MSK, st->p1db_comp ? 3 : 0) |
+		     FIELD_PREP(ADMV1014_IF_AMP_PD_MSK, !(st->input_mode)) |
+		     FIELD_PREP(ADMV1014_BB_AMP_PD_MSK, st->input_mode) |
+		     FIELD_PREP(ADMV1014_DET_EN_MSK, st->det_en);
+
+	return __admv1014_spi_update_bits(st, ADMV1014_REG_ENABLE, enable_reg_msk, enable_reg);
+}
+
+static int admv1014_properties_parse(struct admv1014_state *st)
+{
+	const char *str;
+	struct spi_device *spi = st->spi;
+
+	st->det_en = device_property_read_bool(&spi->dev, "adi,detector-enable");
+
+	st->p1db_comp = device_property_read_bool(&spi->dev, "adi,p1db-compensation-enable");
+
+	str = "iq";
+	device_property_read_string(&spi->dev, "adi,input-mode", &str);
+
+	if (!strcmp(str, "iq"))
+		st->input_mode = ADMV1014_IQ_MODE;
+	else if (!strcmp(str, "if"))
+		st->input_mode = ADMV1014_IF_MODE;
+	else
+		return -EINVAL;
+
+	str = "diff";
+	device_property_read_string(&spi->dev, "adi,quad-se-mode", &str);
+
+	if (!strcmp(str, "diff"))
+		st->quad_se_mode = ADMV1014_SE_MODE_DIFF;
+	else if (!strcmp(str, "se-pos"))
+		st->quad_se_mode = ADMV1014_SE_MODE_POS;
+	else if (!strcmp(str, "se-neg"))

drivers/iio/frequency/admv1014.c line 840

Quoted 10 lines
drivers/iio/frequency/admv1014.c new file +10 -0
+		st->quad_se_mode = ADMV1014_SE_MODE_NEG;
+	else
+		return -EINVAL;
+
+	st->vcm_reg = devm_regulator_get(&spi->dev, "vcm");
+	if (IS_ERR(st->vcm_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->vcm_reg),
+				     "failed to get the common-mode voltage\n");
+
+	st->vcc_if_bb_reg = devm_regulator_get_optional(&spi->dev, "vcc-if-bb");

Are these actually optional? That means we can operate the device in a mode where it doesn't matter if there is power on this pin... It doesn't mean we have to specify them in DT, because they may be always on supplies in which case a dummy regulator is fine (which is what you get from devm_regulator_get() under some circumstances when one isn't specified).

Having made those that aren't actually optional, non optional you can probably use the bulk regulator controls to avoid lots of identical calls.

Quoted 47 lines
drivers/iio/frequency/admv1014.c new file +47 -0
+	if (IS_ERR(st->vcc_if_bb_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->vcc_if_bb_reg),
+				     "failed to get the BB and IF supply\n");
+
+	st->vcc_vga_reg = devm_regulator_get_optional(&spi->dev, "vcc-vga");
+	if (IS_ERR(st->vcc_vga_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->vcc_vga_reg),
+				     "failed to get the RF Amplifier supply\n");
+
+	st->vcc_vva_reg = devm_regulator_get_optional(&spi->dev, "vcc-vva");
+	if (IS_ERR(st->vcc_vva_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->vcc_vva_reg),
+				     "failed to get the VVA Control Circuit supply\n");
+
+	st->vcc_lna_3p3_reg = devm_regulator_get_optional(&spi->dev, "vcc-lna-3p3");
+	if (IS_ERR(st->vcc_lna_3p3_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->vcc_lna_3p3_reg),
+				     "failed to get the Low Noise Amplifier 3.3V supply\n");
+
+	st->vcc_lna_1p5_reg = devm_regulator_get_optional(&spi->dev, "vcc-lna-1p5");
+	if (IS_ERR(st->vcc_lna_1p5_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->vcc_lna_1p5_reg),
+				     "failed to get the Low Noise Amplifier 1.5V supply\n");
+
+	st->vcc_bg_reg = devm_regulator_get_optional(&spi->dev, "vcc-bg");
+	if (IS_ERR(st->vcc_lna_1p5_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->vcc_bg_reg),
+				     "failed to get the Band Gap Circuit supply\n");
+
+	st->vcc_quad_reg = devm_regulator_get_optional(&spi->dev, "vcc-quad");
+	if (IS_ERR(st->vcc_quad_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->vcc_quad_reg),
+				     "failed to get the Quadruple supply\n");
+
+	st->vcc_mixer_reg = devm_regulator_get_optional(&spi->dev, "vcc-mixer");
+	if (IS_ERR(st->vcc_quad_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->vcc_mixer_reg),
+				     "failed to get the Mixer supply\n");
+
+	st->clkin = devm_clk_get(&spi->dev, "lo_in");
+	if (IS_ERR(st->clkin))
+		return dev_err_probe(&spi->dev, PTR_ERR(st->clkin),
+				     "failed to get the LO input clock\n");
+
+	return 0;
+}
+