]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
hwmon: (ina2xx) Shift INA234 shunt and current registers
authorJonas Rebmann <jre@pengutronix.de>
Tue, 3 Mar 2026 11:07:02 +0000 (12:07 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 31 Mar 2026 02:45:05 +0000 (19:45 -0700)
commiteeca1114d1e2cc0eacaebb80f3f2afbaebfc60be
treed300faafb7d4a2972e8785fec1cd7cb02cce368a
parent932ca40b10e94923dc6447f8e9026838793fd188
hwmon: (ina2xx) Shift INA234 shunt and current registers

The INA219 has the lowest three bits of the bus voltage register
zero-reserved, the bus_voltage_shift ina2xx_config field was introduced
to accommodate for that.

The INA234 has four bits of the bus voltage, of the shunt voltage, and
of the current registers zero-reserved but the latter two were
implemented by choosing a 16x higher shunt_div instead of a separate
field specifying a bit shift.

This is possible because shunt voltage and current are divided by
shunt_div, hence a 16x higher shunt_div results in a 16x smaller LSB for
both the shunt voltage and the current register, perfectly accounting
for the missing bit shift.

For consistency and correctness, account for the reserved bits via
shunt_voltage_shift and current_shift configuration fields as already
done for voltage registers and use the conversion constants given in the
INA234 datasheet.

Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
Link: https://lore.kernel.org/r/20260303-ina234-shift-v1-2-318c33ac4480@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina2xx.c