From: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Amit Kucheria" <amitk@kernel.org>,
"Thara Gopinath" <thara.gopinath@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Daniel Lezcano" <daniel.lezcano@kernel.org>,
"Zhang Rui" <rui.zhang@intel.com>,
"Lukasz Luba" <lukasz.luba@arm.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-pm@vger.kernel.org,
"Kamal Wadhwa" <kamal.wadhwa@oss.qualcomm.com>,
"Anjelique Melendez" <anjelique.melendez@oss.qualcomm.com>,
"Manaf Meethalavalappu Pallikunhi"
<manaf.pallikunhi@oss.qualcomm.com>,
"Priyansh Jain" <priyansh.jain@oss.qualcomm.com>
Subject: Re: [PATCH v2 4/7] thermal: qcom: qcom-spmi-adc-tm5-gen3: Add support for QCOM PMIC5 Gen4 ADC
Date: Sun, 29 Nov 2026 19:42:54 +0530 [thread overview]
Message-ID: <d0e717d6-d315-4ca9-af1c-1e7f8309b4c7@oss.qualcomm.com> (raw)
In-Reply-To: <20261121210747.0ab59a9f@jic23-hlaptop>
Hi Jonathan,
On 11/22/2026 2:37 AM, Jonathan Cameron wrote:
> On Fri, 20 Nov 2026 14:49:44 +0530
> Jishnu Prakash <jishnu.prakash@oss.qualcomm.com> wrote:
>
>> PMIC5 Gen4 ADC is similar to PMIC5 Gen3 ADC, with several changes made
>> for improved performance, mostly at the hardware level.
>>
>> One significant software change is that ratiometric conversion resolution
>> has been increased from 14 bits to 16 bits. Add a reverse scaling function
>> for Gen4 ADC thermistor channels.
>>
>> In the latest PMIC arbiter version (v8), there can be up to 4 buses
>> under the PMIC arbiter and 32 PMICs under each bus. In order to
>> support communication between ADC on the master PMIC and ADCs on any
>> of the other PMICs, a field of width 2 bits is added for bus index
>> and the bits for SID are extended from 4 to 5 bits, in the SID
>> register. Add support for this.
>>
>> Co-developed-by: Anjelique Melendez <anjelique.melendez@oss.qualcomm.com>
>> Signed-off-by: Anjelique Melendez <anjelique.melendez@oss.qualcomm.com>
>> Signed-off-by: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
>> ---
>> drivers/iio/adc/qcom-vadc-common.c | 11 +++++++++++
>> drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c | 19 ++++++++++++++-----
>> include/linux/iio/adc/qcom-vadc-common.h | 2 ++
>> 3 files changed, 27 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c
>> index 5c4052f6f24f..779c2a66a858 100644
>> --- a/drivers/iio/adc/qcom-vadc-common.c
>> +++ b/drivers/iio/adc/qcom-vadc-common.c
>> @@ -718,6 +718,17 @@ u16 qcom_adc_tm5_gen2_temp_res_scale(int temp)
>> }
>> EXPORT_SYMBOL(qcom_adc_tm5_gen2_temp_res_scale);
>>
>> +u16 qcom_adc_tm5_gen4_temp_res_scale(int temp)
>> +{
>> + s64 resistance;
>> +
>> + resistance = qcom_vadc_map_temp_voltage(adcmap7_100k,
>> + ARRAY_SIZE(adcmap7_100k), temp);
>> +
>> + return div64_s64(resistance * RATIO_MAX_ADC5_GEN4, resistance + R_PU_100K);
>
> If you were keeping this (See below) I'd have a helper that does the maths
> called by both the gen2 and gen4 versions. I think it just has that multiplier
> different.
With the changes in struct adc5_data I mentioned in the patch 3 thread,
we can eliminate this function, reusing the existing qcom_adc_tm5_gen2_temp_res_scale
with an additional input argument.
>
>> +}
>> +EXPORT_SYMBOL(qcom_adc_tm5_gen4_temp_res_scale);
>> +
>> int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype,
>> unsigned int prescale_ratio,
>> const struct adc5_data *data,
>> diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c
>> index 910b241fa94d..aeaf13f4fc66 100644
>> --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c
>> +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c
>> @@ -207,15 +207,23 @@ static int adc_tm5_gen3_disable_channel(struct adc_tm5_gen3_channel_props *prop)
>> ADC5_GEN3_CONV_REQ, &val, sizeof(val));
>> }
>>
>> +typedef u16 (*temp_res_scale)(int temp);
>> +
>> static int adc_tm5_gen3_configure(struct adc_tm5_gen3_channel_props *prop,
>> int low_temp, int high_temp)
>> {
>> struct adc_tm5_gen3_chip *adc_tm5 = prop->chip;
>> u8 buf[ADC_TM5_GEN3_CONFIG_REGS];
>> + temp_res_scale tm_scal_fn;
>> u8 conv_req;
>> u16 adc_code;
>> int ret;
>>
>> + if (prop->common_props.generation == ADC5_GEN4)
>> + tm_scal_fn = qcom_adc_tm5_gen4_temp_res_scale;
>> + else
>> + tm_scal_fn = qcom_adc_tm5_gen2_temp_res_scale;
>
> A little messy patch ordering wise, but I think those should
> be function pointers in common_props.data and set in the adc
> driver (where it currently sets generation).
>
> That will put all the information in one place rather
> than a mix of data and stuff patched in the code in various
> other places.
>
> For anyone not reading review of previous patch, I want that
> generation value to go away.
>
> However, the two callbacks differ (I think) in only one value.
> Just put that value in the data instead of having two callbacks
> and add a parameter to the function to pass it in.
With the change in struct adc5_data, we can differentiate Gen3
and Gen4 based on the new raw code field added, and that same value
can also be passed as a parameter to qcom_adc_tm5_gen2_temp_res_scale()
as you mentioned here.
Thanks,
Jishnu
>
>> +
>> ret = adc5_gen3_poll_wait_hs(adc_tm5->dev_data, prop->sdam_index);
>> if (ret < 0)
>> return ret;
>> @@ -225,8 +233,9 @@ static int adc_tm5_gen3_configure(struct adc_tm5_gen3_channel_props *prop,
>> if (ret < 0)
>> return ret;
>>
next prev parent reply other threads:[~2026-11-29 14:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 9:19 [PATCH v2 0/7] Add support for QCOM SPMI " Jishnu Prakash
2026-11-20 9:19 ` [PATCH v2 1/7] dt-bindings: iio: adc: Add "qcom,adc5-gen4" property for ADC channels Jishnu Prakash
2026-11-21 20:27 ` Jonathan Cameron
2026-11-29 14:11 ` Jishnu Prakash
2026-11-20 9:19 ` [PATCH v2 2/7] iio: adc: qcom-adc5-gen3: Explicitly assign enum values used in hardware Jishnu Prakash
2026-11-20 9:19 ` [PATCH v2 3/7] iio: adc: qcom-spmi-adc5-gen3: Add support for QCOM PMIC5 Gen4 ADC Jishnu Prakash
2026-11-20 10:14 ` Andy Shevchenko
2026-11-21 20:29 ` Jonathan Cameron
2026-11-29 14:12 ` Jishnu Prakash
2026-11-29 19:14 ` Jonathan Cameron
2026-11-21 20:58 ` Jonathan Cameron
2026-11-29 14:12 ` Jishnu Prakash
2026-11-20 9:19 ` [PATCH v2 4/7] thermal: qcom: qcom-spmi-adc-tm5-gen3: " Jishnu Prakash
2026-11-21 21:07 ` Jonathan Cameron
2026-11-29 14:12 ` Jishnu Prakash [this message]
2026-11-20 9:19 ` [PATCH v2 5/7] iio: adc: qcom-spmi-adc5-gen3: Remove Gen3 virtual channel macros Jishnu Prakash
2026-11-21 21:08 ` Jonathan Cameron
2026-11-20 9:19 ` [PATCH v2 6/7] dt-bindings: iio: adc: Add support for QCOM PMIC5 Gen4 ADC Jishnu Prakash
2026-11-21 21:10 ` Jonathan Cameron
2026-11-20 9:19 ` [PATCH v2 7/7] iio: adc: qcom-spmi-adc5-gen3: Add support for Gen4 ADC master PMICs Jishnu Prakash
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=d0e717d6-d315-4ca9-af1c-1e7f8309b4c7@oss.qualcomm.com \
--to=jishnu.prakash@oss.qualcomm.com \
--cc=amitk@kernel.org \
--cc=andy@kernel.org \
--cc=anjelique.melendez@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=kamal.wadhwa@oss.qualcomm.com \
--cc=krzk+dt@kernel.org \
--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=manaf.pallikunhi@oss.qualcomm.com \
--cc=nuno.sa@analog.com \
--cc=priyansh.jain@oss.qualcomm.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
--cc=thara.gopinath@gmail.com \
/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®