From: Antoniu Miclaus <antoniu.miclaus@analog.com>
To: "Nuno Sá" <nuno.sa@analog.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
"Joshua Crofts" <joshua.crofts1@gmail.com>,
"Radu Sabau" <radu.sabau@analog.com>,
"Janani Sunil" <janani.sunil@analog.com>,
"Salih Erim" <salih.erim@amd.com>,
"Jishnu Prakash" <jishnu.prakash@oss.qualcomm.com>,
"Jakub Szczudlo" <jakubszczudlo40@gmail.com>,
linux@analog.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: [PATCH 1/4] iio: adc: ade9000: parameterise the reactive power channel
Date: Mon, 12 Oct 2026 14:13:37 +0300 [thread overview]
Message-ID: <20261012111342.48040-2-antoniu.miclaus@analog.com> (raw)
In-Reply-To: <20261012111342.48040-1-antoniu.miclaus@analog.com>
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.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/adc/ade9000.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
index e0113b62a261..03b69556b62f 100644
--- a/drivers/iio/adc/ade9000.c
+++ b/drivers/iio/adc/ade9000.c
@@ -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
--
2.43.0
next prev parent reply other threads:[~2026-10-12 11:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 11:13 [PATCH 0/4] iio: adc: ade9000: add support for ADE9039 Antoniu Miclaus
2026-10-12 11:13 ` Antoniu Miclaus [this message]
2026-10-12 13:51 ` [PATCH 1/4] iio: adc: ade9000: parameterise the reactive power channel Joshua Crofts
2026-10-12 11:13 ` [PATCH 2/4] dt-bindings: iio: adc: adi,ade9000: add adi,ade9039 compatible Antoniu Miclaus
2026-10-12 13:46 ` Joshua Crofts
2026-10-12 18:59 ` Conor Dooley
2026-10-12 11:13 ` [PATCH 3/4] iio: adc: ade9000: add support for ADE9039 Antoniu Miclaus
2026-10-12 13:50 ` Joshua Crofts
2026-10-12 11:13 ` [PATCH 4/4] docs: iio: ade9000: document ADE9039 support Antoniu Miclaus
2026-10-12 13:49 ` Joshua Crofts
2026-10-13 9:51 ` [PATCH 0/4] iio: adc: ade9000: add support for ADE9039 Nuno Sá
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261012111342.48040-2-antoniu.miclaus@analog.com \
--to=antoniu.miclaus@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jakubszczudlo40@gmail.com \
--cc=janani.sunil@analog.com \
--cc=jic23@kernel.org \
--cc=jishnu.prakash@oss.qualcomm.com \
--cc=joshua.crofts1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=marcelo.schmitt@analog.com \
--cc=nuno.sa@analog.com \
--cc=radu.sabau@analog.com \
--cc=rdunlap@infradead.org \
--cc=robh@kernel.org \
--cc=salih.erim@amd.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®