Devicetree
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: "David Lechner (TI)" <dlechner@baylibre.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"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>,
	"Chris Hall" <c-hall@ti.com>, "Patrick Edwards" <pedwards@ti.com>,
	"Kurt Borja" <kuurtb@gmail.com>,
	"Nguyen Minh Tien" <zizuzacker@gmail.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 7/8] iio: adc: ti-ads112c14: implement gain on internal short SYS_MON channel
Date: Sat, 11 Jul 2026 12:11:12 +0300	[thread overview]
Message-ID: <alIIsFyoxYLKKmab@ashevche-desk.local> (raw)
In-Reply-To: <20260710-iio-adc-ti-ads122c14-v3-7-746d52cbf1d0@baylibre.com>

On Fri, Jul 10, 2026 at 05:50:40PM -0500, David Lechner (TI) wrote:
> Implement support for the programmable gain amplifier on the internal
> short SYS_MON channel. This channel is used for calibration, so it is
> useful to be able to set the PGA to the same gain as the external
> channels. The gain setting is implemented via the `_scale` attribute.
> 
> In the future, we may want to support different reference voltages for
> this channel, so the scale_available table is populated during probe
> rather than being a static table.

...

> +/*
> + * Available gains as tenths (e.g. value 5 == 0.5 gain). Indexes correspond to
> + * ADS112C14_GAIN_CFG_GAIN values.
> + */
> +static const u32 ads112c14_pga_gains_x10[] = {
> +	5, 10, 20, 40, 50, 80, 100, 160,
> +	200, 320, 500, 640, 1000, 1280, 2000, 2560,

Since the line lengths are quite different, I would add tail comments with
indices.

	5, 10, 20, 40, 50, 80, 100, 160,		/* 0 -  7 */
	200, 320, 500, 640, 1000, 1280, 2000, 2560,	/* 8 - 15 */

(or in hexadecimal, depending on the datasheet).

> +};

...

>  static int ads112c14_prepare_sys_mon_channel(struct ads112c14_data *data,
>  					     const struct iio_chan_spec *chan)
>  {
> +	u32 gain_val;
>  	int ret;
>  
> -	/* TODO: GAIN is useful for shorted PGA inputs. */
> -	/* All SYS_MON channels use GAIN of 1 to keep it simple. */
> +	/*
> +	 * All SYS_MON channels use GAIN of 1 to keep it simple. Other than
> +	 * the internal short channel, where it is useful in practice.
> +	 */
> +	gain_val = chan->channel == ADS112C14_SYS_MON_CHANNEL_SHORT ?
> +		   data->sys_mon_chan_short_gain_val : 1;

Hmm... What about

	if (chan->channel == ADS112C14_SYS_MON_CHANNEL_SHORT)
		gain_val = FIELD_PREP(ADS112C14_GAIN_CFG_GAIN, data->sys_mon_chan_short_gain_val);
	else
		gain_val = FIELD_PREP_CONST(ADS112C14_GAIN_CFG_GAIN, 1);

>  	ret = regmap_update_bits(data->regmap, ADS112C14_REG_GAIN_CFG,
>  				 ADS112C14_GAIN_CFG_SYS_MON |
>  				 ADS112C14_GAIN_CFG_GAIN,
>  				 FIELD_PREP(ADS112C14_GAIN_CFG_SYS_MON, chan->address) |
> -				 FIELD_PREP(ADS112C14_GAIN_CFG_GAIN, 1));
> +				 FIELD_PREP(ADS112C14_GAIN_CFG_GAIN, gain_val));

				 gain_val);

On the second thought this might require to have a separate mon_val to make
this consistent. Up to you.

>  	if (ret)
>  		return ret;

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2026-07-11  9:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 22:50 [PATCH v3 0/8] iio: adc: new ti-ads112c14 driver David Lechner
2026-07-10 22:50 ` [PATCH v3 1/8] dt-bindings: iio: adc: Add reference-sources property David Lechner
2026-07-10 22:50 ` [PATCH v3 2/8] dt-bindings: iio: adc: Add excitation current sources properties David Lechner
2026-07-10 22:50 ` [PATCH v3 3/8] dt-bindings: iio: adc: Add burn-out current properties David Lechner
2026-07-10 22:50 ` [PATCH v3 4/8] dt-bindings: iio: adc: add input-chopping property David Lechner (TI)
2026-07-10 22:50 ` [PATCH v3 5/8] dt-bindings: iio: adc: add ti,ads122c14 David Lechner (TI)
2026-07-10 22:59   ` sashiko-bot
2026-07-10 23:12   ` David Lechner
2026-07-10 22:50 ` [PATCH v3 6/8] iio: adc: add ti-ads112c14 driver David Lechner (TI)
2026-07-10 23:00   ` sashiko-bot
2026-07-12  9:42   ` Andy Shevchenko
2026-07-10 22:50 ` [PATCH v3 7/8] iio: adc: ti-ads112c14: implement gain on internal short SYS_MON channel David Lechner (TI)
2026-07-10 23:04   ` sashiko-bot
2026-07-11  9:11   ` Andy Shevchenko [this message]
2026-07-10 22:50 ` [PATCH v3 8/8] iio: adc: ti-ads112c14: add measurement channel support David Lechner (TI)
2026-07-10 23:08   ` sashiko-bot
2026-07-11 13:00   ` Andy Shevchenko

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=alIIsFyoxYLKKmab@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=c-hall@ti.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuurtb@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=pedwards@ti.com \
    --cc=robh@kernel.org \
    --cc=zizuzacker@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