Skip to contentSkip to conversation

iio: imu: inv_mpu6050: fix interrupt status read for old buggy chips

PATCH Applied [email protected] 3 participants 3 messages Aug 14, 2024 – Aug 17, 2024

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

PATCH 1/1 iio: imu: inv_mpu6050: fix interrupt status read for old buggy chips

From: Jean-Baptiste Maneyrol <[email protected]>

Interrupt status read seems to be broken on some old MPU-6050 like chips. Fix by reverting to previous driver behavior bypassing interrupt status read. This is working because these chips are not supporting WoM and data ready is the only interrupt source.

Fixes 5537f653d9be ("iio: imu: inv_mpu6050: add new interrupt handler for WoM events")
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +11 -2
index 84273660ca2e..3bfeabab0ec4 100644
@@ -248,12 +248,20 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
 	int result;
 
 	switch (st->chip_type) {
+	case INV_MPU6000:
 	case INV_MPU6050:
+	case INV_MPU9150:
+		/*
+		 * WoM is not supported and interrupt status read seems to be broken for
+		 * some chips. Since data ready is the only interrupt, bypass interrupt
+		 * status read and always assert data ready bit.
+		 */
+		wom_bits = 0;
+		int_status = INV_MPU6050_BIT_RAW_DATA_RDY_INT;
+		goto data_ready_interrupt;
 	case INV_MPU6500:
 	case INV_MPU6515:
 	case INV_MPU6880:
-	case INV_MPU6000:
-	case INV_MPU9150:
 	case INV_MPU9250:
 	case INV_MPU9255:
 		wom_bits = INV_MPU6500_BIT_WOM_INT;
@@ -279,6 +287,7 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
 		}
 	}
 
+data_ready_interrupt:
 	/* handle raw data interrupt */
 	if (int_status & INV_MPU6050_BIT_RAW_DATA_RDY_INT) {
 		indio_dev->pollfunc->timestamp = st->it_timestamp;

--
2.34.1

Tested-by Andreas Westman Dorcsak Tested-by on v1 1/1
#1 lore raw

14.08.24 5:37 пп, [email protected]:

Quoted 10 lines

From: Jean-Baptiste Maneyrol <[email protected]>

Interrupt status read seems to be broken on some old MPU-6050 like chips. Fix by reverting to previous driver behavior bypassing interrupt status read. This is working because these chips are not supporting WoM and data ready is the only interrupt source.

Fixes 5537f653d9be ("iio: imu: inv_mpu6050: add new interrupt handler for WoM events")
Quoted 42 lines
---
  drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 13 +++++++++++--
  1 file changed, 11 insertions(+), 2 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +11 -3
index 84273660ca2e..3bfeabab0ec4 100644
@@ -248,12 +248,20 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
  	int result;
 
  	switch (st->chip_type) {
+	case INV_MPU6000:
  	case INV_MPU6050:
+	case INV_MPU9150:
+		/*
+		 * WoM is not supported and interrupt status read seems to be broken for
+		 * some chips. Since data ready is the only interrupt, bypass interrupt
+		 * status read and always assert data ready bit.
+		 */
+		wom_bits = 0;
+		int_status = INV_MPU6050_BIT_RAW_DATA_RDY_INT;
+		goto data_ready_interrupt;
  	case INV_MPU6500:
  	case INV_MPU6515:
  	case INV_MPU6880:
-	case INV_MPU6000:
-	case INV_MPU9150:
  	case INV_MPU9250:
  	case INV_MPU9255:
  		wom_bits = INV_MPU6500_BIT_WOM_INT;
@@ -279,6 +287,7 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
  		}
  	}
 
+data_ready_interrupt:
  	/* handle raw data interrupt */
  	if (int_status & INV_MPU6050_BIT_RAW_DATA_RDY_INT) {
  		indio_dev->pollfunc->timestamp = st->it_timestamp;
--

2.34.1

maintainer Applied
#2 lore raw
Quoted 8 lines · On Wed, 14 Aug 2024 18:50:43 +0300 Svyatoslav Ryhel <[email protected]> wrote:

14.08.24 5:37 пп, [email protected]:

Quoted 7 lines

From: Jean-Baptiste Maneyrol <[email protected]>

Interrupt status read seems to be broken on some old MPU-6050 like chips. Fix by reverting to previous driver behavior bypassing interrupt status read. This is working because these chips are not supporting WoM and data ready is the only interrupt source.

Quoted 6 lines
Quoted 3 lines
Fixes 5537f653d9be ("iio: imu: inv_mpu6050: add new interrupt handler for WoM events")

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

Quoted 43 lines
Quoted 43 lines
---
  drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 13 +++++++++++--
  1 file changed, 11 insertions(+), 2 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +11 -3
index 84273660ca2e..3bfeabab0ec4 100644
@@ -248,12 +248,20 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
  	int result;
 
  	switch (st->chip_type) {
+	case INV_MPU6000:
  	case INV_MPU6050:
+	case INV_MPU9150:
+		/*
+		 * WoM is not supported and interrupt status read seems to be broken for
+		 * some chips. Since data ready is the only interrupt, bypass interrupt
+		 * status read and always assert data ready bit.
+		 */
+		wom_bits = 0;
+		int_status = INV_MPU6050_BIT_RAW_DATA_RDY_INT;
+		goto data_ready_interrupt;
  	case INV_MPU6500:
  	case INV_MPU6515:
  	case INV_MPU6880:
-	case INV_MPU6000:
-	case INV_MPU9150:
  	case INV_MPU9250:
  	case INV_MPU9255:
  		wom_bits = INV_MPU6500_BIT_WOM_INT;
@@ -279,6 +287,7 @@ static irqreturn_t inv_mpu6050_interrupt_handle(int irq, void *p)
  		}
  	}
 
+data_ready_interrupt:
  	/* handle raw data interrupt */
  	if (int_status & INV_MPU6050_BIT_RAW_DATA_RDY_INT) {
  		indio_dev->pollfunc->timestamp = st->it_timestamp;
--

2.34.1