Re: [PATCH v4 14/17] iio: adc: ad7768-1: add support for Synchronization over SPI
From: David Lechner
Date: Tue Apr 01 2025 - 13:02:56 EST
On 3/6/25 3:03 PM, Jonathan Santos wrote:
> The synchronization method using GPIO requires the generated pulse to be
> truly synchronous with the base MCLK signal. When it is not possible to
> do that in hardware, the datasheet recommends using synchronization over
> SPI, where the generated pulse is already synchronous with MCLK. This
> requires the SYNC_OUT pin to be connected to SYNC_IN pin.
>
> Use trigger-sources property to enable device synchronization over SPI.
>
> Signed-off-by: Jonathan Santos <Jonathan.Santos@xxxxxxxxxx>
> ---
...
> +static int ad7768_setup_spi_sync(struct device *dev, struct ad7768_state *st)
> +{
> + struct fwnode_reference_args args;
> + int ret;
> +
> + ret = fwnode_property_get_reference_args(dev_fwnode(dev),
> + "trigger-sources",
> + "#trigger-source-cells",
> + 0, 0, &args);
As in the DT binding patch, we may need to allow an arg here to be
able to tell the difference between /SYNC_OUT and /DRDY triggers.
Also, in reviews on previous versions of this series, Jonathan and
Conor both mentioned that it would be sensible to allow omitting
the trigger-sources property when /SYNC_OUT is connected to /SYNC_IN
if you want to consider that.
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to get trigger-sources reference\n");
> +
> + /*
> + * Currently, the driver supports SPI-based synchronization only for
> + * single-device setups, where the device's own SYNC_OUT is looped back
> + * to its SYNC_IN. Only enable this feature if the trigger-sources
> + * references the current device.
> + */
> + st->en_spi_sync = args.fwnode->dev == dev;
> + fwnode_handle_put(args.fwnode);
> +
> + return st->en_spi_sync ? 0 : -EOPNOTSUPP;
> +}