Skip to contentSkip to conversation

iio: adc: Fix flags in sigma-delta drivers

PATCH Applied [email protected] 2 participants 8 messages Sep 6, 2021 – Sep 11, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover iio: adc: Fix flags in sigma-delta drivers

From: Alexandru Tachici <[email protected]>

In Sigma-Delta devices the SDO line is also used as an interrupt. Leaving IRQ on level instead of falling might trigger a sample read when the IRQ is enabled, as the SDO line is already low. Not sure if SDO line will always imediately go high in ad_sd_buffer_postenable before the IRQ is enabled.

Some sigma-delta drivers use wrong irq_flags specified in the ad_sigma_delta_info struct. Add the flags corresponding to the interrupt type specified in the data-sheets of each chip.

Alexandru Tachici (3):
iio: adc: ad7192: Add IRQ flag
iio: adc: ad7780: Fix IRQ flag
iio: adc: ad7793: Fix IRQ flag

Changelog:
- Changed commit messages

 drivers/iio/adc/ad7192.c | 1 +
 drivers/iio/adc/ad7780.c | 2 +-
 drivers/iio/adc/ad7793.c | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

--
2.25.1

#1 lore raw

PATCH v2 1/3 iio: adc: ad7192: Add IRQ flag

From: Alexandru Tachici <[email protected]>

IRQ type in ad_sigma_delta_info struct was missing.

In Sigma-Delta devices the SDO line is also used as an interrupt. Leaving IRQ on level instead of falling might trigger a sample read when the IRQ is enabled, as the SDO line is already low. Not sure if SDO line will always imediately go high in ad_sd_buffer_postenable before the IRQ is enabled.

Also the datasheet seem to explicitly say the falling edge of the SDO should be used as an interrupt:
From the AD7192 datasheet: "The DOUT/RDY falling edge can be used as an interrupt to a processor,"

Fixes da4d3d6bb9f6 ("iio: adc: ad-sigma-delta: Allow custom IRQ flags")
---
 drivers/iio/adc/ad7192.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/adc/ad7192.c +1 -0
index ee8ed9481025..2121a812b0c3 100644
@@ -293,6 +293,7 @@ static const struct ad_sigma_delta_info ad7192_sigma_delta_info = {
 	.has_registers = true,
 	.addr_shift = 3,
 	.read_mask = BIT(6),
+	.irq_flags = IRQF_TRIGGER_FALLING,
 };
 
 static const struct ad_sd_calib_data ad7192_calib_arr[8] = {
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH v2 1/3] iio: adc: ad7192: Add IRQ flag

Quoted 10 lines · On Mon, 6 Sep 2021 09:56:28 +0300 <[email protected]> wrote:

From: Alexandru Tachici <[email protected]>

IRQ type in ad_sigma_delta_info struct was missing.

In Sigma-Delta devices the SDO line is also used as an interrupt. Leaving IRQ on level instead of falling might trigger a sample read when the IRQ is enabled, as the SDO line is already low. Not sure if SDO line will always imediately go high in ad_sd_buffer_postenable before the IRQ is enabled.

Quoted 7 lines

Also the datasheet seem to explicitly say the falling edge of the SDO should be used as an interrupt:
From the AD7192 datasheet: "The DOUT/RDY falling edge can be used as an interrupt to a processor,"

Fixes da4d3d6bb9f6 ("iio: adc: ad-sigma-delta: Allow custom IRQ flags")

As in thread discussing previous version. This one should probably be left to firmware to configure. It's not 'wrong' before this point as firmware should be specifying it correctly. That allows for the interrupt line to the processor to be inverted and other silliness that happens on real boards.

Jonathan

Quoted 16 lines
---
 drivers/iio/adc/ad7192.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/adc/ad7192.c +1 -0
index ee8ed9481025..2121a812b0c3 100644
@@ -293,6 +293,7 @@ static const struct ad_sigma_delta_info ad7192_sigma_delta_info = {
 	.has_registers = true,
 	.addr_shift = 3,
 	.read_mask = BIT(6),
+	.irq_flags = IRQF_TRIGGER_FALLING,
 };
 
 static const struct ad_sd_calib_data ad7192_calib_arr[8] = {
maintainer
#3 lore raw

Re: [PATCH v2 1/3] iio: adc: ad7192: Add IRQ flag

Quoted 18 lines · On Sat, 11 Sep 2021 18:39:21 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 15 lines · On Mon, 6 Sep 2021 09:56:28 +0300 <[email protected]> wrote:

From: Alexandru Tachici <[email protected]>

IRQ type in ad_sigma_delta_info struct was missing.

In Sigma-Delta devices the SDO line is also used as an interrupt. Leaving IRQ on level instead of falling might trigger a sample read when the IRQ is enabled, as the SDO line is already low. Not sure if SDO line will always imediately go high in ad_sd_buffer_postenable before the IRQ is enabled.

Also the datasheet seem to explicitly say the falling edge of the SDO should be used as an interrupt:
From the AD7192 datasheet: "The DOUT/RDY falling edge can be used as an interrupt to a processor,"

Quoted 8 lines
Quoted 2 lines
Fixes da4d3d6bb9f6 ("iio: adc: ad-sigma-delta: Allow custom IRQ flags")

As in thread discussing previous version. This one should probably be left to firmware to configure. It's not 'wrong' before this point as firmware should be specifying it correctly. That allows for the interrupt line to the processor to be inverted and other silliness that happens on real boards.

Ignore that - I'd forgotten this is a joint DOUT / Data ready pin so it's polarity needs to track that of the SPI pin and inverting that isn't something we cope with.

So applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

Quoted 20 lines

Jonathan

Quoted 16 lines
---
 drivers/iio/adc/ad7192.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/adc/ad7192.c +1 -0
index ee8ed9481025..2121a812b0c3 100644
@@ -293,6 +293,7 @@ static const struct ad_sigma_delta_info ad7192_sigma_delta_info = {
 	.has_registers = true,
 	.addr_shift = 3,
 	.read_mask = BIT(6),
+	.irq_flags = IRQF_TRIGGER_FALLING,
 };
 
 static const struct ad_sd_calib_data ad7192_calib_arr[8] = {
#4 lore raw

PATCH v2 2/3 iio: adc: ad7780: Fix IRQ flag

In reply to [email protected]

From: Alexandru Tachici <[email protected]>

Correct IRQ flag here is falling.

In Sigma-Delta devices the SDO line is also used as an interrupt. Leaving IRQ on level instead of falling might trigger a sample read when the IRQ is enabled, as the SDO line is already low. Not sure if SDO line will always imediately go high in ad_sd_buffer_postenable before the IRQ is enabled.

Also the datasheet seem to explicitly say the falling edge of the SDO should be used as an interrupt:
From the AD7780 datasheet: " The DOUT/Figure 22 RDY falling edge can be used as an interrupt to a processor"

Fixes da4d3d6bb9f6 ("iio: adc: ad-sigma-delta: Allow custom IRQ flags")
---
 drivers/iio/adc/ad7780.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7780.c +1 -1
index 42bb952f4738..b6e8c8abf6f4 100644
@@ -203,7 +203,7 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = {
 	.set_mode = ad7780_set_mode,
 	.postprocess_sample = ad7780_postprocess_sample,
 	.has_registers = false,
-	.irq_flags = IRQF_TRIGGER_LOW,
+	.irq_flags = IRQF_TRIGGER_FALLING,
 };
 
 #define _AD7780_CHANNEL(_bits, _wordsize, _mask_all)		\
Signature · 1 line
2.25.1
maintainer
#5 lore raw

Re: [PATCH v2 2/3] iio: adc: ad7780: Fix IRQ flag

Quoted 10 lines · On Mon, 6 Sep 2021 09:56:29 +0300 <[email protected]> wrote:

From: Alexandru Tachici <[email protected]>

Correct IRQ flag here is falling.

In Sigma-Delta devices the SDO line is also used as an interrupt. Leaving IRQ on level instead of falling might trigger a sample read when the IRQ is enabled, as the SDO line is already low. Not sure if SDO line will always imediately go high in ad_sd_buffer_postenable before the IRQ is enabled.

Quoted 7 lines

Also the datasheet seem to explicitly say the falling edge of the SDO should be used as an interrupt:
From the AD7780 datasheet: " The DOUT/Figure 22 RDY falling edge can be used as an interrupt to a processor"

Fixes da4d3d6bb9f6 ("iio: adc: ad-sigma-delta: Allow custom IRQ flags")

Applied and marked for stable.

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/adc/ad7780.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7780.c +1 -1
index 42bb952f4738..b6e8c8abf6f4 100644
@@ -203,7 +203,7 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = {
 	.set_mode = ad7780_set_mode,
 	.postprocess_sample = ad7780_postprocess_sample,
 	.has_registers = false,
-	.irq_flags = IRQF_TRIGGER_LOW,
+	.irq_flags = IRQF_TRIGGER_FALLING,
 };
 
 #define _AD7780_CHANNEL(_bits, _wordsize, _mask_all)		\
#6 lore raw

PATCH v2 3/3 iio: adc: ad7793: Fix IRQ flag

In reply to [email protected]

From: Alexandru Tachici <[email protected]>

In Sigma-Delta devices the SDO line is also used as an interrupt. Leaving IRQ on level instead of falling might trigger a sample read when the IRQ is enabled, as the SDO line is already low. Not sure if SDO line will always imediately go high in ad_sd_buffer_postenable before the IRQ is enabled.

Also the datasheet seem to explicitly say the falling edge of the SDO should be used as an interrupt:
From the AD7793 datasheet: " The DOUT/RDY falling edge can be used as an interrupt to a processor"

Fixes da4d3d6bb9f6 ("iio: adc: ad-sigma-delta: Allow custom IRQ flags")
---
 drivers/iio/adc/ad7793.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7793.c +1 -1
index ef3e2d3ecb0c..0e7ab3fb072a 100644
@@ -206,7 +206,7 @@ static const struct ad_sigma_delta_info ad7793_sigma_delta_info = {
 	.has_registers = true,
 	.addr_shift = 3,
 	.read_mask = BIT(6),
-	.irq_flags = IRQF_TRIGGER_LOW,
+	.irq_flags = IRQF_TRIGGER_FALLING,
 };
 
 static const struct ad_sd_calib_data ad7793_calib_arr[6] = {
Signature · 1 line
2.25.1
maintainer Applied
#7 lore raw

Re: [PATCH v2 3/3] iio: adc: ad7793: Fix IRQ flag

Quoted 8 lines · On Mon, 6 Sep 2021 09:56:30 +0300 <[email protected]> wrote:

From: Alexandru Tachici <[email protected]>

In Sigma-Delta devices the SDO line is also used as an interrupt. Leaving IRQ on level instead of falling might trigger a sample read when the IRQ is enabled, as the SDO line is already low. Not sure if SDO line will always imediately go high in ad_sd_buffer_postenable before the IRQ is enabled.

Quoted 7 lines

Also the datasheet seem to explicitly say the falling edge of the SDO should be used as an interrupt:
From the AD7793 datasheet: " The DOUT/RDY falling edge can be used as an interrupt to a processor"

Fixes da4d3d6bb9f6 ("iio: adc: ad-sigma-delta: Allow custom IRQ flags")

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/adc/ad7793.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7793.c +1 -1
index ef3e2d3ecb0c..0e7ab3fb072a 100644
@@ -206,7 +206,7 @@ static const struct ad_sigma_delta_info ad7793_sigma_delta_info = {
 	.has_registers = true,
 	.addr_shift = 3,
 	.read_mask = BIT(6),
-	.irq_flags = IRQF_TRIGGER_LOW,
+	.irq_flags = IRQF_TRIGGER_FALLING,
 };
 
 static const struct ad_sd_calib_data ad7793_calib_arr[6] = {