[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251012192422.46775ad1@jic23-huawei>
Date: Sun, 12 Oct 2025 19:24:22 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Hans de Goede <hansg@...nel.org>
Cc: David Lechner <dlechner@...libre.com>, Luca Weiss
<luca.weiss@...rphone.com>, Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, "Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>, Zhang Rui
<rui.zhang@...el.com>, Lukasz Luba <lukasz.luba@....com>, Rob Herring
<robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Laxman Dewangan <ldewangan@...dia.com>, Bjorn
Andersson <andersson@...nel.org>, Konrad Dybcio <konradybcio@...nel.org>,
Jens Reidel <adrian@...nlining.org>, Casey Connolly
<casey.connolly@...aro.org>, ~postmarketos/upstreaming@...ts.sr.ht,
phone-devel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH RFC 0/6] Battery temperature ADC plumbing on Qualcomm
platforms
On Sat, 11 Oct 2025 11:52:43 +0200
Hans de Goede <hansg@...nel.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
>
>
Powered by blists - more mailing lists