From: "Nuno Sá" <noname.nuno@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>,
Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@kernel.org>
Cc: nuno.sa@analog.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Alexandru Ardelean <alexandru.ardelean@analog.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Olivier Moysan <olivier.moysan@foss.st.com>
Subject: Re: [PATCH 8/8] iio: adc: ad9467: support digital interface calibration
Date: Tue, 23 Apr 2024 09:32:19 +0200 [thread overview]
Message-ID: <a7c371ffffa18f49702590147642ed248977224f.camel@gmail.com> (raw)
In-Reply-To: <20240420163404.0fc01ed5@jic23-huawei>
On Sat, 2024-04-20 at 16:34 +0100, Jonathan Cameron wrote:
> On Fri, 19 Apr 2024 17:36:51 +0200
> Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@kernel.org> wrote:
>
> > From: Nuno Sa <nuno.sa@analog.com>
> >
> > To make sure that we have the best timings on the serial data interface
> > we should calibrate it. This means going through the device supported
> > values and see for which ones we get a successful result. To do that, we
> > use a prbs test pattern both in the IIO backend and in the frontend
> > devices. Then for each of the test points we see if there are any
> > errors. Note that the backend is responsible to look for those errors.
> >
> > As calibrating the interface also requires that the data format is disabled
> > (the one thing being done in ad9467_setup()), ad9467_setup() was removed
> > and configuring the data fomat is now part of the calibration process.
> >
> > Signed-off-by: Nuno Sa <nuno.sa@analog.com>
> Trivial comments inline.
>
> Jonathan
>
> > ---
> > drivers/iio/adc/ad9467.c | 337 +++++++++++++++++++++++++++++++++++++++++------
> > 1 file changed, 296 insertions(+), 41 deletions(-)
> >
> > diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
> > index 7db87ccc1ea4..44552dd6f4c6 100644
> > --- a/drivers/iio/adc/ad9467.c
> > +++ b/drivers/iio/adc/ad9467.c
> > @@ -4,6 +4,9 @@
> > *
> > * Copyright 2012-2020 Analog Devices Inc.
> > */
> > +
> > +#include <linux/bitmap.h>
> > +#include <linux/bitops.h>
> > #include <linux/cleanup.h>
> > #include <linux/module.h>
> > #include <linux/mutex.h>
> > @@ -100,6 +103,8 @@
> > #define AD9467_DEF_OUTPUT_MODE 0x08
> > #define AD9467_REG_VREF_MASK 0x0F
> >
> > +#define AD9647_MAX_TEST_POINTS 32
> > +
> > struct ad9467_chip_info {
> > const char *name;
> > unsigned int id;
> > @@ -110,6 +115,8 @@ struct ad9467_chip_info {
> > unsigned long max_rate;
> > unsigned int default_output_mode;
> > unsigned int vref_mask;
> > + unsigned int num_lanes;
> > + bool has_dco;
>
> What is dco? Perhaps a comment, or expand the naming somewhat.
>
data clock output.. will add a comment
> > };
>
> >
> > +static void ad9467_dump_table(const unsigned long *err_map, unsigned int size,
> > + bool invert)
> > +{
> > +#ifdef DEBUG
> > + unsigned int bit;
> > +
> > + pr_debug("Dump calibration table:\n");
>
> If it's useful, poke it in debugfs, otherwise, drop this code.
From our experience, it's useful to dump the table in the tuning process. But I guess
I can also just save the bitmap and dump it on demand (on debugfs).
>
> > + for (bit = 0; bit < size; bit++) {
> > + if (bit == size / 2) {
> > + if (!invert)
> > + break;
> > + pr_cont("\n");
> > + }
> > +
> > + pr_cont("%c", test_bit(bit, err_map) ? 'x' : 'o');
> > + }
> > +#endif
> > +}
> > +
>
> > +static int ad9467_calibrate_apply(const struct ad9467_state *st,
> > + unsigned int val)
> > +{
> > + unsigned int lane;
> > + int ret;
> > +
> > + if (st->info->has_dco) {
> > + int ret;
> Shadowing ret above.
>
ups...
> > +
> > + ret = ad9467_spi_write(st->spi, AN877_ADC_REG_OUTPUT_DELAY,
> > + val);
> > + if (ret)
> > + return ret;
> > +
> > + return ad9467_spi_write(st->spi, AN877_ADC_REG_TRANSFER,
> > + AN877_ADC_TRANSFER_SYNC);
> > + }
> > +
> > + for (lane = 0; lane < st->info->num_lanes; lane++) {
> > + ret = iio_backend_iodelay_set(st->back, lane, val);
> > + if (ret)
> > + return ret;
> > + }
> > +
> > + return 0;
> > +}
>
> > +
> > +static int ad9467_calibrate(const struct ad9467_state *st)
>
> Some docs on the sequence or a reference would be good.
I can point into the datasheets..
- Nuno Sá
next prev parent reply other threads:[~2024-04-23 7:32 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 15:36 [PATCH 0/8] iio: ad9467: support interface tuning Nuno Sa via B4 Relay
2024-04-19 15:36 ` [PATCH 1/8] iio: backend: add API for " Nuno Sa via B4 Relay
2024-04-20 15:00 ` Jonathan Cameron
2024-04-22 15:40 ` Nuno Sá
2024-04-22 17:13 ` Jonathan Cameron
2024-04-23 7:52 ` Nuno Sá
2024-04-28 15:46 ` Jonathan Cameron
2024-04-19 15:36 ` [PATCH 2/8] iio: adc: adi-axi-adc: only error out in major version mismatch Nuno Sa via B4 Relay
2024-04-20 15:02 ` Jonathan Cameron
2024-04-19 15:36 ` [PATCH 3/8] dt-bindings: adc: axi-adc: add clocks property Nuno Sa via B4 Relay
2024-04-19 16:11 ` Krzysztof Kozlowski
2024-04-20 15:04 ` Jonathan Cameron
2024-04-22 15:06 ` Nuno Sá
2024-04-22 17:09 ` Jonathan Cameron
2024-04-19 15:36 ` [PATCH 4/8] iio: adc: axi-adc: make sure AXI clock is enabled Nuno Sa via B4 Relay
2024-04-20 15:04 ` Jonathan Cameron
2024-04-19 15:36 ` [PATCH 5/8] iio: adc: adi-axi-adc: remove regmap max register Nuno Sa via B4 Relay
2024-04-19 15:36 ` [PATCH 6/8] iio: adc: adi-axi-adc: support digital interface calibration Nuno Sa via B4 Relay
2024-04-20 15:13 ` Jonathan Cameron
2024-04-23 7:27 ` Nuno Sá
2024-04-28 15:49 ` Jonathan Cameron
2024-04-19 15:36 ` [PATCH 7/8] iio: adc: ad9467: cache the sample rate Nuno Sa via B4 Relay
2024-04-20 15:19 ` Jonathan Cameron
2024-04-22 15:46 ` Nuno Sá
2024-04-22 17:08 ` Jonathan Cameron
2024-04-19 15:36 ` [PATCH 8/8] iio: adc: ad9467: support digital interface calibration Nuno Sa via B4 Relay
2024-04-20 15:34 ` Jonathan Cameron
2024-04-23 7:32 ` Nuno Sá [this message]
2024-04-20 15:39 ` [PATCH 0/8] iio: ad9467: support interface tuning Jonathan Cameron
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=a7c371ffffa18f49702590147642ed248977224f.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.ardelean@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+nuno.sa.analog.com@kernel.org \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=olivier.moysan@foss.st.com \
--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).