[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4449ec60-08cd-4074-ba0b-95603864a458@baylibre.com>
Date: Tue, 7 Jan 2025 17:40:12 -0600
From: David Lechner <dlechner@...libre.com>
To: Jonathan Santos <Jonathan.Santos@...log.com>, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: lars@...afoo.de, Michael.Hennerich@...log.com, jic23@...nel.org,
robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org,
marcelo.schmitt1@...il.com
Subject: Re: [PATCH v1 05/15] iio: adc: ad7768-1: set MOSI idle state to high
On 1/7/25 9:25 AM, Jonathan Santos wrote:
> All supported parts require that the MOSI line stays high
> while in idle.
>
> Configure SPI controller to set MOSI idle state to high.
>
> Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support")
> Signed-off-by: Jonathan Santos <Jonathan.Santos@...log.com>
> ---
> drivers/iio/adc/ad7768-1.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
> index c3cf04311c40..463a28d09c2e 100644
> --- a/drivers/iio/adc/ad7768-1.c
> +++ b/drivers/iio/adc/ad7768-1.c
> @@ -574,6 +574,15 @@ static int ad7768_probe(struct spi_device *spi)
> return -ENOMEM;
>
> st = iio_priv(indio_dev);
> + /*
> + * The ADC SDI line must be kept high when
> + * data is not being clocked out of the controller.
> + * Request the SPI controller to make MOSI idle high.
> + */
> + spi->mode |= SPI_MOSI_IDLE_HIGH;
> + ret = spi_setup(spi);
> + if (ret < 0)
> + return ret;
> st->spi = spi;
>
> st->vref = devm_regulator_get(&spi->dev, "vref");
Very few SPI controllers currently have the SPI_MOSI_IDLE_HIGH capability flag
set in Linux right now (whether they actually support it or not), so this could
break existing users.
The datasheet says:
When reading back data with CS held low, it is recommended that SDI
idle high to prevent an accidental reset of the device where SCLK is
free running (see the Reset section).
And the reset section says:
When CS is held low, it is possible to provide a reset by clocking
in a 1 followed by 63 zeros on SDI, which is the SPI resume command
reset function used to exit power-down mode.
Since the largest xfer we do is 3 bytes before deasserting CS, I don't think
we have any risk of accidentally resetting right now.
If we ever do implement a data read of more than 64 bits without toggling CS,
then we could just set the TX data to be all 0xFF and have the same effect
without requiring the SPI controller to support SPI_MOSI_IDLE_HIGH.
Powered by blists - more mailing lists