[PATCH 02/16] iio: frequency: ad9523: don't select a powered down M2 divider
From: Nuno Sá
Date: Mon Nov 30 2026 - 12:38:00 EST
For channels 4 to 9, setting the frequency picks either the M1 or the
M2 VCO divider as the clock source. When M2 is not used, it is powered
down and its output frequency is 0, which the selection logic does not
account for: for any frequency below about half of the M1 output, M2
compares as the better choice. The channel then gets switched to the
powered down M2 divider, and both its divider and its frequency end up
being computed from 0 Hz.
Only consider M2 when it is enabled.
Fixes: cd1678f96329 ("iio: frequency: New driver for AD9523 SPI Low Jitter Clock Generator")
Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
drivers/iio/frequency/ad9523.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index b0016317a7ea..aecd94db28bb 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -427,6 +427,12 @@ static int ad9523_set_clock_provider(struct iio_dev *indio_dev,
use_alt_clk_src = (freq == st->vco_out_freq[AD9523_VCXO]);
break;
case 4 ... 9:
+ /* M2 is powered down, so it can't be used */
+ if (!st->vco_out_freq[AD9523_VCO2]) {
+ use_alt_clk_src = false;
+ break;
+ }
+
tmp1 = st->vco_out_freq[AD9523_VCO1] / freq;
tmp2 = st->vco_out_freq[AD9523_VCO2] / freq;
tmp1 *= freq;
--
2.56.0