]> git.baikalelectronics.ru Git - kernel.git/commit
iio: adis16480: fix pps mode sampling frequency math
authorNuno Sa <nuno.sa@analog.com>
Thu, 18 Feb 2021 11:40:36 +0000 (12:40 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 11 Mar 2021 20:47:11 +0000 (20:47 +0000)
commit078ccf545ad279aacd3370c91aad4fa74bc1cef6
tree092573297ac2f7e43061fd07d6c14eb62c50d3d7
parenteebc52a6ed4f8bf82043ef731062f80dfa266c9a
iio: adis16480: fix pps mode sampling frequency math

When using PPS mode, the input clock needs to be scaled so that we have
an IMU sample rate between (optimally) 4000 and 4250. After this, we can
use the decimation filter to lower the sampling rate in order to get what
the user wants. Optimally, the user sample rate is a multiple of both the
IMU sample rate and the input clock. Hence, calculating the sync_scale
dynamically gives us better chances of achieving a perfect/integer value
for DEC_RATE. The math here is:
 1. lcm of the input clock and the desired output rate.
 2. get the highest multiple of the previous result lower than the adis
    max rate.
 3. The last result becomes the IMU sample rate. Use that to calculate
    SYNC_SCALE and DEC_RATE (to get the user output rate).

Fixes: 92ab18e73541d ("iio: imu: adis16480: Add support for external clock")
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210218114039.216091-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/adis16480.c