All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: Peter Rosin <peda@axentia.se>, <linux-iio@vger.kernel.org>
Subject: Re: Reading ADC that comes from a multiplexer
Date: Thu, 23 Sep 2021 11:28:58 +0100	[thread overview]
Message-ID: <20210923112858.000022fa@Huawei.com> (raw)
In-Reply-To: <CAOMZO5AQk4zkgwk9ALkaasFv6t68K-bO6roki1tcdgnyk0wuTg@mail.gmail.com>

On Wed, 22 Sep 2021 11:50:14 -0300
Fabio Estevam <festevam@gmail.com> wrote:

> Hi Peter,
> 
> On Wed, Sep 22, 2021 at 11:28 AM Peter Rosin <peda@axentia.se> wrote:
> 
> > Nice!
> >
> > While I don't completely understand that iio-device node in the beaglebone
> > dts that didn't work for you, it looks like it's just a renumbering thing?  
> 
> The beaglebone dts uses some undocumented properties such as:
> iio-channels and iio-channel-names.

Some of this comes from the dts-schema repo.  We haven't been strict in
adding the entries to individual ADCs until they actually use them - which
has the advantage it gives us a window to think about the of_xlate (see below)

https://github.com/devicetree-org/dt-schema/blob/main/meta-schemas/iio.yaml
Not that it helps much as little in the way of docs in the dt-schema repo.

> 
> > However, your version only remapped 4 channels, and in that case your new
> > iio-device only had those, i.e. 0-3. But the iio-mux was looking for the
> > missing channel 4. Maybe that was why that variant didn't work?  
> 
> Yes, this is where I got confused.
> 
> The stmpe811 has 8 channels. On the apalis board, the first four channels
> (0 to 3) are used for touchscreen. The other 4 channels are for general purpose.
> 
> The ADC that is connected to the MUX is channel 4 (which is the first
> one that is
> free for general usage), so I had to pass:
> 
> io-channels = <&adc0 0>;
> 
> in the mux, instead of  io-channels = <&adc0 4> that I was originally trying.
> 
> and now the mapping is correct and I can read proper voltages when I
> switch the mux.

It's possible to add a translation routine to a given driver to deal with this
sort of case. I guess no one needed on the that driver before + all this
infrastructure post dates that driver.

See the of_xlate callbacks that let you map more obvious numbering to a particular
channel.

We are in an unfortunate mess here, but I'd argue the lack of io-channels entry
in the dt binding should in theory mean no one is using this property (as they
should be verifying against that).  The problem will occur if we have a pre
yaml conversion binding out in the wild with a mux or other consumer.  We could
cross our fingers and fix this now...

Jonathan


> 
> Thanks!

  reply	other threads:[~2021-09-23 10:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22  2:18 Reading ADC that comes from a multiplexer Fabio Estevam
2021-09-22  7:27 ` Peter Rosin
2021-09-22 11:37   ` Fabio Estevam
2021-09-22 12:44     ` Fabio Estevam
2021-09-22 12:53       ` Peter Rosin
2021-09-22 13:41         ` Fabio Estevam
2021-09-22 14:20           ` Fabio Estevam
2021-09-22 14:28             ` Peter Rosin
2021-09-22 14:50               ` Fabio Estevam
2021-09-23 10:28                 ` Jonathan Cameron [this message]
2021-09-24 14:41                   ` Fabio Estevam
2021-09-25 14:32                     ` Jonathan Cameron
2021-09-22 12:44     ` Peter Rosin

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=20210923112858.000022fa@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=festevam@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=peda@axentia.se \
    /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.