devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Nuno Sá" <noname.nuno@gmail.com>
Cc: Marcelo Schmitt <marcelo.schmitt@analog.com>,
	broonie@kernel.org, lars@metafoo.de,
	Michael.Hennerich@analog.com, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
	nuno.sa@analog.com, dlechner@baylibre.com,
	marcelo.schmitt1@gmail.com, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>
Subject: Re: [PATCH v3 6/6] iio: adc: Add support for AD4000
Date: Sun, 9 Jun 2024 10:23:54 +0100	[thread overview]
Message-ID: <20240609102354.02aa1128@jic23-huawei> (raw)
In-Reply-To: <e92871489d416e4f8a350fd24fc5ed0012b3cf2b.camel@gmail.com>

> > +
> > +static int ad4000_convert_and_acquire(struct ad4000_state *st)
> > +{
> > +	int ret;
> > +
> > +	/*
> > +	 * In 4-wire mode, the CNV line is held high for the entire
> > conversion
> > +	 * and acquisition process. In other modes st->cnv_gpio is NULL and
> > is
> > +	 * ignored (CS is wired to CNV in those cases).
> > +	 */
> > +	gpiod_set_value_cansleep(st->cnv_gpio, 1);  
> 
> Not sure it's a good practise to assume internal details as you're going for
> GPIO. I would prefer to have an explicit check for st->cnv_gpio being NULL or
> not.

Hmm. I had it in my head that this was documented behaviour, but
I can't find such in the docs, so agreed checking it makes sense.

I would be very surprised if this ever changed as it's one of the
things that makes optional gpios easy to work with but who knows!

+CC Linus and Bartosz for feedback on this one.


>   
> > +	ret = spi_sync(st->spi, &st->msg);
> > +	gpiod_set_value_cansleep(st->cnv_gpio, 0);
> > +
> > +	return ret;
> > +}
> > +

> > +static int ad4000_config(struct ad4000_state *st)
> > +{
> > +	unsigned int reg_val;
> > +
> > +	if (device_property_present(&st->spi->dev, "adi,high-z-input"))
> > +		reg_val |= FIELD_PREP(AD4000_CFG_HIGHZ, 1);
> > +
> > +	/*
> > +	 * The ADC SDI pin might be connected to controller CS line in which
> > +	 * case the write might fail. This, however, does not prevent the
> > device
> > +	 * from functioning even though in a configuration other than the
> > +	 * requested one.
> > +	 */  
> 
> This raises the question if there's any way to describe that through DT (if not
> doing it already)? So that, if SDI is connected to CS we don't even call this?
> Other question that comes to mind is that in case SDI is connected to CS, will
> all writes fail? Because if that's the case we other writes (like scale) that
> won't work and we should take care of that...

Definitely needs describing and all configuration sysfs etc needs to be read only
if we can't control it.

> 
> > +	return ad4000_write_reg(st, reg_val);
> > +}
> > +

Jonathan

  reply	other threads:[~2024-06-09  9:24 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 22:40 [PATCH v3 0/6] Add support for AD4000 series of ADCs Marcelo Schmitt
2024-06-04 22:41 ` [PATCH v3 1/6] spi: Add SPI mode bit for MOSI idle state configuration Marcelo Schmitt
2024-06-05  9:14   ` Nuno Sá
2024-06-05 12:02     ` Mark Brown
2024-06-06 20:10       ` Marcelo Schmitt
2024-06-07 13:52         ` Mark Brown
2024-06-05 12:24   ` Mark Brown
2024-06-05 16:37     ` David Lechner
2024-06-05 17:04       ` Mark Brown
2024-06-06 22:08         ` Marcelo Schmitt
2024-06-07 13:51           ` Mark Brown
2024-06-06 19:57     ` Marcelo Schmitt
2024-06-07 13:50       ` Mark Brown
2024-06-07 14:55         ` Marcelo Schmitt
2024-06-04 22:42 ` [PATCH v3 2/6] spi: bitbang: Implement support " Marcelo Schmitt
2024-06-05  9:30   ` Nuno Sá
2024-06-04 22:42 ` [PATCH v3 3/6] spi: spi-gpio: Add " Marcelo Schmitt
2024-06-05  9:26   ` Nuno Sá
2024-06-04 22:43 ` [PATCH v3 4/6] spi: spi-axi-spi-engine: Add support for MOSI idle configuration Marcelo Schmitt
2024-06-05  9:25   ` Nuno Sá
2024-06-05 17:03   ` David Lechner
2024-06-06  6:51     ` Nuno Sá
2024-06-06 13:21       ` David Lechner
2024-06-06 21:31         ` Marcelo Schmitt
2024-06-07  7:15           ` Nuno Sá
2024-06-07 14:40             ` Marcelo Schmitt
2024-06-09  9:11               ` Jonathan Cameron
2024-06-04 22:43 ` [PATCH v3 5/6] dt-bindings: iio: adc: Add AD4000 Marcelo Schmitt
2024-06-05 17:14   ` Conor Dooley
2024-06-07 14:35     ` Marcelo Schmitt
2024-06-07 14:49       ` Conor Dooley
2024-06-05  9:31 ` [PATCH v3 0/6] Add support for AD4000 series of ADCs Nuno Sá
2024-06-05 11:19   ` Marcelo Schmitt
2024-06-05 11:14 ` [PATCH v3 6/6] iio: adc: Add support for AD4000 Marcelo Schmitt
2024-06-05 13:03   ` Nuno Sá
2024-06-09  9:23     ` Jonathan Cameron [this message]
2024-06-11 10:34       ` Andy Shevchenko
2024-06-11 17:05         ` Jonathan Cameron
2024-06-05 20:50   ` kernel test robot
2024-06-05 21:32   ` kernel test robot

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=20240609102354.02aa1128@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=marcelo.schmitt@analog.com \
    --cc=noname.nuno@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=robh+dt@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).