mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 05:55:44 +02:00
iio: adc: axp20x_adc: fix charging current reporting on AXP22x
commit92beafb76aupstream. 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:0e34d5de96("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>
This commit is contained in:
parent
af7fbb8c0b
commit
0f86c9e818
|
|
@ -251,19 +251,8 @@ static int axp22x_adc_raw(struct iio_dev *indio_dev,
|
||||||
struct iio_chan_spec const *chan, int *val)
|
struct iio_chan_spec const *chan, int *val)
|
||||||
{
|
{
|
||||||
struct axp20x_adc_iio *info = iio_priv(indio_dev);
|
struct axp20x_adc_iio *info = iio_priv(indio_dev);
|
||||||
int size;
|
|
||||||
|
|
||||||
/*
|
*val = axp20x_read_variable_width(info->regmap, chan->address, 12);
|
||||||
* N.B.: Unlike the Chinese datasheets tell, the charging current is
|
|
||||||
* stored on 12 bits, not 13 bits. Only discharging current is on 13
|
|
||||||
* bits.
|
|
||||||
*/
|
|
||||||
if (chan->type == IIO_CURRENT && chan->channel == AXP22X_BATT_DISCHRG_I)
|
|
||||||
size = 13;
|
|
||||||
else
|
|
||||||
size = 12;
|
|
||||||
|
|
||||||
*val = axp20x_read_variable_width(info->regmap, chan->address, size);
|
|
||||||
if (*val < 0)
|
if (*val < 0)
|
||||||
return *val;
|
return *val;
|
||||||
|
|
||||||
|
|
@ -386,9 +375,8 @@ static int axp22x_adc_scale(struct iio_chan_spec const *chan, int *val,
|
||||||
return IIO_VAL_INT_PLUS_MICRO;
|
return IIO_VAL_INT_PLUS_MICRO;
|
||||||
|
|
||||||
case IIO_CURRENT:
|
case IIO_CURRENT:
|
||||||
*val = 0;
|
*val = 1;
|
||||||
*val2 = 500000;
|
return IIO_VAL_INT;
|
||||||
return IIO_VAL_INT_PLUS_MICRO;
|
|
||||||
|
|
||||||
case IIO_TEMP:
|
case IIO_TEMP:
|
||||||
*val = 100;
|
*val = 100;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user