]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (ina2xx) Make calibration register value fixed
authorMaciej Purski <m.purski@samsung.com>
Wed, 22 Nov 2017 15:32:15 +0000 (16:32 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 2 Jan 2018 23:05:34 +0000 (15:05 -0800)
commit49cdbf6a0576ab3c88e95c52ec2d992dd6803d76
treef29d66a4392038fb1803589ef2cc1101c8b93b15
parentf8222edee24ff161d5c8c5e38d3cb4483c311dc1
hwmon: (ina2xx) Make calibration register value fixed

Calibration register is used for calculating current register in
hardware according to datasheet:
current = shunt_volt * calib_register / 2048 (ina 226)
current = shunt_volt * calib_register / 4096 (ina 219)

Fix calib_register value to 2048 for ina226 and 4096 for ina 219 in
order to avoid truncation error and provide best precision allowed
by shunt_voltage measurement. Make current scale value follow changes
of shunt_resistor from sysfs as calib_register value is now fixed.

Power_lsb value should also follow shunt_resistor changes as stated in
datasheet:
power_lsb = 25 * current_lsb (ina 226)
power_lsb = 20 * current_lsb (ina 219)

Signed-off-by: Maciej Purski <m.purski@samsung.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina2xx.c