Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI / PMIC: xpower: Do pinswitch magic when reading GPADC

Testing has shown that the TS-pin's bias-current needs to be disabled
when reading the GPIO0 pin in GPADC mode.

It seems that there is only 1 bias current source and to be able to use it
for the GPIO0 pin in GPADC mode it must be temporarily turned off for the
TS pin, but the datasheet does not mention this.

This commit adds the necessary writes to turn the TS pin BIAS current
off before and back on after reading the GPADC. This fixes the GPADC
always returning a reading of 0.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Hans de Goede and committed by
Rafael J. Wysocki
58eefe2f 520eccdf

+18 -3
+18 -3
drivers/acpi/pmic/intel_pmic_xpower.c
··· 27 27 #define GPI1_LDO_ON (3 << 0) 28 28 #define GPI1_LDO_OFF (4 << 0) 29 29 30 + #define AXP288_ADC_TS_PIN_GPADC 0xf2 31 + #define AXP288_ADC_TS_PIN_ON 0xf3 32 + 30 33 static struct pmic_table power_table[] = { 31 34 { 32 35 .address = 0x00, ··· 212 209 static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) 213 210 { 214 211 u8 buf[2]; 212 + int ret; 215 213 216 - if (regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2)) 217 - return -EIO; 214 + ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, 215 + AXP288_ADC_TS_PIN_GPADC); 216 + if (ret) 217 + return ret; 218 218 219 - return (buf[0] << 4) + ((buf[1] >> 4) & 0x0F); 219 + /* After switching to the GPADC pin give things some time to settle */ 220 + usleep_range(6000, 10000); 221 + 222 + ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2); 223 + if (ret == 0) 224 + ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f); 225 + 226 + regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON); 227 + 228 + return ret; 220 229 } 221 230 222 231 static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {