Re: [PATCH 13/16] iio: frequency: ad9523: add firmware support and drop platform data

From: Jonathan Cameron

Date: Sat Dec 05 2026 - 18:09:51 EST


On Mon, 30 Nov 2026 17:37:11 +0000
Nuno Sá <nuno.sa@xxxxxxxxxx> wrote:

> 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@xxxxxxxxxx>
Hi Nuno,

Just one small thing inline.

Thanks,

Jonathan

> ---
> 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

> +
> +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);
Even though it is a fair bit more code, we have pretty much standardized
today on
propname = "adi,pll2-loop-filter-rzero-ohms";
if (device_property_present(dev, propname)) {
ret = device_property_read_u32(dev, propname, &rzero);
if (ret)
return ret;
} else {
rzero = 3250;
}
etc

you could group them with the handling of each one rather than
get all properties, then process the property values for all of them.
Not sure if it would end up easier to follow or not.

> +
> + /* 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;
> +}