Lines Matching +full:5 +full:- +full:inch
1 // SPDX-License-Identifier: GPL-2.0-only
3 * axp288_adc.c - X-Powers AXP288 PMIC ADC Driver
24 * This mask enables all ADCs except for the battery temp-sensor (TS), that is
25 * left as-is to avoid breaking charging on devices without a temp-sensor.
30 #define AXP288_ADC_TS_BIAS_MASK GENMASK(5, 4)
98 .channel = 5,
107 IIO_MAP("TS_PIN", "axp288-batt", "axp288-batt-temp"),
108 IIO_MAP("PMIC_TEMP", "axp288-pmic", "axp288-pmic-temp"),
109 IIO_MAP("GPADC", "axp288-gpadc", "axp288-system-temp"),
110 IIO_MAP("BATT_CHG_I", "axp288-chrg", "axp288-chrg-curr"),
111 IIO_MAP("BATT_DISCHRG_I", "axp288-chrg", "axp288-chrg-d-curr"),
112 IIO_MAP("BATT_V", "axp288-batt", "axp288-batt-volt"),
122 return -EIO; in axp288_adc_read_channel()
129 * The current-source used for the battery temp-sensor (TS) is shared
130 * with the GPADC. For proper fuel-gauge and charger operation the TS
131 * current-source needs to be permanently on. But to read the GPADC we
132 * need to temporary switch the TS current-source to ondemand, so that
140 /* No need to switch the current-source if the TS pin is disabled */ in axp288_adc_set_ts()
141 if (!info->ts_enabled) in axp288_adc_set_ts()
148 ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, in axp288_adc_set_ts()
167 mutex_lock(&info->lock); in axp288_adc_read_raw()
171 chan->address)) { in axp288_adc_read_raw()
172 dev_err(&indio_dev->dev, "GPADC mode\n"); in axp288_adc_read_raw()
173 ret = -EINVAL; in axp288_adc_read_raw()
176 ret = axp288_adc_read_channel(val, chan->address, info->regmap); in axp288_adc_read_raw()
178 chan->address)) in axp288_adc_read_raw()
179 dev_err(&indio_dev->dev, "TS pin restore\n"); in axp288_adc_read_raw()
182 ret = -EINVAL; in axp288_adc_read_raw()
184 mutex_unlock(&info->lock); in axp288_adc_read_raw()
195 /* Lenovo Ideapad 100S (11 inch) */
198 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad 100S-11IBY"),
220 ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, in axp288_adc_initialize()
222 (uintptr_t)bias_override->driver_data); in axp288_adc_initialize()
228 * Determine if the TS pin is enabled and set the TS current-source in axp288_adc_initialize()
231 ret = regmap_read(info->regmap, AXP20X_ADC_EN1, &adc_enable_val); in axp288_adc_initialize()
236 info->ts_enabled = true; in axp288_adc_initialize()
237 ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, in axp288_adc_initialize()
241 info->ts_enabled = false; in axp288_adc_initialize()
242 ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, in axp288_adc_initialize()
250 return regmap_set_bits(info->regmap, AXP20X_ADC_EN1, in axp288_adc_initialize()
263 struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); in axp288_adc_probe()
265 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info)); in axp288_adc_probe()
267 return -ENOMEM; in axp288_adc_probe()
270 info->irq = platform_get_irq(pdev, 0); in axp288_adc_probe()
271 if (info->irq < 0) in axp288_adc_probe()
272 return info->irq; in axp288_adc_probe()
274 info->regmap = axp20x->regmap; in axp288_adc_probe()
281 dev_err(&pdev->dev, "unable to enable ADC device\n"); in axp288_adc_probe()
285 indio_dev->name = pdev->name; in axp288_adc_probe()
286 indio_dev->channels = axp288_adc_channels; in axp288_adc_probe()
287 indio_dev->num_channels = ARRAY_SIZE(axp288_adc_channels); in axp288_adc_probe()
288 indio_dev->info = &axp288_adc_iio_info; in axp288_adc_probe()
289 indio_dev->modes = INDIO_DIRECT_MODE; in axp288_adc_probe()
291 ret = devm_iio_map_array_register(&pdev->dev, indio_dev, axp288_adc_default_maps); in axp288_adc_probe()
295 mutex_init(&info->lock); in axp288_adc_probe()
297 return devm_iio_device_register(&pdev->dev, indio_dev); in axp288_adc_probe()
318 MODULE_DESCRIPTION("X-Powers AXP288 ADC Driver");