]> git.proxmox.com Git - mirror_ubuntu-kernels.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)
commit0463e60f087069adf25a815cd88753946aca2565
tree092573297ac2f7e43061fd07d6c14eb62c50d3d7
parentaa29cf932fb345e111cd7fef04320846fa73e372
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: 326e2357553d3 ("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