Commit 0d698a53 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

iio: ad9523-1: Improve reported VCO frequency accuracy

To improve the accuracy of the reported VCO frequency perform all
multiplications before divisions. This reduces rounding errors and makes
sure the reported rates are accurate down to the last digit.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent a2d2010d
...@@ -862,9 +862,11 @@ static int ad9523_setup(struct iio_dev *indio_dev) ...@@ -862,9 +862,11 @@ static int ad9523_setup(struct iio_dev *indio_dev)
if (ret < 0) if (ret < 0)
return ret; return ret;
st->vco_freq = (pdata->vcxo_freq * (pdata->pll2_freq_doubler_en ? 2 : 1) st->vco_freq = div_u64((unsigned long long)pdata->vcxo_freq *
/ pdata->pll2_r2_div) * AD9523_PLL2_FB_NDIV(pdata-> (pdata->pll2_freq_doubler_en ? 2 : 1) *
pll2_ndiv_a_cnt, pdata->pll2_ndiv_b_cnt); AD9523_PLL2_FB_NDIV(pdata->pll2_ndiv_a_cnt,
pdata->pll2_ndiv_b_cnt),
pdata->pll2_r2_div);
ret = ad9523_write(indio_dev, AD9523_PLL2_VCO_CTRL, ret = ad9523_write(indio_dev, AD9523_PLL2_VCO_CTRL,
AD9523_PLL2_VCO_CALIBRATE); AD9523_PLL2_VCO_CALIBRATE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment