From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Jishnu Prakash" <jishnu.prakash@oss.qualcomm.com>,
"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 3/7] iio: adc: qcom-spmi-adc5-gen3: Add support for QCOM PMIC5 Gen4 ADC
Date: Sat, 21 Nov 2026 20:29:50 +0000 [thread overview]
Message-ID: <20261121202950.7dc141dd@jic23-hlaptop> (raw)
In-Reply-To: <awAdgHggEZtBnyYK@ashevche-desk.local>
On Fri, 20 Nov 2026 12:14:24 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Fri, Nov 20, 2026 at 02:49:43PM +0530, Jishnu Prakash 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, so the maximum value of
> > these measurements needs to be updated for Gen4. Add a new scaling
> > function for thermistor channels which use this type of conversion.
> >
> > It is possible that the master PMIC has ADC of one generation and it needs
> > to communicate with another PMIC with ADC of a different generation. For
> > example, on SM8750, PMK8550 is the master PMIC with Gen3 ADC and it
> > communicates with PMIH0108, which has Gen4 ADC. Add a new DT property
> > "qcom,adc5-gen4" to distinguish Gen4 channels under a Gen3 master, to
> > ensure that their conversions are handled correctly.
> >
> > 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.
>
> ...
>
> > - /* Write SID */
> > - buf[0] = FIELD_PREP(ADC5_GEN3_SID_MASK, prop->sid);
> > + /* Write SID and bus_id*/
>
> Missed space.
>
> > + buf[0] = FIELD_PREP(ADC5_GEN4_BUS_INDEX_MASK, prop->bus_index) |
> > + FIELD_PREP(ADC5_GEN4_SID_MASK, prop->sid);
>
> ...
>
> > -static const struct adc5_data adc5_gen3_data_pmic = {
> > - .full_scale_code_volt = 0x70e4,
> > - .adc_chans = adc5_gen3_chans_pmic,
> > - .info = &adc5_gen3_info,
> > - .decimation = (unsigned int [ADC5_DECIMATION_SAMPLES_MAX])
> > - { 85, 340, 1360 },
> > - .hw_settle_1 = (unsigned int [VADC_HW_SETTLE_SAMPLES_MAX])
> > - { 15, 100, 200, 300,
> > - 400, 500, 600, 700,
> > - 1000, 2000, 4000, 8000,
> > - 16000, 32000, 64000, 128000 },
> > -};
>
> Seems like this is existing piece and you moved it up. Please, split that part
> to a separate prerequisite patch.
>
> ...
>
> > +static int qcom_adc5_gen4_scale_hw_calib_therm(
> > + const struct u32_fract *prescale,
> > + const struct adc5_data *data,
> > + u16 adc_code, int *result_mdec)
>
> Even if the rest of the file uses this ugly indentation, correct it for a new code.
> Not a problem if lines will be a bit longer.
>
> > +{
> > + s64 resistance = adc_code;
> > + int ret, result;
> > +
> > + if (adc_code >= RATIO_MAX_ADC5_GEN4)
> > + return -EINVAL;
> > +
> > + /* (ADC code * R_PULLUP (100Kohm)) / (full_scale_code - ADC code)*/
>
> Again, missing space.
>
> > + resistance *= R_PU_100K;
> > + resistance = div64_s64(resistance, RATIO_MAX_ADC5_GEN4 - adc_code);
>
> I would put it like this
>
> resistance = div64_s64(adc_code * R_PU_100K, RATIO_MAX_ADC5_GEN4 - adc_code);
>
Good.
> OR this
>
> resistance =
> div64_s64(adc_code * R_PU_100K, RATIO_MAX_ADC5_GEN4 - adc_code);
>
> (but it still uses two lines, so I find the previous one slightly better).
Not good.
1st one! The second option triggers my ugly detector.
This is definitely a place where slightly long lines make nicer looking
code.
>
> > + ret = qcom_vadc_map_voltage_temp(adcmap7_100k, ARRAY_SIZE(adcmap7_100k),
> > + resistance, &result);
> > + if (ret)
> > + return ret;
> > +
> > + *result_mdec = result;
> > +
> > + return 0;
> > +}
>
next prev parent reply other threads:[~2026-11-21 20:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 9:19 [PATCH v2 0/7] Add support for QCOM SPMI PMIC5 Gen4 ADC 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-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 [this message]
2026-11-21 20:58 ` Jonathan Cameron
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-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=20261121202950.7dc141dd@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=amitk@kernel.org \
--cc=andriy.shevchenko@intel.com \
--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=jishnu.prakash@oss.qualcomm.com \
--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