解决:
就我而言,我必须对该驱动程序执行更多步骤才能解决问题:
- 启用脉冲数据就绪模式而不是锁存模式
- 在 INT1 上启用主 DRDY
- 将中断类型标志从 IRQF_TRIGGER_HIGH 更改为 IRQF_TRIGGER_RISING(设备树中的修改无效)
- 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;
-
注意:当集成到新版本内核如 5.x 时,需要在一些代码语句中将 api 'get_monotonic_boottime' 更改为 'ktime_get_ts'。
|
|
2023-1-29 15:12:09
评论
举报
|
|
|