Skip to contentSkip to conversation

iio: adc: ade9000: add support for ADE9039

PATCH In review Antoniu Miclaus 2 participants 6 messages Oct 22 – Oct 26

Subsystems (5)
lore
Share & tools
lore

Antoniu Miclaus

author maintainer
#0 lore raw

v2 cover iio: adc: ade9000: add support for ADE9039

Add support for the ADE9039, a polyphase energy monitoring device in the ADE9000 family. It is register compatible with the ADE9000 for every register the driver touches. The differences that matter here are:

- full-scale codes match the ADE9078, not the ADE9000;
- dip/swell detection and the digital integrator are both present;
- there is no total reactive power: no AVAR at 0x211, no AVAROS at 0x010, only the fundamental AFVAR and AFVAROS;
- maximum SPI clock is 10 MHz, as on the ADE9078.

It is the first part needing dip/swell present together with total reactive power absent, which the channel-array macro could not express. Patch 1 adds a second selector argument for the reactive power entry; it is a no-op for the existing parts, with the preprocessed ade9000_channels and ade9078_channels tables byte identical before and after.

The missing total reactive power channel is omitted rather than repointed at AFVAR, which would make in_power[0-2]_reactive_raw mean total power on the ADE9000 and fundamental power on the ADE9039 with no IIO modifier to tell them apart. The fundamental reactive energy channels are unaffected.

Changes in v2:
- List the ADE9039 in numeric part order everywhere it appears: the binding title, description and datasheet links, the driver's channel declarations, chip_info definitions, SPI and OF ID tables and Kconfig help text, and the documentation title and datasheet links.
- Spell out in patch 2 why a fallback to adi,ade9000 is not usable for this part.
- Turn the ade9000.rst introduction into a bullet list so that adding the next part to the family does not reflow the paragraph.
- Picked up the review tags from v1.

v1: https://lore.kernel.org/linux-iio/[email protected]/

Antoniu Miclaus (4):
iio: adc: ade9000: parameterise the reactive power channel
dt-bindings: iio: adc: adi,ade9000: add adi,ade9039 compatible
iio: adc: ade9000: add support for ADE9039
docs: iio: ade9000: document ADE9039 support

 .../bindings/iio/adc/adi,ade9000.yaml         | 29 ++++++++------
 Documentation/iio/ade9000.rst                 | 29 +++++++++-----
 drivers/iio/adc/Kconfig                       |  1 +
 drivers/iio/adc/ade9000.c                     | 39 ++++++++++++++++---
 4 files changed, 71 insertions(+), 27 deletions(-)

base-commit: 43ffda3c7f8456bbe641ae8249a077a361b97880

Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v2 1/4 iio: adc: ade9000: parameterise the reactive power channel

The channel array is declared once by ADE9000_DECLARE_CHANNELS() and specialised per part through the altvoltage_rms argument, which lets parts without dip/swell hardware drop those events. Some parts in the family do not compute total reactive power at all and have no AVAR register, so they need to drop the reactive power channel as well.

Add a second argument that selects the reactive power entry and introduce the ADE9000_POWER_REACTIVE_ENTRY()/ADE9000_NO_POWER_REACTIVE_ENTRY() pair for it. The entry macros include their own trailing comma so that the variant for parts lacking the register can expand to nothing.

No functional change: the preprocessed ade9000_channels and ade9078_channels tables are unchanged.

---
Changes in v2:
- None.

 drivers/iio/adc/ade9000.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/iio/adc/ade9000.c +19 -6
index c10b8c3f679c..fb69cbbb38fc 100644
@@ -561,6 +561,15 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = {
 	.scan_index = -1						\
 }
 
+/*
+ * The entry macros below carry their own trailing comma so that parts without
+ * a total reactive power register can expand to nothing.
+ */
+#define ADE9000_POWER_REACTIVE_ENTRY(num)				\
+	ADE9000_POWER_REACTIVE_CHANNEL(num),
+
+#define ADE9000_NO_POWER_REACTIVE_ENTRY(num)
+
 #define ADE9000_POWER_APPARENT_CHANNEL(num) {				\
 	.type = IIO_POWER,						\
 	.channel = num,							\
@@ -618,8 +627,10 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = {
 /*
  * Declare a full channel array. @altvoltage_rms picks the RMS voltage channel
  * variant so parts without dip/swell hardware (e.g. ADE9078) omit those events.
+ * @power_reactive picks the total reactive power entry so parts that only
+ * compute fundamental reactive power omit that channel.
  */
-#define ADE9000_DECLARE_CHANNELS(_name, altvoltage_rms)			      \
+#define ADE9000_DECLARE_CHANNELS(_name, altvoltage_rms, power_reactive)	      \
 	static const struct iio_chan_spec _name[] = {			      \
 		/* Phase A channels */					      \
 		ADE9000_CURRENT_CHANNEL(ADE9000_PHASE_A_NR),		      \
@@ -627,7 +638,7 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = {
 		ADE9000_ALTCURRENT_RMS_CHANNEL(ADE9000_PHASE_A_NR),	      \
 		altvoltage_rms(ADE9000_PHASE_A_NR),			      \
 		ADE9000_POWER_ACTIVE_CHANNEL(ADE9000_PHASE_A_NR),	      \
-		ADE9000_POWER_REACTIVE_CHANNEL(ADE9000_PHASE_A_NR),	      \
+		power_reactive(ADE9000_PHASE_A_NR)			      \
 		ADE9000_POWER_APPARENT_CHANNEL(ADE9000_PHASE_A_NR),	      \
 		ADE9000_ENERGY_ACTIVE_CHANNEL(ADE9000_PHASE_A_NR,	      \
 					      ADE9000_REG_AWATTHR_LO),	      \
@@ -642,7 +653,7 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = {
 		ADE9000_ALTCURRENT_RMS_CHANNEL(ADE9000_PHASE_B_NR),	      \
 		altvoltage_rms(ADE9000_PHASE_B_NR),			      \
 		ADE9000_POWER_ACTIVE_CHANNEL(ADE9000_PHASE_B_NR),	      \
-		ADE9000_POWER_REACTIVE_CHANNEL(ADE9000_PHASE_B_NR),	      \
+		power_reactive(ADE9000_PHASE_B_NR)			      \
 		ADE9000_POWER_APPARENT_CHANNEL(ADE9000_PHASE_B_NR),	      \
 		ADE9000_ENERGY_ACTIVE_CHANNEL(ADE9000_PHASE_B_NR,	      \
 					      ADE9000_REG_BWATTHR_LO),	      \
@@ -657,7 +668,7 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = {
 		ADE9000_ALTCURRENT_RMS_CHANNEL(ADE9000_PHASE_C_NR),	      \
 		altvoltage_rms(ADE9000_PHASE_C_NR),			      \
 		ADE9000_POWER_ACTIVE_CHANNEL(ADE9000_PHASE_C_NR),	      \
-		ADE9000_POWER_REACTIVE_CHANNEL(ADE9000_PHASE_C_NR),	      \
+		power_reactive(ADE9000_PHASE_C_NR)			      \
 		ADE9000_POWER_APPARENT_CHANNEL(ADE9000_PHASE_C_NR),	      \
 		ADE9000_ENERGY_ACTIVE_CHANNEL(ADE9000_PHASE_C_NR,	      \
 					      ADE9000_REG_CWATTHR_LO),	      \
@@ -668,8 +679,10 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = {
 		ADE9000_POWER_FACTOR_CHANNEL(ADE9000_PHASE_C_NR),	      \
 	}
 
-ADE9000_DECLARE_CHANNELS(ade9000_channels, ADE9000_ALTVOLTAGE_RMS_CHANNEL);
-ADE9000_DECLARE_CHANNELS(ade9078_channels, ADE9000_ALTVOLTAGE_RMS_CHANNEL_NO_EVENTS);
+ADE9000_DECLARE_CHANNELS(ade9000_channels, ADE9000_ALTVOLTAGE_RMS_CHANNEL,
+			 ADE9000_POWER_REACTIVE_ENTRY);
+ADE9000_DECLARE_CHANNELS(ade9078_channels, ADE9000_ALTVOLTAGE_RMS_CHANNEL_NO_EVENTS,
+			 ADE9000_POWER_REACTIVE_ENTRY);
 
 /*
  * Full-scale codes referred from the respective datasheets. These are the
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v2 2/4 dt-bindings: iio: adc: adi,ade9000: add adi,ade9039 compatible

In reply to Antoniu Miclaus

The ADE9039 is a polyphase energy metering device from the same family as the ADE9000. It is register compatible with the ADE9000 for everything the driver uses, provides the same on-chip dip/swell detection, and shares the full-scale codes of the ADE9078.

It is deliberately not given a fallback to adi,ade9000: the ADE9039 computes only fundamental reactive power and has no total reactive power register, so a driver matching on adi,ade9000 would expose total reactive power channels backed by a register the part does not implement. The difference is noted in the description.

Like the ADE9078 it supports a maximum serial clock frequency of 10 MHz rather than 20 MHz, so extend the existing spi-max-frequency constraint to cover it.

---
Changes in v2:
- Spell out in the commit message why a fallback to adi,ade9000 is not usable for this part.
- List the ADE9039 in numeric part order in the title, the description and the datasheet links.

 .../bindings/iio/adc/adi,ade9000.yaml         | 29 +++++++++++--------
 1 file changed, 17 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/iio/adc/adi,ade9000.yaml +17 -12
index bcc166aad713..580ced2730bc 100644
@@ -5,24 +5,26 @@
 $id: http://devicetree.org/schemas/iio/adc/adi,ade9000.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Analog Devices ADE9000/ADE9078/ADE9430 High Performance, Polyphase Energy Metering
+title: Analog Devices ADE9000/ADE9039/ADE9078/ADE9430 High Performance, Polyphase Energy Metering
 
 maintainers:
   - Antoniu Miclaus <[email protected]>
 
 description: |
-  The ADE9000, ADE9078 and ADE9430 are highly accurate, fully integrated,
-  multiphase energy and power quality monitoring devices. Superior analog
-  performance and a digital signal processing (DSP) core enable accurate energy
-  monitoring over a wide dynamic range. An integrated high end reference ensures
-  low drift over temperature with a combined drift of less than ±25 ppm/°C
-  maximum for the entire channel including a programmable gain amplifier (PGA)
-  and an analog-to-digital converter (ADC). The ADE9078 and ADE9430 do not
-  provide the on-chip dip/swell detection available on the ADE9000, and the
-  ADE9430 has no on-chip digital integrator (it uses an external analog
-  integrator for Rogowski coils).
+  The ADE9000, ADE9039, ADE9078 and ADE9430 are highly accurate, fully
+  integrated, multiphase energy and power quality monitoring devices. Superior
+  analog performance and a digital signal processing (DSP) core enable accurate
+  energy monitoring over a wide dynamic range. An integrated high end reference
+  ensures low drift over temperature with a combined drift of less than
+  ±25 ppm/°C maximum for the entire channel including a programmable gain
+  amplifier (PGA) and an analog-to-digital converter (ADC). The ADE9078 and
+  ADE9430 do not provide the on-chip dip/swell detection available on the
+  ADE9000 and the ADE9039, and the ADE9430 has no on-chip digital integrator
+  (it uses an external analog integrator for Rogowski coils). The ADE9039 only
+  computes fundamental reactive power and has no total reactive power register.
 
   https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9000.pdf
+  https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9039.pdf
   https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9078.pdf
   https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9430.pdf
 
@@ -32,6 +34,7 @@ properties:
   compatible:
     enum:
       - adi,ade9000
+      - adi,ade9039
       - adi,ade9078
       - adi,ade9430
 
@@ -79,7 +82,9 @@ allOf:
       properties:
         compatible:
           contains:
-            const: adi,ade9078
+            enum:
+              - adi,ade9039
+              - adi,ade9078
     then:
       properties:
         spi-max-frequency:
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v2 3/4 iio: adc: ade9000: add support for ADE9039

In reply to Antoniu Miclaus

The ADE9039 is a polyphase energy metering device that is register compatible with the ADE9000 for every register the driver touches. The differences relevant to the driver are that it shares the full-scale codes of the ADE9078 rather than those of the ADE9000, and that it has no total reactive power register: the register map has no AVAR at 0x211 and no AVAROS at 0x010, only the fundamental AFVAR and AFVAROS.

Add a chip_info for it and a channel table that keeps the dip/swell events of the ADE9000 but drops the three total reactive power channels. The fundamental reactive energy channels are unaffected, as AFVARHR is present.

No change is needed in the CALIBBIAS path: with no channel carrying the AVAR address, that case is simply never reached for this part.

---
Changes in v2:
- List the ADE9039 in numeric part order in the channel declarations, the chip_info definitions, the SPI and OF ID tables and the Kconfig help text.

 drivers/iio/adc/Kconfig   |  1 +
 drivers/iio/adc/ade9000.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
drivers/iio/adc/Kconfig +1 -0
index 02de4809ae31..238957243476 100644
@@ -601,6 +601,7 @@ config ADE9000
 	  highly accurate, multiphase energy and power quality monitoring
 	  integrated circuits:
 	    - ADE9000
+	    - ADE9039
 	    - ADE9078
 	    - ADE9430
 
drivers/iio/adc/ade9000.c +14 -0
index fb69cbbb38fc..b7a29d6b09fc 100644
@@ -681,6 +681,8 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = {
 
 ADE9000_DECLARE_CHANNELS(ade9000_channels, ADE9000_ALTVOLTAGE_RMS_CHANNEL,
 			 ADE9000_POWER_REACTIVE_ENTRY);
+ADE9000_DECLARE_CHANNELS(ade9039_channels, ADE9000_ALTVOLTAGE_RMS_CHANNEL,
+			 ADE9000_NO_POWER_REACTIVE_ENTRY);
 ADE9000_DECLARE_CHANNELS(ade9078_channels, ADE9000_ALTVOLTAGE_RMS_CHANNEL_NO_EVENTS,
 			 ADE9000_POWER_REACTIVE_ENTRY);
 
@@ -698,6 +700,16 @@ static const struct ade9000_chip_info ade9000_chip_info = {
 	.has_digital_integrator = true,
 };
 
+static const struct ade9000_chip_info ade9039_chip_info = {
+	.name = "ade9039",
+	.channels = ade9039_channels,
+	.num_channels = ARRAY_SIZE(ade9039_channels),
+	.rms_full_scale_codes = 52866837,
+	.watt_full_scale_codes = 20823646,
+	.pcf_full_scale_codes = 74680000,
+	.has_digital_integrator = true,
+};
+
 static const struct ade9000_chip_info ade9078_chip_info = {
 	.name = "ade9078",
 	.channels = ade9078_channels,
@@ -1883,6 +1895,7 @@ static int ade9000_probe(struct spi_device *spi)
 
 static const struct spi_device_id ade9000_id[] = {
 	{ .name = "ade9000", .driver_data = (kernel_ulong_t)&ade9000_chip_info },
+	{ .name = "ade9039", .driver_data = (kernel_ulong_t)&ade9039_chip_info },
 	{ .name = "ade9078", .driver_data = (kernel_ulong_t)&ade9078_chip_info },
 	{ .name = "ade9430", .driver_data = (kernel_ulong_t)&ade9430_chip_info },
 	{ }
@@ -1891,6 +1904,7 @@ MODULE_DEVICE_TABLE(spi, ade9000_id);
 
 static const struct of_device_id ade9000_of_match[] = {
 	{ .compatible = "adi,ade9000", .data = &ade9000_chip_info },
+	{ .compatible = "adi,ade9039", .data = &ade9039_chip_info },
 	{ .compatible = "adi,ade9078", .data = &ade9078_chip_info },
 	{ .compatible = "adi,ade9430", .data = &ade9430_chip_info },
 	{ }
Signature · 1 line
2.43.0
author maintainer
#4 lore raw

PATCH v2 4/4 docs: iio: ade9000: document ADE9039 support

In reply to Antoniu Miclaus

Add the ADE9039 to the list of supported devices and note that, unlike the ADE9078 and ADE9430, it does provide the on-chip dip/swell events. Also document that it exposes no total reactive power attributes, since the part computes only fundamental reactive power.

Turn the intro enumeration into a bullet list so that adding the next part to the family does not reflow the paragraph.

---
Changes in v2:
- List the ADE9039 in numeric part order in the title and the datasheet links.
- Turn the introduction into a bullet list so that adding the next part to the family does not reflow the paragraph.

 Documentation/iio/ade9000.rst | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)
Documentation/iio/ade9000.rst +20 -9
index 0c0a8ea8213b..893166f5fc32 100644
@@ -1,17 +1,22 @@
 .. SPDX-License-Identifier: GPL-2.0
 
-==============================
-ADE9000/ADE9078/ADE9430 driver
-==============================
+======================================
+ADE9000/ADE9039/ADE9078/ADE9430 driver
+======================================
 
-+This driver supports Analog Devices' ADE9000, ADE9078 and ADE9430 energy
-+measurement ICs on SPI bus.
-ICs on SPI bus.
+This driver supports the following Analog Devices energy measurement ICs on
+SPI bus:
+
+* ADE9000
+* ADE9039
+* ADE9078
+* ADE9430
 
 1. Supported devices
 ====================
 
 * `ADE9000 <https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9000.pdf>`_
+* `ADE9039 <https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9039.pdf>`_
 * `ADE9078 <https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9078.pdf>`_
 * `ADE9430 <https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9430.pdf>`_
 
@@ -24,9 +29,15 @@ for the entire channel including a programmable gain amplifier (PGA) and an
 analog-to-digital converter (ADC).
 
 The ADE9078 and ADE9430 do not provide the on-chip dip/swell (sag) detection
-available on the ADE9000, so the RMS voltage swell/dip events described below are
-only available on the ADE9000. The ADE9430 additionally has no on-chip digital
-integrator and instead uses an external analog integrator for Rogowski coils.
+available on the ADE9000 and the ADE9039, so the RMS voltage swell/dip events
+described below are only available on those two parts. The ADE9430 additionally
+has no on-chip digital integrator and instead uses an external analog integrator
+for Rogowski coils.
+
+The ADE9039 computes only fundamental reactive power and has no total reactive
+power register, so the ``in_power[0-2]_reactive_*`` files described below are
+not present on that part. The reactive energy files are unaffected, as every
+supported part accumulates fundamental reactive energy.
 
 2. Device attributes
 ====================
Signature · 1 line
2.43.0
maintainer
#5 lore raw
In reply to Antoniu Miclaus
Quoted 9 lines · On Thu, 22 Oct 2026 14:17:53 +0300 Antoniu Miclaus…

Add support for the ADE9039, a polyphase energy monitoring device in the ADE9000 family. It is register compatible with the ADE9000 for every register the driver touches. The differences that matter here are:

- full-scale codes match the ADE9078, not the ADE9000;
- dip/swell detection and the digital integrator are both present;
- there is no total reactive power: no AVAR at 0x211, no AVAROS at 0x010, only the fundamental AFVAR and AFVAROS;
- maximum SPI clock is 10 MHz, as on the ADE9078.

Other than missing Nuno's tag as given for v1 (I added that by hand), this looks good to me.

Applied to the testing branch of iio.git

thanks,

Jonathan