patch "iio: adc: axp20x_adc: fix charging current reporting on AXP22x" added to char-misc-linus
Subsystems (3)
This is a note to let you know that I've just added the patch titled
iio: adc: axp20x_adc: fix charging current reporting on AXP22x
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 92beafb76a31bdc02649eb44e93a8e4f4cfcdbe8 Mon Sep 17 00:00:00 2001
From: Evgeny Boger <[email protected]>
Date: Wed, 17 Nov 2021 00:37:46 +0300
Subject: iio: adc: axp20x_adc: fix charging current reporting on AXP22x
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.
--- drivers/iio/adc/axp20x_adc.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/iio/adc/axp20x_adc.c +3 -15
@@ -251,19 +251,8 @@ static int axp22x_adc_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val) { struct axp20x_adc_iio *info = iio_priv(indio_dev); -int size; -/* -* 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); + *val =axp20x_read_variable_width (info->regmap, chan->address,12 );if (*val <0 )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 ;case IIO_CURRENT : - *val =0 ; - *val2 =500000 ; -return IIO_VAL_INT_PLUS_MICRO ; + *val =1 ; +return IIO_VAL_INT ;case IIO_TEMP : *val =100 ;
Signature · 1 line
2.34.1