From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: David Lechner <david@lechnology.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>,
"kernel@pengutronix.de Mark Brown" <broonie@kernel.org>,
linux-spi@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ti-ads7950: Ensure CS is deasserted after reading channels
Date: Sat, 10 Jul 2021 14:18:15 +0200 [thread overview]
Message-ID: <20210710121815.yxaylkhessvjbtkf@pengutronix.de> (raw)
In-Reply-To: <00b3dd46-48ba-3d40-36dd-79372a956085@lechnology.com>
[-- Attachment #1: Type: text/plain, Size: 2304 bytes --]
Hello,
Cc += Mark + linux-spi
On Fri, Jul 09, 2021 at 11:39:48AM -0500, David Lechner wrote:
> On 7/9/21 5:11 AM, Uwe Kleine-König wrote:
> > The ADS7950 requires that CS is deasserted after each SPI word. Before
> > commit e2540da86ef8 ("iio: adc: ti-ads7950: use SPI_CS_WORD to reduce
> > CPU usage") the driver used a message with one spi transfer per channel
> > where each but the last one had .cs_change set to enforce a CS toggle.
> > This was wrongly translated into a message with a single transfer and
> > .cs_change set which results in a CS toggle after each word but the
> > last which corrupts the first adc conversion of all readouts after the
> > first readout.
> >
> > Fixes: e2540da86ef8 ("iio: adc: ti-ads7950: use SPI_CS_WORD to reduce CPU usage")
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> > drivers/iio/adc/ti-ads7950.c | 1 -
> > 1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
> > index 2383eacada87..a2b83f0bd526 100644
> > --- a/drivers/iio/adc/ti-ads7950.c
> > +++ b/drivers/iio/adc/ti-ads7950.c
> > @@ -568,7 +568,6 @@ static int ti_ads7950_probe(struct spi_device *spi)
> > st->ring_xfer.tx_buf = &st->tx_buf[0];
> > st->ring_xfer.rx_buf = &st->rx_buf[0];
> > /* len will be set later */
> > - st->ring_xfer.cs_change = true;
> > spi_message_add_tail(&st->ring_xfer, &st->ring_msg);
> >
>
> Yes, it seems like the SPI_CS_WORD flag should have replaced this (it's
> been too long, I can't remember if it was intentional). And removing it
> doesn't seem to break anything for me.
If it's not broken for you without my patch, your spi bus driver doesn't
honor .cs_change in the last transfer. Out of interest: Which bus are
you using? I wonder if the driver should refuse the request if it cannot
honer .cs_change?! (spi-imx does honor it only if gpios are used as chip
select, the native chip selects cannot do that.)
> Reviewed-by: David Lechner <david@lechnology.com>
> Tested-by: David Lechner <david@lechnology.com>
Thanks
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-07-10 12:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-09 10:11 [PATCH] iio: adc: ti-ads7950: Ensure CS is deasserted after reading channels Uwe Kleine-König
2021-07-09 16:39 ` David Lechner
2021-07-10 12:18 ` Uwe Kleine-König [this message]
2021-07-10 15:32 ` David Lechner
2021-07-12 11:49 ` Mark Brown
2021-07-17 17:37 ` 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=20210710121815.yxaylkhessvjbtkf@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=broonie@kernel.org \
--cc=david@lechnology.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-spi@vger.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).