* [PATCH 01/16] iio: frequency: ad9523: fix out of bounds access of vco_out_map
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
@ 2026-11-30 17:36 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 02/16] iio: frequency: ad9523: don't select a powered down M2 divider Nuno Sá
` (14 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:36 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
vco_out_map[] only has room for the first 10 channels, which are the
ones that can select their clock source. However, the frequency read
and write paths index it with any channel number, so accessing the
frequency of channels 10 to 13 reads past the end of the array.
Size the array for all channels. The extra entries are never written
and stay at 0 (AD9523_VCO1), which is the only clock source channels 10
to 13 can use.
Fixes: cd1678f96329 ("iio: frequency: New driver for AD9523 SPI Low Jitter Clock Generator")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 1e393f40a8c8..b0016317a7ea 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -237,7 +237,6 @@
#define AD9523_EEPROM_CTRL2_REG2EEPROM (1 << 0)
#define AD9523_NUM_CHAN 14
-#define AD9523_NUM_CHAN_ALT_CLK_SRC 10
/* Helpers to avoid excess line breaks */
#define AD_IFE(_pde, _a, _b) ((pdata->_pde) ? _a : _b)
@@ -274,7 +273,7 @@ struct ad9523_state {
unsigned long vcxo_freq;
unsigned long vco_freq;
unsigned long vco_out_freq[AD9523_NUM_CLK_SRC];
- unsigned char vco_out_map[AD9523_NUM_CHAN_ALT_CLK_SRC];
+ unsigned char vco_out_map[AD9523_NUM_CHAN];
/*
* Lock for accessing device registers. Some operations require
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 02/16] iio: frequency: ad9523: don't select a powered down M2 divider
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
2026-11-30 17:36 ` [PATCH 01/16] iio: frequency: ad9523: fix out of bounds access of vco_out_map Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 03/16] iio: frequency: ad9523: fix the M2 divider selection Nuno Sá
` (13 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
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@analog.com>
---
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
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 03/16] iio: frequency: ad9523: fix the M2 divider selection
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
2026-11-30 17:36 ` [PATCH 01/16] iio: frequency: ad9523: fix out of bounds access of vco_out_map Nuno Sá
2026-11-30 17:37 ` [PATCH 02/16] iio: frequency: ad9523: don't select a powered down M2 divider Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 04/16] iio: frequency: ad9523: fix GPIO polarity handling Nuno Sá
` (12 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
For channels 4 to 9, the M2 divider is used if it looks closer to the
requested frequency than M1. However, the comparison is done on the
largest multiple of the requested frequency below each source, which
does not tell how close the resulting output is. For example, with a
3000 MHz VCO, M1 = 3 and M2 = 4, asking for 500 MHz selects M2 and gives
750 MHz, while asking for 375 MHz selects M1 and gives 500 MHz.
Compare the output frequencies each source actually gives instead, and
only use M2 if it gets closer to the requested frequency.
Fixes: cd1678f96329 ("iio: frequency: New driver for AD9523 SPI Low Jitter Clock Generator")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index aecd94db28bb..e6913ef36fb0 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -415,6 +415,13 @@ static int ad9523_vco_out_map(struct iio_dev *indio_dev,
return ret;
}
+static unsigned long ad9523_chan_freq(struct ad9523_state *st, unsigned int src,
+ unsigned long freq)
+{
+ return st->vco_out_freq[src] /
+ clamp(st->vco_out_freq[src] / freq, 1, 1024);
+}
+
static int ad9523_set_clock_provider(struct iio_dev *indio_dev,
unsigned int ch, unsigned long freq)
{
@@ -433,11 +440,10 @@ static int ad9523_set_clock_provider(struct iio_dev *indio_dev,
break;
}
- tmp1 = st->vco_out_freq[AD9523_VCO1] / freq;
- tmp2 = st->vco_out_freq[AD9523_VCO2] / freq;
- tmp1 *= freq;
- tmp2 *= freq;
- use_alt_clk_src = (abs(tmp1 - freq) > abs(tmp2 - freq));
+ /* Use M2 only if the output gets closer to the requested rate */
+ tmp1 = abs_diff(ad9523_chan_freq(st, AD9523_VCO1, freq), freq);
+ tmp2 = abs_diff(ad9523_chan_freq(st, AD9523_VCO2, freq), freq);
+ use_alt_clk_src = tmp2 < tmp1;
break;
default:
/* Ch 10..14: No action required, return success */
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 04/16] iio: frequency: ad9523: fix GPIO polarity handling
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (2 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 03/16] iio: frequency: ad9523: fix the M2 divider selection Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 05/16] iio: frequency: ad9523: factor out the channel divider calculation Nuno Sá
` (11 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
The PD, RESET and SYNC pins are all active low, but the driver handles
the GPIOs as if they were active high: it drives powerdown and sync
high to keep the device running, and drives reset low and then high to
reset it. This only works if the GPIOs are described as active high,
which is the opposite of what the hardware does.
Use logical values instead, so that the GPIOs can be described with
their real polarity: keep powerdown and sync de-asserted, and assert
reset before de-asserting it again.
There are no in-tree users of this driver, so nothing relies on the
inverted logic. Out of tree users need to flag the GPIOs as active low.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index e6913ef36fb0..92bbe4d196b5 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -982,22 +982,22 @@ static int ad9523_probe(struct spi_device *spi)
return ret;
st->pwrdown_gpio = devm_gpiod_get_optional(dev, "powerdown",
- GPIOD_OUT_HIGH);
+ GPIOD_OUT_LOW);
if (IS_ERR(st->pwrdown_gpio))
return PTR_ERR(st->pwrdown_gpio);
st->reset_gpio = devm_gpiod_get_optional(dev, "reset",
- GPIOD_OUT_LOW);
+ GPIOD_OUT_HIGH);
if (IS_ERR(st->reset_gpio))
return PTR_ERR(st->reset_gpio);
if (st->reset_gpio) {
udelay(1);
- gpiod_direction_output(st->reset_gpio, 1);
+ gpiod_set_value_cansleep(st->reset_gpio, 0);
}
st->sync_gpio = devm_gpiod_get_optional(dev, "sync",
- GPIOD_OUT_HIGH);
+ GPIOD_OUT_LOW);
if (IS_ERR(st->sync_gpio))
return PTR_ERR(st->sync_gpio);
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 05/16] iio: frequency: ad9523: factor out the channel divider calculation
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (3 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 04/16] iio: frequency: ad9523: fix GPIO polarity handling Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 06/16] MAINTAINERS: add an entry for the AD9523 driver Nuno Sá
` (10 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
The channel divider for a given frequency is computed both when
setting the frequency and, to get the resulting output frequency, when
selecting the clock source. Add a small helper for it, so that both
stay in sync.
No functional change.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 92bbe4d196b5..44774577b4bf 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -415,11 +415,16 @@ static int ad9523_vco_out_map(struct iio_dev *indio_dev,
return ret;
}
+static unsigned int ad9523_chan_div(struct ad9523_state *st, unsigned int src,
+ unsigned long freq)
+{
+ return clamp(st->vco_out_freq[src] / freq, 1, 1024);
+}
+
static unsigned long ad9523_chan_freq(struct ad9523_state *st, unsigned int src,
unsigned long freq)
{
- return st->vco_out_freq[src] /
- clamp(st->vco_out_freq[src] / freq, 1, 1024);
+ return st->vco_out_freq[src] / ad9523_chan_div(st, src, freq);
}
static int ad9523_set_clock_provider(struct iio_dev *indio_dev,
@@ -685,8 +690,7 @@ static int ad9523_write_raw(struct iio_dev *indio_dev,
ret = ad9523_set_clock_provider(indio_dev, chan->channel, val);
if (ret < 0)
goto out;
- tmp = st->vco_out_freq[st->vco_out_map[chan->channel]] / val;
- tmp = clamp(tmp, 1, 1024);
+ tmp = ad9523_chan_div(st, st->vco_out_map[chan->channel], val);
reg &= ~(0x3FF << 8);
reg |= AD9523_CLK_DIST_DIV(tmp);
break;
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 06/16] MAINTAINERS: add an entry for the AD9523 driver
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (4 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 05/16] iio: frequency: ad9523: factor out the channel divider calculation Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 07/16] iio: frequency: ad9523: move the platform data into the driver Nuno Sá
` (9 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
The AD9523 driver is only covered by the generic IIO entries. Add a
dedicated entry for it, as it is about to get a binding and a fair
amount of changes.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
MAINTAINERS | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 658895c3b0fa..8e18a68379e6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1758,6 +1758,16 @@ W: https://ez.analog.com/linux-software-drivers
F: Documentation/devicetree/bindings/iio/dac/adi,ad8460.yaml
F: drivers/iio/dac/ad8460.c
+ANALOG DEVICES INC AD9523 DRIVER
+M: Michael Hennerich <Michael.Hennerich@analog.com>
+M: Nuno Sá <nuno.sa@analog.com>
+L: linux@analog.com
+L: linux-iio@vger.kernel.org
+S: Supported
+W: https://ez.analog.com/linux-software-drivers
+F: drivers/iio/frequency/ad9523.c
+F: include/linux/iio/frequency/ad9523.h
+
ANALOG DEVICES INC AD9739a DRIVER
M: Nuno Sa <nuno.sa@analog.com>
M: Dragos Bogdan <dragos.bogdan@analog.com>
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 07/16] iio: frequency: ad9523: move the platform data into the driver
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (5 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 06/16] MAINTAINERS: add an entry for the AD9523 driver Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 08/16] iio: frequency: ad9523: rename the platform data to config Nuno Sá
` (8 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
There are no in-tree users of struct ad9523_platform_data, and the
driver is going to get its configuration from firmware instead. Move
the platform data definitions from the header into the driver, so that
the switch to firmware properties can be done on top of them, and drop
the header.
Only 'unsigned' is turned into 'unsigned int' and the structure
members are no longer tab aligned, the rest is moved as is.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
MAINTAINERS | 1 -
drivers/iio/frequency/ad9523.c | 184 ++++++++++++++++++++++++++++++++-
include/linux/iio/frequency/ad9523.h | 194 -----------------------------------
3 files changed, 183 insertions(+), 196 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 8e18a68379e6..d747e10ef125 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1766,7 +1766,6 @@ L: linux-iio@vger.kernel.org
S: Supported
W: https://ez.analog.com/linux-software-drivers
F: drivers/iio/frequency/ad9523.c
-F: include/linux/iio/frequency/ad9523.h
ANALOG DEVICES INC AD9739a DRIVER
M: Nuno Sa <nuno.sa@analog.com>
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 44774577b4bf..4fca7e36072c 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -18,7 +18,6 @@
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
-#include <linux/iio/frequency/ad9523.h>
#define AD9523_READ (1 << 15)
#define AD9523_WRITE (0 << 15)
@@ -242,6 +241,189 @@
#define AD_IFE(_pde, _a, _b) ((pdata->_pde) ? _a : _b)
#define AD_IF(_pde, _a) AD_IFE(_pde, _a, 0)
+enum outp_drv_mode {
+ TRISTATE,
+ LVPECL_8mA,
+ LVDS_4mA,
+ LVDS_7mA,
+ HSTL0_16mA,
+ HSTL1_8mA,
+ CMOS_CONF1,
+ CMOS_CONF2,
+ CMOS_CONF3,
+ CMOS_CONF4,
+ CMOS_CONF5,
+ CMOS_CONF6,
+ CMOS_CONF7,
+ CMOS_CONF8,
+ CMOS_CONF9
+};
+
+enum ref_sel_mode {
+ NONEREVERTIVE_STAY_ON_REFB,
+ REVERT_TO_REFA,
+ SELECT_REFA,
+ SELECT_REFB,
+ EXT_REF_SEL
+};
+
+/**
+ * struct ad9523_channel_spec - Output channel configuration
+ *
+ * @channel_num: Output channel number.
+ * @divider_output_invert_en: Invert the polarity of the output clock.
+ * @sync_ignore_en: Ignore chip-level SYNC signal.
+ * @low_power_mode_en: Reduce power used in the differential output modes.
+ * @use_alt_clock_src: Channel divider uses alternative clk source.
+ * @output_dis: Disables, powers down the entire channel.
+ * @driver_mode: Output driver mode (logic level family).
+ * @divider_phase: Divider initial phase after a SYNC. Range 0..63
+ * LSB = 1/2 of a period of the divider input clock.
+ * @channel_divider: 10-bit channel divider.
+ * @extended_name: Optional descriptive channel name.
+ */
+
+struct ad9523_channel_spec {
+ unsigned int channel_num;
+ bool divider_output_invert_en;
+ bool sync_ignore_en;
+ bool low_power_mode_en;
+ /* CH0..CH3 VCXO, CH4..CH9 VCO2 */
+ bool use_alt_clock_src;
+ bool output_dis;
+ enum outp_drv_mode driver_mode;
+ unsigned char divider_phase;
+ unsigned short channel_divider;
+ char extended_name[16];
+};
+
+enum pll1_rzero_resistor {
+ RZERO_883_OHM,
+ RZERO_677_OHM,
+ RZERO_341_OHM,
+ RZERO_135_OHM,
+ RZERO_10_OHM,
+ RZERO_USE_EXT_RES = 8,
+};
+
+enum rpole2_resistor {
+ RPOLE2_900_OHM,
+ RPOLE2_450_OHM,
+ RPOLE2_300_OHM,
+ RPOLE2_225_OHM,
+};
+
+enum rzero_resistor {
+ RZERO_3250_OHM,
+ RZERO_2750_OHM,
+ RZERO_2250_OHM,
+ RZERO_2100_OHM,
+ RZERO_3000_OHM,
+ RZERO_2500_OHM,
+ RZERO_2000_OHM,
+ RZERO_1850_OHM,
+};
+
+enum cpole1_capacitor {
+ CPOLE1_0_PF,
+ CPOLE1_8_PF,
+ CPOLE1_16_PF,
+ CPOLE1_24_PF,
+ _CPOLE1_24_PF, /* place holder */
+ CPOLE1_32_PF,
+ CPOLE1_40_PF,
+ CPOLE1_48_PF,
+};
+
+/**
+ * struct ad9523_platform_data - platform specific information
+ *
+ * @vcxo_freq: External VCXO frequency in Hz
+ * @refa_diff_rcv_en: REFA differential/single-ended input selection.
+ * @refb_diff_rcv_en: REFB differential/single-ended input selection.
+ * @zd_in_diff_en: Zero Delay differential/single-ended input selection.
+ * @osc_in_diff_en: OSC differential/ single-ended input selection.
+ * @refa_cmos_neg_inp_en: REFA single-ended neg./pos. input enable.
+ * @refb_cmos_neg_inp_en: REFB single-ended neg./pos. input enable.
+ * @zd_in_cmos_neg_inp_en: Zero Delay single-ended neg./pos. input enable.
+ * @osc_in_cmos_neg_inp_en: OSC single-ended neg./pos. input enable.
+ * @refa_r_div: PLL1 10-bit REFA R divider.
+ * @refb_r_div: PLL1 10-bit REFB R divider.
+ * @pll1_feedback_div: PLL1 10-bit Feedback N divider.
+ * @pll1_charge_pump_current_nA: Magnitude of PLL1 charge pump current (nA).
+ * @zero_delay_mode_internal_en: Internal, external Zero Delay mode selection.
+ * @osc_in_feedback_en: PLL1 feedback path, local feedback from
+ * the OSC_IN receiver or zero delay mode
+ * @pll1_loop_filter_rzero: PLL1 Loop Filter Zero Resistor selection.
+ * @ref_mode: Reference selection mode.
+ * @pll2_charge_pump_current_nA: Magnitude of PLL2 charge pump current (nA).
+ * @pll2_ndiv_a_cnt: PLL2 Feedback N-divider, A Counter, range 0..4.
+ * @pll2_ndiv_b_cnt: PLL2 Feedback N-divider, B Counter, range 0..63.
+ * @pll2_freq_doubler_en: PLL2 frequency doubler enable.
+ * @pll2_r2_div: PLL2 R2 divider, range 0..31.
+ * @pll2_vco_div_m1: VCO1 divider, range 3..5.
+ * @pll2_vco_div_m2: VCO2 divider, range 3..5.
+ * @rpole2: PLL2 loop filter Rpole resistor value.
+ * @rzero: PLL2 loop filter Rzero resistor value.
+ * @cpole1: PLL2 loop filter Cpole capacitor value.
+ * @rzero_bypass_en: PLL2 loop filter Rzero bypass enable.
+ * @num_channels: Array size of struct ad9523_channel_spec.
+ * @channels: Pointer to channel array.
+ * @name: Optional alternative iio device name.
+ */
+
+struct ad9523_platform_data {
+ unsigned long vcxo_freq;
+
+ /* Differential/ Single-Ended Input Configuration */
+ bool refa_diff_rcv_en;
+ bool refb_diff_rcv_en;
+ bool zd_in_diff_en;
+ bool osc_in_diff_en;
+
+ /*
+ * Valid if differential input disabled
+ * if false defaults to pos input
+ */
+ bool refa_cmos_neg_inp_en;
+ bool refb_cmos_neg_inp_en;
+ bool zd_in_cmos_neg_inp_en;
+ bool osc_in_cmos_neg_inp_en;
+
+ /* PLL1 Setting */
+ unsigned short refa_r_div;
+ unsigned short refb_r_div;
+ unsigned short pll1_feedback_div;
+ unsigned short pll1_charge_pump_current_nA;
+ bool zero_delay_mode_internal_en;
+ bool osc_in_feedback_en;
+ enum pll1_rzero_resistor pll1_loop_filter_rzero;
+
+ /* Reference */
+ enum ref_sel_mode ref_mode;
+
+ /* PLL2 Setting */
+ unsigned int pll2_charge_pump_current_nA;
+ unsigned char pll2_ndiv_a_cnt;
+ unsigned char pll2_ndiv_b_cnt;
+ bool pll2_freq_doubler_en;
+ unsigned char pll2_r2_div;
+ unsigned char pll2_vco_div_m1; /* 3..5 */
+ unsigned char pll2_vco_div_m2; /* 3..5 */
+
+ /* Loop Filter PLL2 */
+ enum rpole2_resistor rpole2;
+ enum rzero_resistor rzero;
+ enum cpole1_capacitor cpole1;
+ bool rzero_bypass_en;
+
+ /* Output Channel Configuration */
+ int num_channels;
+ struct ad9523_channel_spec *channels;
+
+ char name[SPI_NAME_SIZE];
+};
+
enum {
AD9523_STAT_PLL1_LD,
AD9523_STAT_PLL2_LD,
diff --git a/include/linux/iio/frequency/ad9523.h b/include/linux/iio/frequency/ad9523.h
deleted file mode 100644
index 236437a226b2..000000000000
--- a/include/linux/iio/frequency/ad9523.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * AD9523 SPI Low Jitter Clock Generator
- *
- * Copyright 2012 Analog Devices Inc.
- */
-
-#ifndef IIO_FREQUENCY_AD9523_H_
-#define IIO_FREQUENCY_AD9523_H_
-
-enum outp_drv_mode {
- TRISTATE,
- LVPECL_8mA,
- LVDS_4mA,
- LVDS_7mA,
- HSTL0_16mA,
- HSTL1_8mA,
- CMOS_CONF1,
- CMOS_CONF2,
- CMOS_CONF3,
- CMOS_CONF4,
- CMOS_CONF5,
- CMOS_CONF6,
- CMOS_CONF7,
- CMOS_CONF8,
- CMOS_CONF9
-};
-
-enum ref_sel_mode {
- NONEREVERTIVE_STAY_ON_REFB,
- REVERT_TO_REFA,
- SELECT_REFA,
- SELECT_REFB,
- EXT_REF_SEL
-};
-
-/**
- * struct ad9523_channel_spec - Output channel configuration
- *
- * @channel_num: Output channel number.
- * @divider_output_invert_en: Invert the polarity of the output clock.
- * @sync_ignore_en: Ignore chip-level SYNC signal.
- * @low_power_mode_en: Reduce power used in the differential output modes.
- * @use_alt_clock_src: Channel divider uses alternative clk source.
- * @output_dis: Disables, powers down the entire channel.
- * @driver_mode: Output driver mode (logic level family).
- * @divider_phase: Divider initial phase after a SYNC. Range 0..63
- * LSB = 1/2 of a period of the divider input clock.
- * @channel_divider: 10-bit channel divider.
- * @extended_name: Optional descriptive channel name.
- */
-
-struct ad9523_channel_spec {
- unsigned channel_num;
- bool divider_output_invert_en;
- bool sync_ignore_en;
- bool low_power_mode_en;
- /* CH0..CH3 VCXO, CH4..CH9 VCO2 */
- bool use_alt_clock_src;
- bool output_dis;
- enum outp_drv_mode driver_mode;
- unsigned char divider_phase;
- unsigned short channel_divider;
- char extended_name[16];
-};
-
-enum pll1_rzero_resistor {
- RZERO_883_OHM,
- RZERO_677_OHM,
- RZERO_341_OHM,
- RZERO_135_OHM,
- RZERO_10_OHM,
- RZERO_USE_EXT_RES = 8,
-};
-
-enum rpole2_resistor {
- RPOLE2_900_OHM,
- RPOLE2_450_OHM,
- RPOLE2_300_OHM,
- RPOLE2_225_OHM,
-};
-
-enum rzero_resistor {
- RZERO_3250_OHM,
- RZERO_2750_OHM,
- RZERO_2250_OHM,
- RZERO_2100_OHM,
- RZERO_3000_OHM,
- RZERO_2500_OHM,
- RZERO_2000_OHM,
- RZERO_1850_OHM,
-};
-
-enum cpole1_capacitor {
- CPOLE1_0_PF,
- CPOLE1_8_PF,
- CPOLE1_16_PF,
- CPOLE1_24_PF,
- _CPOLE1_24_PF, /* place holder */
- CPOLE1_32_PF,
- CPOLE1_40_PF,
- CPOLE1_48_PF,
-};
-
-/**
- * struct ad9523_platform_data - platform specific information
- *
- * @vcxo_freq: External VCXO frequency in Hz
- * @refa_diff_rcv_en: REFA differential/single-ended input selection.
- * @refb_diff_rcv_en: REFB differential/single-ended input selection.
- * @zd_in_diff_en: Zero Delay differential/single-ended input selection.
- * @osc_in_diff_en: OSC differential/ single-ended input selection.
- * @refa_cmos_neg_inp_en: REFA single-ended neg./pos. input enable.
- * @refb_cmos_neg_inp_en: REFB single-ended neg./pos. input enable.
- * @zd_in_cmos_neg_inp_en: Zero Delay single-ended neg./pos. input enable.
- * @osc_in_cmos_neg_inp_en: OSC single-ended neg./pos. input enable.
- * @refa_r_div: PLL1 10-bit REFA R divider.
- * @refb_r_div: PLL1 10-bit REFB R divider.
- * @pll1_feedback_div: PLL1 10-bit Feedback N divider.
- * @pll1_charge_pump_current_nA: Magnitude of PLL1 charge pump current (nA).
- * @zero_delay_mode_internal_en: Internal, external Zero Delay mode selection.
- * @osc_in_feedback_en: PLL1 feedback path, local feedback from
- * the OSC_IN receiver or zero delay mode
- * @pll1_loop_filter_rzero: PLL1 Loop Filter Zero Resistor selection.
- * @ref_mode: Reference selection mode.
- * @pll2_charge_pump_current_nA: Magnitude of PLL2 charge pump current (nA).
- * @pll2_ndiv_a_cnt: PLL2 Feedback N-divider, A Counter, range 0..4.
- * @pll2_ndiv_b_cnt: PLL2 Feedback N-divider, B Counter, range 0..63.
- * @pll2_freq_doubler_en: PLL2 frequency doubler enable.
- * @pll2_r2_div: PLL2 R2 divider, range 0..31.
- * @pll2_vco_div_m1: VCO1 divider, range 3..5.
- * @pll2_vco_div_m2: VCO2 divider, range 3..5.
- * @rpole2: PLL2 loop filter Rpole resistor value.
- * @rzero: PLL2 loop filter Rzero resistor value.
- * @cpole1: PLL2 loop filter Cpole capacitor value.
- * @rzero_bypass_en: PLL2 loop filter Rzero bypass enable.
- * @num_channels: Array size of struct ad9523_channel_spec.
- * @channels: Pointer to channel array.
- * @name: Optional alternative iio device name.
- */
-
-struct ad9523_platform_data {
- unsigned long vcxo_freq;
-
- /* Differential/ Single-Ended Input Configuration */
- bool refa_diff_rcv_en;
- bool refb_diff_rcv_en;
- bool zd_in_diff_en;
- bool osc_in_diff_en;
-
- /*
- * Valid if differential input disabled
- * if false defaults to pos input
- */
- bool refa_cmos_neg_inp_en;
- bool refb_cmos_neg_inp_en;
- bool zd_in_cmos_neg_inp_en;
- bool osc_in_cmos_neg_inp_en;
-
- /* PLL1 Setting */
- unsigned short refa_r_div;
- unsigned short refb_r_div;
- unsigned short pll1_feedback_div;
- unsigned short pll1_charge_pump_current_nA;
- bool zero_delay_mode_internal_en;
- bool osc_in_feedback_en;
- enum pll1_rzero_resistor pll1_loop_filter_rzero;
-
- /* Reference */
- enum ref_sel_mode ref_mode;
-
- /* PLL2 Setting */
- unsigned int pll2_charge_pump_current_nA;
- unsigned char pll2_ndiv_a_cnt;
- unsigned char pll2_ndiv_b_cnt;
- bool pll2_freq_doubler_en;
- unsigned char pll2_r2_div;
- unsigned char pll2_vco_div_m1; /* 3..5 */
- unsigned char pll2_vco_div_m2; /* 3..5 */
-
- /* Loop Filter PLL2 */
- enum rpole2_resistor rpole2;
- enum rzero_resistor rzero;
- enum cpole1_capacitor cpole1;
- bool rzero_bypass_en;
-
- /* Output Channel Configuration */
- int num_channels;
- struct ad9523_channel_spec *channels;
-
- char name[SPI_NAME_SIZE];
-};
-
-#endif /* IIO_FREQUENCY_AD9523_H_ */
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 08/16] iio: frequency: ad9523: rename the platform data to config
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (6 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 07/16] iio: frequency: ad9523: move the platform data into the driver Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 09/16] iio: frequency: ad9523: always bypass PLL1 Nuno Sá
` (7 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
The platform data structure is going to be filled from firmware
properties, so it is not platform data anymore. Rename struct
ad9523_platform_data to struct ad9523_config, and pdata to cfg.
No functional change.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 76 +++++++++++++++++++++---------------------
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 4fca7e36072c..c3d3209b5ce4 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -238,7 +238,7 @@
#define AD9523_NUM_CHAN 14
/* Helpers to avoid excess line breaks */
-#define AD_IFE(_pde, _a, _b) ((pdata->_pde) ? _a : _b)
+#define AD_IFE(_pde, _a, _b) ((cfg->_pde) ? _a : _b)
#define AD_IF(_pde, _a) AD_IFE(_pde, _a, 0)
enum outp_drv_mode {
@@ -336,7 +336,7 @@ enum cpole1_capacitor {
};
/**
- * struct ad9523_platform_data - platform specific information
+ * struct ad9523_config - device configuration
*
* @vcxo_freq: External VCXO frequency in Hz
* @refa_diff_rcv_en: REFA differential/single-ended input selection.
@@ -372,7 +372,7 @@ enum cpole1_capacitor {
* @name: Optional alternative iio device name.
*/
-struct ad9523_platform_data {
+struct ad9523_config {
unsigned long vcxo_freq;
/* Differential/ Single-Ended Input Configuration */
@@ -446,7 +446,7 @@ enum {
struct ad9523_state {
struct spi_device *spi;
- struct ad9523_platform_data *pdata;
+ struct ad9523_config *cfg;
struct iio_chan_spec ad9523_channels[AD9523_NUM_CHAN];
struct gpio_desc *pwrdown_gpio;
struct gpio_desc *reset_gpio;
@@ -934,7 +934,7 @@ static const struct iio_info ad9523_info = {
static int ad9523_setup(struct iio_dev *indio_dev)
{
struct ad9523_state *st = iio_priv(indio_dev);
- struct ad9523_platform_data *pdata = st->pdata;
+ struct ad9523_config *cfg = st->cfg;
struct ad9523_channel_spec *chan;
unsigned long active_mask = 0;
int ret, i;
@@ -959,22 +959,22 @@ static int ad9523_setup(struct iio_dev *indio_dev)
* PLL1 Setup
*/
ret = ad9523_write(indio_dev, AD9523_PLL1_REF_A_DIVIDER,
- pdata->refa_r_div);
+ cfg->refa_r_div);
if (ret < 0)
return ret;
ret = ad9523_write(indio_dev, AD9523_PLL1_REF_B_DIVIDER,
- pdata->refb_r_div);
+ cfg->refb_r_div);
if (ret < 0)
return ret;
ret = ad9523_write(indio_dev, AD9523_PLL1_FEEDBACK_DIVIDER,
- pdata->pll1_feedback_div);
+ cfg->pll1_feedback_div);
if (ret < 0)
return ret;
ret = ad9523_write(indio_dev, AD9523_PLL1_CHARGE_PUMP_CTRL,
- AD9523_PLL1_CHARGE_PUMP_CURRENT_nA(pdata->pll1_charge_pump_current_nA) |
+ AD9523_PLL1_CHARGE_PUMP_CURRENT_nA(cfg->pll1_charge_pump_current_nA) |
AD9523_PLL1_CHARGE_PUMP_MODE_NORMAL |
AD9523_PLL1_BACKLASH_PW_MIN);
if (ret < 0)
@@ -1005,12 +1005,12 @@ static int ad9523_setup(struct iio_dev *indio_dev)
ret = ad9523_write(indio_dev, AD9523_PLL1_MISC_CTRL,
AD9523_PLL1_REFB_INDEP_DIV_CTRL_EN |
- AD9523_PLL1_REF_MODE(pdata->ref_mode));
+ AD9523_PLL1_REF_MODE(cfg->ref_mode));
if (ret < 0)
return ret;
ret = ad9523_write(indio_dev, AD9523_PLL1_LOOP_FILTER_CTRL,
- AD9523_PLL1_LOOP_FILTER_RZERO(pdata->pll1_loop_filter_rzero));
+ AD9523_PLL1_LOOP_FILTER_RZERO(cfg->pll1_loop_filter_rzero));
if (ret < 0)
return ret;
/*
@@ -1018,13 +1018,13 @@ static int ad9523_setup(struct iio_dev *indio_dev)
*/
ret = ad9523_write(indio_dev, AD9523_PLL2_CHARGE_PUMP,
- AD9523_PLL2_CHARGE_PUMP_CURRENT_nA(pdata->pll2_charge_pump_current_nA));
+ AD9523_PLL2_CHARGE_PUMP_CURRENT_nA(cfg->pll2_charge_pump_current_nA));
if (ret < 0)
return ret;
ret = ad9523_write(indio_dev, AD9523_PLL2_FEEDBACK_DIVIDER_AB,
- AD9523_PLL2_FB_NDIV_A_CNT(pdata->pll2_ndiv_a_cnt) |
- AD9523_PLL2_FB_NDIV_B_CNT(pdata->pll2_ndiv_b_cnt));
+ AD9523_PLL2_FB_NDIV_A_CNT(cfg->pll2_ndiv_a_cnt) |
+ AD9523_PLL2_FB_NDIV_B_CNT(cfg->pll2_ndiv_b_cnt));
if (ret < 0)
return ret;
@@ -1035,11 +1035,11 @@ static int ad9523_setup(struct iio_dev *indio_dev)
if (ret < 0)
return ret;
- st->vco_freq = div_u64((unsigned long long)pdata->vcxo_freq *
- (pdata->pll2_freq_doubler_en ? 2 : 1) *
- AD9523_PLL2_FB_NDIV(pdata->pll2_ndiv_a_cnt,
- pdata->pll2_ndiv_b_cnt),
- pdata->pll2_r2_div);
+ st->vco_freq = div_u64((unsigned long long)cfg->vcxo_freq *
+ (cfg->pll2_freq_doubler_en ? 2 : 1) *
+ AD9523_PLL2_FB_NDIV(cfg->pll2_ndiv_a_cnt,
+ cfg->pll2_ndiv_b_cnt),
+ cfg->pll2_r2_div);
ret = ad9523_write(indio_dev, AD9523_PLL2_VCO_CTRL,
AD9523_PLL2_VCO_CALIBRATE);
@@ -1047,8 +1047,8 @@ static int ad9523_setup(struct iio_dev *indio_dev)
return ret;
ret = ad9523_write(indio_dev, AD9523_PLL2_VCO_DIVIDER,
- AD9523_PLL2_VCO_DIV_M1(pdata->pll2_vco_div_m1) |
- AD9523_PLL2_VCO_DIV_M2(pdata->pll2_vco_div_m2) |
+ AD9523_PLL2_VCO_DIV_M1(cfg->pll2_vco_div_m1) |
+ AD9523_PLL2_VCO_DIV_M2(cfg->pll2_vco_div_m2) |
AD_IFE(pll2_vco_div_m1, 0,
AD9523_PLL2_VCO_DIV_M1_PWR_DOWN_EN) |
AD_IFE(pll2_vco_div_m2, 0,
@@ -1056,32 +1056,32 @@ static int ad9523_setup(struct iio_dev *indio_dev)
if (ret < 0)
return ret;
- if (pdata->pll2_vco_div_m1)
+ if (cfg->pll2_vco_div_m1)
st->vco_out_freq[AD9523_VCO1] =
- st->vco_freq / pdata->pll2_vco_div_m1;
+ st->vco_freq / cfg->pll2_vco_div_m1;
- if (pdata->pll2_vco_div_m2)
+ if (cfg->pll2_vco_div_m2)
st->vco_out_freq[AD9523_VCO2] =
- st->vco_freq / pdata->pll2_vco_div_m2;
+ st->vco_freq / cfg->pll2_vco_div_m2;
- st->vco_out_freq[AD9523_VCXO] = pdata->vcxo_freq;
+ st->vco_out_freq[AD9523_VCXO] = cfg->vcxo_freq;
ret = ad9523_write(indio_dev, AD9523_PLL2_R2_DIVIDER,
- AD9523_PLL2_R2_DIVIDER_VAL(pdata->pll2_r2_div));
+ AD9523_PLL2_R2_DIVIDER_VAL(cfg->pll2_r2_div));
if (ret < 0)
return ret;
ret = ad9523_write(indio_dev, AD9523_PLL2_LOOP_FILTER_CTRL,
- AD9523_PLL2_LOOP_FILTER_CPOLE1(pdata->cpole1) |
- AD9523_PLL2_LOOP_FILTER_RZERO(pdata->rzero) |
- AD9523_PLL2_LOOP_FILTER_RPOLE2(pdata->rpole2) |
+ AD9523_PLL2_LOOP_FILTER_CPOLE1(cfg->cpole1) |
+ AD9523_PLL2_LOOP_FILTER_RZERO(cfg->rzero) |
+ AD9523_PLL2_LOOP_FILTER_RPOLE2(cfg->rpole2) |
AD_IF(rzero_bypass_en,
AD9523_PLL2_LOOP_FILTER_RZERO_BYPASS_EN));
if (ret < 0)
return ret;
- for (i = 0; i < pdata->num_channels; i++) {
- chan = &pdata->channels[i];
+ for (i = 0; i < cfg->num_channels; i++) {
+ chan = &cfg->channels[i];
if (chan->channel_num < AD9523_NUM_CHAN) {
__set_bit(chan->channel_num, &active_mask);
ret = ad9523_write(indio_dev,
@@ -1146,13 +1146,13 @@ static int ad9523_setup(struct iio_dev *indio_dev)
static int ad9523_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
- struct ad9523_platform_data *pdata;
+ struct ad9523_config *cfg;
struct iio_dev *indio_dev;
struct ad9523_state *st;
int ret;
- pdata = dev_get_platdata(dev);
- if (!pdata)
+ cfg = dev_get_platdata(dev);
+ if (!cfg)
return dev_err_probe(dev, -EINVAL, "no platform data?\n");
indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
@@ -1188,14 +1188,14 @@ static int ad9523_probe(struct spi_device *spi)
return PTR_ERR(st->sync_gpio);
st->spi = spi;
- st->pdata = pdata;
+ st->cfg = cfg;
- indio_dev->name = (pdata->name[0] != 0) ? pdata->name :
+ indio_dev->name = (cfg->name[0] != 0) ? cfg->name :
spi_get_device_id(spi)->name;
indio_dev->info = &ad9523_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = st->ad9523_channels;
- indio_dev->num_channels = pdata->num_channels;
+ indio_dev->num_channels = cfg->num_channels;
ret = ad9523_setup(indio_dev);
if (ret < 0)
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 09/16] iio: frequency: ad9523: always bypass PLL1
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (7 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 08/16] iio: frequency: ad9523: rename the platform data to config Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 10/16] iio: frequency: ad9523: drop unused channel options Nuno Sá
` (6 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
As far as we know, downstream users of this driver only run the device
in single loop mode, with PLL1 bypassed and the VCXO on OSC_IN directly
feeding PLL2. Dual loop operation is only available through platform
data, which has no users.
So enforce single loop mode and always bypass PLL1: tristate its charge
pump, power down the REFA and REFB receivers and bypass the feedback
divider. The remaining PLL1 registers are left at their reset values,
so drop the PLL1 configuration options.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 100 ++++-------------------------------------
1 file changed, 8 insertions(+), 92 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index c3d3209b5ce4..bf6954e8c099 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -259,14 +259,6 @@ enum outp_drv_mode {
CMOS_CONF9
};
-enum ref_sel_mode {
- NONEREVERTIVE_STAY_ON_REFB,
- REVERT_TO_REFA,
- SELECT_REFA,
- SELECT_REFB,
- EXT_REF_SEL
-};
-
/**
* struct ad9523_channel_spec - Output channel configuration
*
@@ -297,15 +289,6 @@ struct ad9523_channel_spec {
char extended_name[16];
};
-enum pll1_rzero_resistor {
- RZERO_883_OHM,
- RZERO_677_OHM,
- RZERO_341_OHM,
- RZERO_135_OHM,
- RZERO_10_OHM,
- RZERO_USE_EXT_RES = 8,
-};
-
enum rpole2_resistor {
RPOLE2_900_OHM,
RPOLE2_450_OHM,
@@ -339,23 +322,8 @@ enum cpole1_capacitor {
* struct ad9523_config - device configuration
*
* @vcxo_freq: External VCXO frequency in Hz
- * @refa_diff_rcv_en: REFA differential/single-ended input selection.
- * @refb_diff_rcv_en: REFB differential/single-ended input selection.
- * @zd_in_diff_en: Zero Delay differential/single-ended input selection.
* @osc_in_diff_en: OSC differential/ single-ended input selection.
- * @refa_cmos_neg_inp_en: REFA single-ended neg./pos. input enable.
- * @refb_cmos_neg_inp_en: REFB single-ended neg./pos. input enable.
- * @zd_in_cmos_neg_inp_en: Zero Delay single-ended neg./pos. input enable.
* @osc_in_cmos_neg_inp_en: OSC single-ended neg./pos. input enable.
- * @refa_r_div: PLL1 10-bit REFA R divider.
- * @refb_r_div: PLL1 10-bit REFB R divider.
- * @pll1_feedback_div: PLL1 10-bit Feedback N divider.
- * @pll1_charge_pump_current_nA: Magnitude of PLL1 charge pump current (nA).
- * @zero_delay_mode_internal_en: Internal, external Zero Delay mode selection.
- * @osc_in_feedback_en: PLL1 feedback path, local feedback from
- * the OSC_IN receiver or zero delay mode
- * @pll1_loop_filter_rzero: PLL1 Loop Filter Zero Resistor selection.
- * @ref_mode: Reference selection mode.
* @pll2_charge_pump_current_nA: Magnitude of PLL2 charge pump current (nA).
* @pll2_ndiv_a_cnt: PLL2 Feedback N-divider, A Counter, range 0..4.
* @pll2_ndiv_b_cnt: PLL2 Feedback N-divider, B Counter, range 0..63.
@@ -376,32 +344,14 @@ struct ad9523_config {
unsigned long vcxo_freq;
/* Differential/ Single-Ended Input Configuration */
- bool refa_diff_rcv_en;
- bool refb_diff_rcv_en;
- bool zd_in_diff_en;
bool osc_in_diff_en;
/*
* Valid if differential input disabled
* if false defaults to pos input
*/
- bool refa_cmos_neg_inp_en;
- bool refb_cmos_neg_inp_en;
- bool zd_in_cmos_neg_inp_en;
bool osc_in_cmos_neg_inp_en;
- /* PLL1 Setting */
- unsigned short refa_r_div;
- unsigned short refb_r_div;
- unsigned short pll1_feedback_div;
- unsigned short pll1_charge_pump_current_nA;
- bool zero_delay_mode_internal_en;
- bool osc_in_feedback_en;
- enum pll1_rzero_resistor pll1_loop_filter_rzero;
-
- /* Reference */
- enum ref_sel_mode ref_mode;
-
/* PLL2 Setting */
unsigned int pll2_charge_pump_current_nA;
unsigned char pll2_ndiv_a_cnt;
@@ -956,63 +906,29 @@ static int ad9523_setup(struct iio_dev *indio_dev)
return ret;
/*
- * PLL1 Setup
+ * PLL1 Setup: only single loop mode is supported, so PLL1 is bypassed
+ * and OSC_IN directly feeds PLL2. The rest of PLL1 is left at its
+ * reset values as it is not used.
*/
- ret = ad9523_write(indio_dev, AD9523_PLL1_REF_A_DIVIDER,
- cfg->refa_r_div);
- if (ret < 0)
- return ret;
-
- ret = ad9523_write(indio_dev, AD9523_PLL1_REF_B_DIVIDER,
- cfg->refb_r_div);
- if (ret < 0)
- return ret;
-
- ret = ad9523_write(indio_dev, AD9523_PLL1_FEEDBACK_DIVIDER,
- cfg->pll1_feedback_div);
- if (ret < 0)
- return ret;
-
ret = ad9523_write(indio_dev, AD9523_PLL1_CHARGE_PUMP_CTRL,
- AD9523_PLL1_CHARGE_PUMP_CURRENT_nA(cfg->pll1_charge_pump_current_nA) |
- AD9523_PLL1_CHARGE_PUMP_MODE_NORMAL |
- AD9523_PLL1_BACKLASH_PW_MIN);
+ AD9523_PLL1_CHARGE_PUMP_TRISTATE);
if (ret < 0)
return ret;
ret = ad9523_write(indio_dev, AD9523_PLL1_INPUT_RECEIVERS_CTRL,
- AD_IF(refa_diff_rcv_en, AD9523_PLL1_REFA_RCV_EN) |
- AD_IF(refb_diff_rcv_en, AD9523_PLL1_REFB_RCV_EN) |
+ AD9523_PLL1_REFA_REFB_PWR_CTRL_EN |
AD_IF(osc_in_diff_en, AD9523_PLL1_OSC_IN_DIFF_EN) |
AD_IF(osc_in_cmos_neg_inp_en,
- AD9523_PLL1_OSC_IN_CMOS_NEG_INP_EN) |
- AD_IF(refa_diff_rcv_en, AD9523_PLL1_REFA_DIFF_RCV_EN) |
- AD_IF(refb_diff_rcv_en, AD9523_PLL1_REFB_DIFF_RCV_EN));
+ AD9523_PLL1_OSC_IN_CMOS_NEG_INP_EN));
if (ret < 0)
return ret;
ret = ad9523_write(indio_dev, AD9523_PLL1_REF_CTRL,
- AD_IF(zd_in_diff_en, AD9523_PLL1_ZD_IN_DIFF_EN) |
- AD_IF(zd_in_cmos_neg_inp_en,
- AD9523_PLL1_ZD_IN_CMOS_NEG_INP_EN) |
- AD_IF(zero_delay_mode_internal_en,
- AD9523_PLL1_ZERO_DELAY_MODE_INT) |
- AD_IF(osc_in_feedback_en, AD9523_PLL1_OSC_IN_PLL_FEEDBACK_EN) |
- AD_IF(refa_cmos_neg_inp_en, AD9523_PLL1_REFA_CMOS_NEG_INP_EN) |
- AD_IF(refb_cmos_neg_inp_en, AD9523_PLL1_REFB_CMOS_NEG_INP_EN));
+ AD9523_PLL1_BYPASS_FEEDBACK_DIV_EN |
+ AD9523_PLL1_ZERO_DELAY_MODE_INT);
if (ret < 0)
return ret;
- ret = ad9523_write(indio_dev, AD9523_PLL1_MISC_CTRL,
- AD9523_PLL1_REFB_INDEP_DIV_CTRL_EN |
- AD9523_PLL1_REF_MODE(cfg->ref_mode));
- if (ret < 0)
- return ret;
-
- ret = ad9523_write(indio_dev, AD9523_PLL1_LOOP_FILTER_CTRL,
- AD9523_PLL1_LOOP_FILTER_RZERO(cfg->pll1_loop_filter_rzero));
- if (ret < 0)
- return ret;
/*
* PLL2 Setup
*/
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 10/16] iio: frequency: ad9523: drop unused channel options
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (8 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 09/16] iio: frequency: ad9523: always bypass PLL1 Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 11/16] iio: frequency: ad9523: use read_label() for channel names Nuno Sá
` (5 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
Most of the channel options are only available through platform data,
which has no users:
- ignoring the SYNC signal and the lower power mode of the output
driver.
- the clock source, the divider, the phase and whether the output is
enabled. The driver selects the clock source when the channel
frequency is set, and the frequency, phase and enable can all be set
at runtime.
So drop these options. All channels now start powered down, from the M1
divider and with the divider and phase power-up defaults.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 32 ++++++++------------------------
1 file changed, 8 insertions(+), 24 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index bf6954e8c099..66083af2be4e 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -264,28 +264,14 @@ enum outp_drv_mode {
*
* @channel_num: Output channel number.
* @divider_output_invert_en: Invert the polarity of the output clock.
- * @sync_ignore_en: Ignore chip-level SYNC signal.
- * @low_power_mode_en: Reduce power used in the differential output modes.
- * @use_alt_clock_src: Channel divider uses alternative clk source.
- * @output_dis: Disables, powers down the entire channel.
* @driver_mode: Output driver mode (logic level family).
- * @divider_phase: Divider initial phase after a SYNC. Range 0..63
- * LSB = 1/2 of a period of the divider input clock.
- * @channel_divider: 10-bit channel divider.
* @extended_name: Optional descriptive channel name.
*/
struct ad9523_channel_spec {
unsigned int channel_num;
bool divider_output_invert_en;
- bool sync_ignore_en;
- bool low_power_mode_en;
- /* CH0..CH3 VCXO, CH4..CH9 VCO2 */
- bool use_alt_clock_src;
- bool output_dis;
enum outp_drv_mode driver_mode;
- unsigned char divider_phase;
- unsigned short channel_divider;
char extended_name[16];
};
@@ -1000,24 +986,22 @@ static int ad9523_setup(struct iio_dev *indio_dev)
chan = &cfg->channels[i];
if (chan->channel_num < AD9523_NUM_CHAN) {
__set_bit(chan->channel_num, &active_mask);
+ /*
+ * The output starts powered down, with the divider and
+ * phase power-up defaults. They are set at runtime.
+ */
ret = ad9523_write(indio_dev,
AD9523_CHANNEL_CLOCK_DIST(chan->channel_num),
AD9523_CLK_DIST_DRIVER_MODE(chan->driver_mode) |
- AD9523_CLK_DIST_DIV(chan->channel_divider) |
- AD9523_CLK_DIST_DIV_PHASE(chan->divider_phase) |
- (chan->sync_ignore_en ?
- AD9523_CLK_DIST_IGNORE_SYNC_EN : 0) |
+ AD9523_CLK_DIST_DIV(32) |
+ AD9523_CLK_DIST_DIV_PHASE(1) |
(chan->divider_output_invert_en ?
AD9523_CLK_DIST_INV_DIV_OUTPUT_EN : 0) |
- (chan->low_power_mode_en ?
- AD9523_CLK_DIST_LOW_PWR_MODE_EN : 0) |
- (chan->output_dis ?
- AD9523_CLK_DIST_PWR_DOWN_EN : 0));
+ AD9523_CLK_DIST_PWR_DOWN_EN);
if (ret < 0)
return ret;
- ret = ad9523_vco_out_map(indio_dev, chan->channel_num,
- chan->use_alt_clock_src);
+ ret = ad9523_vco_out_map(indio_dev, chan->channel_num, 0);
if (ret < 0)
return ret;
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 11/16] iio: frequency: ad9523: use read_label() for channel names
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (9 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 10/16] iio: frequency: ad9523: drop unused channel options Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 12/16] dt-bindings: iio: frequency: Add AD9523-1 Nuno Sá
` (4 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
The optional channel name is passed in as extend_name, which ends up in
the name of every sysfs attribute of the channel, like
out_altvoltage1_DAC_CLK_frequency. Using extend_name for this is
discouraged, and it does not fit names coming from firmware.
Expose the name through the channel label instead, so the attributes
keep their standard names. This changes the attribute names of named
channels, but the name can only be given through platform data, which
has no users.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 66083af2be4e..dbf29797130b 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -392,6 +392,7 @@ struct ad9523_state {
unsigned long vco_freq;
unsigned long vco_out_freq[AD9523_NUM_CLK_SRC];
unsigned char vco_out_map[AD9523_NUM_CHAN];
+ const char *labels[AD9523_NUM_CHAN];
/*
* Lock for accessing device registers. Some operations require
@@ -860,9 +861,21 @@ static int ad9523_reg_access(struct iio_dev *indio_dev,
return ret;
}
+static int ad9523_read_label(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, char *label)
+{
+ struct ad9523_state *st = iio_priv(indio_dev);
+
+ if (!st->labels[chan->channel])
+ return -ENOENT;
+
+ return sysfs_emit(label, "%s\n", st->labels[chan->channel]);
+}
+
static const struct iio_info ad9523_info = {
.read_raw = &ad9523_read_raw,
.write_raw = &ad9523_write_raw,
+ .read_label = &ad9523_read_label,
.debugfs_reg_access = &ad9523_reg_access,
.attrs = &ad9523_attribute_group,
};
@@ -1009,8 +1022,9 @@ static int ad9523_setup(struct iio_dev *indio_dev)
st->ad9523_channels[i].output = 1;
st->ad9523_channels[i].indexed = 1;
st->ad9523_channels[i].channel = chan->channel_num;
- st->ad9523_channels[i].extend_name =
- chan->extended_name;
+ if (chan->extended_name[0])
+ st->labels[chan->channel_num] =
+ chan->extended_name;
st->ad9523_channels[i].info_mask_separate =
BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_PHASE) |
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 12/16] dt-bindings: iio: frequency: Add AD9523-1
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (10 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 11/16] iio: frequency: ad9523: use read_label() for channel names Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 18:50 ` Conor Dooley
2026-11-30 17:37 ` [PATCH 13/16] iio: frequency: ad9523: add firmware support and drop platform data Nuno Sá
` (3 subsequent siblings)
15 siblings, 1 reply; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
Document the Analog Devices AD9523-1 jitter cleaner and clock generator.
Only single loop operation is described for now, with PLL1 bypassed and
the VCXO on OSC_IN directly feeding PLL2. This is how the known boards
use it. REFA/REFB and the PLL1 properties can be added later without
breaking anything, as a missing reference clock keeps meaning that PLL1
is bypassed.
The PLL2 frequency plan is described by the M1 (and optionally M2)
output frequency, which also sets the VCO frequency. Like for other
PLLs, the reference divider and doubler can be given as they affect the
PFD frequency, and with it the loop filter design. The charge pump
current and the loop filter components are given in physical units.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
.../bindings/iio/frequency/adi,ad9523-1.yaml | 289 +++++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 290 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/frequency/adi,ad9523-1.yaml b/Documentation/devicetree/bindings/iio/frequency/adi,ad9523-1.yaml
new file mode 100644
index 000000000000..e0f328866859
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/frequency/adi,ad9523-1.yaml
@@ -0,0 +1,289 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/frequency/adi,ad9523-1.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices AD9523-1 low jitter clock generator
+
+maintainers:
+ - Michael Hennerich <michael.hennerich@analog.com>
+ - Nuno Sá <nuno.sa@analog.com>
+
+description:
+ Jitter cleaner and clock generator with 14 differential (or up to 29 LVCMOS)
+ outputs. It has two cascaded PLLs. PLL1 cleans up a reference on REFA/REFB
+ using an external VCXO on OSC_IN, and PLL2 multiplies the OSC_IN clock up to
+ the VCO frequency. The VCO output goes through the M1 and M2 dividers to the
+ output channels, each with its own divider.
+
+ Only single loop operation is described for now, with PLL1 bypassed and the
+ VCXO on OSC_IN directly feeding PLL2.
+
+ https://www.analog.com/media/en/technical-documentation/data-sheets/AD9523-1.pdf
+
+properties:
+ compatible:
+ const: adi,ad9523-1
+
+ reg:
+ maxItems: 1
+
+ spi-max-frequency:
+ maximum: 25000000
+
+ "#address-cells":
+ const: 1
+
+ "#size-cells":
+ const: 0
+
+ clocks:
+ items:
+ - description: VCXO connected to OSC_IN.
+
+ clock-names:
+ items:
+ - const: oscin
+
+ "#clock-cells":
+ const: 1
+
+ clock-output-names:
+ minItems: 1
+ maxItems: 14
+
+ vdd3-pll-supply:
+ description: 3.3 V supply for PLL1 and PLL2 (VDD3_PLL).
+
+ vdd3-vco-supply:
+ description: 3.3 V supply for the VCO and VCO divider M1 (VDD3_VCO).
+
+ vdd3-ref-supply:
+ description:
+ 3.3 V supply for the output drivers reference and VCO divider M2
+ (VDD3_REF).
+
+ vdd3-out-supply:
+ description: 3.3 V supply for the output drivers (VDD3_OUT[x:y]).
+
+ vdd18-out-supply:
+ description: 1.8 V supply for the output dividers (VDD1.8_OUT[x:y]).
+
+ powerdown-gpios:
+ description: GPIO connected to the active low PD pin.
+ maxItems: 1
+
+ reset-gpios:
+ description: GPIO connected to the active low RESET pin.
+ maxItems: 1
+
+ sync-gpios:
+ description: GPIO connected to the active low SYNC pin.
+ maxItems: 1
+
+ adi,oscin-mode:
+ description:
+ How the OSC_IN receiver is used. In single-ended mode, either the
+ positive (OSC_IN) or the negative (OSC_IN complement) pin is used.
+ enum: [single-ended-positive, single-ended-negative, differential]
+ default: single-ended-positive
+
+ adi,pll2-charge-pump-current-nanoamp:
+ description:
+ PLL2 charge pump current, in steps of 3.5 uA. This value depends on the
+ PLL2 loop filter design.
+ minimum: 3500
+ maximum: 892500
+
+ adi,pll2-m1-frequency-hz:
+ description:
+ Output frequency of the VCO divider M1, which feeds all output channels.
+ M1 divides the VCO frequency (2940 MHz to 3100 MHz) by 3, 4 or 5, so the
+ valid ranges are 588 MHz to 620 MHz, 735 MHz to 775 MHz and 980 MHz to
+ 1033.33 MHz. It sets the frequencies the outputs can provide and,
+ together with the PFD frequency, the PLL2 feedback divider the loop
+ filter is designed for.
+ minimum: 588000000
+ maximum: 1033333333
+
+ adi,pll2-m2-frequency-hz:
+ description:
+ Output frequency of the VCO divider M2, which can feed output channels 4
+ to 9. The VCO frequency divided by this value must be 3, 4 or 5. If not
+ present, the M2 divider is powered down.
+ minimum: 588000000
+ maximum: 1033333333
+
+ adi,pll2-reference-div-factor:
+ description:
+ PLL2 reference divider (R2). Together with the reference doubler, it
+ sets the PLL2 PFD frequency, which must not exceed 259 MHz. The VCO
+ frequency must be an integer multiple N of the PFD frequency, where the
+ feedback divider supports N = 12, 16 to 17, 20 to 22, 24 to 26 and 28 to
+ 255. As it affects the PFD frequency, this value depends on the PLL2
+ loop filter design.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 1
+ maximum: 31
+ default: 1
+
+ adi,pll2-reference-doubler-enable:
+ description:
+ Enable the frequency doubler at the PLL2 input. As it affects the PFD
+ frequency, this value depends on the PLL2 loop filter design.
+ type: boolean
+
+ adi,pll2-loop-filter-rzero-ohms:
+ description:
+ Internal PLL2 loop filter zero resistor (RZERO). The PLL2 loop filter is
+ made of these internal components and an external capacitor on the
+ board, and together with the charge pump current they set the loop
+ bandwidth and phase margin. So their values come from the loop filter
+ design of the board. 0 bypasses the internal resistor, which requires an
+ external series zero resistor.
+ enum: [0, 1850, 2000, 2100, 2250, 2500, 2750, 3000, 3250]
+ default: 3250
+
+ adi,pll2-loop-filter-rpole2-ohms:
+ description:
+ Internal PLL2 loop filter pole 2 resistor (RPOLE2). Like the other loop
+ filter components, its value depends on the loop filter design.
+ enum: [225, 300, 450, 900]
+ default: 900
+
+ adi,pll2-loop-filter-cpole1-picofarads:
+ description:
+ Internal PLL2 loop filter pole 1 capacitor (CPOLE1). Like the other loop
+ filter components, its value depends on the loop filter design.
+ enum: [0, 8, 16, 24, 32, 40, 48]
+ default: 0
+
+patternProperties:
+ "^channel@([0-9]|1[0-3])$":
+ type: object
+ description: Output channel.
+
+ properties:
+ reg:
+ description: Output channel number.
+ maximum: 13
+
+ label: true
+
+ adi,driver-mode:
+ description:
+ Output driver mode. The CMOS modes are named cmos-<pos>-<neg>, where
+ each pin is either true or complement phase relative to the divider
+ output, or high-Z.
+ enum:
+ - lvpecl-8ma
+ - lvds-3.5ma
+ - lvds-7ma
+ - hstl0-16ma
+ - hstl1-8ma
+ - cmos-true-true
+ - cmos-true-complement
+ - cmos-true-hiz
+ - cmos-hiz-true
+ - cmos-hiz-hiz
+ - cmos-complement-complement
+ - cmos-complement-true
+ - cmos-complement-hiz
+ - cmos-hiz-complement
+
+ adi,divider-output-invert-enable:
+ description: Invert the polarity of the channel output.
+ type: boolean
+
+ always-on:
+ description: Keep the output running even if no consumer uses it.
+ type: boolean
+
+ required:
+ - reg
+ - adi,driver-mode
+
+ additionalProperties: false
+
+dependencies:
+ clock-output-names: [ "#clock-cells" ]
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - vdd3-pll-supply
+ - vdd3-vco-supply
+ - vdd3-ref-supply
+ - vdd3-out-supply
+ - vdd18-out-supply
+ - adi,pll2-charge-pump-current-nanoamp
+ - adi,pll2-m1-frequency-hz
+
+allOf:
+ - $ref: /schemas/spi/spi-peripheral-props.yaml#
+ - if:
+ not:
+ required:
+ - "#clock-cells"
+ then:
+ patternProperties:
+ "^channel@([0-9]|1[0-3])$":
+ properties:
+ always-on: false
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+
+ spi {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ clock-controller@0 {
+ compatible = "adi,ad9523-1";
+ reg = <0>;
+ spi-max-frequency = <10000000>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ #clock-cells = <1>;
+
+ clocks = <&vcxo>;
+ clock-names = "oscin";
+
+ vdd3-pll-supply = <&vdd3>;
+ vdd3-vco-supply = <&vdd3>;
+ vdd3-ref-supply = <&vdd3>;
+ vdd3-out-supply = <&vdd3>;
+ vdd18-out-supply = <&vdd18>;
+
+ powerdown-gpios = <&gpio 93 GPIO_ACTIVE_LOW>;
+ reset-gpios = <&gpio 91 GPIO_ACTIVE_LOW>;
+ sync-gpios = <&gpio 92 GPIO_ACTIVE_LOW>;
+
+ adi,oscin-mode = "differential";
+ adi,pll2-charge-pump-current-nanoamp = <413000>;
+ adi,pll2-m1-frequency-hz = <1000000000>;
+ adi,pll2-loop-filter-rzero-ohms = <1850>;
+ adi,pll2-loop-filter-rpole2-ohms = <900>;
+ adi,pll2-loop-filter-cpole1-picofarads = <16>;
+
+ channel@1 {
+ reg = <1>;
+ label = "dac-clk";
+ adi,driver-mode = "lvds-7ma";
+ };
+
+ channel@5 {
+ reg = <5>;
+ label = "fpga-clk";
+ adi,driver-mode = "lvds-7ma";
+ always-on;
+ };
+ };
+ };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index d747e10ef125..3edb552c50ea 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1765,6 +1765,7 @@ L: linux@analog.com
L: linux-iio@vger.kernel.org
S: Supported
W: https://ez.analog.com/linux-software-drivers
+F: Documentation/devicetree/bindings/iio/frequency/adi,ad9523-1.yaml
F: drivers/iio/frequency/ad9523.c
ANALOG DEVICES INC AD9739a DRIVER
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 12/16] dt-bindings: iio: frequency: Add AD9523-1
2026-11-30 17:37 ` [PATCH 12/16] dt-bindings: iio: frequency: Add AD9523-1 Nuno Sá
@ 2026-11-30 18:50 ` Conor Dooley
0 siblings, 0 replies; 18+ messages in thread
From: Conor Dooley @ 2026-11-30 18:50 UTC (permalink / raw)
To: Nuno Sá
Cc: linux-iio, linux-kernel, devicetree, Jonathan Cameron,
Michael Hennerich, David Lechner, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann, linux
[-- Attachment #1: Type: text/plain, Size: 11590 bytes --]
On Mon, Nov 30, 2026 at 05:37:10PM +0000, Nuno Sá wrote:
> Document the Analog Devices AD9523-1 jitter cleaner and clock generator.
>
> Only single loop operation is described for now, with PLL1 bypassed and
> the VCXO on OSC_IN directly feeding PLL2. This is how the known boards
> use it. REFA/REFB and the PLL1 properties can be added later without
> breaking anything, as a missing reference clock keeps meaning that PLL1
> is bypassed.
>
> The PLL2 frequency plan is described by the M1 (and optionally M2)
> output frequency, which also sets the VCO frequency. Like for other
> PLLs, the reference divider and doubler can be given as they affect the
> PFD frequency, and with it the loop filter design. The charge pump
> current and the loop filter components are given in physical units.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
> .../bindings/iio/frequency/adi,ad9523-1.yaml | 289 +++++++++++++++++++++
> MAINTAINERS | 1 +
> 2 files changed, 290 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/frequency/adi,ad9523-1.yaml b/Documentation/devicetree/bindings/iio/frequency/adi,ad9523-1.yaml
> new file mode 100644
> index 000000000000..e0f328866859
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/frequency/adi,ad9523-1.yaml
> @@ -0,0 +1,289 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/frequency/adi,ad9523-1.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Analog Devices AD9523-1 low jitter clock generator
> +
> +maintainers:
> + - Michael Hennerich <michael.hennerich@analog.com>
> + - Nuno Sá <nuno.sa@analog.com>
> +
> +description:
> + Jitter cleaner and clock generator with 14 differential (or up to 29 LVCMOS)
> + outputs. It has two cascaded PLLs. PLL1 cleans up a reference on REFA/REFB
> + using an external VCXO on OSC_IN, and PLL2 multiplies the OSC_IN clock up to
> + the VCO frequency. The VCO output goes through the M1 and M2 dividers to the
> + output channels, each with its own divider.
> +
> + Only single loop operation is described for now, with PLL1 bypassed and the
> + VCXO on OSC_IN directly feeding PLL2.
> +
> + https://www.analog.com/media/en/technical-documentation/data-sheets/AD9523-1.pdf
> +
> +properties:
> + compatible:
> + const: adi,ad9523-1
> +
> + reg:
> + maxItems: 1
> +
> + spi-max-frequency:
> + maximum: 25000000
> +
> + "#address-cells":
> + const: 1
> +
> + "#size-cells":
> + const: 0
> +
> + clocks:
> + items:
> + - description: VCXO connected to OSC_IN.
> +
> + clock-names:
> + items:
> + - const: oscin
> +
> + "#clock-cells":
> + const: 1
> +
> + clock-output-names:
> + minItems: 1
> + maxItems: 14
> +
> + vdd3-pll-supply:
> + description: 3.3 V supply for PLL1 and PLL2 (VDD3_PLL).
> +
> + vdd3-vco-supply:
> + description: 3.3 V supply for the VCO and VCO divider M1 (VDD3_VCO).
> +
> + vdd3-ref-supply:
> + description:
> + 3.3 V supply for the output drivers reference and VCO divider M2
> + (VDD3_REF).
> +
> + vdd3-out-supply:
> + description: 3.3 V supply for the output drivers (VDD3_OUT[x:y]).
> +
> + vdd18-out-supply:
> + description: 1.8 V supply for the output dividers (VDD1.8_OUT[x:y]).
> +
> + powerdown-gpios:
> + description: GPIO connected to the active low PD pin.
> + maxItems: 1
> +
> + reset-gpios:
> + description: GPIO connected to the active low RESET pin.
> + maxItems: 1
> +
> + sync-gpios:
> + description: GPIO connected to the active low SYNC pin.
> + maxItems: 1
> +
> + adi,oscin-mode:
> + description:
> + How the OSC_IN receiver is used. In single-ended mode, either the
> + positive (OSC_IN) or the negative (OSC_IN complement) pin is used.
> + enum: [single-ended-positive, single-ended-negative, differential]
> + default: single-ended-positive
> +
> + adi,pll2-charge-pump-current-nanoamp:
> + description:
> + PLL2 charge pump current, in steps of 3.5 uA. This value depends on the
> + PLL2 loop filter design.
> + minimum: 3500
> + maximum: 892500
> +
> + adi,pll2-m1-frequency-hz:
> + description:
> + Output frequency of the VCO divider M1, which feeds all output channels.
> + M1 divides the VCO frequency (2940 MHz to 3100 MHz) by 3, 4 or 5, so the
> + valid ranges are 588 MHz to 620 MHz, 735 MHz to 775 MHz and 980 MHz to
> + 1033.33 MHz. It sets the frequencies the outputs can provide and,
> + together with the PFD frequency, the PLL2 feedback divider the loop
> + filter is designed for.
> + minimum: 588000000
> + maximum: 1033333333
> +
> + adi,pll2-m2-frequency-hz:
> + description:
> + Output frequency of the VCO divider M2, which can feed output channels 4
> + to 9. The VCO frequency divided by this value must be 3, 4 or 5. If not
> + present, the M2 divider is powered down.
> + minimum: 588000000
> + maximum: 1033333333
I note that these properties are exceptional in that they don't have a
comment noting that they depend on hardware characteristics of the
board.
Why are these not computable?
Cheers,
Conor.
> +
> + adi,pll2-reference-div-factor:
> + description:
> + PLL2 reference divider (R2). Together with the reference doubler, it
> + sets the PLL2 PFD frequency, which must not exceed 259 MHz. The VCO
> + frequency must be an integer multiple N of the PFD frequency, where the
> + feedback divider supports N = 12, 16 to 17, 20 to 22, 24 to 26 and 28 to
> + 255. As it affects the PFD frequency, this value depends on the PLL2
> + loop filter design.
> + $ref: /schemas/types.yaml#/definitions/uint32
> + minimum: 1
> + maximum: 31
> + default: 1
> +
> + adi,pll2-reference-doubler-enable:
> + description:
> + Enable the frequency doubler at the PLL2 input. As it affects the PFD
> + frequency, this value depends on the PLL2 loop filter design.
> + type: boolean
> +
> + adi,pll2-loop-filter-rzero-ohms:
> + description:
> + Internal PLL2 loop filter zero resistor (RZERO). The PLL2 loop filter is
> + made of these internal components and an external capacitor on the
> + board, and together with the charge pump current they set the loop
> + bandwidth and phase margin. So their values come from the loop filter
> + design of the board. 0 bypasses the internal resistor, which requires an
> + external series zero resistor.
> + enum: [0, 1850, 2000, 2100, 2250, 2500, 2750, 3000, 3250]
> + default: 3250
> +
> + adi,pll2-loop-filter-rpole2-ohms:
> + description:
> + Internal PLL2 loop filter pole 2 resistor (RPOLE2). Like the other loop
> + filter components, its value depends on the loop filter design.
> + enum: [225, 300, 450, 900]
> + default: 900
> +
> + adi,pll2-loop-filter-cpole1-picofarads:
> + description:
> + Internal PLL2 loop filter pole 1 capacitor (CPOLE1). Like the other loop
> + filter components, its value depends on the loop filter design.
> + enum: [0, 8, 16, 24, 32, 40, 48]
> + default: 0
> +
> +patternProperties:
> + "^channel@([0-9]|1[0-3])$":
> + type: object
> + description: Output channel.
> +
> + properties:
> + reg:
> + description: Output channel number.
> + maximum: 13
> +
> + label: true
> +
> + adi,driver-mode:
> + description:
> + Output driver mode. The CMOS modes are named cmos-<pos>-<neg>, where
> + each pin is either true or complement phase relative to the divider
> + output, or high-Z.
> + enum:
> + - lvpecl-8ma
> + - lvds-3.5ma
> + - lvds-7ma
> + - hstl0-16ma
> + - hstl1-8ma
> + - cmos-true-true
> + - cmos-true-complement
> + - cmos-true-hiz
> + - cmos-hiz-true
> + - cmos-hiz-hiz
> + - cmos-complement-complement
> + - cmos-complement-true
> + - cmos-complement-hiz
> + - cmos-hiz-complement
> +
> + adi,divider-output-invert-enable:
> + description: Invert the polarity of the channel output.
> + type: boolean
> +
> + always-on:
> + description: Keep the output running even if no consumer uses it.
> + type: boolean
> +
> + required:
> + - reg
> + - adi,driver-mode
> +
> + additionalProperties: false
> +
> +dependencies:
> + clock-output-names: [ "#clock-cells" ]
> +
> +required:
> + - compatible
> + - reg
> + - clocks
> + - clock-names
> + - vdd3-pll-supply
> + - vdd3-vco-supply
> + - vdd3-ref-supply
> + - vdd3-out-supply
> + - vdd18-out-supply
> + - adi,pll2-charge-pump-current-nanoamp
> + - adi,pll2-m1-frequency-hz
> +
> +allOf:
> + - $ref: /schemas/spi/spi-peripheral-props.yaml#
> + - if:
> + not:
> + required:
> + - "#clock-cells"
> + then:
> + patternProperties:
> + "^channel@([0-9]|1[0-3])$":
> + properties:
> + always-on: false
> +
> +unevaluatedProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/gpio/gpio.h>
> +
> + spi {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + clock-controller@0 {
> + compatible = "adi,ad9523-1";
> + reg = <0>;
> + spi-max-frequency = <10000000>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + #clock-cells = <1>;
> +
> + clocks = <&vcxo>;
> + clock-names = "oscin";
> +
> + vdd3-pll-supply = <&vdd3>;
> + vdd3-vco-supply = <&vdd3>;
> + vdd3-ref-supply = <&vdd3>;
> + vdd3-out-supply = <&vdd3>;
> + vdd18-out-supply = <&vdd18>;
> +
> + powerdown-gpios = <&gpio 93 GPIO_ACTIVE_LOW>;
> + reset-gpios = <&gpio 91 GPIO_ACTIVE_LOW>;
> + sync-gpios = <&gpio 92 GPIO_ACTIVE_LOW>;
> +
> + adi,oscin-mode = "differential";
> + adi,pll2-charge-pump-current-nanoamp = <413000>;
> + adi,pll2-m1-frequency-hz = <1000000000>;
> + adi,pll2-loop-filter-rzero-ohms = <1850>;
> + adi,pll2-loop-filter-rpole2-ohms = <900>;
> + adi,pll2-loop-filter-cpole1-picofarads = <16>;
> +
> + channel@1 {
> + reg = <1>;
> + label = "dac-clk";
> + adi,driver-mode = "lvds-7ma";
> + };
> +
> + channel@5 {
> + reg = <5>;
> + label = "fpga-clk";
> + adi,driver-mode = "lvds-7ma";
> + always-on;
> + };
> + };
> + };
> +...
> diff --git a/MAINTAINERS b/MAINTAINERS
> index d747e10ef125..3edb552c50ea 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1765,6 +1765,7 @@ L: linux@analog.com
> L: linux-iio@vger.kernel.org
> S: Supported
> W: https://ez.analog.com/linux-software-drivers
> +F: Documentation/devicetree/bindings/iio/frequency/adi,ad9523-1.yaml
> F: drivers/iio/frequency/ad9523.c
>
> ANALOG DEVICES INC AD9739a DRIVER
>
> --
> 2.56.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 13/16] iio: frequency: ad9523: add firmware support and drop platform data
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (11 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 12/16] dt-bindings: iio: frequency: Add AD9523-1 Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 14/16] iio: frequency: ad9523: sync the dividers at the end of probe Nuno Sá
` (2 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
The driver refuses to probe without platform data, and there are no
in-tree users of it. That means the driver can not be used at all on a
modern system.
Get the configuration from firmware properties instead, following the
new binding, and drop the platform data support:
- The OSC_IN (VCXO) frequency comes from the oscin clock.
- The PLL2 dividers are computed from the M1 (and optional M2) output
frequency. The VCO frequency follows from the M1 frequency, and the
feedback divider from the VCO frequency and the PFD frequency, given
by the reference divider and doubler.
- The charge pump current and the loop filter components are given in
physical units.
- Each output channel has a child node with its driver mode, polarity
and label.
While at it, get the supplies as named in the datasheet instead of the
single vcc supply. The option to override the IIO device name is gone,
the standard label property can be used instead.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 341 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 321 insertions(+), 20 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index dbf29797130b..f0caaae4d39a 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -5,8 +5,12 @@
* Copyright 2012 Analog Devices Inc.
*/
+#include <linux/bitops.h>
+#include <linux/clk.h>
#include <linux/device.h>
#include <linux/kernel.h>
+#include <linux/math64.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/spi/spi.h>
@@ -15,6 +19,7 @@
#include <linux/err.h>
#include <linux/module.h>
#include <linux/delay.h>
+#include <linux/units.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -237,6 +242,12 @@
#define AD9523_NUM_CHAN 14
+#define AD9523_VCO_FREQ_MIN (2940 * HZ_PER_MHZ)
+#define AD9523_VCO_FREQ_MAX (3100 * HZ_PER_MHZ)
+#define AD9523_PLL2_PFD_FREQ_MAX (259 * HZ_PER_MHZ)
+#define AD9523_PLL2_CHARGE_PUMP_NA_MIN 3500
+#define AD9523_PLL2_CHARGE_PUMP_NA_MAX (255 * 3500)
+
/* Helpers to avoid excess line breaks */
#define AD_IFE(_pde, _a, _b) ((cfg->_pde) ? _a : _b)
#define AD_IF(_pde, _a) AD_IFE(_pde, _a, 0)
@@ -265,14 +276,14 @@ enum outp_drv_mode {
* @channel_num: Output channel number.
* @divider_output_invert_en: Invert the polarity of the output clock.
* @driver_mode: Output driver mode (logic level family).
- * @extended_name: Optional descriptive channel name.
+ * @label: Optional channel label.
*/
struct ad9523_channel_spec {
unsigned int channel_num;
bool divider_output_invert_en;
enum outp_drv_mode driver_mode;
- char extended_name[16];
+ const char *label;
};
enum rpole2_resistor {
@@ -323,7 +334,6 @@ enum cpole1_capacitor {
* @rzero_bypass_en: PLL2 loop filter Rzero bypass enable.
* @num_channels: Array size of struct ad9523_channel_spec.
* @channels: Pointer to channel array.
- * @name: Optional alternative iio device name.
*/
struct ad9523_config {
@@ -356,8 +366,6 @@ struct ad9523_config {
/* Output Channel Configuration */
int num_channels;
struct ad9523_channel_spec *channels;
-
- char name[SPI_NAME_SIZE];
};
enum {
@@ -382,7 +390,7 @@ enum {
struct ad9523_state {
struct spi_device *spi;
- struct ad9523_config *cfg;
+ struct ad9523_config cfg;
struct iio_chan_spec ad9523_channels[AD9523_NUM_CHAN];
struct gpio_desc *pwrdown_gpio;
struct gpio_desc *reset_gpio;
@@ -883,7 +891,7 @@ static const struct iio_info ad9523_info = {
static int ad9523_setup(struct iio_dev *indio_dev)
{
struct ad9523_state *st = iio_priv(indio_dev);
- struct ad9523_config *cfg = st->cfg;
+ struct ad9523_config *cfg = &st->cfg;
struct ad9523_channel_spec *chan;
unsigned long active_mask = 0;
int ret, i;
@@ -1022,9 +1030,7 @@ static int ad9523_setup(struct iio_dev *indio_dev)
st->ad9523_channels[i].output = 1;
st->ad9523_channels[i].indexed = 1;
st->ad9523_channels[i].channel = chan->channel_num;
- if (chan->extended_name[0])
- st->labels[chan->channel_num] =
- chan->extended_name;
+ st->labels[chan->channel_num] = chan->label;
st->ad9523_channels[i].info_mask_separate =
BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_PHASE) |
@@ -1057,18 +1063,303 @@ static int ad9523_setup(struct iio_dev *indio_dev)
return 0;
}
+static bool ad9523_pll2_n_div_valid(u64 n)
+{
+ /* N = 4 * B + A, with the A and B counter constraints from Table 45 */
+ switch (n) {
+ case 12:
+ case 16 ... 17:
+ case 20 ... 22:
+ case 24 ... 26:
+ case 28 ... 255:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static int ad9523_pll2_calc_dividers(struct device *dev,
+ struct ad9523_config *cfg)
+{
+ u32 m1_freq, m2_freq = 0, r2 = 1;
+ u64 vco_freq, ref_freq, n, rem;
+ unsigned int m;
+ int ret;
+
+ ret = device_property_read_u32(dev, "adi,pll2-m1-frequency-hz", &m1_freq);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to read adi,pll2-m1-frequency-hz\n");
+
+ /*
+ * The M1 divider is 3, 4 or 5 and the resulting VCO frequency ranges
+ * do not overlap, so both are given by the M1 frequency.
+ */
+ for (m = 3; m <= 5; m++) {
+ vco_freq = (u64)m1_freq * m;
+ if (vco_freq >= AD9523_VCO_FREQ_MIN && vco_freq <= AD9523_VCO_FREQ_MAX)
+ break;
+ }
+
+ if (m > 5)
+ return dev_err_probe(dev, -EINVAL,
+ "Invalid M1 frequency: %u Hz\n", m1_freq);
+
+ cfg->pll2_vco_div_m1 = m;
+
+ /* If not given, M2 stays at 0, which powers it down */
+ device_property_read_u32(dev, "adi,pll2-m2-frequency-hz", &m2_freq);
+ if (m2_freq) {
+ n = div64_u64_rem(vco_freq, m2_freq, &rem);
+ if (rem || n < 3 || n > 5)
+ return dev_err_probe(dev, -EINVAL,
+ "Invalid M2 frequency: %u Hz\n",
+ m2_freq);
+
+ cfg->pll2_vco_div_m2 = n;
+ }
+
+ ref_freq = cfg->vcxo_freq;
+ if (device_property_read_bool(dev, "adi,pll2-reference-doubler-enable")) {
+ ref_freq *= 2;
+ /* The doubler output must not exceed the maximum PFD frequency */
+ if (ref_freq > AD9523_PLL2_PFD_FREQ_MAX)
+ return dev_err_probe(dev, -EINVAL,
+ "OSC_IN too fast for the doubler\n");
+
+ cfg->pll2_freq_doubler_en = true;
+ }
+
+ device_property_read_u32(dev, "adi,pll2-reference-div-factor", &r2);
+ if (!r2 || r2 > 31)
+ return dev_err_probe(dev, -EINVAL,
+ "Invalid PLL2 reference divider: %u\n", r2);
+
+ /* f_pfd = f_ref / R2 */
+ if (ref_freq > (u64)AD9523_PLL2_PFD_FREQ_MAX * r2)
+ return dev_err_probe(dev, -EINVAL,
+ "PLL2 PFD frequency too high\n");
+
+ /* PLL2 is integer-N: f_vco = f_pfd * N, so N = f_vco * R2 / f_ref */
+ n = div64_u64_rem(vco_freq * r2, ref_freq, &rem);
+ if (rem || !ad9523_pll2_n_div_valid(n))
+ return dev_err_probe(dev, -EINVAL,
+ "No valid PLL2 feedback divider for a %llu Hz VCO\n",
+ vco_freq);
+
+ cfg->pll2_r2_div = r2;
+ cfg->pll2_ndiv_a_cnt = n % 4;
+ cfg->pll2_ndiv_b_cnt = n / 4;
+
+ return 0;
+}
+
+static const u16 ad9523_rpole2_ohms[] = {
+ [RPOLE2_900_OHM] = 900,
+ [RPOLE2_450_OHM] = 450,
+ [RPOLE2_300_OHM] = 300,
+ [RPOLE2_225_OHM] = 225,
+};
+
+static const u16 ad9523_rzero_ohms[] = {
+ [RZERO_3250_OHM] = 3250,
+ [RZERO_2750_OHM] = 2750,
+ [RZERO_2250_OHM] = 2250,
+ [RZERO_2100_OHM] = 2100,
+ [RZERO_3000_OHM] = 3000,
+ [RZERO_2500_OHM] = 2500,
+ [RZERO_2000_OHM] = 2000,
+ [RZERO_1850_OHM] = 1850,
+};
+
+static const u16 ad9523_cpole1_pf[] = {
+ [CPOLE1_0_PF] = 0,
+ [CPOLE1_8_PF] = 8,
+ [CPOLE1_16_PF] = 16,
+ [CPOLE1_24_PF] = 24,
+ [_CPOLE1_24_PF] = 24,
+ [CPOLE1_32_PF] = 32,
+ [CPOLE1_40_PF] = 40,
+ [CPOLE1_48_PF] = 48,
+};
+
+static int ad9523_lookup_loop_filter(struct device *dev, const char *prop,
+ const u16 *table, unsigned int size,
+ u32 val)
+{
+ for (unsigned int i = 0; i < size; i++) {
+ if (table[i] == val)
+ return i;
+ }
+
+ return dev_err_probe(dev, -EINVAL, "Invalid %s: %u\n", prop, val);
+}
+
+static int ad9523_parse_loop_filter(struct device *dev,
+ struct ad9523_config *cfg)
+{
+ u32 rzero = 3250, rpole2 = 900, cpole1 = 0;
+ int ret;
+
+ device_property_read_u32(dev, "adi,pll2-loop-filter-rzero-ohms", &rzero);
+ device_property_read_u32(dev, "adi,pll2-loop-filter-rpole2-ohms", &rpole2);
+ device_property_read_u32(dev, "adi,pll2-loop-filter-cpole1-picofarads",
+ &cpole1);
+
+ /* 0 ohms means the internal zero resistor is bypassed */
+ if (!rzero) {
+ cfg->rzero_bypass_en = true;
+ } else {
+ ret = ad9523_lookup_loop_filter(dev, "PLL2 loop filter rzero",
+ ad9523_rzero_ohms,
+ ARRAY_SIZE(ad9523_rzero_ohms),
+ rzero);
+ if (ret < 0)
+ return ret;
+
+ cfg->rzero = ret;
+ }
+
+ ret = ad9523_lookup_loop_filter(dev, "PLL2 loop filter rpole2",
+ ad9523_rpole2_ohms,
+ ARRAY_SIZE(ad9523_rpole2_ohms), rpole2);
+ if (ret < 0)
+ return ret;
+
+ cfg->rpole2 = ret;
+
+ ret = ad9523_lookup_loop_filter(dev, "PLL2 loop filter cpole1",
+ ad9523_cpole1_pf,
+ ARRAY_SIZE(ad9523_cpole1_pf), cpole1);
+ if (ret < 0)
+ return ret;
+
+ cfg->cpole1 = ret;
+
+ return 0;
+}
+
+static int ad9523_parse_channels(struct device *dev, struct ad9523_config *cfg)
+{
+ /* In enum outp_drv_mode order, starting at LVPECL_8mA */
+ static const char * const drv_modes[] = {
+ "lvpecl-8ma", "lvds-3.5ma", "lvds-7ma", "hstl0-16ma", "hstl1-8ma",
+ "cmos-true-true", "cmos-true-complement", "cmos-true-hiz",
+ "cmos-hiz-true", "cmos-hiz-hiz", "cmos-complement-complement",
+ "cmos-complement-true", "cmos-complement-hiz",
+ "cmos-hiz-complement",
+ };
+ struct ad9523_channel_spec *chan;
+ unsigned long mask = 0;
+ unsigned int i = 0;
+ int ret;
+
+ cfg->num_channels = device_get_child_node_count(dev);
+ if (!cfg->num_channels)
+ return dev_err_probe(dev, -EINVAL, "No output channels\n");
+
+ cfg->channels = devm_kcalloc(dev, cfg->num_channels,
+ sizeof(*cfg->channels), GFP_KERNEL);
+ if (!cfg->channels)
+ return -ENOMEM;
+
+ device_for_each_child_node_scoped(dev, child) {
+ chan = &cfg->channels[i++];
+
+ ret = fwnode_property_read_u32(child, "reg", &chan->channel_num);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to read channel reg\n");
+
+ if (chan->channel_num >= AD9523_NUM_CHAN ||
+ __test_and_set_bit(chan->channel_num, &mask))
+ return dev_err_probe(dev, -EINVAL,
+ "Invalid or duplicated channel %u\n",
+ chan->channel_num);
+
+ ret = fwnode_property_match_property_string(child,
+ "adi,driver-mode",
+ drv_modes,
+ ARRAY_SIZE(drv_modes));
+ if (ret < 0)
+ return dev_err_probe(dev, ret,
+ "Invalid or missing channel %u driver mode\n",
+ chan->channel_num);
+
+ chan->driver_mode = LVPECL_8mA + ret;
+
+ if (fwnode_property_read_bool(child, "adi,divider-output-invert-enable"))
+ chan->divider_output_invert_en = true;
+
+ fwnode_property_read_string(child, "label", &chan->label);
+ }
+
+ return 0;
+}
+
+static int ad9523_parse_fw(struct device *dev, struct ad9523_state *st)
+{
+ static const char * const osc_in_modes[] = {
+ "single-ended-positive", "single-ended-negative", "differential",
+ };
+ struct ad9523_config *cfg = &st->cfg;
+ struct clk *clk;
+ u32 val;
+ int ret;
+
+ clk = devm_clk_get_enabled(dev, "oscin");
+ if (IS_ERR(clk))
+ return dev_err_probe(dev, PTR_ERR(clk),
+ "Failed to get the oscin clock\n");
+
+ cfg->vcxo_freq = clk_get_rate(clk);
+ if (!cfg->vcxo_freq)
+ return dev_err_probe(dev, -EINVAL, "Invalid oscin frequency\n");
+
+ if (device_property_present(dev, "adi,oscin-mode")) {
+ ret = device_property_match_property_string(dev, "adi,oscin-mode",
+ osc_in_modes,
+ ARRAY_SIZE(osc_in_modes));
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Invalid adi,oscin-mode\n");
+
+ cfg->osc_in_cmos_neg_inp_en = ret == 1;
+ cfg->osc_in_diff_en = ret == 2;
+ }
+
+ ret = device_property_read_u32(dev, "adi,pll2-charge-pump-current-nanoamp",
+ &val);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to read adi,pll2-charge-pump-current-nanoamp\n");
+
+ if (val < AD9523_PLL2_CHARGE_PUMP_NA_MIN || val > AD9523_PLL2_CHARGE_PUMP_NA_MAX)
+ return dev_err_probe(dev, -EINVAL,
+ "Invalid PLL2 charge pump current: %u nA\n", val);
+
+ cfg->pll2_charge_pump_current_nA = val;
+
+ ret = ad9523_pll2_calc_dividers(dev, cfg);
+ if (ret)
+ return ret;
+
+ ret = ad9523_parse_loop_filter(dev, cfg);
+ if (ret)
+ return ret;
+
+ return ad9523_parse_channels(dev, cfg);
+}
+
static int ad9523_probe(struct spi_device *spi)
{
+ static const char * const supplies[] = {
+ "vdd3-pll", "vdd3-vco", "vdd3-ref", "vdd3-out", "vdd18-out",
+ };
struct device *dev = &spi->dev;
- struct ad9523_config *cfg;
struct iio_dev *indio_dev;
struct ad9523_state *st;
int ret;
- cfg = dev_get_platdata(dev);
- if (!cfg)
- return dev_err_probe(dev, -EINVAL, "no platform data?\n");
-
indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -1077,7 +1368,12 @@ static int ad9523_probe(struct spi_device *spi)
mutex_init(&st->lock);
- ret = devm_regulator_get_enable(dev, "vcc");
+ ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(supplies),
+ supplies);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to enable supplies\n");
+
+ ret = ad9523_parse_fw(dev, st);
if (ret)
return ret;
@@ -1102,14 +1398,12 @@ static int ad9523_probe(struct spi_device *spi)
return PTR_ERR(st->sync_gpio);
st->spi = spi;
- st->cfg = cfg;
- indio_dev->name = (cfg->name[0] != 0) ? cfg->name :
- spi_get_device_id(spi)->name;
+ indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->info = &ad9523_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = st->ad9523_channels;
- indio_dev->num_channels = cfg->num_channels;
+ indio_dev->num_channels = st->cfg.num_channels;
ret = ad9523_setup(indio_dev);
if (ret < 0)
@@ -1124,9 +1418,16 @@ static const struct spi_device_id ad9523_id[] = {
};
MODULE_DEVICE_TABLE(spi, ad9523_id);
+static const struct of_device_id ad9523_of_match[] = {
+ { .compatible = "adi,ad9523-1" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ad9523_of_match);
+
static struct spi_driver ad9523_driver = {
.driver = {
.name = "ad9523",
+ .of_match_table = ad9523_of_match,
},
.probe = ad9523_probe,
.id_table = ad9523_id,
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 14/16] iio: frequency: ad9523: sync the dividers at the end of probe
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (12 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 13/16] iio: frequency: ad9523: add firmware support and drop platform data Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 15/16] iio: frequency: ad9523: split the clock source selection Nuno Sá
2026-11-30 17:37 ` [PATCH 16/16] iio: frequency: ad9523: add clock provider support Nuno Sá
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
The datasheet recommends initiating a distribution sync after the VCO
calibration, so that the outputs get the deterministic phase
relationship given by the programmed divider phases. The driver never
does this on its own, leaving it up to userspace through the
sync_dividers attribute.
Sync the dividers once everything is set up during probe.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index f0caaae4d39a..216b1a92ce1a 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -1409,6 +1409,10 @@ static int ad9523_probe(struct spi_device *spi)
if (ret < 0)
return ret;
+ ret = ad9523_sync(indio_dev);
+ if (ret < 0)
+ return ret;
+
return devm_iio_device_register(dev, indio_dev);
}
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 15/16] iio: frequency: ad9523: split the clock source selection
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (13 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 14/16] iio: frequency: ad9523: sync the dividers at the end of probe Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
2026-11-30 17:37 ` [PATCH 16/16] iio: frequency: ad9523: add clock provider support Nuno Sá
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
ad9523_set_clock_provider() decides which clock source a channel uses
for a given frequency and also programs it. Move the decision into
ad9523_use_alt_clk_src(), so that it can be reused without touching the
device.
No functional change.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/ad9523.c | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 216b1a92ce1a..d226ab897b14 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -554,35 +554,39 @@ static unsigned long ad9523_chan_freq(struct ad9523_state *st, unsigned int src,
return st->vco_out_freq[src] / ad9523_chan_div(st, src, freq);
}
-static int ad9523_set_clock_provider(struct iio_dev *indio_dev,
- unsigned int ch, unsigned long freq)
+static bool ad9523_use_alt_clk_src(struct ad9523_state *st, unsigned int ch,
+ unsigned long freq)
{
- struct ad9523_state *st = iio_priv(indio_dev);
long tmp1, tmp2;
- bool use_alt_clk_src;
switch (ch) {
case 0 ... 3:
- use_alt_clk_src = (freq == st->vco_out_freq[AD9523_VCXO]);
- break;
+ return freq == st->vco_out_freq[AD9523_VCXO];
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;
- }
+ if (!st->vco_out_freq[AD9523_VCO2])
+ return false;
/* Use M2 only if the output gets closer to the requested rate */
tmp1 = abs_diff(ad9523_chan_freq(st, AD9523_VCO1, freq), freq);
tmp2 = abs_diff(ad9523_chan_freq(st, AD9523_VCO2, freq), freq);
- use_alt_clk_src = tmp2 < tmp1;
- break;
+ return tmp2 < tmp1;
default:
- /* Ch 10..14: No action required, return success */
- return 0;
+ return false;
}
+}
- return ad9523_vco_out_map(indio_dev, ch, use_alt_clk_src);
+static int ad9523_set_clock_provider(struct iio_dev *indio_dev,
+ unsigned int ch, unsigned long freq)
+{
+ struct ad9523_state *st = iio_priv(indio_dev);
+
+ /* Ch 10..13: No action required, return success */
+ if (ch > 9)
+ return 0;
+
+ return ad9523_vco_out_map(indio_dev, ch,
+ ad9523_use_alt_clk_src(st, ch, freq));
}
static int ad9523_store_eeprom(struct iio_dev *indio_dev)
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 16/16] iio: frequency: ad9523: add clock provider support
2026-11-30 17:36 [PATCH 00/16] iio: frequency: ad9523: add firmware support Nuno Sá
` (14 preceding siblings ...)
2026-11-30 17:37 ` [PATCH 15/16] iio: frequency: ad9523: split the clock source selection Nuno Sá
@ 2026-11-30 17:37 ` Nuno Sá
15 siblings, 0 replies; 18+ messages in thread
From: Nuno Sá @ 2026-11-30 17:37 UTC (permalink / raw)
To: linux-iio, linux-kernel, devicetree
Cc: Jonathan Cameron, Michael Hennerich, David Lechner,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Arnd Bergmann, linux
The AD9523-1 is a clock generator, and the devices it clocks can only
get their clocks through the clock framework.
If #clock-cells is present, register a clock for each output channel
described in firmware. Like other IIO frequency drivers, the channels
are then controlled only through the clock framework and are not
exposed as IIO channels. The IIO device stays around for the PLL status
and the other device attributes.
As clock providers need the common clock framework, make the driver
depend on COMMON_CLK.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/frequency/Kconfig | 2 +-
drivers/iio/frequency/ad9523.c | 150 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 150 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/frequency/Kconfig b/drivers/iio/frequency/Kconfig
index 994d199080eb..65d7740183bd 100644
--- a/drivers/iio/frequency/Kconfig
+++ b/drivers/iio/frequency/Kconfig
@@ -13,7 +13,7 @@ menu "Clock Generator/Distribution"
config AD9523
tristate "Analog Devices AD9523 Low Jitter Clock Generator"
- depends on SPI
+ depends on SPI && COMMON_CLK
help
Say yes here to build support for Analog Devices AD9523 Low Jitter
Clock Generator. The driver provides direct access via sysfs.
diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index d226ab897b14..7968d8b60e58 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -7,6 +7,7 @@
#include <linux/bitops.h>
#include <linux/clk.h>
+#include <linux/clk-provider.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/math64.h>
@@ -277,6 +278,7 @@ enum outp_drv_mode {
* @divider_output_invert_en: Invert the polarity of the output clock.
* @driver_mode: Output driver mode (logic level family).
* @label: Optional channel label.
+ * @always_on: Keep the output running without consumers (clock provider).
*/
struct ad9523_channel_spec {
@@ -284,6 +286,7 @@ struct ad9523_channel_spec {
bool divider_output_invert_en;
enum outp_drv_mode driver_mode;
const char *label;
+ bool always_on;
};
enum rpole2_resistor {
@@ -388,10 +391,19 @@ enum {
AD9523_NUM_CLK_SRC,
};
+struct ad9523_clk {
+ struct clk_hw hw;
+ struct iio_dev *indio_dev;
+ const struct iio_chan_spec *chan;
+};
+
+#define to_ad9523_clk(_hw) container_of(_hw, struct ad9523_clk, hw)
+
struct ad9523_state {
struct spi_device *spi;
struct ad9523_config cfg;
struct iio_chan_spec ad9523_channels[AD9523_NUM_CHAN];
+ struct ad9523_clk clks[AD9523_NUM_CHAN];
struct gpio_desc *pwrdown_gpio;
struct gpio_desc *reset_gpio;
struct gpio_desc *sync_gpio;
@@ -892,6 +904,127 @@ static const struct iio_info ad9523_info = {
.attrs = &ad9523_attribute_group,
};
+static int ad9523_clk_prepare(struct clk_hw *hw)
+{
+ struct ad9523_clk *clk = to_ad9523_clk(hw);
+
+ return ad9523_write_raw(clk->indio_dev, clk->chan, 1, 0,
+ IIO_CHAN_INFO_RAW);
+}
+
+static void ad9523_clk_unprepare(struct clk_hw *hw)
+{
+ struct ad9523_clk *clk = to_ad9523_clk(hw);
+
+ ad9523_write_raw(clk->indio_dev, clk->chan, 0, 0, IIO_CHAN_INFO_RAW);
+}
+
+static unsigned long ad9523_clk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct ad9523_clk *clk = to_ad9523_clk(hw);
+ int ret, val;
+
+ ret = ad9523_read_raw(clk->indio_dev, clk->chan, &val, NULL,
+ IIO_CHAN_INFO_FREQUENCY);
+ if (ret < 0)
+ return 0;
+
+ return val;
+}
+
+static int ad9523_clk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
+{
+ struct ad9523_clk *clk = to_ad9523_clk(hw);
+ struct ad9523_state *st = iio_priv(clk->indio_dev);
+ unsigned int ch = clk->chan->channel;
+ unsigned int src;
+
+ if (!req->rate)
+ return -EINVAL;
+
+ src = AD9523_VCO1;
+ if (ad9523_use_alt_clk_src(st, ch, req->rate))
+ src = ch < 4 ? AD9523_VCXO : AD9523_VCO2;
+
+ req->rate = ad9523_chan_freq(st, src, req->rate);
+
+ return 0;
+}
+
+static int ad9523_clk_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ struct ad9523_clk *clk = to_ad9523_clk(hw);
+
+ return ad9523_write_raw(clk->indio_dev, clk->chan, rate, 0,
+ IIO_CHAN_INFO_FREQUENCY);
+}
+
+static const struct clk_ops ad9523_clk_ops = {
+ .prepare = ad9523_clk_prepare,
+ .unprepare = ad9523_clk_unprepare,
+ .recalc_rate = ad9523_clk_recalc_rate,
+ .determine_rate = ad9523_clk_determine_rate,
+ .set_rate = ad9523_clk_set_rate,
+};
+
+static int ad9523_clk_register(struct iio_dev *indio_dev)
+{
+ struct ad9523_state *st = iio_priv(indio_dev);
+ const char *names[AD9523_NUM_CHAN] = { };
+ struct clk_hw_onecell_data *clk_data;
+ struct ad9523_config *cfg = &st->cfg;
+ struct device *dev = &st->spi->dev;
+ int ret;
+
+ clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, AD9523_NUM_CHAN),
+ GFP_KERNEL);
+ if (!clk_data)
+ return -ENOMEM;
+
+ clk_data->num = AD9523_NUM_CHAN;
+ for (unsigned int i = 0; i < AD9523_NUM_CHAN; i++)
+ clk_data->hws[i] = ERR_PTR(-ENOENT);
+
+ device_property_read_string_array(dev, "clock-output-names", names,
+ ARRAY_SIZE(names));
+
+ for (unsigned int i = 0; i < cfg->num_channels; i++) {
+ struct ad9523_channel_spec *chan = &cfg->channels[i];
+ unsigned int num = chan->channel_num;
+ struct ad9523_clk *clk = &st->clks[num];
+ struct clk_init_data init = { };
+
+ init.name = names[num];
+ if (!init.name) {
+ init.name = devm_kasprintf(dev, GFP_KERNEL, "%s_out%u",
+ dev_name(dev), num);
+ if (!init.name)
+ return -ENOMEM;
+ }
+
+ init.ops = &ad9523_clk_ops;
+ if (chan->always_on)
+ init.flags = CLK_IS_CRITICAL;
+
+ clk->indio_dev = indio_dev;
+ clk->chan = &st->ad9523_channels[i];
+ clk->hw.init = &init;
+
+ ret = devm_clk_hw_register(dev, &clk->hw);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to register output %u clock\n",
+ num);
+
+ clk_data->hws[num] = &clk->hw;
+ }
+
+ return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
+}
+
static int ad9523_setup(struct iio_dev *indio_dev)
{
struct ad9523_state *st = iio_priv(indio_dev);
@@ -1296,6 +1429,7 @@ static int ad9523_parse_channels(struct device *dev, struct ad9523_config *cfg)
chan->divider_output_invert_en = true;
fwnode_property_read_string(child, "label", &chan->label);
+ chan->always_on = fwnode_property_read_bool(child, "always-on");
}
return 0;
@@ -1362,6 +1496,7 @@ static int ad9523_probe(struct spi_device *spi)
struct device *dev = &spi->dev;
struct iio_dev *indio_dev;
struct ad9523_state *st;
+ bool clk_provider;
int ret;
indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
@@ -1377,6 +1512,8 @@ static int ad9523_probe(struct spi_device *spi)
if (ret)
return dev_err_probe(dev, ret, "Failed to enable supplies\n");
+ clk_provider = device_property_present(dev, "#clock-cells");
+
ret = ad9523_parse_fw(dev, st);
if (ret)
return ret;
@@ -1407,12 +1544,23 @@ static int ad9523_probe(struct spi_device *spi)
indio_dev->info = &ad9523_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = st->ad9523_channels;
- indio_dev->num_channels = st->cfg.num_channels;
+ /*
+ * When used as a clock provider, the outputs are controlled through
+ * the clock framework only.
+ */
+ if (!clk_provider)
+ indio_dev->num_channels = st->cfg.num_channels;
ret = ad9523_setup(indio_dev);
if (ret < 0)
return ret;
+ if (clk_provider) {
+ ret = ad9523_clk_register(indio_dev);
+ if (ret)
+ return ret;
+ }
+
ret = ad9523_sync(indio_dev);
if (ret < 0)
return ret;
--
2.56.0
^ permalink raw reply [flat|nested] 18+ messages in thread