summaryrefslogtreecommitdiffstats
path: root/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
diff options
context:
space:
mode:
authorJean-Baptiste Maneyrol2018-05-28 15:22:04 +0200
committerJonathan Cameron2018-06-10 12:52:30 +0200
commit4bcc19f1b218983be841a319a3a506f2e446c6b5 (patch)
treecc6fac3c9fea51379e2286b3451beffb717dbcb3 /drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
parentiio: 104-quad-8: Provide defines for magic numbers (diff)
downloadkernel-qcow2-linux-4bcc19f1b218983be841a319a3a506f2e446c6b5.tar.gz
kernel-qcow2-linux-4bcc19f1b218983be841a319a3a506f2e446c6b5.tar.xz
kernel-qcow2-linux-4bcc19f1b218983be841a319a3a506f2e446c6b5.zip
iio: imu: inv_mpu6050: new timestamp mechanism
Check validity of interrupt timestamps by computing time between 2 interrupts. If it matches the chip frequency modulo 4%, it is used as the data timestamp and also for estimating the chip frequency measured from the system. Otherwise timestamp is computed using the estimated chip frequency. Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/imu/inv_mpu6050/inv_mpu_core.c')
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index f50477c360e2..de68e83fc52d 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -295,6 +295,13 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev)
memcpy(&st->chip_config, hw_info[st->chip_type].config,
sizeof(struct inv_mpu6050_chip_config));
+ /*
+ * Internal chip period is 1ms (1kHz).
+ * Let's use at the beginning the theorical value before measuring
+ * with interrupt timestamps.
+ */
+ st->chip_period = NSEC_PER_MSEC;
+
return inv_mpu6050_set_power_itg(st, false);
error_power_off: