• N
    iio: adis16480: fix pps mode sampling frequency math · 0463e60f
    Nuno Sa 提交于
    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: 326e2357 ("iio: imu: adis16480: Add support for external clock")
    Signed-off-by: NNuno Sa <nuno.sa@analog.com>
    Link: https://lore.kernel.org/r/20210218114039.216091-2-nuno.sa@analog.comSigned-off-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
    0463e60f
adis16480.c 41.1 KB