44 lines
1.4 KiB
Diff
44 lines
1.4 KiB
Diff
|
From 422f27508ccf61136587af30bad547720dbb0a7e Mon Sep 17 00:00:00 2001
|
||
|
From: Icenowy Zheng <icenowy@aosc.io>
|
||
|
Date: Tue, 10 Sep 2019 12:03:32 +0800
|
||
|
Subject: [PATCH 221/469] iio: adc: axp20x_adc: allow to set TS pin to GPADC
|
||
|
mode
|
||
|
|
||
|
The TS pin of AXP PMICs can be set to GPADC mode. In this situation, it
|
||
|
doesn't affect battery charging.
|
||
|
|
||
|
Add the code to do the mode setting.
|
||
|
|
||
|
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
|
||
|
---
|
||
|
drivers/iio/adc/axp20x_adc.c | 6 ++++++
|
||
|
1 file changed, 6 insertions(+)
|
||
|
|
||
|
diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c
|
||
|
index 75bda94dbce1..83e228980ad5 100644
|
||
|
--- a/drivers/iio/adc/axp20x_adc.c
|
||
|
+++ b/drivers/iio/adc/axp20x_adc.c
|
||
|
@@ -40,6 +40,7 @@
|
||
|
#define AXP813_TS_GPIO0_ADC_RATE_HZ(x) AXP20X_ADC_RATE_HZ(x)
|
||
|
#define AXP813_V_I_ADC_RATE_HZ(x) ((ilog2((x) / 100) << 4) & AXP813_V_I_ADC_RATE_MASK)
|
||
|
#define AXP813_ADC_RATE_HZ(x) (AXP20X_ADC_RATE_HZ(x) | AXP813_V_I_ADC_RATE_HZ(x))
|
||
|
+#define AXP20X_TS_FUNCTION_GPADC BIT(2)
|
||
|
|
||
|
#define AXP20X_ADC_CHANNEL(_channel, _name, _type, _reg) \
|
||
|
{ \
|
||
|
@@ -716,6 +717,11 @@ static int axp20x_probe(struct platform_device *pdev)
|
||
|
info->data->adc_en2_mask,
|
||
|
info->data->adc_en2_mask);
|
||
|
|
||
|
+ if (of_property_read_bool(pdev->dev.of_node, "x-powers,ts-as-gpadc"))
|
||
|
+ regmap_update_bits(info->regmap, AXP20X_ADC_RATE,
|
||
|
+ AXP20X_TS_FUNCTION_GPADC,
|
||
|
+ AXP20X_TS_FUNCTION_GPADC);
|
||
|
+
|
||
|
/* Configure ADCs rate */
|
||
|
info->data->adc_rate(info, 100);
|
||
|
|
||
|
--
|
||
|
2.34.1
|
||
|
|