public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Supporting a Device with Switchable Current/Voltage Measurement
@ 2024-05-01 23:38 João Paulo Gonçalves
  2024-05-02  0:31 ` Bagas Sanjaya
  2024-05-02 12:36 ` Jonathan Cameron
  0 siblings, 2 replies; 10+ messages in thread
From: João Paulo Gonçalves @ 2024-05-01 23:38 UTC (permalink / raw)
  To: linux-iio, linux-kernel; +Cc: joao.goncalves

Hello all,

We need to support a hardware that can measure current and voltage on
the same differential analog input, similar to a multimeter. The mode
of measurement is controlled by a GPIO switch and goes to different
ADC inputs depending on the mode. If the switch is enabled, a current
loop with a shunt is enabled for current measurement; otherwise, voltage
is measured. From the software point of view, we are considering using
the iio-rescale driver as a consumer of an ADC IIO parent device. One
of the problems is that we need to change the mode of measurement at
runtime, but we are trying to avoid using some userspace "hack". The
other is that for a minimal solution to enable the mode from boot, we
can use a gpio-hog and control it with overlays. However,
still would be better that this was done by the kernel. Do you know
or have some guidance on how to properly support this in the kernel?

For the in kernel gpio solution, this is a draft of DT we are thinking:

current-sense {
      compatible = "current-sense-shunt";
      io-channels = <&adc 0>;
      gpio = <&main_gpio0 29 GPIO_ACTIVE_HIGH>;
      shunt-resistor-micro-ohms = <3300000>;      
};

voltage-sense {
        compatible = "voltage-divider";
        io-channels = <&adc 1>;
        gpio = <&main_gpio0 29 GPIO_ACTIVE_LOW>;
        output-ohms = <22>;
        full-ohms = <222>;
};

Regards,
João Paulo Gonçalves


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-05-02 16:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-01 23:38 Supporting a Device with Switchable Current/Voltage Measurement 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
2024-05-02 15:09       ` Jonathan Cameron
2024-05-02 16:43         ` Peter Rosin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox