xref: /linux/Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml (revision f4b369c6fe0ceaba2da2daff8c9eb415f85926dd)
1# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/iio/afe/voltage-divider.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Voltage divider
8
9maintainers:
10  - Peter Rosin <peda@axentia.se>
11
12description: |
13  When an io-channel measures the midpoint of a voltage divider, the
14  interesting voltage is often the voltage over the full resistance
15  of the divider. This binding describes the voltage divider in such
16  a circuit.
17
18    Vin ----.
19            |
20         .-----.
21         |  R  |
22         '-----'
23            |
24            +---- Vout
25            |
26         .-----.
27         | Rout|
28         '-----'
29            |
30           GND
31
32properties:
33  compatible:
34    const: voltage-divider
35
36  io-channels:
37    maxItems: 1
38    description: |
39      Channel node of a voltage io-channel.
40
41  '#io-channel-cells':
42    description:
43      In addition to consuming the measurement services of a voltage
44      output channel, the voltage divider can act as a provider of
45      measurement services to other devices. This is particularly
46      useful in scenarios wherein an ADC has an analog frontend,
47      such as a voltage divider, and then consuming its raw value
48      isn't interesting. In this case, the voltage before the divider
49      is desired.
50    const: 1
51
52  output-ohms:
53    description:
54      Resistance Rout over which the output voltage is measured. See full-ohms.
55
56  full-ohms:
57    description:
58      Resistance R + Rout for the full divider. The io-channel is scaled by
59      the Rout / (R + Rout) quotient.
60
61required:
62  - compatible
63  - io-channels
64  - output-ohms
65  - full-ohms
66
67additionalProperties: false
68
69examples:
70  - |
71    #include <dt-bindings/interrupt-controller/irq.h>
72    /*
73     * The system voltage is circa 12V, but divided down with a 22/222
74     * voltage divider (R = 200 Ohms, Rout = 22 Ohms) and fed to an ADC.
75     */
76    spi {
77        #address-cells = <1>;
78        #size-cells = <0>;
79        maxadc: adc@0 {
80            compatible = "maxim,max1027";
81            reg = <0>;
82            #io-channel-cells = <1>;
83            interrupt-parent = <&gpio5>;
84            interrupts = <15 IRQ_TYPE_EDGE_RISING>;
85            spi-max-frequency = <1000000>;
86        };
87    };
88    sysv {
89        compatible = "voltage-divider";
90        io-channels = <&maxadc 1>;
91
92        /* Scale the system voltage by 22/222 to fit the ADC range. */
93        output-ohms = <22>;
94        full-ohms = <222>; /* 200 + 22 */
95    };
96...
97