diff mbox series

[1/2] dt-bindings: iio: adc: Add binding for current-from-voltage

Message ID BN6PR04MB06600A3AFE160C6E07BF5B2CA3BA0@BN6PR04MB0660.namprd04.prod.outlook.com
State Changes Requested, archived
Headers show
Series iio: adc: Add a current from voltage driver | expand

Checks

Context Check Description
robh/checkpatch success
robh/dt-meta-schema success

Commit Message

Jonathan Bakker May 16, 2020, 2:26 a.m. UTC
Some devices may require a current adc, but only have a voltage
ADC onboard.  In order to read the current, they have a resistor
connected to the ADC.  Add bindings for this possibility.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
---
 .../iio/adc/linux,current-from-voltage.yaml   | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml

Comments

Rob Herring May 28, 2020, 8:13 p.m. UTC | #1
On Fri, May 15, 2020 at 07:26:18PM -0700, Jonathan Bakker wrote:
> Some devices may require a current adc, but only have a voltage
> ADC onboard.  In order to read the current, they have a resistor
> connected to the ADC.  Add bindings for this possibility.
> 
> Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
> ---
>  .../iio/adc/linux,current-from-voltage.yaml   | 47 +++++++++++++++++++
>  1 file changed, 47 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml b/Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml
> new file mode 100644
> index 000000000000..385d317607c3
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml
> @@ -0,0 +1,47 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/adc/linux,current-from-voltage.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Current ADC from voltage ADC and resistor
> +
> +maintainers:
> +  - Jonathan Bakker <xc-racer2@live.ca>
> +
> +properties:
> +  compatible:
> +    const: linux,current-from-voltage

How is an ADC with a resistor attached a Linux thing? So you don't need 
'linux', but then 'current-from-voltage' isn't the best naming. I don't 
have a suggestion ATM.

> +
> +  io-channel-names:
> +    const: adc
> +
> +  io-channels:
> +    maxItems: 1
> +    description: Voltage ADC channel
> +
> +  linux,resistor-ohms:
> +    description: Strength of resistor connected to voltage ADC

Wouldn't you need this to be micro-ohms? Otherwise, there'd be too much 
voltage drop?

Rob
Jonathan Bakker May 28, 2020, 8:16 p.m. UTC | #2
Hi Rob,

On 2020-05-28 1:13 p.m., Rob Herring wrote:
> On Fri, May 15, 2020 at 07:26:18PM -0700, Jonathan Bakker wrote:
>> Some devices may require a current adc, but only have a voltage
>> ADC onboard.  In order to read the current, they have a resistor
>> connected to the ADC.  Add bindings for this possibility.
>>
>> Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
>> ---
>>  .../iio/adc/linux,current-from-voltage.yaml   | 47 +++++++++++++++++++
>>  1 file changed, 47 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml b/Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml
>> new file mode 100644
>> index 000000000000..385d317607c3
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml
>> @@ -0,0 +1,47 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/iio/adc/linux,current-from-voltage.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Current ADC from voltage ADC and resistor
>> +
>> +maintainers:
>> +  - Jonathan Bakker <xc-racer2@live.ca>
>> +
>> +properties:
>> +  compatible:
>> +    const: linux,current-from-voltage
> 
> How is an ADC with a resistor attached a Linux thing? So you don't need 
> 'linux', but then 'current-from-voltage' isn't the best naming. I don't 
> have a suggestion ATM.
> 

The good/bad news is that I was re-implementing an existing driver under a new name :)

The compatible is current-sense-shunt for this exact same purpose.

Thanks,
Jonathan

>> +
>> +  io-channel-names:
>> +    const: adc
>> +
>> +  io-channels:
>> +    maxItems: 1
>> +    description: Voltage ADC channel
>> +
>> +  linux,resistor-ohms:
>> +    description: Strength of resistor connected to voltage ADC
> 
> Wouldn't you need this to be micro-ohms? Otherwise, there'd be too much 
> voltage drop?
> 
> Rob
>
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml b/Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml
new file mode 100644
index 000000000000..385d317607c3
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/linux,current-from-voltage.yaml
@@ -0,0 +1,47 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/linux,current-from-voltage.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Current ADC from voltage ADC and resistor
+
+maintainers:
+  - Jonathan Bakker <xc-racer2@live.ca>
+
+properties:
+  compatible:
+    const: linux,current-from-voltage
+
+  io-channel-names:
+    const: adc
+
+  io-channels:
+    maxItems: 1
+    description: Voltage ADC channel
+
+  linux,resistor-ohms:
+    description: Strength of resistor connected to voltage ADC
+
+  "#io-channel-cells":
+    const: 0
+
+required:
+  - compatible
+  - io-channel-names
+  - io-channels
+  - linux,resistor-ohms
+  - "#io-channel-cells"
+
+examples:
+  - |
+    current-from-voltage {
+      compatible = "linux,current-from-voltage";
+      io-channel-names = "adc";
+      io-channels = <&adc 9>;
+      linux,resistor-ohms = <47>;
+      #io-channel-cells = <0>;
+      io-channel-ranges;
+    };
+
+...