Devicetree
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "David Lechner (TI)" <dlechner@baylibre.com>
Cc: "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 6/8] iio: adc: add ti-ads112c14 driver
Date: Mon, 13 Jul 2026 03:11:10 +0100	[thread overview]
Message-ID: <20260713031110.55ab2764@jic23-huawei> (raw)
In-Reply-To: <20260710-iio-adc-ti-ads122c14-v3-6-746d52cbf1d0@baylibre.com>

On Fri, 10 Jul 2026 17:50:39 -0500
"David Lechner (TI)" <dlechner@baylibre.com> wrote:

> Add a new driver for the TI ADS112C14/ADS122C14 ADC chips.
> 
> This first step is adding a very basic driver that only supports power
> on/reset and reading the system monitor channels.
> 
> ADS112C14_SYS_MON_CHANNEL_SHORT is the last channel rather than being in
> logical order by address to keep the voltage channels together and in
> case we find we need to add variants of this channel with different
> voltage reference later.
> 
> Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>
> ---
> 
> A few other notes for review that didn't seem worth putting in the
> commit message:
> * I intentionally did not use bulk regmap because later we may need to
>   get the voltage of the avdd supply.
> * I left some comments in the code where the code might look funny (e.g.
>   to reduce future diff) or does not exactly match the datasheet, in
>   which case later changes will address that.
> 

A couple of really minor comments from a fresh read.

> diff --git a/drivers/iio/adc/ti-ads112c14.c b/drivers/iio/adc/ti-ads112c14.c
> new file mode 100644
> index 000000000000..4d2e7d37be82
> --- /dev/null
> +++ b/drivers/iio/adc/ti-ads112c14.c

...

> +static int ads112c14_read_raw(struct iio_dev *indio_dev,
> +			      struct iio_chan_spec const *chan, int *val,
> +			      int *val2, long mask)

I'd go with a logical split and bring val down a line.
Trivial however. I don't care much!

> +{
> +	struct ads112c14_data *data = iio_priv(indio_dev);

> +	case IIO_CHAN_INFO_SCALE:
> +		if (chan->type == IIO_TEMP) {
> +			/* TS_TC (typical) = 405 uV/°C */
> +			*val = MILLI * vref_uV / 405;
> +			*val2 = fsr_bits;
> +			return IIO_VAL_FRACTIONAL_LOG2;
> +		}
> +
> +		*val = vref_uV / (MICRO / MILLI);
> +		/*
> +		 * Last 3 SYS_MON channels (ext ref, AVDD, DVDD) need to be
> +		 * multiplied by 8 to account for internal attenuation of / 8.
> +		 */

I'd be tempted to make it an explicit match on those 3 channels.  A greater than
when other channels might turn up later for whatever reason seems flaky.

> +		*val2 = fsr_bits - (chan->address >= 3 ? 3 : 0);
> +		return IIO_VAL_FRACTIONAL_LOG2;

...

> +
> +static int ads112c14_probe(struct i2c_client *client)
> +{
> +	struct device *dev = &client->dev;
> +	const struct ads112c14_chip_info *info;

...
> +	/* Write magic reset value (0x16) to ensure known state. */
> +	ret = regmap_write(data->regmap, ADS112C14_REG_CONVERSION_CTRL,
> +			   FIELD_PREP(ADS112C14_CONVERSION_CTRL_RESET, 0x16));
> +	/*
> +	 * The reset may cause an -EREMOTEIO error because of failing to get the
> +	 * I2C ACK at the end of the message. The device still gets reset so it
> +	 * is safe to ignore this error.

Feels like a place where we might not always get the same error as it's surfacing
from each individual i2c controller.

I couldn't immediately spot anything in regmap or i2c function docs about this.
Where is that guarantee coming from?  In other cases we've simply not
checked regmap_write() return values at all.

> +	 */
> +	if (ret == -EREMOTEIO)
> +		ret = 0;
> +	if (ret)
> +		return ret;
> +
> +	fsleep(ADS112C14_DELAY_RESET_US);

...


> +	ret = regmap_read(data->regmap, ADS112C14_REG_DEVICE_ID, &reg_val);
> +	if (ret)
> +		return ret;
> +
> +	if (FIELD_GET(ADS112C14_DEVICE_ID_BITS, reg_val) != info->device_id)
> +		dev_info(dev, "device ID mismatch, expected 0xX%X, got 0x%lX\n",
0xX%X?  (sashiko)

> +			 info->device_id,
> +			 FIELD_GET(ADS112C14_DEVICE_ID_BITS, reg_val));
> +
> +	/* Place in single-shot conversion mode to make ready for raw read. */
Writing a bit called conv mode puts it in single-shot?  (sashiko) 

> +	ret = regmap_set_bits(data->regmap, ADS112C14_REG_DEVICE_CFG,
> +			      ADS112C14_DEVICE_CFG_CONV_MODE);

Thanks,

Jonathan



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

Thread overview: 31+ 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-13  1:32   ` Jonathan Cameron
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-13  1:34   ` Jonathan Cameron
2026-07-13 14:55     ` David Lechner
2026-07-13 15:24       ` Jonathan Cameron
2026-07-13 16:29         ` Conor Dooley
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-13  1:54   ` Jonathan Cameron
2026-07-13 16:28   ` Conor Dooley
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-12 16:30     ` David Lechner
2026-07-13  2:11   ` Jonathan Cameron [this message]
2026-07-13 14:03     ` David Lechner
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
2026-07-13  2:21   ` Jonathan Cameron
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
2026-07-13 19:40     ` David Lechner
2026-07-14  1:04       ` Andy Shevchenko
2026-07-13  2:35   ` Jonathan Cameron

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=20260713031110.55ab2764@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=c-hall@ti.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --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