]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Thu, 12 Apr 2018 13:04:21 +0000 (10:04 -0300)
commit6400a8619df824900d7fe962039e5a3ac5868588
treee4e171a728799a4055108250d05f732ca9b12b9e
parentba489e0dca7b9475ddf0b08ec33ae97b1bdd0bc4
hwmon: (ina2xx) Make calibration register value fixed

BugLink: http://bugs.launchpad.net/bugs/1763366
[ Upstream commit 5d389b125186cf254ad5b8015763ac07c151aea4 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
drivers/hwmon/ina2xx.c