Skip to content

Commit a1f7b8f

Browse files
jwrdegoedegregkh
authored andcommitted
iio: adc: axp288: Drop bogus AXP288_ADC_TS_PIN_CTRL register modifications
[ Upstream commit fa2849e9649b5180ffc4cb3c3b005261c403093a ] For some reason the axp288_adc driver was modifying the AXP288_ADC_TS_PIN_CTRL register, changing bits 0-1 depending on whether the GP_ADC channel or another channel was written. These bits control when a bias current is send to the TS_PIN, the GP_ADC has its own pin and a separate bit in another register to control the bias current. Not only does changing when to enable the TS_PIN bias current (always or only when sampling) when reading the GP_ADC make no sense at all, the code is modifying these bits is writing the entire register, assuming that all the other bits have their default value. So if the firmware has configured a different bias-current for either pin, then that change gets clobbered by the write, likewise if the firmware has set bit 2 to indicate that the battery has no thermal sensor, this will get clobbered by the write. This commit fixes all this, by simply removing all writes to the AXP288_ADC_TS_PIN_CTRL register, they are not needed to read the GP_ADC pin, and can actually be harmful. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 297b8b0 commit a1f7b8f

1 file changed

Lines changed: 1 addition & 31 deletions

File tree

drivers/iio/adc/axp288_adc.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include <linux/iio/driver.h>
2929

3030
#define AXP288_ADC_EN_MASK 0xF1
31-
#define AXP288_ADC_TS_PIN_GPADC 0xF2
32-
#define AXP288_ADC_TS_PIN_ON 0xF3
3331

3432
enum axp288_adc_id {
3533
AXP288_ADC_TS,
@@ -123,16 +121,6 @@ static int axp288_adc_read_channel(int *val, unsigned long address,
123121
return IIO_VAL_INT;
124122
}
125123

126-
static int axp288_adc_set_ts(struct regmap *regmap, unsigned int mode,
127-
unsigned long address)
128-
{
129-
/* channels other than GPADC do not need to switch TS pin */
130-
if (address != AXP288_GP_ADC_H)
131-
return 0;
132-
133-
return regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, mode);
134-
}
135-
136124
static int axp288_adc_read_raw(struct iio_dev *indio_dev,
137125
struct iio_chan_spec const *chan,
138126
int *val, int *val2, long mask)
@@ -143,16 +131,7 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
143131
mutex_lock(&indio_dev->mlock);
144132
switch (mask) {
145133
case IIO_CHAN_INFO_RAW:
146-
if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_GPADC,
147-
chan->address)) {
148-
dev_err(&indio_dev->dev, "GPADC mode\n");
149-
ret = -EINVAL;
150-
break;
151-
}
152134
ret = axp288_adc_read_channel(val, chan->address, info->regmap);
153-
if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_ON,
154-
chan->address))
155-
dev_err(&indio_dev->dev, "TS pin restore\n");
156135
break;
157136
default:
158137
ret = -EINVAL;
@@ -162,15 +141,6 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
162141
return ret;
163142
}
164143

165-
static int axp288_adc_set_state(struct regmap *regmap)
166-
{
167-
/* ADC should be always enabled for internal FG to function */
168-
if (regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON))
169-
return -EIO;
170-
171-
return regmap_write(regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);
172-
}
173-
174144
static const struct iio_info axp288_adc_iio_info = {
175145
.read_raw = &axp288_adc_read_raw,
176146
.driver_module = THIS_MODULE,
@@ -199,7 +169,7 @@ static int axp288_adc_probe(struct platform_device *pdev)
199169
* Set ADC to enabled state at all time, including system suspend.
200170
* otherwise internal fuel gauge functionality may be affected.
201171
*/
202-
ret = axp288_adc_set_state(axp20x->regmap);
172+
ret = regmap_write(info->regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);
203173
if (ret) {
204174
dev_err(&pdev->dev, "unable to enable ADC device\n");
205175
return ret;

0 commit comments

Comments
 (0)