From: Antoniu Miclaus <antoniu.miclaus@analog.com>
To: "Antoniu Miclaus" <antoniu.miclaus@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Michael Hennerich" <Michael.Hennerich@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>,
"Salih Erim" <salih.erim@amd.com>,
"Jishnu Prakash" <jishnu.prakash@oss.qualcomm.com>,
"Jakub Szczudlo" <jakubszczudlo40@gmail.com>,
linux-iio@vger.kernel.org, linux@analog.com,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: [PATCH v2 4/6] iio: adc: ade9000: gate the DICOEFF write behind a chip_info flag
Date: Fri, 18 Sep 2026 10:35:33 +0300 [thread overview]
Message-ID: <20260918073537.1572-5-antoniu.miclaus@analog.com> (raw)
In-Reply-To: <20260918073537.1572-1-antoniu.miclaus@analog.com>
Some parts in the ADE9000 family have no on-chip digital integrator and
therefore lack the DICOEFF register; they use an external analog integrator
for Rogowski coil current sensors. Prepare for such parts by adding a
has_digital_integrator flag to the chip_info and only writing DICOEFF when
it is set.
Move the DICOEFF and RUN writes out of the shared initialization sequence
into ade9000_setup() so DICOEFF can be issued conditionally while RUN still
starts the DSP afterwards. All currently supported parts set the flag, so
there is no functional change.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
Changes in v2:
- new precursor patch, split out of the ADE9430 support patch.
drivers/iio/adc/ade9000.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
index ce0317766698..0167d5bcdb74 100644
--- a/drivers/iio/adc/ade9000.c
+++ b/drivers/iio/adc/ade9000.c
@@ -290,6 +290,7 @@ enum ade9000_wfb_cfg {
* @rms_full_scale_codes: digital code produced at full-scale RMS input
* @watt_full_scale_codes: digital code produced at full-scale power input
* @pcf_full_scale_codes: digital code produced at full-scale xI_PCF/xV_PCF input
+ * @has_digital_integrator: part has an on-chip digital integrator (DICOEFF)
*
* The full-scale codes are taken from the respective datasheets and are used to
* derive the IIO scale of the raw measurement channels.
@@ -301,6 +302,7 @@ struct ade9000_chip_info {
unsigned int rms_full_scale_codes;
unsigned int watt_full_scale_codes;
unsigned int pcf_full_scale_codes;
+ bool has_digital_integrator;
};
struct ade9000_state {
@@ -680,6 +682,7 @@ static const struct ade9000_chip_info ade9000_chip_info = {
.rms_full_scale_codes = 52702092,
.watt_full_scale_codes = 20694066,
.pcf_full_scale_codes = 74532013,
+ .has_digital_integrator = true,
};
static const struct ade9000_chip_info ade9078_chip_info = {
@@ -689,6 +692,7 @@ static const struct ade9000_chip_info ade9078_chip_info = {
.rms_full_scale_codes = 52866837,
.watt_full_scale_codes = 20823646,
.pcf_full_scale_codes = 74680000,
+ .has_digital_integrator = true,
};
static const struct reg_sequence ade9000_initialization_sequence[] = {
@@ -704,13 +708,11 @@ static const struct reg_sequence ade9000_initialization_sequence[] = {
{ ADE9000_REG_EVENT_MASK, ADE9000_EVENT_DISABLE },
{ ADE9000_REG_WFB_CFG, ADE9000_WFB_CFG },
{ ADE9000_REG_VLEVEL, ADE9000_VLEVEL },
- { ADE9000_REG_DICOEFF, ADE9000_DICOEFF },
{ ADE9000_REG_EGY_TIME, ADE9000_EGY_TIME },
{ ADE9000_REG_EP_CFG, ADE9000_EP_CFG },
/* Clear all pending status bits by writing 1s */
{ ADE9000_REG_STATUS0, GENMASK(31, 0) },
{ ADE9000_REG_STATUS1, GENMASK(31, 0) },
- { ADE9000_REG_RUN, ADE9000_RUN_ON }
};
static int ade9000_spi_write_reg(void *context, unsigned int reg,
@@ -1672,6 +1674,21 @@ static int ade9000_setup(struct ade9000_state *st)
if (ret)
return dev_err_probe(dev, ret, "Failed to write register sequence");
+ /*
+ * DICOEFF must be configured before the DSP is started. Parts without
+ * an on-chip digital integrator lack this register, so skip it there.
+ */
+ if (st->info->has_digital_integrator) {
+ ret = regmap_write(st->regmap, ADE9000_REG_DICOEFF,
+ ADE9000_DICOEFF);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to set DICOEFF\n");
+ }
+
+ ret = regmap_write(st->regmap, ADE9000_REG_RUN, ADE9000_RUN_ON);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to start DSP\n");
+
fsleep(2000);
return 0;
--
2.43.0
next prev parent reply other threads:[~2026-09-18 7:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 7:35 [PATCH v2 0/6] iio: adc: ade9000: add ADE9430 support Antoniu Miclaus
2026-09-18 7:35 ` [PATCH v2 1/6] iio: adc: ade9000: fix ADE9000 full-scale RMS and PCF codes Antoniu Miclaus
2026-09-18 7:35 ` [PATCH v2 2/6] iio: adc: ade9000: fix DIPC event never being handled or cleared Antoniu Miclaus
2026-09-18 7:35 ` [PATCH v2 3/6] dt-bindings: iio: adc: adi,ade9000: add adi,ade9430 compatible Antoniu Miclaus
2026-09-18 7:35 ` Antoniu Miclaus [this message]
2026-09-18 7:35 ` [PATCH v2 5/6] iio: adc: ade9000: add support for ADE9430 Antoniu Miclaus
2026-09-18 7:35 ` [PATCH v2 6/6] docs: iio: ade9000: document ADE9430 support Antoniu Miclaus
2026-09-18 15:27 ` [PATCH v2 0/6] iio: adc: ade9000: add " 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=20260918073537.1572-5-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=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®