From: Jonathan Cameron <jic23@kernel.org>
To: Hans de Goede <hansg@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Luca Weiss" <luca.weiss@fairphone.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>,
"Jens Reidel" <adrian@mainlining.org>,
"Casey Connolly" <casey.connolly@linaro.org>,
~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 RFC 0/6] Battery temperature ADC plumbing on Qualcomm platforms
Date: Sun, 12 Oct 2025 19:24:22 +0100 [thread overview]
Message-ID: <20251012192422.46775ad1@jic23-huawei> (raw)
In-Reply-To: <0beae4dd-2feb-4891-b7b0-0f63db8f5615@kernel.org>
On Sat, 11 Oct 2025 11:52:43 +0200
Hans de Goede <hansg@kernel.org> wrote:
> Hi All,
>
> Luca thank you for Cc-ing me.
>
> On 10-Oct-25 10:56 PM, David Lechner wrote:
> > On 10/10/25 6:21 AM, Luca Weiss wrote:
> >> This is an RFC which implements a potential solution to get battery
> >> temperature readings working on for example smartphones with Qualcomm
> >> SoCs.
> >>
> >
> > ...
> >
> >> 3. Add temperature-lookup-table as property to simple-battery
> >>
> >> Since the NTC is a part of the battery pack, adding a
> >> temperature-lookup-table property to simple-battery would make sense
> >> instead of having this lookup table be standalone in the
> >> generic-adc-thermal node. However being able to re-use the existing code
> >> in generic-adc-thermal lead me to the current proposal.
> >>
> > Did you consider creating a specific compatible string for the battery pack?
> > Then the battery node could have the io-channels property for the ADC
> > connected to the temperature sensor. Then a specific battery driver could
> > handle the conversion as needed rather than filling the devicetree with
> > conversion tables.
>
> That will require a driver update, filling the driver (and thus memory)
> with conversion tables each time a new battery model (one model phone
> can have multiple battery revisions) comes out.
>
> That seems undesirable. To me these conversion tables are very much
> something which belongs in DT rather then being hardcoded in
> the driver.
>
> Also contrast this to ACPI where there actually is a mechanism defined
> for thermal lookup tables and there all these things typically just
> work when the ACPI tables are written properly. IMHO we want to move
> more towards this direction where things just work without requiring
> kernel code changes for every new model.
>
> And we already have a mechanism in DT to map an ADC voltage to
> a temperature in the generic-adc-thermal driver.
>
> So all that is left to do really is to come up with a clean way
> to export the temperature from the generic-adc-thermal driver
> to the generic-adc-battery driver.
>
> > The simple-battery bindings are already far from simple! So I would not
> > be inclined to add more to it.
>
> I think we all agree on this and we also don't want to duplicate
> the generic-adc-thermal bindings + code implementing that functionality.
>
> IMHO not wanting to duplicate the bindings + functionality applies to
> both: a) directly exporting an IIO temp channel from the ADC driver and
> b) adding volt -> temp mapping functionality to the simple-battery bindings.
>
> So that basically leaves us with coming up with a way for
> the generic-adc-battery code to consume the temperature coming out of
> the generic-adc-thermal code and there are 2 ways to do this:
>
> 1. Modify the generic-adc-thermal driver to export an IIO channel
Other than the fact this is embedded in an existing driver, this is just
a case of modelling an analog sensor in IIO. There's an ancient accelerometer
that does this and the analog fronted ends handle things like potential dividers
which are similar but with far simpler DT than this.
So conceptually I have no problem with the approach.
If we were starting from scratch we might have had an explicit representation
of the thermal sensor analog part (like our accelerometer), and then done
Generic temperature device sensor driver is consumer of the ADC channel.
generic-adc-thermal is consumer of the generic temp device sensor.
But retrofitting that split may be a pain (I haven't looked at this though so
maybe not!)
> 2. Modify the thermal-zone core to allow referencing to a thermal-zone
> with a phandle *and* modify generic-adc-battery to be able to
> optionally get the temperature from a thermal-zone instead of
> from an IIO-channel
>
> Of these two options 1. clear is the most KISS option. SO I agree with
> Luca that 1. as implemented in this series is the best way forward.
>
> Regards,
>
> Hans
>
>
prev parent reply other threads:[~2025-10-12 18:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 11:21 [PATCH RFC 0/6] Battery temperature ADC plumbing on Qualcomm platforms Luca Weiss
2025-10-10 11:21 ` [PATCH RFC 1/6] iio: adc: qcom-spmi-adc5: Add battery thermal channels Luca Weiss
2025-10-10 11:22 ` [PATCH RFC 2/6] dt-bindings: thermal: generic-adc: Document #io-channel-cells Luca Weiss
2025-10-10 11:22 ` [PATCH RFC 3/6] thermal/drivers/generic-adc: Register as IIO device Luca Weiss
2025-10-12 18:41 ` Jonathan Cameron
2025-10-10 11:22 ` [PATCH RFC 4/6] thermal/drivers/generic-adc: Allow probe without TZ registration Luca Weiss
2025-10-10 11:22 ` [PATCH RFC 5/6] arm64: dts: qcom: pm7250b: Define battery temperature ADC channels Luca Weiss
2025-10-10 11:22 ` [PATCH RFC 6/6] arm64: dts: qcom: sm7225-fairphone-fp4: Add battery temperature node Luca Weiss
2025-10-10 14:40 ` [PATCH RFC 0/6] Battery temperature ADC plumbing on Qualcomm platforms Nuno Sá
2025-10-10 20:56 ` David Lechner
2025-10-11 9:52 ` Hans de Goede
2025-10-12 18:24 ` Jonathan Cameron [this message]
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=20251012192422.46775ad1@jic23-huawei \
--to=jic23@kernel.org \
--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=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=luca.weiss@fairphone.com \
--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