Resolved:
In my case, I have to do more steps with this driver to resolve issue:
- Enable pulsed data-ready mode instead of Latch mode
- Enable master DRDY on INT1
- Change interrupt type flag from IRQF_TRIGGER_HIGH to IRQF_TRIGGER_RISING (modification in device tree is not effect)
diff --git a/drivers/iio/imu/st_ism330dlc/st_ism330dlc_core.c b/drivers/iio/imu/st_ism330dlc/st_ism330dlc_core.c
index 998d234..d326d74 100644
--- a/drivers/iio/imu/st_ism330dlc/st_ism330dlc_core.c
+++ b/drivers/iio/imu/st_ism330dlc/st_ism330dlc_core.c
@@ -117,6 +117,14 @@
#define ST_ISM330DLC_SELFTEST_FAIL_MS "fail"
#define ST_ISM330DLC_SELFTEST_PASS_MS "pass"
+
+#define ST_ISM330DLC_DRDY_PULSED_ADDR 0x0b
+#define ST_ISM330DLC_DRDY_PULSED_MASK 0x80
+
+#define ST_ISM330DLC_DRDY_ON_INT1_ADDR 0x1a
+#define ST_ISM330DLC_DRDY_ON_INT1_MASK 0x80
+
+
/* CUSTOM VALUES FOR ACCEL SENSOR */
#define ST_ISM330DLC_ACCEL_ODR_ADDR 0x10
#define ST_ISM330DLC_ACCEL_ODR_MASK 0xf0
@@ -1723,10 +1731,10 @@ static int st_ism330dlc_init_sensor(struct ism330dlc_data *cdata)
msleep(200);
/* Latch interrupts */
- err = st_ism330dlc_write_data_with_mask(cdata, ST_ISM330DLC_LIR_ADDR,
- ST_ISM330DLC_LIR_MASK, ST_ISM330DLC_EN_BIT, true);
- if (err < 0)
- return err;
+// err = st_ism330dlc_write_data_with_mask(cdata, ST_ISM330DLC_LIR_ADDR,
+// ST_ISM330DLC_LIR_MASK, ST_ISM330DLC_EN_BIT, true);
+// if (err < 0)
+// return err;
/* Enable BDU for sensors data */
err = st_ism330dlc_write_data_with_mask(cdata, ST_ISM330DLC_BDU_ADDR,
@@ -1741,6 +1749,15 @@ static int st_ism330dlc_init_sensor(struct ism330dlc_data *cdata)
if (err < 0)
return err;
+ /* Enable pulsed data-ready mode */
+ err = st_ism330dlc_write_data_with_mask(cdata,
+ ST_ISM330DLC_DRDY_PULSED_ADDR,
+ ST_ISM330DLC_DRDY_PULSED_MASK,
+ ST_ISM330DLC_EN_BIT, true);
+ if (err < 0)
+ return err;
+
+
/* Redirect INT2 on INT1, all interrupt will be available on INT1 */
err = st_ism330dlc_write_data_with_mask(cdata,
ST_ISM330DLC_INT2_ON_INT1_ADDR,
@@ -1749,6 +1766,14 @@ static int st_ism330dlc_init_sensor(struct ism330dlc_data *cdata)
if (err < 0)
return err;
+ /* Enable master DRDY on INT1 */
+ err = st_ism330dlc_write_data_with_mask(cdata,
+ ST_ISM330DLC_DRDY_ON_INT1_ADDR,
+ ST_ISM330DLC_DRDY_ON_INT1_MASK,
+ ST_ISM330DLC_EN_BIT, true);
+ if (err < 0)
+ return err;
+
return st_ism330dlc_get_drdy_reg(cdata, &cdata->drdy_reg);
}
diff --git a/drivers/iio/imu/st_ism330dlc/st_ism330dlc_trigger.c b/drivers/iio/imu/st_ism330dlc/st_ism330dlc_trigger.c
index 98038b5..07e887f 100644
--- a/drivers/iio/imu/st_ism330dlc/st_ism330dlc_trigger.c
+++ b/drivers/iio/imu/st_ism330dlc/st_ism330dlc_trigger.c
@@ -132,7 +132,7 @@ int st_ism330dlc_allocate_triggers(struct ism330dlc_data *cdata,
}
err = request_threaded_irq(cdata->irq, NULL, ism330dlc_irq_management,
- IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
cdata->name, cdata);
if (err)
goto deallocate_trigger;
Note: When integrating to new version of kernel as 5.x, need to change api 'get_monotonic_boottime' to 'ktime_get_ts' in a few code statements.