Skip to content

Commit 9729174

Browse files
jwrdegoedejic23
authored andcommitted
iio: adc: axp288: Override TS pin bias current for some models
Since commit 9bcf15f ("iio: adc: axp288: Fix TS-pin handling") we preserve the bias current set by the firmware at boot. This fixes issues we were seeing on various models, but it seems our old hardcoded 80ųA bias current was working around a firmware bug on at least one model laptop. In order to both have our cake and eat it, this commit adds a dmi based list of models where we need to override the firmware set bias current and adds the one model we now know needs this to it: The Lenovo Ideapad 100S (11 inch version). Fixes: 9bcf15f ("iio: adc: axp288: Fix TS-pin handling") BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=203829 Signed-off-by: Hans de Goede <[email protected]> Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 9c0530e commit 9729174

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

drivers/iio/adc/axp288_adc.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88
*/
99

10+
#include <linux/dmi.h>
1011
#include <linux/module.h>
1112
#include <linux/kernel.h>
1213
#include <linux/device.h>
@@ -25,6 +26,11 @@
2526
#define AXP288_ADC_EN_MASK 0xF0
2627
#define AXP288_ADC_TS_ENABLE 0x01
2728

29+
#define AXP288_ADC_TS_BIAS_MASK GENMASK(5, 4)
30+
#define AXP288_ADC_TS_BIAS_20UA (0 << 4)
31+
#define AXP288_ADC_TS_BIAS_40UA (1 << 4)
32+
#define AXP288_ADC_TS_BIAS_60UA (2 << 4)
33+
#define AXP288_ADC_TS_BIAS_80UA (3 << 4)
2834
#define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0)
2935
#define AXP288_ADC_TS_CURRENT_OFF (0 << 0)
3036
#define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING (1 << 0)
@@ -177,10 +183,36 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
177183
return ret;
178184
}
179185

186+
/*
187+
* We rely on the machine's firmware to correctly setup the TS pin bias current
188+
* at boot. This lists systems with broken fw where we need to set it ourselves.
189+
*/
190+
static const struct dmi_system_id axp288_adc_ts_bias_override[] = {
191+
{
192+
/* Lenovo Ideapad 100S (11 inch) */
193+
.matches = {
194+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
195+
DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad 100S-11IBY"),
196+
},
197+
.driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA,
198+
},
199+
{}
200+
};
201+
180202
static int axp288_adc_initialize(struct axp288_adc_info *info)
181203
{
204+
const struct dmi_system_id *bias_override;
182205
int ret, adc_enable_val;
183206

207+
bias_override = dmi_first_match(axp288_adc_ts_bias_override);
208+
if (bias_override) {
209+
ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL,
210+
AXP288_ADC_TS_BIAS_MASK,
211+
(uintptr_t)bias_override->driver_data);
212+
if (ret)
213+
return ret;
214+
}
215+
184216
/*
185217
* Determine if the TS pin is enabled and set the TS current-source
186218
* accordingly.

0 commit comments

Comments
 (0)