linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: "Miclaus, Antoniu" <Antoniu.Miclaus@analog.com>,
	"jic23@kernel.org"	 <jic23@kernel.org>,
	"robh@kernel.org" <robh@kernel.org>,
	"conor+dt@kernel.org"	 <conor+dt@kernel.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	 "devicetree@vger.kernel.org"	 <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org"	 <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 13/13] iio: adc: ad4080: add driver support
Date: Tue, 22 Apr 2025 12:39:15 +0100	[thread overview]
Message-ID: <f2f0ef05a738a16083d686a246499788b6d353d2.camel@gmail.com> (raw)
In-Reply-To: <CY4PR03MB3399B23673D9C3210C8CE9B99BBB2@CY4PR03MB3399.namprd03.prod.outlook.com>

On Tue, 2025-04-22 at 08:12 +0000, Miclaus, Antoniu wrote:
> > > +	int ret;
> > > +
> > > +	guard(mutex)(&st->lock);
> > > +	if (st->num_lanes == 1)
> > > +		ret = regmap_write(st->regmap,
> > > AD4080_REG_ADC_DATA_INTF_CONFIG_A,
> > > +				   AD4080_RESERVED_CONFIG_A_MSK |
> > > +				   AD4080_INTF_CHK_EN_MSK);
> > > +	else
> > > +		ret = regmap_write(st->regmap,
> > > AD4080_REG_ADC_DATA_INTF_CONFIG_A,
> > > +				   AD4080_RESERVED_CONFIG_A_MSK |
> > > +				   AD4080_INTF_CHK_EN_MSK |
> > > +				   AD4080_SPI_LVDS_LANES_MSK);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ret = iio_backend_data_alignment_enable(st->back);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	do {
> > > +		ret = iio_backend_sync_status_get(st->back, &sync_en);
> > > +		if (ret)
> > > +			return ret;
> > > +
> > > +		if (!sync_en)
> > > +			dev_dbg(&st->spi->dev, "Not Locked: Running Bit
> > > Slip\n");
> > > +	} while (--timeout && !sync_en);
> > > +
> > > +	if (timeout) {
> > > +		dev_info(&st->spi->dev, "Success: Pattern correct and
> > > Locked!\n");
> > > +		if (st->num_lanes == 1)
> > > +			return regmap_write(st->regmap,
> > > AD4080_REG_ADC_DATA_INTF_CONFIG_A,
> > > +
> > 	    AD4080_RESERVED_CONFIG_A_MSK);
> > > +		else
> > > +			return regmap_write(st->regmap,
> > > AD4080_REG_ADC_DATA_INTF_CONFIG_A,
> > > +
> > 	    AD4080_RESERVED_CONFIG_A_MSK |
> > > +					    AD4080_SPI_LVDS_LANES_MSK);
> > > +	} else {
> > > +		dev_info(&st->spi->dev, "LVDS Sync Timeout.\n");
> > > +		if (st->num_lanes == 1) {
> > > +			ret = regmap_write(st->regmap,
> > > AD4080_REG_ADC_DATA_INTF_CONFIG_A,
> > > +
> > 	   AD4080_RESERVED_CONFIG_A_MSK);
> > > +			if (ret)
> > > +				return ret;
> > > +		} else {
> > > +			ret = regmap_write(st->regmap,
> > > AD4080_REG_ADC_DATA_INTF_CONFIG_A,
> > > +
> > 	   AD4080_RESERVED_CONFIG_A_MSK |
> > > +					   AD4080_SPI_LVDS_LANES_MSK);
> > > +			if (ret)
> > > +				return ret;
> > > +		}
> > > +
> > > +		return -ETIMEDOUT;
> > 
> > So, first the things that I don't really get (also the hdl docs need to be
> > improved FWIW):
> > 
> > * It seems that we can have data alignment or data capture synchronization
> > through an internal AMD FPGA technique called bit-slip or an external
> > signal,
> > right? In here, it seems that we only use bit-slip and never disable it. Is
> > that
> > really the goal?
> > 
> > * This whole process seems to be some kind of calibration at the interface
> > level, right?
> > 
> > * What's the point of the conv clock? Is it only used to get the sample
> > rate? If
> > so, the hdl docs are misleading as it seems that it can be used instead of
> > bit-
> > slip for data capture alignment?
> > 
> > Now, speaking about the backend API's, it looks like that
> > iio_backend_self_sync_enable() and iio_backend_data_alignment_enable()
> > could be
> > merged into one API. From what I can tell,
> > iio_backend_data_alignment_enable()
> > just enables the bit-slip process but that likely does nothing unless the
> > SELF_SYNC bit is also set to bit-slip, right? In fact, we could think about
> > a
> > more generic (less flexible though) API like:
> > 
> > * iio_backend_intf_data_align(back, timeout_us), or
> > * iio_backend_intf_calib(back, timeout_us), or
> > * iio_backend_intf_data_capture_sync(back, timeout_us)
> > 
> > On the backend side, you could then enable bit-slip and do the status read
> > (with
> > timeout) and return success or an error code.
> > 
> > The above seems to be pretty much what you're doing but in just one API that
> > makes sense to me.
> > 
> > Of course that the following questions still come to mind:
> > 
> > * Do we need to disable bit-slip after we're done (still fits into the one
> > API
> > model)?
> > * Do we need a meaningful API to change between the syncing/alignment
> > methods?
> > External signal vs bit-slip?
> > 
> > The above is key to better think of an API. Right now it feels that you're
> > just
> > adding an API for every bit you want to control in this process...
> > 
> > If we end up needing more flexibility for this, we can also consider the
> > existing iio_backend_data_sample_trigger() API. I know is abusing a bit and
> > a
> > stretch but in the end of the day the whole thing is related with aligning,
> > syncing, calibrating the interface for properly sampling data. Even bit-slip
> > (while not a traditional external trigger) looks like some kind of self-
> > adjusting, data-driven trigger mechanism to establish the correct starting
> > point
> > for capturing data. So having two new enums like:
> > 
> > IIO_BACKEND_SAMPLE_TRIGGER_EXT_SIGNAL,
> > IIO_BACKEND_SAMPLE_TRIGGER_BIT_SLIP // or maybe a more generic name
> > like
> > s/BIT_SLIP/INTERNAL
> > 
> > I do not think the above is that horrible :P... But I would really like to
> > get
> > more opinions about this.
> 
> There've been some update on the HDL side changing a bit the behavior:
> - bitslip_enable is removed, instead the `sync` bit is used which is already
> part
>   of the adc common core.
>  SYNC:
>        This bit enables capture synchronization. When activated, it initiates
>        an HDL process that aligns the sample's most significant bit (MSB)
> based
>        solely on the captured data, without considering the AD4080's CNV
> signal.
>        This bit is self-clearing and should be toggled whenever
> synchronization
>        is needed (e.g., at boot or after updating the sampling rate).
> 
> The SELF_SYNC bit was removed.
> 
> SYNC_STATUS bit (which is also part of the common core) has the following
> behavior:
>       This bit indicates whether the sample's MSB alignment has been correctly
>       performed and the capture is synchronized. If successful, this bit will
>       be set to 1.

So this looks like it would fir in first approach of just one new backend API
right?

What about the CNV signal? Is that something we can fully control on the
frontend driver (though it also seems that signal is an output of the backend
device)?

Thx!
- Nuno Sá

  reply	other threads:[~2025-04-22 11:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11 12:36 [PATCH v2 00/13] Add support for AD4080 ADC Antoniu Miclaus
2025-04-11 12:36 ` [PATCH v2 01/13] iio: backend: add support for filter config Antoniu Miclaus
2025-04-11 15:37   ` Nuno Sá
2025-04-11 12:36 ` [PATCH v2 02/13] iio: backend: add support for sync process Antoniu Miclaus
2025-04-11 12:36 ` [PATCH v2 03/13] iio: backend: add support for self sync Antoniu Miclaus
2025-04-15  9:02   ` Nuno Sá
2025-04-11 12:36 ` [PATCH v2 04/13] iio: backend: add support for sync status Antoniu Miclaus
2025-04-11 12:36 ` [PATCH v2 05/13] iio: backend: add support for number of lanes Antoniu Miclaus
2025-04-11 12:36 ` [PATCH v2 06/13] dt-bindings: iio: adc: add ad408x axi variant Antoniu Miclaus
2025-04-11 21:42   ` Rob Herring (Arm)
2025-04-11 12:36 ` [PATCH v2 07/13] iio: adc: adi-axi-adc: add filter enable/disable Antoniu Miclaus
2025-04-11 12:36 ` [PATCH v2 08/13] iio: adc: adi-axi-adc: add bitslip enable/disable Antoniu Miclaus
2025-04-11 12:36 ` [PATCH v2 09/13] iio: adc: adi-axi-adc: add self sync support Antoniu Miclaus
2025-04-11 12:36 ` [PATCH v2 10/13] iio: adc: adi-axi-adc: add sync status Antoniu Miclaus
2025-04-12 17:04   ` Jonathan Cameron
2025-04-11 12:36 ` [PATCH v2 11/13] iio: adc: adi-axi-adc: add num lanes support Antoniu Miclaus
2025-04-11 12:36 ` [PATCH v2 12/13] dt-bindings: iio: adc: add ad4080 Antoniu Miclaus
2025-04-11 21:43   ` Rob Herring (Arm)
2025-04-11 12:36 ` [PATCH v2 13/13] iio: adc: ad4080: add driver support Antoniu Miclaus
2025-04-12 17:19   ` Jonathan Cameron
2025-04-15  8:58   ` Nuno Sá
2025-04-18 14:33     ` Jonathan Cameron
2025-04-22  8:12     ` Miclaus, Antoniu
2025-04-22 11:39       ` Nuno Sá [this message]
2025-04-25  7:56         ` Miclaus, Antoniu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f2f0ef05a738a16083d686a246499788b6d353d2.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Antoniu.Miclaus@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).