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
32
33properties:
34  compatible:
35    const: voltage-divider
36
37  io-channels:
38    maxItems: 1
39    description: |
40      Channel node of a voltage io-channel.
41
42  '#io-channel-cells':
43    description:
44      In addition to consuming the measurement services of a voltage
45      output channel, the voltage divider can act as a provider of
46      measurement services to other devices. This is particularly
47      useful in scenarios wherein an ADC has an analog frontend,
48      such as a voltage divider, and then consuming its raw value
49      isn't interesting. In this case, the voltage before the divider
50      is desired.
51    const: 1
52
53  output-ohms:
54    description:
55      Resistance Rout over which the output voltage is measured. See full-ohms.
56
57  full-ohms:
58    description:
59      Resistance R + Rout for the full divider. The io-channel is scaled by
60      the Rout / (R + Rout) quotient.
61
62required:
63  - compatible
64  - io-channels
65  - output-ohms
66  - full-ohms
67
68additionalProperties: false
69
70examples:
71  - |
72    #include <dt-bindings/interrupt-controller/irq.h>
73    /*
74     * The system voltage is circa 12V, but divided down with a 22/222
75     * voltage divider (R = 200 Ohms, Rout = 22 Ohms) and fed to an ADC.
76     */
77    spi {
78        #address-cells = <1>;
79        #size-cells = <0>;
80        maxadc: adc@0 {
81            compatible = "maxim,max1027";
82            reg = <0>;
83            #io-channel-cells = <1>;
84            interrupt-parent = <&gpio5>;
85            interrupts = <15 IRQ_TYPE_EDGE_RISING>;
86            spi-max-frequency = <1000000>;
87        };
88    };
89    sysv {
90        compatible = "voltage-divider";
91        io-channels = <&maxadc 1>;
92
93        /* Scale the system voltage by 22/222 to fit the ADC range. */
94        output-ohms = <22>;
95        full-ohms = <222>; /* 200 + 22 */
96    };
97...
98