From: jpaulo.silvagoncalves@gmail.com
To: Jonathan Cameron <Jonathan.Cameron@Huawei.com>,
Peter Rosin <peda@axentia.se>
Cc: "João Paulo Gonçalves" <jpaulo.silvagoncalves@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Supporting a Device with Switchable Current/Voltage Measurement
Date: Thu, 2 May 2024 11:53:04 -0300 [thread overview]
Message-ID: <20240502145228.qgocejdzjaaxt2zq@joaog-nb> (raw)
In-Reply-To: <20240502133623.0000463e@Huawei.com> <44f47927-52aa-5248-6ae4-21028076fd51@axentia.se> <ad190ae3-48d2-a5db-dd36-d52b1c4cf460@axentia.se>
On Thu, May 02, 2024 at 01:36:23PM +0100, Jonathan Cameron wrote:
> Superficially sounds like you want a mixture of appropriate analog front ends
> and a Mux. I haven't tried the combination but it should be possible to do
> something like this with
>
> An IIO mux via this binding
> https://elixir.bootlin.com/linux/v6.9-rc6/source/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
> (that includes a gpio-mux example).
>
> Consumed in turn by a pair of AFE devices.
>
> Then you should be able to just read from which ever of the AFE device you want.
> A sysfs read from
> /sys/bus/iio/devices/iio\:deviceA/in_voltage_raw
> will switch the mux to appropriate place then request the
> voltage from the iio-mux, which in turn requests it from the ADC IIO driver.
>
> /sys/bus/iio/devices/iio\:deviceB/in_current_raw
> switches the mux the other way and otherwise the flow as above.
>
> Jonathan
>
On Thu, May 02, 2024 at 03:49:03PM +0200, Peter Rosin wrote:
> I just realized that it's also possible to do this "the other way around". Maybe
> that makes more sense?
>
> Cheers,
> Peter
>
> mux: gpio-mux {
> compatible = "gpio-mux";
> #mux-control-cells = <0>;
>
> gpios-mux = <&main_gpio0 29 GPIO_ACTIVE_HIGH>;
> };
>
> rcs: raw-current-sense {
> compatible = "io-channel-mux";
> io-channels = <&adc 0>;
> io-channel-names = "parent";
> #io-channel-cells = <1>;
>
> mux-controls = <&mux>;
>
> channels = "raw-current", "";
> };
>
> rvs: raw-voltage-sense {
> compatible = "io-channel-mux";
> io-channels = <&adc 1>;
> io-channel-names = "parent";
> #io-channel-cells = <1>;
>
> mux-controls = <&mux>;
>
> channels = "", "raw-voltage";
> };
>
> current-sense {
> compatible = "current-sense-shunt";
> io-channels = <&rcs 0>;
> io-channel-name = "current";
>
> shunt-resistor-micro-ohms = <3300000>;
> };
>
> voltage-sense {
> compatible = "voltage-divider";
> io-channels = <&rvs 1>;
> io-channel-name = "voltage";
>
> output-ohms = <22>;
> full-ohms = <222>;
> };
>
> Cheers,
> Peter
A lot of good information. I didn't know about the iio-mux. It might
solve our problem, and I will do some testing with it.
Thanks a lot for the help!
Regards,
João Paulo Gonçalves
next prev parent reply other threads:[~2024-05-02 14:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-01 23:38 João Paulo Gonçalves
2024-05-02 0:31 ` Bagas Sanjaya
2024-05-02 0:42 ` João Paulo Silva Gonçalves
2024-05-02 0:50 ` Bagas Sanjaya
2024-05-02 12:36 ` Jonathan Cameron
2024-05-02 13:49 ` Peter Rosin
2024-05-02 14:05 ` Peter Rosin
2024-05-02 14:53 ` jpaulo.silvagoncalves [this message]
2024-05-02 15:09 ` Jonathan Cameron
2024-05-02 16:43 ` 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=20240502145228.qgocejdzjaaxt2zq@joaog-nb \
--to=jpaulo.silvagoncalves@gmail.com \
--cc=Jonathan.Cameron@Huawei.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®