* [PATCH 0/3] iio: adc: ade9000: series of probe and channel fixes
@ 2026-08-07 8:56 Antoniu Miclaus
2026-08-07 8:56 ` [PATCH 1/3] iio: adc: ade9000: request interrupts after powering the device Antoniu Miclaus
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Antoniu Miclaus @ 2026-08-07 8:56 UTC (permalink / raw)
To: Antoniu Miclaus, Nuno Sá, Michael Hennerich,
Jonathan Cameron, David Lechner, linux-iio, linux, linux-kernel
This series fixes three issues in the ade9000 driver, all present since
the driver was added.
Patch 1 moves the interrupt requests after the vdd regulator is enabled,
so an early interrupt no longer runs a handler doing SPI accesses against
an unpowered chip.
Patch 2 corrects the overlapping scan_index values for the current and
voltage channels, which caused the Phase B and C waveform buffers to be
configured incorrectly.
Patch 3 fixes the STATUS1 event scan bound so that Phase C dip events
(bit 25) are actually reported.
Antoniu Miclaus (3):
iio: adc: ade9000: request interrupts after powering the device
iio: adc: ade9000: fix overlapping scan_index for current and voltage
channels
iio: adc: ade9000: handle Phase C dip events in IRQ1 handler
drivers/iio/adc/ade9000.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] iio: adc: ade9000: request interrupts after powering the device
2026-08-07 8:56 [PATCH 0/3] iio: adc: ade9000: series of probe and channel fixes Antoniu Miclaus
@ 2026-08-07 8:56 ` Antoniu Miclaus
2026-08-07 10:37 ` Joshua Crofts
2026-08-07 8:56 ` [PATCH 2/3] iio: adc: ade9000: fix overlapping scan_index for current and voltage channels Antoniu Miclaus
2026-08-07 8:56 ` [PATCH 3/3] iio: adc: ade9000: handle Phase C dip events in IRQ1 handler Antoniu Miclaus
2 siblings, 1 reply; 5+ messages in thread
From: Antoniu Miclaus @ 2026-08-07 8:56 UTC (permalink / raw)
To: Antoniu Miclaus, Nuno Sá, Michael Hennerich,
Jonathan Cameron, David Lechner, linux-iio, linux, linux-kernel
The IRQ handlers do SPI register accesses, but the interrupts were
requested before the vdd regulator was enabled. An interrupt arriving
while the chip is unpowered runs a handler against a dead chip, causing
SPI errors or garbage reads.
Request the interrupts after enabling the regulator. This keeps irq1
registered before ade9000_reset(), which waits on it, and lets devm free
the interrupts before the regulator is disabled.
Fixes: 81de7b4619fc ("iio: adc: add ade9000 support")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/adc/ade9000.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
index c6c3ea953fea..51cb43755a1f 100644
--- a/drivers/iio/adc/ade9000.c
+++ b/drivers/iio/adc/ade9000.c
@@ -1705,18 +1705,6 @@ static int ade9000_probe(struct spi_device *spi)
if (ret)
return ret;
- ret = ade9000_request_irq(dev, "irq0", ade9000_irq0_thread, indio_dev);
- if (ret)
- return ret;
-
- ret = ade9000_request_irq(dev, "irq1", ade9000_irq1_thread, indio_dev);
- if (ret)
- return ret;
-
- ret = ade9000_request_irq(dev, "dready", ade9000_dready_thread, indio_dev);
- if (ret)
- return ret;
-
/* External CMOS clock input (optional - crystal can be used instead) */
st->clkin = devm_clk_get_optional_enabled(dev, NULL);
if (IS_ERR(st->clkin))
@@ -1736,6 +1724,19 @@ static int ade9000_probe(struct spi_device *spi)
return dev_err_probe(&spi->dev, ret,
"Failed to get and enable vdd regulator\n");
+ /* Request IRQs only after powering the chip; the handlers do SPI access. */
+ ret = ade9000_request_irq(dev, "irq0", ade9000_irq0_thread, indio_dev);
+ if (ret)
+ return ret;
+
+ ret = ade9000_request_irq(dev, "irq1", ade9000_irq1_thread, indio_dev);
+ if (ret)
+ return ret;
+
+ ret = ade9000_request_irq(dev, "dready", ade9000_dready_thread, indio_dev);
+ if (ret)
+ return ret;
+
indio_dev->channels = ade9000_channels;
indio_dev->num_channels = ARRAY_SIZE(ade9000_channels);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] iio: adc: ade9000: fix overlapping scan_index for current and voltage channels
2026-08-07 8:56 [PATCH 0/3] iio: adc: ade9000: series of probe and channel fixes Antoniu Miclaus
2026-08-07 8:56 ` [PATCH 1/3] iio: adc: ade9000: request interrupts after powering the device Antoniu Miclaus
@ 2026-08-07 8:56 ` Antoniu Miclaus
2026-08-07 8:56 ` [PATCH 3/3] iio: adc: ade9000: handle Phase C dip events in IRQ1 handler Antoniu Miclaus
2 siblings, 0 replies; 5+ messages in thread
From: Antoniu Miclaus @ 2026-08-07 8:56 UTC (permalink / raw)
To: Antoniu Miclaus, Nuno Sá, Michael Hennerich,
Jonathan Cameron, David Lechner, linux-iio, linux, linux-kernel
Current channels used scan_index "num" and voltage "num + 1", so with
phases 0, 1 and 2 the indices overlapped and no longer matched the
IA=0, VA=1, IB=2, VB=3, IC=4, VC=5 layout expected by
ade9000_waveform_buffer_config(). Phase B and C buffers were configured
incorrectly.
Use "num * 2" for current and "num * 2 + 1" for voltage to get the
non-overlapping 0/1, 2/3, 4/5 layout.
Fixes: 81de7b4619fc ("iio: adc: add ade9000 support")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/adc/ade9000.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
index 51cb43755a1f..167b1f4d6279 100644
--- a/drivers/iio/adc/ade9000.c
+++ b/drivers/iio/adc/ade9000.c
@@ -444,7 +444,7 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = {
BIT(IIO_CHAN_INFO_CALIBSCALE), \
.event_spec = ade9000_current_events, \
.num_event_specs = ARRAY_SIZE(ade9000_current_events), \
- .scan_index = num, \
+ .scan_index = num * 2, \
.indexed = 1, \
.scan_type = { \
.sign = 's', \
@@ -464,7 +464,7 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = {
BIT(IIO_CHAN_INFO_FREQUENCY), \
.event_spec = ade9000_voltage_events, \
.num_event_specs = ARRAY_SIZE(ade9000_voltage_events), \
- .scan_index = num + 1, /* interleave with current channels */ \
+ .scan_index = num * 2 + 1, /* interleave with current channels */ \
.indexed = 1, \
.scan_type = { \
.sign = 's', \
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] iio: adc: ade9000: handle Phase C dip events in IRQ1 handler
2026-08-07 8:56 [PATCH 0/3] iio: adc: ade9000: series of probe and channel fixes Antoniu Miclaus
2026-08-07 8:56 ` [PATCH 1/3] iio: adc: ade9000: request interrupts after powering the device Antoniu Miclaus
2026-08-07 8:56 ` [PATCH 2/3] iio: adc: ade9000: fix overlapping scan_index for current and voltage channels Antoniu Miclaus
@ 2026-08-07 8:56 ` Antoniu Miclaus
2 siblings, 0 replies; 5+ messages in thread
From: Antoniu Miclaus @ 2026-08-07 8:56 UTC (permalink / raw)
To: Antoniu Miclaus, Nuno Sá, Michael Hennerich,
Jonathan Cameron, David Lechner, linux-iio, linux, linux-kernel
ADE9000_ST1_CROSSING_DEPTH is the exclusive upper bound for scanning the
STATUS1 event bits, so a value of 25 left out the highest event bit,
ADE9000_ST1_DIPC_BIT (bit 25). Phase C dip events were never reported.
Bump the value to 26 so bit 25 is scanned.
Fixes: 81de7b4619fc ("iio: adc: add ade9000 support")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/adc/ade9000.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
index 167b1f4d6279..da6caabfe2a4 100644
--- a/drivers/iio/adc/ade9000.c
+++ b/drivers/iio/adc/ade9000.c
@@ -219,7 +219,7 @@
#define ADE9000_ST1_ERROR2_BIT BIT(30)
#define ADE9000_ST1_ERROR3_BIT BIT(31)
#define ADE9000_ST1_CROSSING_FIRST 6
-#define ADE9000_ST1_CROSSING_DEPTH 25
+#define ADE9000_ST1_CROSSING_DEPTH 26
#define ADE9000_WFB_TRG_DIP_BIT BIT(0)
#define ADE9000_WFB_TRG_SWELL_BIT BIT(1)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] iio: adc: ade9000: request interrupts after powering the device
2026-08-07 8:56 ` [PATCH 1/3] iio: adc: ade9000: request interrupts after powering the device Antoniu Miclaus
@ 2026-08-07 10:37 ` Joshua Crofts
0 siblings, 0 replies; 5+ messages in thread
From: Joshua Crofts @ 2026-08-07 10:37 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Nuno Sá, Michael Hennerich, Jonathan Cameron, David Lechner,
linux-iio, linux, linux-kernel
On Fri, 7 Aug 2026 11:56:41 +0300
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
> The IRQ handlers do SPI register accesses, but the interrupts were
> requested before the vdd regulator was enabled. An interrupt arriving
> while the chip is unpowered runs a handler against a dead chip, causing
> SPI errors or garbage reads.
>
> Request the interrupts after enabling the regulator. This keeps irq1
> registered before ade9000_reset(), which waits on it, and lets devm free
> the interrupts before the regulator is disabled.
>
> Fixes: 81de7b4619fc ("iio: adc: add ade9000 support")
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
LGTM.
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-07 10:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 8:56 [PATCH 0/3] iio: adc: ade9000: series of probe and channel fixes Antoniu Miclaus
2026-08-07 8:56 ` [PATCH 1/3] iio: adc: ade9000: request interrupts after powering the device Antoniu Miclaus
2026-08-07 10:37 ` Joshua Crofts
2026-08-07 8:56 ` [PATCH 2/3] iio: adc: ade9000: fix overlapping scan_index for current and voltage channels Antoniu Miclaus
2026-08-07 8:56 ` [PATCH 3/3] iio: adc: ade9000: handle Phase C dip events in IRQ1 handler Antoniu Miclaus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox