All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Beniamin Bia <beniamin.bia@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<knaack.h@gmx.de>, <pmeerw@pmeerw.net>,
	<Michael.Hennerich@analog.com>, <biabeniamin@outlook.com>,
	Dragos Bogdan <dragos.bogdan@analog.com>
Subject: Re: [PATCH 1/4] iio: adc: ad7476: Generate CONVST signal internally
Date: Sun, 15 Mar 2020 13:15:28 +0000	[thread overview]
Message-ID: <20200315131528.11d1b8bd@archlinux> (raw)
In-Reply-To: <20200311084328.17680-1-beniamin.bia@analog.com>

On Wed, 11 Mar 2020 10:43:25 +0200
Beniamin Bia <beniamin.bia@analog.com> wrote:

> From: Dragos Bogdan <dragos.bogdan@analog.com>
> 
> Compared to the other supported parts, AD7091R are dependent of
> a CONVST signal that initiates the conversion. At this moment, only
> sampling in buffered mode is supported for AD7091R and the only
> option until now was to generate this signal externally using an
> IIO trigger. This patch adds the option of generating it internally,
> more compatible triggers being available in this case.
> 
> Also, it is an intermiate step of adding support more devices.
> 
> Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
> Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Seems sensible.  Applied to the togreg branch of iio.git and pushed
out as testing for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ad7476.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index 76747488044b..32e857dfec9c 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -12,9 +12,11 @@
>  #include <linux/sysfs.h>
>  #include <linux/spi/spi.h>
>  #include <linux/regulator/consumer.h>
> +#include <linux/gpio/consumer.h>
>  #include <linux/err.h>
>  #include <linux/module.h>
>  #include <linux/bitops.h>
> +#include <linux/delay.h>
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> @@ -34,6 +36,7 @@ struct ad7476_state {
>  	struct spi_device		*spi;
>  	const struct ad7476_chip_info	*chip_info;
>  	struct regulator		*reg;
> +	struct gpio_desc		*convst_gpio;
>  	struct spi_transfer		xfer;
>  	struct spi_message		msg;
>  	/*
> @@ -64,6 +67,17 @@ enum ad7476_supported_device_ids {
>  	ID_ADS7868,
>  };
>  
> +static void ad7091_convst(struct ad7476_state *st)
> +{
> +	if (!st->convst_gpio)
> +		return;
> +
> +	gpiod_set_value(st->convst_gpio, 0);
> +	udelay(1); /* CONVST pulse width: 10 ns min */
> +	gpiod_set_value(st->convst_gpio, 1);
> +	udelay(1); /* Conversion time: 650 ns max */
> +}
> +
>  static irqreturn_t ad7476_trigger_handler(int irq, void  *p)
>  {
>  	struct iio_poll_func *pf = p;
> @@ -71,6 +85,8 @@ static irqreturn_t ad7476_trigger_handler(int irq, void  *p)
>  	struct ad7476_state *st = iio_priv(indio_dev);
>  	int b_sent;
>  
> +	ad7091_convst(st);
> +
>  	b_sent = spi_sync(st->spi, &st->msg);
>  	if (b_sent < 0)
>  		goto done;
> @@ -254,6 +270,12 @@ static int ad7476_probe(struct spi_device *spi)
>  	if (ret)
>  		return ret;
>  
> +	st->convst_gpio = devm_gpiod_get_optional(&spi->dev,
> +						  "adi,conversion-start",
> +						  GPIOD_OUT_LOW);
> +	if (IS_ERR(st->convst_gpio))
> +		return PTR_ERR(st->convst_gpio);
> +
>  	spi_set_drvdata(spi, indio_dev);
>  
>  	st->spi = spi;


      parent reply	other threads:[~2020-03-15 13:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11  8:43 [PATCH 1/4] iio: adc: ad7476: Generate CONVST signal internally Beniamin Bia
2020-03-11  8:43 ` [PATCH 2/4] iio: adc: ad7476: Add IIO_CHAN_INFO_RAW for AD7091R Beniamin Bia
2020-03-15 13:16   ` Jonathan Cameron
2020-03-11  8:43 ` [PATCH 3/4] iio: adc: ad7476: Add AD7091 support Beniamin Bia
2020-03-15 13:17   ` Jonathan Cameron
2020-03-11  8:43 ` [PATCH 4/4] iio: adc: ad7476: implement devm_add_action_or_reset Beniamin Bia
2020-03-15 13:18   ` Jonathan Cameron
2020-03-15 13:15 ` Jonathan Cameron [this message]

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=20200315131528.11d1b8bd@archlinux \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=beniamin.bia@analog.com \
    --cc=biabeniamin@outlook.com \
    --cc=dragos.bogdan@analog.com \
    --cc=knaack.h@gmx.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.