2021-01-07 10:34:03

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH v3 0/4] hwmon: (ltc2945): add support for sense resistor

Changeset adds support for sense resistor.

Changelog v2 -> v3:
* https://lore.kernel.org/linux-hwmon/[email protected]/
* dropped patch 'docs: hwmon: (ltc2945): change type of val to ULL in ltc2945_val_to_reg()'
* add patch 'hwmon: (ltc2945): clamp values before converting'
* for patch 'hwmon: (ltc2945): add support for sense resistor'
- sense-resistor is represented in milli-ohms internally; this
risks of any other potential overflows with the multiplication to
1000; the scaling in the driver becomes simpler, but we can't allow
a lower resistor value that 1 mOhm, and all resistor values
need to be integer in mOhm.
- added max power and max amps limits, adjusted to sense resistor
* for patch 'dt-bindings: hwmon: ltc2945: add device tree doc for ltc2945 '
added 'Reviewed-by: Rob Herring <[email protected]>'

Alexandru Ardelean (4):
hwmon: (ltc2945): wrap regmap into an ltc2945_state struct
hwmon: (ltc2945): clamp values before converting
hwmon: (ltc2945): add support for sense resistor
dt-bindings: hwmon: ltc2945: add device tree doc for ltc2945

.../bindings/hwmon/adi,ltc2945.yaml | 49 +++++++
drivers/hwmon/ltc2945.c | 128 +++++++++++++++---
2 files changed, 156 insertions(+), 21 deletions(-)
create mode 100644 Documentation/devicetree/bindings/hwmon/adi,ltc2945.yaml

--
2.17.1


2021-01-07 10:34:15

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH v3 4/4] dt-bindings: hwmon: ltc2945: add device tree doc for ltc2945

This change adds a device-tree binding documentation for the Linear
Technology (now Analog Devices) LTC2945 Wide Range I2C Power Monitor.

Reviewed-by: Rob Herring <[email protected]>
Signed-off-by: Alexandru Ardelean <[email protected]>
---
.../bindings/hwmon/adi,ltc2945.yaml | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 Documentation/devicetree/bindings/hwmon/adi,ltc2945.yaml

diff --git a/Documentation/devicetree/bindings/hwmon/adi,ltc2945.yaml b/Documentation/devicetree/bindings/hwmon/adi,ltc2945.yaml
new file mode 100644
index 000000000000..e49d7da09f74
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/adi,ltc2945.yaml
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/adi,ltc2945.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Linear Technology LTC2945 Wide Range I2C Power Monitor
+
+maintainers:
+ - Guenter Roeck <[email protected]>
+
+description: |
+ The LTC2945 is a rail-to-rail system monitor that measures current, voltage,
+ and power consumption.
+
+properties:
+ compatible:
+ enum:
+ - adi,ltc2945
+
+ reg:
+ maxItems: 1
+
+ shunt-resistor-micro-ohms:
+ description:
+ The value of curent sense resistor in microohms. If not provided,
+ a default value of 1000 microohms is used.
+ default: 1000
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ltc2945_i2c: ltc2945@6f {
+ compatible = "adi,ltc2945";
+ reg = <0x6f>;
+
+ shunt-resistor-micro-ohms = <20000>;
+ };
+ };
+...
--
2.17.1

2021-01-07 15:32:45

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v3 0/4] hwmon: (ltc2945): add support for sense resistor

On Thu, Jan 07, 2021 at 12:34:13PM +0200, Alexandru Ardelean wrote:
> Changeset adds support for sense resistor.
>
> Changelog v2 -> v3:
> * https://lore.kernel.org/linux-hwmon/[email protected]/
> * dropped patch 'docs: hwmon: (ltc2945): change type of val to ULL in ltc2945_val_to_reg()'
> * add patch 'hwmon: (ltc2945): clamp values before converting'
> * for patch 'hwmon: (ltc2945): add support for sense resistor'
> - sense-resistor is represented in milli-ohms internally; this
> risks of any other potential overflows with the multiplication to
> 1000; the scaling in the driver becomes simpler, but we can't allow
> a lower resistor value that 1 mOhm, and all resistor values
> need to be integer in mOhm.
> - added max power and max amps limits, adjusted to sense resistor
> * for patch 'dt-bindings: hwmon: ltc2945: add device tree doc for ltc2945 '
> added 'Reviewed-by: Rob Herring <[email protected]>'
>
> Alexandru Ardelean (4):
> hwmon: (ltc2945): wrap regmap into an ltc2945_state struct
> hwmon: (ltc2945): clamp values before converting
> hwmon: (ltc2945): add support for sense resistor
> dt-bindings: hwmon: ltc2945: add device tree doc for ltc2945
>

As mentioned in patch 3/3, this series solves a generic problem
affecting all hwmon drivers, but it only solves it for one of those
drivers. We should work on a generic solution (in-kernel scaling)
instead, one that works for all hwmon drivers, not just one.

Thanks,
Guenter

> .../bindings/hwmon/adi,ltc2945.yaml | 49 +++++++
> drivers/hwmon/ltc2945.c | 128 +++++++++++++++---
> 2 files changed, 156 insertions(+), 21 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/hwmon/adi,ltc2945.yaml
>
> --
> 2.17.1
>