Skip to content

Battery temperature ADC plumbing on Qualcomm platforms

Luca Weiss linux-arm-msm linux-devicetree linux-iio linux-pm lkml phone-devel 4 versions – In review

Get series with b4
b4 am [email protected] change-id 20251010-bat-temp-adc-8539bf0b85bc

Versions newest first

  1. v4 Latest5 patches 8 repliesIn review
  2. v35 patches 8 repliesSuperseded
  3. v25 patches 14 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v1 RFC6 patches5 repliesSuperseded

Changes in v4 from the cover letter

- spmi-adc5/vadc-common: Fix inconsistency micro vs milli (Sashiko)
- spmi-adc5/vadc-common: use 'MICRO / MILLI' instead of 1000, use _mV (Andy)
- thermal-generic-adc: simplify devm_thermal_of_zone_register return (Andy)
- thermal-generic-adc: move iio read + convert into gadc_thermal_iio_to_temp() function (Jonathan)
- thermal-generic-adc: convert 'register failed' dev_info to dev_dbg (Jonathan)
- Link to v3: https://patch.msgid.link/[email protected]

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5iio: adc: qcom-spmi-adc5: Add battery thermal channelsdrivers/iio/adc/qcom-spmi-adc5.c drivers/iio/adc/qcom-vadc-common.c include/linux/iio/adc/qcom-vadc-common.h+25 -04 replies
2/5dt-bindings: thermal: generic-adc: Document #io-channel-cellsDocumentation/devicetree/bindings/thermal/generic-adc-thermal.yaml+4 -04 replies
3/5thermal/drivers/generic-adc: Allow probe without TZ registrationdrivers/thermal/thermal-generic-adc.c+15 -120 replies
4/5arm64: dts: qcom: pm7250b: Define battery temperature ADC channelsarch/arm64/boot/dts/qcom/pm7250b.dtsi+24 -00 replies
5/5arm64: dts: qcom: sm7225-fairphone-fp4: Add battery temperature nodearch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts+83 -00 replies

Reviews trailers per patch

2 of 5 patches have a Reviewed-by or Acked-by.

PatchKonrad DybcioRob Herring (Arm)
1/5
2/5R-b
3/5
4/5R-b
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/5] Battery temperature ADC plumbing on Qualcomm platforms

This implements a solution to get battery temperature readings working on (for example) smartphones with Qualcomm SoCs.

The solution chosen in downstream Qualcomm kernels is exposing ADC_BAT_THERM_PU* in the ADC driver as temperature channels with the lookup table ("struct vadc_map_pt") for the specific NTC found in a device's battery patched to adjust the lookup table. Patching a kernel per-device is obviously nothing we can put upstream.

The high level solution proposed here:
* ADC driver provides temperature channel in (milli)volt as IIO channel
* generic-adc-thermal driver converts voltage to temperature based on provided lookup table from DT (driver has one IIO channel input, one IIO channel output)
* The fuel gauge driver can use that temperature IIO channel to expose battery temperature via the power supply device

See RFC for other variants or alternatives considered.

---
Changes in v4:
- spmi-adc5/vadc-common: Fix inconsistency micro vs milli (Sashiko)
- spmi-adc5/vadc-common: use 'MICRO / MILLI' instead of 1000, use _mV (Andy)
- thermal-generic-adc: simplify devm_thermal_of_zone_register return (Andy)
- thermal-generic-adc: move iio read + convert into gadc_thermal_iio_to_temp() function (Jonathan)
- thermal-generic-adc: convert 'register failed' dev_info to dev_dbg (Jonathan)
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- Expand commit message on dt-bindings patch (Rob)
- Some commit message improvements in generic-adc patch (Andy)
- Fix dt node location, move higher up (Konrad)
- Pick up tags
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Rebase on linux-next (a different patch to add IIO to
generic-adc-thermal has already landed upstream)
- Un-mark as RFC
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Luca Weiss (5):
iio: adc: qcom-spmi-adc5: Add battery thermal channels
dt-bindings: thermal: generic-adc: Document #io-channel-cells thermal/drivers/generic-adc: Allow probe without TZ registration
arm64: dts: qcom: pm7250b: Define battery temperature ADC channels
arm64: dts: qcom: sm7225-fairphone-fp4: Add battery temperature node

 .../bindings/thermal/generic-adc-thermal.yaml      |  4 ++
 arch/arm64/boot/dts/qcom/pm7250b.dtsi              | 24 +++++++
 arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts  | 83 ++++++++++++++++++++++
 drivers/iio/adc/qcom-spmi-adc5.c                   |  6 ++
 drivers/iio/adc/qcom-vadc-common.c                 | 16 +++++
 drivers/thermal/thermal-generic-adc.c              | 27 +++----
 include/linux/iio/adc/qcom-vadc-common.h           |  3 +
 7 files changed, 151 insertions(+), 12 deletions(-)

---
base-commit: 6aa7dbf8ad5ebd3babf53a4d6209018f86939f17
change-id: 20251010-bat-temp-adc-8539bf0b85bc

Best regards,

Signature · 1 line
Luca Weiss <[email protected]>