From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <david@lechnology.com>
Cc: justinpopo6@gmail.com, linux-iio@vger.kernel.org,
linux-gpio@vger.kernel.org,
bcm-kernel-feedback-list@broadcom.com, f.fainelli@gmail.com,
bgolaszewski@baylibre.com, linus.walleij@linaro.org,
knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iio: adc: ti-ads7950: add GPIO support
Date: Wed, 20 Feb 2019 17:23:31 +0000 [thread overview]
Message-ID: <20190220172331.40d7cbf0@archlinux> (raw)
In-Reply-To: <96ec33f3-6e58-325f-9c55-4f1a92f635f7@lechnology.com>
On Wed, 20 Feb 2019 10:48:49 -0600
David Lechner <david@lechnology.com> wrote:
> On 2/20/19 6:00 AM, Jonathan Cameron wrote:
> > On Wed, 13 Feb 2019 09:10:53 +0100
> > David Lechner <david@lechnology.com> wrote:
> >
> >> On 2/12/19 9:57 PM, justinpopo6@gmail.com wrote:
> >>> From: Justin Chen <justinpopo6@gmail.com>
> >>>
> >>> The ADS79XX has GPIO pins that can be used. Add support for the GPIO
> >>> pins using the GPIO chip framework.
> >>>
> >>> Signed-off-by: Justin Chen <justinpopo6@gmail.com>
> >>> ---
> >>
> >> It will be better to split this up into two patches[1]. One to replace
> >> all uses of indio_dev->mlock with the new local lock and then another to
> >> add GPIO support.
> >>
> >> How are you using/testing this patch? Do we need device tree bindings?
> >>
> >> It will also help reviewers if you add a note about what you changed in
> >> each revision of the patch when you resubmit. The usual way to do this
> >> is something like:
> >>
> >> v3 changes:
> >>
> >> - Fixed unlocking mutex too many times in ti_ads7950_init_gpio()
> >>
> >> It also is nice to wait a few days at least before submitting the next
> >> revision to give people some time to respond.
> >
> > Agreed with all comments except the endian one.
> > SPI doesn't define an endianness of data on the wire, so we may need
> > to convert to match whatever ordering the ti chip expects.
> > I would expect things to be thoroughly broken if we remove those
> > conversions - particularly as I doubt this is being tested with a
> > big endian host!
> >
> > Jonathan
>
> I'm a bit confused then. I got this idea from include/linux/spi.h, which
> says:
>
> * In-memory data values are always in native CPU byte order, translated
> * from the wire byte order (big-endian except with SPI_LSB_FIRST). So
> * for example when bits_per_word is sixteen, buffers are 2N bytes long
> * (@len = 2N) and hold N sixteen bit words in CPU byte order.
>
>
> And in the most recent patches to the ti-ads7950 driver where we switched
> from 8-bit words to 16-bit words, I had to remove the calls to cpu_to_be16()
> to keep things working.
Ah, my apologies, I didn't look at this closely enough.
I was assuming we weren't in 16 bit mode here - oops.
Otherwise this wouldn't have any hope of working... Except I'm assuming it is...
hohum.
Hmm. Given the result of that cpu_to_be16 will be to swap (as almost certainly
on le system), I'm going to hazzard a guess that the ti device is expecting
little endian and we should be setting SPI_LSB_FIRST.
Which is odd because the data sheet definitely looks MSB first. Not to mention
this isn't be done elsewhere in the driver.
So only option I can fall back on is that it is being used on a be system
(hence noop) or is a forward port of an older patch for the driver that missed
your 16 bit change...
>
> I realize that I am only using one SPI controller, so I may be making a bad
> assumption here, but it seems to me that it is up to the SPI controller to
> make sure the bits get sent over the wire in the correct order and we
> shouldn't have to worry about it here. We are implicitly telling the SPI
> controller that we need big-endian over the wire by omitting the SPI_LSB_FIRST
> flag here:
>
> spi->bits_per_word = 16;
> spi->mode |= SPI_CS_WORD;
> ret = spi_setup(spi);
>
You are entirely correct, I was too lazy and had forgotten your change to
move to 16 bits.
Jonathan
next prev parent reply other threads:[~2019-02-20 17:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-13 3:57 [PATCH v3] iio: adc: ti-ads7950: add GPIO support justinpopo6
2019-02-13 8:10 ` David Lechner
2019-02-20 12:00 ` Jonathan Cameron
2019-02-20 16:48 ` David Lechner
2019-02-20 17:23 ` Jonathan Cameron [this message]
2019-02-20 19:43 ` Justin Chen
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=20190220172331.40d7cbf0@archlinux \
--to=jic23@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bgolaszewski@baylibre.com \
--cc=david@lechnology.com \
--cc=f.fainelli@gmail.com \
--cc=justinpopo6@gmail.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--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 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).