]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
iio: meter: ina3221: add dt binding header for iio channel support
authorLaxman Dewangan <ldewangan@nvidia.com>
Sun, 13 Apr 2014 06:48:00 +0000 (12:18 +0530)
committerLaxman Dewangan <ldewangan@nvidia.com>
Sun, 13 Apr 2014 12:36:21 +0000 (05:36 -0700)
Update the INA3221x DT binding documents and add dt-binding header to use
the macro from DTS file.

The updates details how it can be instantiated as iio channels and client
driver use this from DT node for measuring different parameters of different
channels. It also details the index for different signal monitor which
is require for iio channel consumer interface.

bug 1413219

Change-Id: I1c31322d4d905983e16ef132c0bd75af29fd0583
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/395549

Documentation/devicetree/bindings/iio/meter/ina3221.txt
include/dt-bindings/iio/meter/ina3221x.h [new file with mode: 0644]

index 9444b54dfb8790a55b3d35ba0af59bfbb3658d68..8d4910280c86fcbdce89ad9ba373dc229752b6b7 100644 (file)
@@ -23,6 +23,37 @@ Optional subnode properties:
 - ti,current-critical-limit-ma: Current critical limit for the given channel.
 - ti,shunt-resistor-mohm: Shunt register in milli ohm.
 
+IIO channel properties:
+It follows same mechanism for iio properties detailed on ../iio-bindings.txt
+The iio cells size must be 1.
+       #io-channel-cells = <1>;
+The ina3221 driver provides following monitoring:
+       voltage, current, current_trigger, power, power_trigger.
+       The sequence of index assigned in drivers are:
+               voltage, current, current_trigger, power, power_trigger
+       The above monitoring is provided for channel 0, 1 and 2.
+The sysfs are
+       in_voltage0_input, in_current0_input, in_current0_trigger_input
+       in_power0_input, in_power0_trigger_input
+       in_voltage1_input, in_current1_input, in_current1_trigger_input,
+       in_power1_input, in_power1_trigger_input
+       in_voltage2_input, in_current2_input, in_current2_trigger_input,
+       in_power2_input,in_power2_trigger_input
+The channel index are in above sequence starting from 0.
+
+To ease the DT entry, the macros are added in header dt-bindings/iio/meter/ina3221x.h
+The Voltage/current/power macros are defines and can be use with INA3221_CHAN_INDEX to
+get the proper index.
+Example: For Channel 0, normal power it is INA3221_CHAN_INDEX(0, POWER, NORMAL)
+for channel 2, normal current it is INA3221_CHAN_INDEX(2, CURRENT, NORMAL).
+
+The typical macro for voltage/current and powers are:
+       INA3221_VOLTAGE, INA3221_CURRENT, INA3221_POWER
+The typical macro for normal/trigger are INA3221_NORMAL and INA3221_TRIGGER.
+
+The INA3221_CHAN_INDEX defined as:
+#define INA3221_CHAN_INDEX(chan, type, add) (chan * 5 + INA3221_##type + INA3221_##add)
+
 Example:
        ina3221x@40 {
                compatible = "ti,ina3221x";
@@ -31,6 +62,7 @@ Example:
                ti,continuous-config = <0x7c07>;
                #address-cells = <1>;
                #size-cells = <0>;
+               #io-channel-cells = <1>;
 
                channel@0 {
                        reg = <0x0>;
@@ -53,3 +85,8 @@ Example:
                };
        };
 
+
+clients {
+       io-channels = <&ina3221x INA3221_CHAN_INDEX(0, CURRENT, NORMAL)>;
+       io-channel-names = "battery-current"
+}
diff --git a/include/dt-bindings/iio/meter/ina3221x.h b/include/dt-bindings/iio/meter/ina3221x.h
new file mode 100644 (file)
index 0000000..5f2ea66
--- /dev/null
@@ -0,0 +1,24 @@
+/* This header provides constants for binding ti,ina3221x */
+
+#ifndef _DT_BINDINGS_IIO_METER_INA3221X_H
+#define _DT_BINDINGS_IIO_METER_INA3221X_H
+
+/* Channel numbers */
+#define INA3221_CHANNEL0       0
+#define INA3221_CHANNEL1       1
+#define INA3221_CHANNEL2       2
+
+/* Monitor type */
+#define INA3221_VOLTAGE                0
+#define INA3221_CURRENT                1
+#define INA3221_POWER          3
+
+/* Measurement technique normal/trigger */
+#define INA3221_NORMAL         0
+#define INA3221_TRIGGER                1
+
+/* To get the iio spec index */
+#define INA3221_CHAN_INDEX(chan, type, add)    \
+       (chan * 5 + INA3221_##type + INA3221_##add)
+
+#endif