diff mbox series

dt-bindings: iio: afe: voltage-divider: Add io-channel-cells

Message ID 20240126115509.1459425-1-naresh.solanki@9elements.com
State Accepted
Commit f1f99fcbf997b50a32844c31523ed41da0428f08
Headers show
Series dt-bindings: iio: afe: voltage-divider: Add io-channel-cells | expand

Commit Message

Naresh Solanki Jan. 26, 2024, 11:55 a.m. UTC
Add #io-channel-cells expected by driver. i.e., below is the message
seen in kernel log:
OF: /iio-hwmon: could not get #io-channel-cells for /voltage_divider1

TEST=Run below command & make sure there is no error:
make DT_CHECKER_FLAGS=-m dt_binding_check -j1

Signed-off-by: Naresh Solanki <naresh.solanki@9elements.com>
---
 Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml | 3 +++
 1 file changed, 3 insertions(+)


base-commit: ecb1b8288dc7ccbdcb3b9df005fa1c0e0c0388a7

Comments

Peter Rosin Jan. 27, 2024, 9:40 a.m. UTC | #1
2024-01-26 at 23:14, Conor Dooley wrote:
> On Fri, Jan 26, 2024 at 11:10:36PM +0530, Naresh Solanki wrote:

> I did look at what you have there and I think your dts is wrong.
> 
> The iio-hwmon binding says:
> | description: >
> |   Bindings for hardware monitoring devices connected to ADC controllers
> |   supporting the Industrial I/O bindings.
> | 
> |   io-channels:
> |     minItems: 1
> |     maxItems: 51 # Should be enough
> |     description: >
> |       List of phandles to ADC channels to read the monitoring values
> 
> And then you have:
> |	iio-hwmon {
> |		compatible = "iio-hwmon";
> |		// Voltage sensors top to down
> |		io-channels = <&p12v_vd 0>, <&p5v_aux_vd 0>, <&p5v_bmc_aux_vd 0>, <&p3v3_aux_vd 0>,
> |			<&p3v3_bmc_aux_vd 0>, <&p1v8_bmc_aux_vd 0>, <&adc1 4>, <&adc0 2>, <&adc1 0>,
> |			<&p2V5_aux_vd 0>, <&p3v3_rtc_vd 0>;
> |	};
> |
> |	p12v_vd: voltage_divider1 {
> |		compatible = "voltage-divider";
> |		io-channels = <&adc1 3>;
> |		#io-channel-cells = <1>;
> |
> |		/* Scale the system voltage by 1127/127 to fit the ADC range.
> |		 * Use small nominator to prevent integer overflow.
> |		 */
> |		output-ohms = <15>;
> |		full-ohms = <133>;
> |	};
> 
> A voltage divider is _not_ an ADC channel, so I don't know why you are
> treating it as one in the iio-hwmon entry. Can you explain this please?

This is the exact intent of the voltage divider (and the other bindings
handled by the iio-rescaler). The raw ADC reports the voltage at its input,
which is fine, but if there is an analog frontend in front of the ADC
such as a voltage divider the voltage at the ADC is not the interesting
property. You are likely to want the "real" voltage before the voltage
divider to better understand the value.

In this case it's much more interesting to see values such as 12.050V
which is presumably close to the nominal voltage (12V? guessing from
the node name) rather than some unscaled raw ADC voltage (in this
example it would be ~1.359V, which tells you rather little w/o rescaling
it first).

It's all in the description of the binding...

Cheers,
Peter
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml b/Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml
index dddf97b50549..b4b5489ad98e 100644
--- a/Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml
+++ b/Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml
@@ -39,6 +39,9 @@  properties:
     description: |
       Channel node of a voltage io-channel.
 
+  '#io-channel-cells':
+    const: 1
+
   output-ohms:
     description:
       Resistance Rout over which the output voltage is measured. See full-ohms.