|
7 | 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
8 | 8 | */
|
9 | 9 |
|
| 10 | +#include <linux/dmi.h> |
10 | 11 | #include <linux/module.h>
|
11 | 12 | #include <linux/kernel.h>
|
12 | 13 | #include <linux/device.h>
|
|
25 | 26 | #define AXP288_ADC_EN_MASK 0xF0
|
26 | 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 | 34 | #define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0)
|
29 | 35 | #define AXP288_ADC_TS_CURRENT_OFF (0 << 0)
|
30 | 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 | 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 | + */ |
| 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 | + |
180 | 202 | static int axp288_adc_initialize(struct axp288_adc_info *info)
|
181 | 203 | {
|
| 204 | + const struct dmi_system_id *bias_override; |
182 | 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 | 217 | * Determine if the TS pin is enabled and set the TS current-source
|
186 | 218 | * accordingly.
|
|
0 commit comments