]> git.baikalelectronics.ru Git - kernel.git/commit
iio: adc: axp20x_adc: fix charging current reporting on AXP22x
authorEvgeny Boger <boger@wirenboard.com>
Tue, 16 Nov 2021 21:37:46 +0000 (00:37 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Dec 2021 09:57:21 +0000 (10:57 +0100)
commitf36cf62bcd98ffce862c6171c277bfb7eedf8a95
tree3f374066947822b76b2dc5477c852137a63b90e6
parent46987c82aaecf120828ee6bb992f6b67463dbcdb
iio: adc: axp20x_adc: fix charging current reporting on AXP22x

commit 5f4714def17e89a085c429242aea6f9d5d8f0c7f upstream.

Both the charging and discharging currents on AXP22x are stored as
12-bit integers, in accordance with the datasheet.
It's also confirmed by vendor BSP (axp20x_adc.c:axp22_icharge_to_mA).

The scale factor of 0.5 is never mentioned in datasheet, nor in the
vendor source code. I think it was here to compensate for
erroneous addition bit in register width.

Tested on custom A40i+AXP221s board with external ammeter as
a reference.

Fixes: d8cbe9d38499 ("iio: adc: add support for X-Powers AXP20X and AXP22X PMICs ADCs")
Signed-off-by: Evgeny Boger <boger@wirenboard.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20211116213746.264378-1-boger@wirenboard.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/axp20x_adc.c