Skip to contentSkip to conversation

Add an initial DT binding doc for ina3221

PATCH In review Nicolin Chen 3 participants 6 messages Oct 2, 2018 – Oct 5, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v9 cover Add an initial DT binding doc for ina3221

This series adds a initial DT binding doc for ina3221. It defines a child node to describe the input source of each ina3221 channel. Then it changes the driver to handle the information properly.

Changelog
v8->v9:
* Fixed a potential race condition (PATCH-2)
v7->v8:
* Refined two places in ina3221 driver (PATCH-2)
v6->v7:
* Refined the example in the binding doc (PATCH-1)
v5->v6:
* Removed status property and merged examples (PATCH-1)
* Added in[123]_enable sysfs nodes (PATCH-2)
v4->v5:
* Changed two property names of child node (PATCH-1)
* Changed the driver accordingly and simplified is_visible (PATCH-2)
v3->v4:
* Fixed one place in child DT node bindings (PATCH-1)
* Changed the driver accordingly and added is_visible (PATCH-2)
v2->v3:
* Fixed two places in DT bindings (PATCH-1)
v1->v2:
* Redefined DT bindings (detail in PATCH-1)
* Changed the driver code accordingly (detail in PATCH-2)

Nicolin Chen (2):
dt-bindings: hwmon: Add ina3221 documentation
hwmon: (ina3221) Read channel input source info from DT

 .../devicetree/bindings/hwmon/ina3221.txt     |  44 ++++
 Documentation/hwmon/ina3221                   |   2 +
 drivers/hwmon/ina3221.c                       | 235 ++++++++++++++++--
 3 files changed, 267 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/hwmon/ina3221.txt
Signature · 1 line
2.17.1
#1 lore raw

PATCH v9 1/2 dt-bindings: hwmon: Add ina3221 documentation

Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it.

---
Changelog
v7->v9:
* N/A
v6->v7:
* Restored three channel examples and merged them with the parent one
v5->v6:
* Removed status property as no need to explicitly list it.
* Combined all examples into a complete one.
v4->v5:
* Replaced "input-id" with "reg" and added address-cells and size-cells
* Replaced "input-label" with "label"
* Replaced "shunt-resistor" with "shunt-resistor-micro-ohms"
v3->v4:
* Removed the attempt of putting labels in the node names
* Added a new optional label property in the child node
* Updated examples accordingly
v2->v3:
* Added a simple subject in the line 1
* Fixed the shunt resistor value in the example
v1->v2:
* Dropped channel name properties
* Added child node definitions.
* * Added shunt resistor property in the child node
* * Added status property to indicate connection status
* * Changed to use child node name as the label of input source

 .../devicetree/bindings/hwmon/ina3221.txt     | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/ina3221.txt
Documentation/devicetree/bindings/hwmon/ina3221.txt new file +44 -0
new file mode 100644
index 000000000000..a7b25caa2b8e
@@ -0,0 +1,44 @@
+Texas Instruments INA3221 Device Tree Bindings
+
+1) ina3221 node
+  Required properties:
+  - compatible: Must be "ti,ina3221"
+  - reg: I2C address
+
+  Optional properties:
+  = The node contains optional child nodes for three channels =
+  = Each child node describes the information of input source =
+
+  - #address-cells: Required only if a child node is present. Must be 1.
+  - #size-cells: Required only if a child node is present. Must be 0.
+
+2) child nodes
+  Required properties:
+  - reg: Must be 0, 1 or 2, corresponding to IN1, IN2 or IN3 port of INA3221
+
+  Optional properties:
+  - label: Name of the input source
+  - shunt-resistor-micro-ohms: Shunt resistor value in micro-Ohm
+
+Example:
+
+ina3221@40 {
+	compatible = "ti,ina3221";
+	reg = <0x40>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	input@0 {
+		reg = <0x0>;
+		status = "disabled";
+	};
+	input@1 {
+		reg = <0x1>;
+		shunt-resistor-micro-ohms = <5000>;
+	};
+	input@2 {
+		reg = <0x2>;
+		label = "VDD_5V";
+		shunt-resistor-micro-ohms = <5000>;
+	};
+};
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v9 1/2] dt-bindings: hwmon: Add ina3221 documentation

Hi Nicolin,

Quoted 5 lines · Nicolin Chen

Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it.

---

This version of the series looks good to me. I'll add both patches to hwmon-next, with the understanding that I may pull them if Rob has bindings related concerns.

Thanks,
Guenter

Quoted 83 lines

Changelog
v7->v9:
* N/A
v6->v7:
* Restored three channel examples and merged them with the parent one
v5->v6:
* Removed status property as no need to explicitly list it.
* Combined all examples into a complete one.
v4->v5:
* Replaced "input-id" with "reg" and added address-cells and size-cells
* Replaced "input-label" with "label"
* Replaced "shunt-resistor" with "shunt-resistor-micro-ohms"
v3->v4:
* Removed the attempt of putting labels in the node names
* Added a new optional label property in the child node
* Updated examples accordingly
v2->v3:
* Added a simple subject in the line 1
* Fixed the shunt resistor value in the example
v1->v2:
* Dropped channel name properties
* Added child node definitions.
* * Added shunt resistor property in the child node
* * Added status property to indicate connection status
* * Changed to use child node name as the label of input source

 .../devicetree/bindings/hwmon/ina3221.txt     | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/ina3221.txt
Documentation/devicetree/bindings/hwmon/ina3221.txt new file +44 -0
new file mode 100644
index 000000000000..a7b25caa2b8e
@@ -0,0 +1,44 @@
+Texas Instruments INA3221 Device Tree Bindings
+
+1) ina3221 node
+  Required properties:
+  - compatible: Must be "ti,ina3221"
+  - reg: I2C address
+
+  Optional properties:
+  = The node contains optional child nodes for three channels =
+  = Each child node describes the information of input source =
+
+  - #address-cells: Required only if a child node is present. Must be 1.
+  - #size-cells: Required only if a child node is present. Must be 0.
+
+2) child nodes
+  Required properties:
+  - reg: Must be 0, 1 or 2, corresponding to IN1, IN2 or IN3 port of INA3221
+
+  Optional properties:
+  - label: Name of the input source
+  - shunt-resistor-micro-ohms: Shunt resistor value in micro-Ohm
+
+Example:
+
+ina3221@40 {
+	compatible = "ti,ina3221";
+	reg = <0x40>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	input@0 {
+		reg = <0x0>;
+		status = "disabled";
+	};
+	input@1 {
+		reg = <0x1>;
+		shunt-resistor-micro-ohms = <5000>;
+	};
+	input@2 {
+		reg = <0x2>;
+		label = "VDD_5V";
+		shunt-resistor-micro-ohms = <5000>;
+	};
+};
Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH v9 1/2] dt-bindings: hwmon: Add ina3221 documentation

Quoted 6 lines · Guenter Roeck

Hi Nicolin,

Quoted 3 lines · Nicolin Chen

Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it.

Quoted 6 lines
Quoted 2 lines

---

This version of the series looks good to me. I'll add both patches to hwmon-next, with the understanding that I may pull them if Rob has bindings related concerns.

Thanks a lot, especially for the review.

Nicolin

maintainer Reviewed-by on v9 1/2
#4 lore raw

Re: [PATCH v9 1/2] dt-bindings: hwmon: Add ina3221 documentation

In reply to Nicolin Chen
Quoted 31 lines · Nicolin Chen

Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it.

---
Changelog
v7->v9:
* N/A
v6->v7:
* Restored three channel examples and merged them with the parent one
v5->v6:
* Removed status property as no need to explicitly list it.
* Combined all examples into a complete one.
v4->v5:
* Replaced "input-id" with "reg" and added address-cells and size-cells
* Replaced "input-label" with "label"
* Replaced "shunt-resistor" with "shunt-resistor-micro-ohms"
v3->v4:
* Removed the attempt of putting labels in the node names
* Added a new optional label property in the child node
* Updated examples accordingly
v2->v3:
* Added a simple subject in the line 1
* Fixed the shunt resistor value in the example
v1->v2:
* Dropped channel name properties
* Added child node definitions.
* * Added shunt resistor property in the child node
* * Added status property to indicate connection status
* * Changed to use child node name as the label of input source

Quoted 4 lines
 .../devicetree/bindings/hwmon/ina3221.txt     | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/ina3221.txt
#5 lore raw

PATCH v9 2/2 hwmon: (ina3221) Read channel input source info from DT

In reply to Nicolin Chen

An ina3221 chip has three input ports. Each port is used to measure the voltage and current of its input source.

The DT binding now has defined bindings for their input sources, so the driver should read these information and handle accordingly.

This patch adds a new structure of input source specific information including input source label, shunt resistor value and its connection status. It exposes these labels via in[123]_label sysfs nodes upon available, and also disables those channels where there are no input source being connected. Meanwhile, it also adds in[123]_enable sysfs nodes for users to get control of three channels, and returns -ENODATA code for any sensor read according to hwmon ABI.

---
Changelog
v8->v9:
* Renamed the subject by following hwmon naming convention
* Rebased the patch after the merged ina3221 changes
* Fixed the potential race condition in ina3221_set_enable()
v7->v8:
* Rebased the change after the new suspend-resume patch
* * Please apply suspend-resume patch prior to this one
* Renamed ina3221_is_enable() to ina3221_is_enabled()
* Removed "> 0" check in the is_enabled() function
* Replaced regmap_read() with ina->reg_config in is_enabled()
* Used kstrtobool() in the ina3221_set_enable() function
v6->v7:
* N/A
v5->v6:
* Removed the code of hiding disconnected channels
* Added in[123]_label sysfs nodes to control channels
* Added -ENODATA return for sensor read at disabled channels
v4->v5:
* Replaced "shunt-resistor" with "shunt-resistor-micro-ohms"
* Replaced "input-label" with "label"
* Replaced "input-id" with "reg"
* Simplified is_visible() by using index of the attr
* Moved inX_label to index-0 and added comments for safety
v3->v4:
* Added is_visible callback function to hide sysfs nodes
v2->v3:
* N/A
v1->v2:
* Added a structure for input source corresponding to DT bindings
* Moved shunt resistor value to the structure
* Defined in[123]_label sysfs nodes instead of name[123]_input
* Updated probe() function to get information from DT
* Updated ina3221 hwmon documentation for the labels
* Dropped dynamical group definition to keep all groups as they were

 Documentation/hwmon/ina3221 |   2 +
 drivers/hwmon/ina3221.c     | 235 +++++++++++++++++++++++++++++++++---
 2 files changed, 223 insertions(+), 14 deletions(-)
Documentation/hwmon/ina3221 +2 -0
index 0ff74854cb2e..4b82cbfb551c 100644
@@ -21,6 +21,8 @@ and power are calculated host-side from these.
 Sysfs entries
 -------------
 
+in[123]_label           Voltage channel labels
+in[123]_enable          Voltage channel enable controls
 in[123]_input           Bus voltage(mV) channels
 curr[123]_input         Current(mA) measurement channels
 shunt[123]_resistor     Shunt resistance(uOhm) channels
drivers/hwmon/ina3221.c +221 -14

362 lines not on this page · raw message

Signature · 1 line
2.17.1