Re: hwmon: trace event support?

2018-10-04 Thread Nicolin Chen
Hello, On Thu, Oct 04, 2018 at 09:48:02AM -0700, Guenter Roeck wrote: > > > I would not object to adding trace support into the hwmon subsystem. > > > However, it should be tied to the new API. I would resist patches > > > adding trace support to individual hwmon drivers unless the new API > > >

hwmon: trace event support?

2018-10-03 Thread Nicolin Chen
Hello Guenter, I am thinking about a possibility of adding a trace event support in hwmon subsystem. Ftrace is pretty useful and widely applied to different subsystems already while hwmon doesn't seem to have one yet. I know some power/perf folks who rely on the trace events to analyse

Re: hwmon: trace event support?

2018-10-03 Thread Nicolin Chen
Thanks for the quick response. On Wed, Oct 03, 2018 at 05:42:23PM -0700, Guenter Roeck wrote: > > Ftrace data. Similar to tz->poll_queue in thermal_core, hwmon core > > could also have a work queue polling the registered sensor inputs > > (by default disabled; enabled only if users configure

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2019-01-04 Thread Nicolin Chen
Hi Stefan, Sorry for a super late reply. I took a long vacation. On Wed, Nov 21, 2018 at 10:16:09PM +, Brüns, Stefan wrote: > > > Another concern may be voltage drop over the shunt, but for this case you > > > have a nominal voltage of 1.8V, so 30uV are 0.001%. > > > > > > > When measuring

[PATCH v2 0/2] hwmon (ina3221) Add single-shot mode support

2019-01-04 Thread Nicolin Chen
. Changelog v1->v2: * Cleaned-up PATCH-2 Nicolin Chen (2): dt-bindings: hwmon: ina3221: Add ti,single-shot property hwmon: (ina3221) Implement ti,single-shot DT property .../devicetree/bindings/hwmon/ina3221.txt | 10 ++ drivers/hwmon/ina3221.c |

[PATCH 1/2] dt-bindings: hwmon: ina3221: Add ti,single-shot property

2019-01-04 Thread Nicolin Chen
ingle-shot operating mode. Signed-off-by: Nicolin Chen --- Documentation/devicetree/bindings/hwmon/ina3221.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/ina3221.txt b/Documentation/devicetree/bindings/hwmon/ina3221.txt index a7b25caa2b8e..fa

[PATCH 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-04 Thread Nicolin Chen
consuming mode to single-shot mode, which will measure input on demand and then shut down to save power. So this patch implements the DT property accordingly. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 28 1 file changed, 28 insertions(+) diff --git

[PATCH 0/2] hwmon (ina3221) Add single-shot mode support

2019-01-04 Thread Nicolin Chen
By default, ina3221, as a hardware monitor, continuously measures the inputs and generates corresponding data. However, for battery powered devices, this mode might be power consuming. This series of patches add a feature of changing default operating mode to its single-shot mode via DT. Nicolin

[PATCH v2 1/2] dt-bindings: hwmon: ina3221: Add ti,single-shot property

2019-01-04 Thread Nicolin Chen
ingle-shot operating mode. Signed-off-by: Nicolin Chen --- Documentation/devicetree/bindings/hwmon/ina3221.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/ina3221.txt b/Documentation/devicetree/bindings/hwmon/ina3221.txt index a7b25caa2b8e..fa

[PATCH v2 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-04 Thread Nicolin Chen
consuming mode to single-shot mode, which will measure input on demand and then shut down to save power. So this patch implements the DT property accordingly. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Replaced the useless mode defines with a boolean variable. drivers/hwmon/ina322

Re: [PATCH 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-04 Thread Nicolin Chen
On Fri, Jan 04, 2019 at 06:37:55PM -0800, Guenter Roeck wrote: > > +enum ina3221_modes { > > + INA3221_MODE_SINGLE_SHOT, > > + INA3221_MODE_CONTINUOUS, > > + INA3221_NUM_MODES, > > Is NUM_MODES used anywhere ? Please drop unless there is a reason to keep it. Will clean it up in v2. Thanks

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2019-01-17 Thread Nicolin Chen
Hi Guenter, On Thu, Jan 17, 2019 at 03:13:23PM -0800, Guenter Roeck wrote: > I have one claim stating that your change won't make a difference, > and your claim that it would. That leaves me with no choice but to > spend a large amount of time with the datasheet, and possibly with > my

Re: [PATCH v2 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-17 Thread Nicolin Chen
On Mon, Jan 07, 2019 at 11:35:55AM -0800, Guenter Roeck wrote: > > + if (of_property_read_bool(np, "ti,single-shot")) > > + ina->single_shot = true; > > + > ina->single_shot = of_property_read_bool(np, "ti,single-shot"); > > No need to resend right now; let's wait for feedback

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2019-01-17 Thread Nicolin Chen
On Fri, Jan 04, 2019 at 05:26:42PM -0800, Nicolin Chen wrote: > Hi Stefan, > > Sorry for a super late reply. I took a long vacation. > > On Wed, Nov 21, 2018 at 10:16:09PM +, Brüns, Stefan wrote: > > > > Another concern may be voltage drop over the shunt, but

Re: [PATCH v2 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-17 Thread Nicolin Chen
On Thu, Jan 17, 2019 at 02:58:42PM -0800, Guenter Roeck wrote: > "Right now" was supposed to mean that you should wait for Rob's > feedback before sending v3 with the feedback above applied. > Did you send that version ? I don't see it in patchwork, nor > in my inbox. Oh, sorry. Will resend it.

[PATCH v3 0/2] hwmon (ina3221) Add single-shot mode support

2019-01-17 Thread Nicolin Chen
. Changelog v2->v3: * Added "Reviewed-by" from Rob to PATCH-1 * Cleaned-up PATCH-2 v1->v2: * Cleaned-up PATCH-2 Nicolin Chen (2): dt-bindings: hwmon: ina3221: Add ti,single-shot property hwmon: (ina3221) Implement ti,single-shot DT property .../devicetree/bindings/hwmon/ina3

[PATCH v3 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-17 Thread Nicolin Chen
consuming mode to single-shot mode, which will measure input on demand and then shut down to save power. So this patch implements the DT property accordingly. Signed-off-by: Nicolin Chen --- Changelog v2->v3: * Dropped useless if condition by using the return value directly. v1->v2: * Re

[PATCH v3 1/2] dt-bindings: hwmon: ina3221: Add ti,single-shot property

2019-01-17 Thread Nicolin Chen
ingle-shot operating mode. Signed-off-by: Nicolin Chen Reviewed-by: Rob Herring --- Changelog v2->v3: * Added "Reviewed-by" from Rob v1->v2: * N/A Documentation/devicetree/bindings/hwmon/ina3221.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicet

[PATCH 0/2] Add an initial DT binding doc for ina3221

2018-09-20 Thread Nicolin Chen
This series adds a initial DT binding doc for ina3221. It adds channel names (which should be according to board schematics) and implements the corresponding actions (disabling channels) in the driver. Nicolin Chen (2): dt-bindings: hwmon: Add ina3221 documentation hwmon: ina3221: Get channel

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

2018-09-20 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- .../devicetree/bindings/hwmon/ina3221.txt | 23 +++ 1 file changed, 23 insertions(+) create mode 100644 Documentation

[PATCH 2/2] hwmon: ina3221: Get channel names from DT node

2018-09-20 Thread Nicolin Chen
based on the hardware design. So the channel name should support NC so the driver could disable the channel accordingly. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 88 + 1 file changed, 80 insertions(+), 8 deletions(-) diff --git a/drivers

Re: [PATCH 2/2] hwmon: ina3221: Get channel names from DT node

2018-09-21 Thread Nicolin Chen
Hi, On Thu, Sep 20, 2018 at 06:20:38PM -0700, Nicolin Chen wrote: > > So if there are no devicetree entries, the user now gets a sequence of > > "unknown" sensors ? I don't think so. Please keep in mind that there are > > users of this chip who don't have devicet

Re: [PATCH 2/2] hwmon: ina3221: Get channel names from DT node

2018-09-21 Thread Nicolin Chen
On Fri, Sep 21, 2018 at 05:56:00AM -0700, Guenter Roeck wrote: > > I tried is_visible but it looks like it won't be that neat to > > implement as some attributes of this driver don't really pass > > the channel index to the store()/show() but some other indexes. > > > > The channel index is not

[PATCH v2 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-21 Thread Nicolin Chen
From: 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

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

2018-09-21 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Dropped channel name properties * Added child node definitions. * * Added shunt resistor property in the child n

[PATCH v2 0/2] Add an initial DT binding doc for ina3221

2018-09-21 Thread Nicolin Chen
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 v1->v2: * Redefined DT bindings (detail in PATCH-1) * Changed the driver code accordingly

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

2018-09-21 Thread Nicolin Chen
Found two mistakes at this doc, sending v3. On Fri, Sep 21, 2018 at 1:12 PM Nicolin Chen wrote: > +++ b/Documentation/devicetree/bindings/hwmon/ina3221.txt > @@ -0,0 +1,38 @@ > +ina3221 properties > + Should be a description of the doc. > + VDD_GPU { > + s

[PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-21 Thread Nicolin Chen
From: 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

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

2018-09-21 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v2->v3: * Added a simple subject in the line 1 * Fixed the shunt resistor value in the example v1->v2: * Dropped channe

[PATCH v3 0/2] Add an initial DT binding doc for ina3221

2018-09-21 Thread Nicolin Chen
ndings (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 | 38 ++ Documentation/hwmon/i

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

2018-09-22 Thread Nicolin Chen
> >+2) child nodes > >+ The names of child nodes should indicate input source names > >+ > >+ Required properties: > >+ - input-id: Must be 1, 2 or 3 > >+ > >+ Optional properties: > >+ - shunt-resistor: Shunt resistor value in micro-Ohm > >+ - status: Should be "disabled" if no input source

Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
> >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 sysfs and also disables those channels where there's > >no input source being connected. > > > > I see you

Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 04:59:55PM -0700, Guenter Roeck wrote: > > > > + /* Disable channels if their inputs are disconnected */ > > > > + for (i = 0, mask = 0; i < INA3221_NUM_CHANNELS; i++) { > > > > + if (ina->inputs[i].disconnected) > > > > +

Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 08:33:00PM -0700, Nicolin Chen wrote: > On Sat, Sep 22, 2018 at 07:07:02PM -0700, Guenter Roeck wrote: > > On 09/22/2018 05:38 PM, Nicolin Chen wrote: > > >On Sat, Sep 22, 2018 at 04:59:55PM -0700, Guenter Roeck wrote: > > > > >

[PATCH v4 0/2] Add an initial DT binding doc for ina3221

2018-09-22 Thread Nicolin Chen
ver 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: Rea

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

2018-09-22 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v3->v4: * Removed the attempt of putting labels in the node names * Added a new optional label property in the child node * Upda

[PATCH v4 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
specific information including input source label, shunt resistor value and its connection status. It exposes these labels via sysfs if available and also disables those channels where there's no input source being connected. Signed-off-by: Nicolin Chen --- Changelog v3->v4: * Added is_visi

Re: [PATCH v4 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-22 Thread Nicolin Chen
Thank you for the quick response! On Sat, Sep 22, 2018 at 10:11:26PM -0700, Guenter Roeck wrote: > >+static umode_t ina3221_attr_is_visible(struct kobject *kobj, > >+ struct attribute *attr, int n) > >+{ > >+const int max_attrs = ARRAY_SIZE(ina3221_attrs) -

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

2018-09-22 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 10:19:42PM -0700, Guenter Roeck wrote: > >+2) child nodes > >+ Required properties: > >+ - input-id: Must be 1, 2 or 3 > >+ > >+ Optional properties: > >+ - input-label: Name of the input source > >+ - shunt-resistor: Shunt resistor value in micro-Ohm > >+ - status:

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

2018-09-23 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 10:45:49PM -0700, Guenter Roeck wrote: > On 09/22/2018 10:31 PM, Nicolin Chen wrote: > > On Sat, Sep 22, 2018 at 10:19:42PM -0700, Guenter Roeck wrote: > > > > +2) child nodes > > > > + Required properties: > &g

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

2018-09-23 Thread Nicolin Chen
On Sat, Sep 22, 2018 at 11:36:22PM -0700, Guenter Roeck wrote: > >+ Optional properties: > >+ - input-label: Name of the input source > > Just noticed the "input-" here. Please just use "label". Will fix in v5. > >+ input1 { > >+ input-id = <0x1>; > > We'll

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

2018-09-25 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v4->v5: * Replaced "input-id" with "reg" and added address-cells and size-cells * Replaced "input-lab

[PATCH v5 0/2] Add an initial DT binding doc for ina3221

2018-09-25 Thread Nicolin Chen
d 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 | 49 ++ Documentation/hwmon/ina3221 | 1 + drivers/hwm

[PATCH v5 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-25 Thread Nicolin Chen
specific information including input source label, shunt resistor value and its connection status. It exposes these labels via sysfs if available and also disables those channels where there's no input source being connected. Signed-off-by: Nicolin Chen --- Changelog v4->v5: * Replaced &qu

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

2018-09-25 Thread Nicolin Chen
Hello Guenter, On Tue, Sep 25, 2018 at 06:52:29PM -0700, Guenter Roeck wrote: > > +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 > > + -

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

2018-09-26 Thread Nicolin Chen
On Tue, Sep 25, 2018 at 08:40:59PM -0700, Guenter Roeck wrote: > >>>+2) child nodes > >>>+ Required properties: > >>>+ - reg: Must be 0, 1 or 2, corresponding to IN1, IN2 or IN3 port of > >>>INA3221 > >>>+ input@0 { > >>>+ reg = <0x0>; > >>>+ status = "disabled"; > >>saying

[PATCH 1/2] hwmon: ina3221: Add power sysfs nodes

2018-09-26 Thread Nicolin Chen
The hwmon sysfs ABI supports powerX_input and powerX_crit. This can ease user space programs who care more about power in total than voltage or current individually. So this patch adds these two sysfs nodes for INA3221 driver. Signed-off-by: Nicolin Chen --- Documentation/hwmon/ina3221 | 4

[PATCH 0/2] hwmon: ina3221: Add power and enable sysfs nodes

2018-09-26 Thread Nicolin Chen
om DT" As this patch is still under review (waiting for an ack from DT binding side), these two patches can only go through review at this point -- needs to wait for the patch above getting merged first. Nicolin Chen (2): hwmon: ina3221: Add power sysfs nodes hwmon: ina3221: Add en

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-26 Thread Nicolin Chen
On Wed, Sep 26, 2018 at 06:06:32AM -0700, Guenter Roeck wrote: > On 09/25/2018 11:42 PM, Nicolin Chen wrote: > > The inX_enable interface allows user space to enable or disable > > the corresponding channel. Meanwhile, according to hwmon ABI, a > > disabled channel/sensor s

Re: [PATCH 1/2] hwmon: ina3221: Add power sysfs nodes

2018-09-26 Thread Nicolin Chen
On Wed, Sep 26, 2018 at 05:34:53AM -0700, Guenter Roeck wrote: > Hi Nicolin, > > On 09/25/2018 11:42 PM, Nicolin Chen wrote: > > The hwmon sysfs ABI supports powerX_input and powerX_crit. This > > can ease user space programs who care more about power in total > &

Re: [PATCH 1/2] hwmon: ina3221: Add power sysfs nodes

2018-09-26 Thread Nicolin Chen
Hello Guenter, On Wed, Sep 26, 2018 at 12:45:34PM -0700, Guenter Roeck wrote: > Hi Nicolin, > > On Wed, Sep 26, 2018 at 11:20:06AM -0700, Nicolin Chen wrote: > > On Wed, Sep 26, 2018 at 05:34:53AM -0700, Guenter Roeck wrote: > > > Hi Nicolin, > > > > >

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-26 Thread Nicolin Chen
Hello, On Wed, Sep 26, 2018 at 12:58:17PM -0700, Guenter Roeck wrote: > On Wed, Sep 26, 2018 at 11:02:44AM -0700, Nicolin Chen wrote: > > On Wed, Sep 26, 2018 at 06:06:32AM -0700, Guenter Roeck wrote: > > > On 09/25/2018 11:42 PM, Nicolin Chen wrote: > > > > The in

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-26 Thread Nicolin Chen
On Wed, Sep 26, 2018 at 01:44:55PM -0700, Guenter Roeck wrote: > On Wed, Sep 26, 2018 at 01:25:20PM -0700, Nicolin Chen wrote: > > Hello, > > > > On Wed, Sep 26, 2018 at 12:58:17PM -0700, Guenter Roeck wrote: > > > On Wed, Sep 26, 2018 at 11:02:44AM -0700, Nicolin C

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-27 Thread Nicolin Chen
Hello Guenter, On Thu, Sep 27, 2018 at 09:05:09AM -0700, Guenter Roeck wrote: > > > Point is that I don't _know_ how this is going to be used, so I'd > > > rather keep it flexible. > > > > Well, taking one step back, I am okay to follow your way if you > > are really firm about it. Just please

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

2018-09-27 Thread Nicolin Chen
On Thu, Sep 27, 2018 at 12:44:13PM -0500, Rob Herring wrote: > > +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 > > + -

[PATCH v6 0/2] Add an initial DT binding doc for ina3221

2018-09-27 Thread Nicolin Chen
* 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

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

2018-09-27 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v5->v6: * Removed status property as no need to explicitly list it. * Combined all examples into a complete one. v4->v5: * Re

[PATCH v6 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-27 Thread Nicolin Chen
for users to get control of three channels, and returns -ENODATA code for any sensor read according to hwmon ABI. Signed-off-by: Nicolin Chen --- Changelog v5->v6: * Removed the code of hiding disconnected channels * Added in[123]_label sysfs nodes to control channels * Added -ENODATA ret

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

2018-09-27 Thread Nicolin Chen
On Thu, Sep 27, 2018 at 03:38:44PM -0500, Rob Herring wrote: > On Thu, Sep 27, 2018 at 2:49 PM Nicolin Chen wrote: > > > > Texas Instruments INA3221 is a triple-channel shunt and bus > > voltage monitor. This patch adds a DT binding doc for it. > > >

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

2018-09-27 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v6->v7: * Restored three channel examples and merged them with the parent one v5->v6: * Removed status property as n

Re: [PATCH v7 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-27 Thread Nicolin Chen
On Thu, Sep 27, 2018 at 03:06:20PM -0700, Guenter Roeck wrote: > I am quite sure I asked to use kstrtobool(). Did that get lost or do you have > some reason to not use it ? > > I can understand if you don't want to change ina3221_is_enable() to > ina3221_is_enabled(), since that is POV, but I

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-27 Thread Nicolin Chen
On Wed, Sep 26, 2018 at 06:06:32AM -0700, Guenter Roeck wrote: > > +static inline bool ina3221_is_enable(struct ina3221_data *ina, int channel) > > s/is_enable/is_enabled/, maybe ? Fixing. > > + return (config & INA3221_CONFIG_CHx_EN(channel)) > 0; > > The "> 0" is unnecessary. Conversion to

Re: [PATCH 2/2] hwmon: ina3221: Add enable sysfs nodes

2018-09-27 Thread Nicolin Chen
On Thu, Sep 27, 2018 at 03:52:00PM -0700, Guenter Roeck wrote: > The proper fix for this problem would be to add support for suspend / > resume to the driver. At resume time, all channels will have been > re-enabled if the chip was powered off, even if they were explicitly > disabled by

[PATCH 0/2] hwmon: ina3221: Add suspend and resume functions

2018-09-28 Thread Nicolin Chen
This series of patches add system suspend and resume functiosn for ina3221 hwmon driver. Nicolin Chen (2): hwmon: ina3221: Add INA3221_CONFIG to volatile_table hwmon: ina3221: Add suspend and resume functions drivers/hwmon/ina3221.c | 56 - 1 file

[PATCH 1/2] hwmon: ina3221: Add INA3221_CONFIG to volatile_table

2018-09-28 Thread Nicolin Chen
not be a severe bug for the current code line since there's no second place touching the INA3221_CONFIG except the reset routine in the probe(). Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ina3221.c b

[PATCH 2/2] hwmon: ina3221: Add suspend and resume functions

2018-09-28 Thread Nicolin Chen
Depending on the hardware design, an INA3221 chip might lose its power during system suspend/resume. So this patch adds a pair of suspend and resume functions to cache the register values including config register value and limit settings. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c

[PATCH v8 2/2] hwmon: ina3221: Read channel input source info from DT

2018-09-28 Thread Nicolin Chen
for users to get control of three channels, and returns -ENODATA code for any sensor read according to hwmon ABI. Signed-off-by: Nicolin Chen --- Changelog v7->v8: * Rebased the change after the new suspend-resume patch * * Please apply suspend-resume patch prior to this one * Rena

[PATCH v8 0/2] Add an initial DT binding doc for ina3221

2018-09-28 Thread Nicolin Chen
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 Ch

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

2018-09-28 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v7->v8: * N/A v6->v7: * Restored three channel examples and merged them with the parent one v5->v6: * Removed status

Re: [PATCH 2/2] hwmon: ina3221: Add suspend and resume functions

2018-09-29 Thread Nicolin Chen
On Sat, Sep 29, 2018 at 08:33:46AM -0700, Guenter Roeck wrote: > On Fri, Sep 28, 2018 at 02:49:21PM -0700, Nicolin Chen wrote: > > Depending on the hardware design, an INA3221 chip might lose > > its power during system suspend/resume. So this patch adds > > a pair of suspend

[PATCH v2 3/3] hwmon: ina3221: Add suspend and resume functions

2018-09-29 Thread Nicolin Chen
Depending on the hardware design, an INA3221 chip might lose its power during system suspend/resume. So this patch adds a set of suspend and resume functions to cache the register values including config register value and limit settings. Signed-off-by: Nicolin Chen --- Changelog v1->

[PATCH v2 0/3] Add suspend and resume functions

2018-09-29 Thread Nicolin Chen
This series of patches add system suspend and resume functiosn for ina3221 hwmon driver. To do so, it also needs two small fixes. Changelog v1->v2: * Added PATCH-2 to fix macros * Added power-down setting during suspend in PATCH-3 Nicolin Chen (3): hwmon: ina3221: Add INA3221_CON

[PATCH v2 1/3] hwmon: ina3221: Add INA3221_CONFIG to volatile_table

2018-09-29 Thread Nicolin Chen
not be a severe bug for the current code line since there's no second place touching the INA3221_CONFIG except the reset routine in the probe(). Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ina3221.c b

[PATCH v2 2/3] hwmon: ina3221: Fix INA3221_CONFIG_MODE macros

2018-09-29 Thread Nicolin Chen
at this point. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index cfe65ff01051..e0c4f4d83f4e 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -38,9

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

2018-10-01 Thread Nicolin Chen
Texas Instruments INA3221 is a triple-channel shunt and bus voltage monitor. This patch adds a DT binding doc for it. Signed-off-by: Nicolin Chen --- Changelog v7->v9: * N/A v6->v7: * Restored three channel examples and merged them with the parent one v5->v6: * Removed status

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

2018-10-01 Thread Nicolin Chen
for users to get control of three channels, and returns -ENODATA code for any sensor read according to hwmon ABI. Signed-off-by: Nicolin Chen --- Changelog v8->v9: * Renamed the subject by following hwmon naming convention * Rebased the patch after the merged ina3221 changes * Fi

[PATCH v9 0/2] Add an initial DT binding doc for ina3221

2018-10-01 Thread Nicolin Chen
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 +

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

2018-10-02 Thread Nicolin Chen
On Tue, Oct 02, 2018 at 10:05:18AM -0700, Guenter Roeck wrote: > Hi Nicolin, > > On Mon, Oct 01, 2018 at 06:05:22PM -0700, Nicolin Chen wrote: > > Texas Instruments INA3221 is a triple-channel shunt and bus > > voltage monitor. This patch adds a DT binding doc for it

[PATCH 0/2] hwmon: (ina3221) Apply _info API

2018-10-05 Thread Nicolin Chen
This series of patches applies _info API of hwmon core to the ina3221 hwmon driver. Nicolin Chen (2): hwmon: (core) Add hwmon_in_enable attribute hwmon: (ina3221) Use _info API to register hwmon device drivers/hwmon/hwmon.c | 1 + drivers/hwmon/ina3221.c | 528

[PATCH 2/2] hwmon: (ina3221) Use _info API to register hwmon device

2018-10-05 Thread Nicolin Chen
The hwmon core has a newer API which abstracts most of common things in the core so as to simplify the hwmon device drivers. This patch implements this _info API to ina3221 hwmon driver. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 528 +++- 1

[PATCH 1/2] hwmon: (core) Add hwmon_in_enable attribute

2018-10-05 Thread Nicolin Chen
According to hwmon ABI, in%d_enable is a sysfs interface that allows user space to enable and disable the input sensor. So this patch just simply adds the attribute to the list. Signed-off-by: Nicolin Chen --- drivers/hwmon/hwmon.c | 1 + include/linux/hwmon.h | 2 ++ 2 files changed, 3

[PATCH] hwmon: (ina3221) Clamp shunt resistor value from DT

2018-10-08 Thread Nicolin Chen
The input->shunt_resistor is int type while the value from DT is unsigned int. Meanwhile, a divide-by-zero error would happen if the value is 0. So this patch just simply clamps the value. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 4 +++- 1 file changed, 3 insertions(+)

[PATCH v2] hwmon: (ina3221) Use _info API to register hwmon device

2018-10-08 Thread Nicolin Chen
68261aaa drivers/hwmon/ina3221_before.o 4456 440 048961320 drivers/hwmon/ina3221.o Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Added a binary size comparison in commit message * Dropped unnecessary checks * Dropped misleading ID conversion in the comme

[PATCH v2] hwmon: (ina3221) Validate shunt resistor value from DT

2018-10-08 Thread Nicolin Chen
The input->shunt_resistor is int type while the value from DT is unsigned int. Meanwhile, a divide-by-zero error would happen if the value is 0. So this patch just simply validates the value. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Validate the value and error out drivers

[PATCH] hwmon: (core) Add trace events to _attr_show/store functions

2018-10-09 Thread Nicolin Chen
_with_info API to register a hwmon device. Signed-off-by: Nicolin Chen --- MAINTAINERS | 1 + drivers/hwmon/hwmon.c| 27 ++ include/trace/events/hwmon.h | 71 3 files changed, 92 insertions(+), 7 deletions(-) create mode

Re: [PATCH] hwmon: (core) Add trace events to _attr_show/store functions

2018-10-09 Thread Nicolin Chen
On Tue, Oct 09, 2018 at 02:57:21PM -0400, Steven Rostedt wrote: > > Trace events are useful for people who collect data from the > > ftrace output. This patch adds initial trace events for the > > hwmon core. To call hwmon_attr_base() for aligned attr index > > numbers, this patch also moves the

Re: [PATCH] hwmon: (core) Add trace events to _attr_show/store functions

2018-10-09 Thread Nicolin Chen
On Tue, Oct 09, 2018 at 03:49:45PM -0400, Steven Rostedt wrote: > > > > Trace events are useful for people who collect data from the > > > > ftrace output. This patch adds initial trace events for the > > > > hwmon core. To call hwmon_attr_base() for aligned attr index > > > > numbers, this patch

[PATCH v2] hwmon: (core) Add trace events to _attr_show/store functions

2018-10-09 Thread Nicolin Chen
-by: Nicolin Chen --- Changelog v1->v2: * Added a descriptive reason for this change in the commit message MAINTAINERS | 1 + drivers/hwmon/hwmon.c| 27 ++ include/trace/events/hwmon.h | 71 3 files changed, 92 inserti

[PATCH 0/2] hwmon: Add operating mode support for core and ina3221

2018-10-09 Thread Nicolin Chen
Add operating mode support in the core and ina3221. Nicolin Chen (2): hwmon: (core) Add hwmon_mode structure and mode sysfs node hwmon: (ina3221) Add operating mode support Documentation/hwmon/sysfs-interface | 15 + drivers/hwmon/hwmon.c | 87

[PATCH 1/2] hwmon: (core) Add hwmon_mode structure and mode sysfs node

2018-10-09 Thread Nicolin Chen
;mode" and "available_modes" for user to check and configure the operating mode. For hwmon device drivers that implemented the _with_info API, the change also adds an optional hwmon_mode structure in hwmon_chip_info structure so that those drivers can pass mode related information. Si

[PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-09 Thread Nicolin Chen
The hwmon core now has a new optional mode interface. So this patch just implements this mode support so that user space can check and configure via sysfs node its operating modes: power-down, one-shot, and continuous modes. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 64

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-10 Thread Nicolin Chen
> I am open to help explore adding support for runtime power management > to the hwmon subsystem, but that would be less than straightforward and > require an actual use case to warrant the effort. Is there any feasible solution from your point of view? Thanks Nicolin > > As s

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-10 Thread Nicolin Chen
Hi Guenter, On Wed, Oct 10, 2018 at 04:43:00PM -0700, Guenter Roeck wrote: > > > The effort to do all this using CPU cycles would in most if not all cases > > > outweigh any perceived power savings. As such, I just don't see the > > > practical use case. > > > > It really depends on the use case

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-11 Thread Nicolin Chen
On Thu, Oct 11, 2018 at 12:31:52PM -0700, Guenter Roeck wrote: > > One more question here, and this might sound a bit abuse of using > > the existing hwmon ABI: would it sound plausible to you that the > > driver powers down the chip when all three channels get disabled > > via in[123]_enable

[PATCH 4/5] hwmon: (ina3221) Make sure data is ready after channel enabling

2018-10-16 Thread Nicolin Chen
The data might need some time to get ready after channel enabling, although the data register is readable without CVRF being set. So this patch adds a CVRF polling to make sure that data register is updated with the new data. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 32

[PATCH 3/5] hwmon: (ina3221) Serialize sysfs ABI accesses

2018-10-16 Thread Nicolin Chen
by reading other fields like alert flags. So this patch adds a mutex lock to protect the write() and read() callbacks. The read_string() callback won't need the lock since it just returns the label without touching any hardware register. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 51

[PATCH 5/5] hwmon: (ina3221) Add PM runtime support

2018-10-16 Thread Nicolin Chen
necessary to do so to match initial refcount with the number of enabled channels. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 104 +++- 1 file changed, 82 insertions(+), 22 deletions(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c

[PATCH 0/5] hwmon: (ina3221) Implement PM runtime to save power

2018-10-16 Thread Nicolin Chen
This series patches implement PM runtime feature in the ina3221 hwmon driver (PATCH-5). However, PATCH-[1:4] are required to make sure that the PM runtime feature would be functional and safe. Nicolin Chen (5): hwmon: (core) Inherit power properties to hdev hwmon: (ina3221) Return -ENODATA

[PATCH 1/5] hwmon: (core) Inherit power properties to hdev

2018-10-16 Thread Nicolin Chen
pointers. Note that the dev->driver pointer is the place that contains a dev_pm_ops pointer defined in the parent device driver and the pm runtime core also checks this pointer: if (!cb && dev->driver && dev->driver->pm) Signed-off-by: Nicolin Chen --- driv

[PATCH 2/5] hwmon: (ina3221) Return -ENODATA for two alarms attributes

2018-10-16 Thread Nicolin Chen
-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index d61688f04594..3e98b59108ee 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -200,6 +200,8 @@ static int

  1   2   >