From: "Luca Weiss" <luca.weiss@fairphone.com>
To: "Konrad Dybcio" <konrad.dybcio@oss.qualcomm.com>,
"Luca Weiss" <luca.weiss@fairphone.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Daniel Lezcano" <daniel.lezcano@linaro.org>,
"Zhang Rui" <rui.zhang@intel.com>,
"Lukasz Luba" <lukasz.luba@arm.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Laxman Dewangan" <ldewangan@nvidia.com>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konradybcio@kernel.org>,
"Hans de Goede" <hansg@kernel.org>,
"Jens Reidel" <adrian@mainlining.org>,
"Casey Connolly" <casey.connolly@linaro.org>
Cc: <~postmarketos/upstreaming@lists.sr.ht>,
<phone-devel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-pm@vger.kernel.org>, <devicetree@vger.kernel.org>
Subject: Re: [PATCH v2 5/5] arm64: dts: qcom: sm7225-fairphone-fp4: Add battery temperature node
Date: Fri, 20 Feb 2026 12:26:48 +0100 [thread overview]
Message-ID: <DGJR40B5R6MB.1V4ZK5SW1PXAV@fairphone.com> (raw)
In-Reply-To: <a422e087-a91c-4bb2-9d95-e1cefc9a91bf@oss.qualcomm.com>
On Fri Feb 20, 2026 at 11:51 AM CET, Konrad Dybcio wrote:
> On 2/20/26 11:40 AM, Luca Weiss wrote:
>> On Fri Feb 20, 2026 at 11:00 AM CET, Konrad Dybcio wrote:
>>> On 2/20/26 10:19 AM, Luca Weiss wrote:
>>>> Add a generic-adc-thermal node to convert the voltage read by the
>>>> battery temperature ADC into degree Celsius using the provided lookup
>>>> table.
>>>>
>>>> This will later be used as input for the fuel gauge node (QGauge on the
>>>> PM7250B).
>>>>
>>>> Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
>>>> ---
>>>> arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts | 83 +++++++++++++++++++++++
>>>> 1 file changed, 83 insertions(+)
>>>>
>>>> diff --git a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
>>>> index b697051a0aaa..7857003099a6 100644
>>>> --- a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
>>>> +++ b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
>>>> @@ -108,6 +108,89 @@ rear_cam_sensor: thermal-sensor-rear-cam {
>>>> io-channel-names = "sensor-channel";
>>>> };
>>>>
>>>> + bat_therm_sensor: thermal-sensor-bat-therm {
>>>
>>> nit: this should be a little higher
>>
>> meh, it's surprisingly easy to miss this sorting stuff. Will fix in v3.
>>
>>>
>>>> + compatible = "generic-adc-thermal";
>>>> + #thermal-sensor-cells = <0>;
>>>> + #io-channel-cells = <0>;
>>>> + io-channels = <&pm7250b_adc ADC5_BAT_THERM_30K_PU>;
>>>> + io-channel-names = "sensor-channel";
>>>> + /*
>>>> + * Voltage to temperature table for 10kΩ (B=3435K) NTC with a
>>>> + * 1.875V reference and 30kΩ pull-up.
>>>> + */
>>>
>>> I think this looks good. Is this data going to be correct for all/most
>>> devices (i.e. is there a single battery sku)?
>>
>> Yes, from my info there's just a single battery SKU, so that makes it
>> easy here.
>>
>> For Fairphone 3 there's two battery SKUs:
>>
>> * (Fuji) F3AC with NTC 100kOhm B=4100, ID resistor 10kOhm
>> * (Kayo) F3AC1 with NTC 100kOhm B=4050, ID resistor 49.9kOhm
>>
>> In reality, one can probably ignore the difference between the LUT for
>> either B value since it only differs by a marginal amount, but
>> conceptually I'm not sure how this should really be resolved.
>>
>> We could have both battery definitions in the dtb, and then the charging
>> driver could determine the battery that's actually present in the
>> system (based on the BATT_ID measurement), but given the design here
>> now, I'm not sure how this temperature lookup table would be propagated
>> to the rest of the system...
>
> The path of least resistance (pun intended) would probably be to make
> generic-adc-thermal consume an ID channel and accept a number of LUTs..
Not the worst idea ;)
>
> That sounds sensible since most battery ID mechanisms are probably also
> ADC-based and one would hope (tm) that the values output by these ADC channels
> would then be distinct enough for the driver to have an easy time confidently
> selecting one of the options (or a fallback)
Charger / fuel guage and everything else battery-related would also need
to get the correct battery properties for the actual one present, not
just this generic-adc-thermal driver.
But I feel like soon DT maintainers will say that Linux shouldn't
dynamically detect hardware that's present and the DT should be the
absolute source of truth. That works fine in simple cases, but in case
of interchangeable batteries, display panels, camera sensors, this won't
work. *Something* needs to determine what's actually there.
And for most of the ways to detect which of those are present in the
device that is booting, you need half a kernel to power up the various
hardware and do some basic communication to figure out what's there. Of
course you could say that's U-Boot's job for example but not sure you
want to add a CCI (I2C), ADC driver and much more...
Regards
Luca
> That said, this is just my guesstimates and perhaps the IIO folks could comment
> on that
>
> Konrad
next prev parent reply other threads:[~2026-02-20 11:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 9:19 [PATCH v2 0/5] Battery temperature ADC plumbing on Qualcomm platforms Luca Weiss
2026-02-20 9:19 ` [PATCH v2 1/5] iio: adc: qcom-spmi-adc5: Add battery thermal channels Luca Weiss
2026-02-20 9:19 ` [PATCH v2 2/5] dt-bindings: thermal: generic-adc: Document #io-channel-cells Luca Weiss
2026-02-23 18:48 ` Rob Herring
2026-02-24 8:14 ` Luca Weiss
2026-02-20 9:19 ` [PATCH v2 3/5] thermal/drivers/generic-adc: Allow probe without TZ registration Luca Weiss
2026-02-20 10:50 ` Andy Shevchenko
2026-02-20 11:31 ` Luca Weiss
2026-02-20 13:43 ` Andy Shevchenko
2026-02-20 9:19 ` [PATCH v2 4/5] arm64: dts: qcom: pm7250b: Define battery temperature ADC channels Luca Weiss
2026-02-20 9:57 ` Konrad Dybcio
2026-02-20 9:19 ` [PATCH v2 5/5] arm64: dts: qcom: sm7225-fairphone-fp4: Add battery temperature node Luca Weiss
2026-02-20 10:00 ` Konrad Dybcio
2026-02-20 10:40 ` Luca Weiss
2026-02-20 10:51 ` Konrad Dybcio
2026-02-20 11:26 ` Luca Weiss [this message]
2026-02-21 2:49 ` Dmitry Baryshkov
2026-02-23 7:50 ` Luca Weiss
2026-02-23 19:05 ` Dmitry Baryshkov
2026-02-20 11:58 ` [PATCH v2 0/5] Battery temperature ADC plumbing on Qualcomm platforms Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DGJR40B5R6MB.1V4ZK5SW1PXAV@fairphone.com \
--to=luca.weiss@fairphone.com \
--cc=adrian@mainlining.org \
--cc=andersson@kernel.org \
--cc=andy@kernel.org \
--cc=casey.connolly@linaro.org \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=hansg@kernel.org \
--cc=jic23@kernel.org \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=ldewangan@nvidia.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=nuno.sa@analog.com \
--cc=phone-devel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox