From: Jonathan Cameron <jic23@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
kernel@pengutronix.de, Geert Uytterhoeven <geert@glider.be>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: enabling a regulator before doing an ADC measurement
Date: Fri, 21 Feb 2020 10:15:54 +0000 [thread overview]
Message-ID: <20200221101554.6b229991@archlinux> (raw)
In-Reply-To: <20200219103235.u2roy3uchlrxqgqw@pengutronix.de>
On Wed, 19 Feb 2020 11:32:35 +0100
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> Hello,
>
> I have a hardware setup that looks as follows:
>
> ,-------------------.
> ,---------. ,---/ -------| current-regulator |
> | ADC | | `-------------------'
> | CH0--------+
> | | |
> `.........' ,-----.
> |PT100|
> `-----'
> |
> ⏚
>
> So the idea is that I enable the regulator and then measure the adc's
> input to determine the resistance of the PT100 and so its temperature.
>
> I wonder if/how I should represent that in my device's device tree. I
> discussed this already a bit with Geert on irc and he came up with
> something like:
>
> adc {
> ...
> channel@0 {
> reg = <0>;
> supply = <&myregulator>;
> };
> };
>
> with the intention that the adc driver enables myregulator before
> starting a measurement on channel 0.
>
> Does this sound sensible? Does something like this maybe even already
> exist and I missed it?
>
> What is a bit special here is that usually a regulator is used to supply
> a device and it's just enabled at probe time (or when the device is
> started to be used) and disabled when done. Here the regulator is
> supposed to be enabled only during a measurement[1] to yield the reference
> current and doesn't supply a device. So maybe better use another
> property name instead of plain "supply", maybe "reference-supply"?
There are similar cases though they tend to be wrapped
up in runtime pm rather than enable and disable each time.
Note this tends not to be the case in 'first' posts of drivers, because
it's a bit fiddly to do. Hence it gets added later if relevant. Often
the regulator being disabled is the reference voltage rather than
the primary power supply.
For this particular case, I'd rather see the pt100 fully represented
(with a tiny driver). That would be a consumer of the ADC channel
and present it's own temperature channel. We do this for things
like analog accelerometers. Then you can control the regulator
either every time.
That way it looks just like a normal device with simple bindings.
The oddity being the necessity to turn the power off after a reading
(and I guess keep it off for some minimum time?)
Thanks,
Jonathan
>
> Best regards
> Uwe
>
> [1] When the current measurement is done, the regulator must be swiched
> off again to not warm up the PT100 and so fudge future measurements.
>
prev parent reply other threads:[~2020-02-21 10:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-19 10:32 enabling a regulator before doing an ADC measurement Uwe Kleine-König
2020-02-21 10:15 ` Jonathan Cameron [this message]
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=20200221101554.6b229991@archlinux \
--to=jic23@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=geert@glider.be \
--cc=kernel@pengutronix.de \
--cc=linux-iio@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).