Re: [PATCH 3/5] iio: adc: qcom-spmi-adc5: Add ADC5_BAT_THERM_100K_PU
From: Val Packett
Date: Fri Nov 13 2026 - 09:00:23 EST
On 11/13/26 7:09 AM, Luca Weiss wrote:
Hi Val,
On Thu Nov 12, 2026 at 6:07 PM CET, Val Packett wrote:
Even though it existed in bindings for the longest time,While this will work fine for some devices, unfortunately this won't
ADC5_BAT_THERM_100K_PU was never assigned in the driver. Do so.
Signed-off-by: Val Packett <val@xxxxxxxxxxxx>
---
drivers/iio/adc/qcom-spmi-adc5.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c
index d57ba8526e0c..c27ff89429f5 100644
--- a/drivers/iio/adc/qcom-spmi-adc5.c
+++ b/drivers/iio/adc/qcom-spmi-adc5.c
@@ -542,6 +542,8 @@ static const struct adc5_channels adc5_chans_pmic[ADC5_MAX_CHANNEL] = {
SCALE_HW_CALIB_DEFAULT)
[ADC5_XO_THERM_100K_PU] = ADC5_CHAN_TEMP("xo_therm", 0,
SCALE_HW_CALIB_XOTHERM)
+ [ADC5_BAT_THERM_100K_PU] = ADC5_CHAN_TEMP("bat_therm", 0,
+ SCALE_HW_CALIB_THERM_100K_PULLUP)
work for quite some other devices that don't use a 30K, 100K or 400K
NTC in the battery - or when the NTC beta (B) is differing to the
hardcoded lookup table.
For example on Fairphone 4 (pm7250b fwiw), the battery has a 10kΩ NTC,
so using the ADC5_BAT_THERM_30K_PU with the hard-coded lookup tables
would result in very wrong temperature values. Even ignoring the whole
NTC beta topic.
You can see my proposed patch series at
https://lore.kernel.org/linux-arm-msm/20260220-bat-temp-adc-v2-0-fe34ed4ea851@xxxxxxxxxxxxx/
Unfortunately it's from February and I haven't spent more time on this
topic since then, mostly because fuel gauge anyways was downstream, so
pushing just this upstream wouldn't make much difference.
Now it does, so I should get back to it... Let me know your thoughts!
Looks like your series has had very positive feedback so far, from a quick look I haven't even noticed any pending changes really..
It's orthogonal to the qgauge driver itself as the driver just consumes an IIO channel which can be whatever's appropriate for the device, but that's informative in that I probably should not set a default channel and rather leave an explanation in the example in the bindings that it's very battery-specific.
(Fairphone 3 with SDM632/PMI632 would actually be fine-ish as-is because
the battery has a 100kΩ NTC and the beta probably is close enough to
what's in adcmap_100k_104ef_104fb_1875_vref)
Regards
Luca
[ADC5_BAT_ID_100K_PU] = ADC5_CHAN_TEMP("bat_id", 0,
SCALE_HW_CALIB_DEFAULT)
[ADC5_AMUX_THM1_100K_PU] = ADC5_CHAN_TEMP("amux_thm1_100k_pu", 0,
Thanks,
~val