summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2019-09-15 14:53:42 -0400
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-10-09 14:11:27 -0400
commit972917419a0ba25afbf69d5d8c9fa644d676f887 (patch)
tree76ae70de7944f1d479d177c9792b6cfc0f4a972f
parent9c0530e898f384c5d279bfcebd8bb17af1105873 (diff)
iio: adc: axp288: Override TS pin bias current for some models
Since commit 9bcf15f75cac ("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: 9bcf15f75cac ("iio: adc: axp288: Fix TS-pin handling") BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=203829 Signed-off-by: Hans de Goede <hdegoede@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/adc/axp288_adc.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
index adc9cf7a075d..8ea2aed6d6f5 100644
--- a/drivers/iio/adc/axp288_adc.c
+++ b/drivers/iio/adc/axp288_adc.c
@@ -7,6 +7,7 @@
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 */ 8 */
9 9
10#include <linux/dmi.h>
10#include <linux/module.h> 11#include <linux/module.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
12#include <linux/device.h> 13#include <linux/device.h>
@@ -25,6 +26,11 @@
25#define AXP288_ADC_EN_MASK 0xF0 26#define AXP288_ADC_EN_MASK 0xF0
26#define AXP288_ADC_TS_ENABLE 0x01 27#define AXP288_ADC_TS_ENABLE 0x01
27 28
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)
28#define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0) 34#define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0)
29#define AXP288_ADC_TS_CURRENT_OFF (0 << 0) 35#define AXP288_ADC_TS_CURRENT_OFF (0 << 0)
30#define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING (1 << 0) 36#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,
177 return ret; 183 return ret;
178} 184}
179 185
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 */
190static 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
180static int axp288_adc_initialize(struct axp288_adc_info *info) 202static int axp288_adc_initialize(struct axp288_adc_info *info)
181{ 203{
204 const struct dmi_system_id *bias_override;
182 int ret, adc_enable_val; 205 int ret, adc_enable_val;
183 206
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
184 /* 216 /*
185 * Determine if the TS pin is enabled and set the TS current-source 217 * Determine if the TS pin is enabled and set the TS current-source
186 * accordingly. 218 * accordingly.