Re: [PATCH 00/17] hwmon: (ina238) Various improvements and added chip support
From: Guenter Roeck <linux@roeck-us.net>
Date: 2025-09-07 23:32:14
Also in:
linux-hwmon
Hi Chris, On 9/7/25 16:00, Chris Packham wrote:
Hi Guenter, On 06/09/2025 08:41, Guenter Roeck wrote:quoted
Add support for INA700 and INA780 to the ina238 driver. To prepare for this, implement various improvements. - Update documention and Kconfig entry to list all supported chips. - Drop platform data support. The driver supports device properties, and there are no in-tree platform data users. - Stop checking the attribute value when writing the power_max attribute as unnecessary. - Simplify temperature calculations. Instead of shift and lsb, only require the resulution and use it to calculate temperatures. - Pre-calculate voltage, current, power and energy LSB. The values don't change during runtime and can therefore be pre-calculated. Also use the equations provided in the dataasheets to calculate power and energy LSB from the current LSB instead of calculating it from scratch. - Use ROUND_CLOSEST operations instead of divide operations to reduce rounding errors. - Improve current dynamic range by matching shunt voltage and current register values. With that, the dynamic range is always the full 16 bit provided by the ADC. - Stop using the shunt voltage register. With shunt and current register values now always matching, it is unnecessary to read both. - Provide current limits from shunt voltage limit registers. After all, there is no difference for the ADC, so the shunt voltage limits translate into current limits. - Order chip information alphabetically. No functional change, it just simplifies adding support for new chips. - Add 64-bit energy attribute support to the hwmon core. - Use the hwmon core to report 64-bit energy values. - Add support for active-high alert polarity - Limit shunt and calibration register writes to chips requiring/supporting it. - Add support for INA700 and INA780. Both chips have internal shunt resistors and do not explicitly report the shunt voltage. This patch series was inspired by Chris Packham's initial patch set of a new INA780 driver, by his subsequent patch set adding support for that chip to the ina238 driver, and by Christian Kahr's submission of a new INA700 driver. The series was tested with INA228, INA237, INA238, and INA780 evaluation boards as well as with unit test code. ---------------------------------------------------------------- Guenter Roeck (17): hwmon: (ina238) Drop platform data support hwmon: (ina238) Update documentation and Kconfig entry hwmon: (ina238) Drop pointless power attribute check on attribute writes hwmon: (ina238) Rework and simplify temperature calculations hwmon: (ina238) Pre-calculate current, power, and energy LSB hwmon: (ina238) Simplify voltage register accesses hwmon: (ina238) Improve current dynamic range hwmon: (ina238) Stop using the shunt voltage register hwmon: (ina238) Add support for current limits hwmon: (ina238) Order chip information alphabetically hwmon: Introduce 64-bit energy attribute support hwmon: (ina238) Use the energy64 attribute type to report the energy hwmon: (ina238) Support active-high alert polarity hwmon: (ina238) Only configure calibration and shunt registers if needed hwmon: (ina238) Add support for INA780 dt-bindings: hwmon: ti,ina2xx: Add INA700 hwmon: (ina238) Add support for INA700 .../devicetree/bindings/hwmon/ti,ina2xx.yaml | 4 + Documentation/hwmon/hwmon-kernel-api.rst | 3 + Documentation/hwmon/ina238.rst | 64 ++- drivers/hwmon/Kconfig | 9 +- drivers/hwmon/hwmon.c | 16 +- drivers/hwmon/ina238.c | 583 +++++++++++---------- include/linux/hwmon.h | 1 + include/trace/events/hwmon.h | 10 +- 8 files changed, 382 insertions(+), 308 deletions(-)For the series Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # INA780
Thanks a lot, appreciate it! Guenter