Linux IIO development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Andrei Stancovici <andrei.stancovici@analog.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Liam Beguin" <liambeguin@gmail.com>,
	linux@analog.com, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] iio: adc: ltc2497: add LTC2499 internal temperature channel
Date: Thu, 3 Sep 2026 09:45:21 +0300	[thread overview]
Message-ID: <apkXgcoYFiR4d0w9@ashevche-desk.local> (raw)
In-Reply-To: <20260902064415.132588-3-andrei.stancovici@analog.com>

On Wed, Sep 02, 2026 at 09:44:11AM +0300, Andrei Stancovici wrote:
> The LTC2499 has an internal PTAT (proportional to absolute temperature)
> sensor that is activated by a second I2C configuration byte (EN2 | IM).
> Expose it as an IIO_TEMP channel providing raw, scale and offset so the
> standard IIO formula
> 
> 	T[m°C] = (raw + offset) * scale
> 
> reconstructs the temperature.
> 
> The PTAT sensor yields the absolute temperature as
> 
> 	T(K) = DATAOUT24 * Vref / 1570		(Vref in volts)
> 
> The raw value exported here is sign-extended and normalised to
> 2^(resolution + 1) == 2^25, i.e. raw = 2 * DATAOUT24, so on the IIO
> milli-degree-Celsius convention
> 
> 	scale[m°C/LSB] = Vref_uV / 3140000
> 	offset         = -273150 * 3140000 / Vref_uV
> 
> The scale and offset are derived from the reference voltage returned by
> regulator_get_voltage(); its error is propagated as before, so a board
> that fails to describe vref-supply gets a clear read error instead of a
> silently wrong temperature. No board-specific reference value is assumed
> in the driver.
> 
> The single temperature channel is appended as the last entry of the
> shared channel array and excluded via num_channels for parts without an
> internal sensor, so the existing LTC2497 channel layout and device name
> are unchanged.
> 
> The LTC2499 latches its converter configuration from the second command
> byte and only re-evaluates it when that byte has EN2 set. EN2 | IM
> selects the internal temperature sensor. Because a single-byte command,
> or a second byte with EN2 = 0, means "keep previous", a one-byte channel
> select cannot pull the device back out of temperature mode: after a
> temperature read every subsequent voltage read would keep returning the
> PTAT result instead of the selected input. Temperature support is
> therefore only correct if the voltage path also emits a second command
> byte that re-selects an external input.
> 
> Send two-byte commands for all conversions on parts that have the sensor
> (has_temp):
> 
> 	temperature:	EN2 | IM
> 	voltage:	EN2			(IM = 0 -> external input)
> 
> The LTC2497 and LTC2496, which lack the second-byte mechanism, keep using
> the original single-byte channel select and are unchanged.

Looks good to me,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

...

>  struct ltc2497_chip_info {
>  	u32 resolution;
> +	bool has_temp;
>  	const char *name;

While `pahole` probably has found no issues with this layout, I would still
move boolean to be the last member here.

>  };

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-09-03  6:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02  6:44 [PATCH v3 0/3] iio: adc: add LTC2499 features support Andrei Stancovici
2026-09-02  6:44 ` [PATCH v3 1/3] dt-bindings: iio: adc: lltc,ltc2497: add LTC2499 to title Andrei Stancovici
2026-09-02  6:44 ` [PATCH v3 2/3] iio: adc: ltc2497: add LTC2499 internal temperature channel Andrei Stancovici
2026-09-03  6:45   ` Andy Shevchenko [this message]
2026-09-02  6:44 ` [PATCH v3 3/3] iio: adc: ltc2497: add 2x conversion speed mode Andrei Stancovici
2026-09-03  6:52   ` 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=apkXgcoYFiR4d0w9@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andrei.stancovici@analog.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=liambeguin@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    /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