Skip to content

Commit 33d7ecb

Browse files
mhennerichjic23
authored andcommitted
iio: frequency: adf4350: Fix prescaler usage.
The ADF4350/1 features a programmable dual-modulus prescaler of 4/5 or 8/9. When set to 4/5, the maximum RF frequency allowed is 3 GHz. Therefore, when operating the ADF4351 above 3 GHz, this must be set to 8/9. In this context not the RF output frequency is meant - it's the VCO frequency. Therefore move the prescaler selection after we derived the VCO frequency from the desired RF output frequency. This BUG may have caused PLL lock instabilities when operating the VCO at the very high range close to 4.4 GHz. Fixes: e31166f ("iio: frequency: New driver for Analog Devices ADF4350/ADF4351 Wideband Synthesizers") Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/20250829-adf4350-fix-v2-1-0bf543ba797d@analog.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 1315cc2 commit 33d7ecb

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

drivers/iio/frequency/adf4350.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
149149
if (freq > ADF4350_MAX_OUT_FREQ || freq < st->min_out_freq)
150150
return -EINVAL;
151151

152+
st->r4_rf_div_sel = 0;
153+
154+
/*
155+
* !\TODO: The below computation is making sure we get a power of 2
156+
* shift (st->r4_rf_div_sel) so that freq becomes higher or equal to
157+
* ADF4350_MIN_VCO_FREQ. This might be simplified with fls()/fls_long()
158+
* and friends.
159+
*/
160+
while (freq < ADF4350_MIN_VCO_FREQ) {
161+
freq <<= 1;
162+
st->r4_rf_div_sel++;
163+
}
164+
152165
if (freq > ADF4350_MAX_FREQ_45_PRESC) {
153166
prescaler = ADF4350_REG1_PRESCALER;
154167
mdiv = 75;
@@ -157,13 +170,6 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
157170
mdiv = 23;
158171
}
159172

160-
st->r4_rf_div_sel = 0;
161-
162-
while (freq < ADF4350_MIN_VCO_FREQ) {
163-
freq <<= 1;
164-
st->r4_rf_div_sel++;
165-
}
166-
167173
/*
168174
* Allow a predefined reference division factor
169175
* if not set, compute our own

0 commit comments

Comments
 (0)