Skip to contentSkip to conversation

iio: adc: ade9000: series of probe and channel fixes

PATCH In review Antoniu Miclaus 3 participants 6 messages Aug 7 – Aug 16

Subsystems (3)
lore
Share & tools
lore

Antoniu Miclaus

author maintainer
#0 lore raw

cover iio: adc: ade9000: series of probe and channel fixes

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(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH 1/3 iio: adc: ade9000: request interrupts after powering the device

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")
---
 drivers/iio/adc/ade9000.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/iio/adc/ade9000.c +13 -12
index c6c3ea953fea..51cb43755a1f 100644
@@ -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);
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] iio: adc: ade9000: request interrupts after powering the device

Quoted 5 lines · On Fri, 7 Aug 2026 11:56:41 +0300 Antoniu Miclaus <[email protected]>…

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.

Quoted 7 lines

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")

---

LGTM.

Signature · 2 lines
Kind regards,
Joshua Crofts
author maintainer
#3 lore raw

PATCH 2/3 iio: adc: ade9000: fix overlapping scan_index for current and voltage channels

In reply to Antoniu Miclaus

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")
---
 drivers/iio/adc/ade9000.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ade9000.c +2 -2
index 51cb43755a1f..167b1f4d6279 100644
@@ -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',						\
Signature · 1 line
2.43.0
author maintainer
#4 lore raw

PATCH 3/3 iio: adc: ade9000: handle Phase C dip events in IRQ1 handler

In reply to Antoniu Miclaus

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")
---
 drivers/iio/adc/ade9000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ade9000.c +1 -1
index 167b1f4d6279..da6caabfe2a4 100644
@@ -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)
Signature · 1 line
2.43.0
maintainer
#5 lore raw
In reply to Antoniu Miclaus
Quoted 7 lines · On Fri, 7 Aug 2026 11:56:40 +0300 Antoniu Miclaus <[email protected]>…

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.

Quoted 6 lines

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.

Series applied to the fixes-togreg branch of iio.git. They probably won't go upstream until after rc1 however.

I marked them all for stable

thanks,

Jonathan

Quoted 10 lines

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(-)