From: Jonathan Cameron <jic23@kernel.org>
To: "Luca Weiss" <luca.weiss@fairphone.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.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>,
"Val Packett" <val@packett.cool>,
"Daniel Lezcano" <daniel.lezcano@kernel.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 v4 1/5] iio: adc: qcom-spmi-adc5: Add battery thermal channels
Date: Sun, 29 Nov 2026 01:24:56 +0000 [thread overview]
Message-ID: <20261129012456.526c5670@jic23-hlaptop> (raw)
In-Reply-To: <DN2H797ASILD.3P89IOZH1IU1H@fairphone.com>
On Mon, 23 Nov 2026 10:17:21 +0100
"Luca Weiss" <luca.weiss@fairphone.com> wrote:
> Hi Jonathan,
>
> On Sun Nov 22, 2026 at 4:13 AM CET, Jonathan Cameron wrote:
> > On Tue, 17 Nov 2026 09:23:11 +0100
> > Luca Weiss <luca.weiss@fairphone.com> wrote:
> >
> >> Add the BAT_THERM channels with millivolt as output, which can then be
> >> used along with information regarding the NTC in the battery, to get the
> >> actual battery temperature.
> >>
> >> A static lookup table in the ADC driver won't work since different
> >> devices have different Ohm and Beta values in their battery NTCs, for
> >> example a NTC can be 10kOhm & B=3435K.
> >>
> >> Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
> > Given this is independent of the following elements other than
> > the dtsi changes, do you want me to pick it up now?
> >
> > You may need to use numeric values in dtsi until the header
> > catches up then chase with a patch flipping to the defines next cycle.
> > That's how we normally avoid that dependency slowing things down.
>
> Sounds good from my side. Thank you!
>
> I think realistically, there's no other option than what's implemented
> in this patch, even if PATCH 2/5 (dt-bindings change for generic-adc) is
> not reviewed yet. But I hope the dt maintainers will be okay with that
> as well.
>
I'm going to hold off on this until patch 2 discussion resolves.
J
> Regards
> Luca
>
> >
> > Thanks,
> >
> > Jonathan
> >
> >> ---
> >> drivers/iio/adc/qcom-spmi-adc5.c | 6 ++++++
> >> drivers/iio/adc/qcom-vadc-common.c | 16 ++++++++++++++++
> >> include/linux/iio/adc/qcom-vadc-common.h | 3 +++
> >> 3 files changed, 25 insertions(+)
> >>
> >> diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c
> >> index d57ba8526e0c..24ac84580570 100644
> >> --- a/drivers/iio/adc/qcom-spmi-adc5.c
> >> +++ b/drivers/iio/adc/qcom-spmi-adc5.c
> >> @@ -542,6 +542,12 @@ 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_30K_PU] = ADC5_CHAN_VOLT("bat_therm_30k_pu", 0,
> >> + SCALE_HW_CALIB_THERM_VOLT)
> >> + [ADC5_BAT_THERM_100K_PU] = ADC5_CHAN_VOLT("bat_therm_100k_pu", 0,
> >> + SCALE_HW_CALIB_THERM_VOLT)
> >> + [ADC5_BAT_THERM_400K_PU] = ADC5_CHAN_VOLT("bat_therm_400k_pu", 0,
> >> + SCALE_HW_CALIB_THERM_VOLT)
> >> [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,
> >> diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c
> >> index b03cf584b165..101b3c724f8d 100644
> >> --- a/drivers/iio/adc/qcom-vadc-common.c
> >> +++ b/drivers/iio/adc/qcom-vadc-common.c
> >> @@ -309,6 +309,10 @@ static int qcom_vadc_scale_hw_calib_therm(
> >> const struct u32_fract *prescale,
> >> const struct adc5_data *data,
> >> u16 adc_code, int *result_mdec);
> >> +static int qcom_vadc_scale_hw_calib_therm_volt(
> >> + const struct u32_fract *prescale,
> >> + const struct adc5_data *data,
> >> + u16 adc_code, int *result_mV);
> >> static int qcom_vadc7_scale_hw_calib_therm(
> >> const struct u32_fract *prescale,
> >> const struct adc5_data *data,
> >> @@ -333,6 +337,7 @@ static int qcom_vadc7_scale_hw_calib_die_temp(
> >> static const struct qcom_adc5_scale_type scale_adc5_fn[] = {
> >> [SCALE_HW_CALIB_DEFAULT] = {qcom_vadc_scale_hw_calib_volt},
> >> [SCALE_HW_CALIB_THERM_100K_PULLUP] = {qcom_vadc_scale_hw_calib_therm},
> >> + [SCALE_HW_CALIB_THERM_VOLT] = {qcom_vadc_scale_hw_calib_therm_volt},
> >> [SCALE_HW_CALIB_XOTHERM] = {qcom_vadc_scale_hw_calib_therm},
> >> [SCALE_HW_CALIB_THERM_100K_PU_PM7] = {
> >> qcom_vadc7_scale_hw_calib_therm},
> >> @@ -583,6 +588,17 @@ static int qcom_vadc_scale_hw_calib_therm(
> >> voltage, result_mdec);
> >> }
> >>
> >> +static int qcom_vadc_scale_hw_calib_therm_volt(
> >> + const struct u32_fract *prescale,
> >> + const struct adc5_data *data,
> >> + u16 adc_code, int *result_mV)
> >> +{
> >> + *result_mV = qcom_vadc_scale_code_voltage_factor(adc_code,
> >> + prescale, data, MICRO / MILLI);
> >> +
> >> + return 0;
> >> +}
> >> +
> >> static int qcom_vadc_scale_hw_calib_die_temp(
> >> const struct u32_fract *prescale,
> >> const struct adc5_data *data,
> >> diff --git a/include/linux/iio/adc/qcom-vadc-common.h b/include/linux/iio/adc/qcom-vadc-common.h
> >> index 3bf4c49726a7..7586016ff14d 100644
> >> --- a/include/linux/iio/adc/qcom-vadc-common.h
> >> +++ b/include/linux/iio/adc/qcom-vadc-common.h
> >> @@ -93,6 +93,8 @@ struct vadc_linear_graph {
> >> * voltage (uV) with hardware applied offset/slope values to adc code.
> >> * @SCALE_HW_CALIB_THERM_100K_PULLUP: Returns temperature in millidegC using
> >> * lookup table. The hardware applies offset/slope to adc code.
> >> + * @SCALE_HW_CALIB_THERM_VOLT: Returns voltage in mV of a temperature channel.
> >> + * The hardware applies offset/slope to adc code.
> >> * @SCALE_HW_CALIB_XOTHERM: Returns XO thermistor voltage in millidegC using
> >> * 100k pullup. The hardware applies offset/slope to adc code.
> >> * @SCALE_HW_CALIB_THERM_100K_PU_PM7: Returns temperature in millidegC using
> >> @@ -114,6 +116,7 @@ enum vadc_scale_fn_type {
> >> SCALE_PMI_CHG_TEMP,
> >> SCALE_HW_CALIB_DEFAULT,
> >> SCALE_HW_CALIB_THERM_100K_PULLUP,
> >> + SCALE_HW_CALIB_THERM_VOLT,
> >> SCALE_HW_CALIB_XOTHERM,
> >> SCALE_HW_CALIB_THERM_100K_PU_PM7,
> >> SCALE_HW_CALIB_PMIC_THERM,
> >>
>
>
>
next prev parent reply other threads:[~2026-11-29 1:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 8:23 [PATCH v4 0/5] Battery temperature ADC plumbing on Qualcomm platforms Luca Weiss
2026-11-17 8:23 ` [PATCH v4 1/5] iio: adc: qcom-spmi-adc5: Add battery thermal channels Luca Weiss
2026-11-22 3:13 ` Jonathan Cameron
2026-11-23 9:17 ` Luca Weiss
2026-11-29 1:24 ` Jonathan Cameron [this message]
2026-11-17 8:23 ` [PATCH v4 2/5] dt-bindings: thermal: generic-adc: Document #io-channel-cells Luca Weiss
2026-11-18 16:42 ` Rob Herring
2026-11-19 9:13 ` Luca Weiss
2026-11-17 8:23 ` [PATCH v4 3/5] thermal/drivers/generic-adc: Allow probe without TZ registration Luca Weiss
2026-11-17 8:23 ` [PATCH v4 4/5] arm64: dts: qcom: pm7250b: Define battery temperature ADC channels Luca Weiss
2026-11-17 8:23 ` [PATCH v4 5/5] arm64: dts: qcom: sm7225-fairphone-fp4: Add battery temperature node Luca Weiss
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=20261129012456.526c5670@jic23-hlaptop \
--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@kernel.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=val@packett.cool \
--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
all inboxes | Powered by JetHome®