Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1646154

Re: [PATCH 4/4] iio: hi8435: cleanup reset gpio

From Jonathan Cameron <jic23@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 4/4] iio: hi8435: cleanup reset gpio
Date 2017-05-20 18:40 +0200
Message-ID <tJfA6-3RZ-19@gated-at.bofh.it> (permalink)
References <tIRo5-3Bo-5@gated-at.bofh.it> <tIRo6-3Bo-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 19/05/17 15:48, Nikita Yushchenko wrote:
> Reset GPIO is active low.
> 
> Currently driver uses gpiod_set_value(1) to clean reset, which depends
> on device tree to contain GPIO_ACTIVE_HIGH - that does not match reality.
> 
> This fixes driver to use _raw version of gpiod_set_value() to enforce
> active-low semantics despite of what's written in device tree. Allowing
> device tree to override that only opens possibility for errors and does
> not add any value.
> 
> Additionally, use _cansleep version to make things work with i2c-gpio
> and other sleeping gpio drivers.
> 
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Hopefully we don't have any 'interesting' wiring schemes out there
that actually have a not gate on that wire.

Your argument seems sound to me so applied to the togreg branch
of iio.git and pushed out as testing for the autobuilders to play with
it.

Again, input from Vladimir would be particularly welcome!

Jonathan
> ---
>   drivers/iio/adc/hi8435.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c
> index d09cb6ff8044..ab59969b7c49 100644
> --- a/drivers/iio/adc/hi8435.c
> +++ b/drivers/iio/adc/hi8435.c
> @@ -476,13 +476,15 @@ static int hi8435_probe(struct spi_device *spi)
>   	priv->spi = spi;
>   
>   	reset_gpio = devm_gpiod_get(&spi->dev, NULL, GPIOD_OUT_LOW);
> -	if (IS_ERR(reset_gpio)) {
> -		/* chip s/w reset if h/w reset failed */
> +	if (!IS_ERR(reset_gpio)) {
> +		/* need >=100ns low pulse to reset chip */
> +		gpiod_set_raw_value_cansleep(reset_gpio, 0);
> +		udelay(1);
> +		gpiod_set_raw_value_cansleep(reset_gpio, 1);
> +	} else {
> +		/* s/w reset chip if h/w reset is not available */
>   		hi8435_writeb(priv, HI8435_CTRL_REG, HI8435_CTRL_SRST);
>   		hi8435_writeb(priv, HI8435_CTRL_REG, 0);
> -	} else {
> -		udelay(5);
> -		gpiod_set_value(reset_gpio, 1);
>   	}
>   
>   	spi_set_drvdata(spi, idev);
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/4] iio: hi8435: add raw access Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2017-05-19 16:50 +0200
  [PATCH 4/4] iio: hi8435: cleanup reset gpio Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2017-05-19 16:50 +0200
    Re: [PATCH 4/4] iio: hi8435: cleanup reset gpio Jonathan Cameron <jic23@kernel.org> - 2017-05-20 18:40 +0200
    Re: [PATCH 4/4] iio: hi8435: cleanup reset gpio Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2017-05-23 10:20 +0200
      Re: [PATCH 4/4] iio: hi8435: cleanup reset gpio Vladimir Barinov <vladimir.barinov@cogentembedded.com> - 2017-05-24 13:30 +0200
        Re: [PATCH 4/4] iio: hi8435: cleanup reset gpio Jonathan Cameron <jic23@kernel.org> - 2017-05-24 21:40 +0200
  [PATCH 2/4] iio: hi8435: avoid garbage event at first enable Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2017-05-19 16:50 +0200
    Re: [PATCH 2/4] iio: hi8435: avoid garbage event at first enable Jonathan Cameron <jic23@kernel.org> - 2017-05-20 18:40 +0200
    Re: [PATCH 2/4] iio: hi8435: avoid garbage event at first enable Vladimir Barinov <vladimir.barinov@cogentembedded.com> - 2017-05-22 20:30 +0200
      Re: [PATCH 2/4] iio: hi8435: avoid garbage event at first enable Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2017-05-23 09:30 +0200
  Re: [PATCH 1/4] iio: hi8435: add raw access Jonathan Cameron <jic23@kernel.org> - 2017-05-20 18:40 +0200
    Re: [PATCH 1/4] iio: hi8435: add raw access Vladimir Barinov <vladimir.barinov@cogentembedded.com> - 2017-05-22 19:30 +0200

csiph-web