On Wed, 22 Sep 2021 11:50:14 -0300 Fabio Estevam <festevam@xxxxxxxxx> wrote: > Hi Peter, > > On Wed, Sep 22, 2021 at 11:28 AM Peter Rosin <peda@xxxxxxxxxx> 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!