All of lore.kernel.org
 help / color / mirror / Atom feed
* enabling a regulator before doing an ADC measurement
@ 2020-02-19 10:32 Uwe Kleine-König
  2020-02-21 10:15 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2020-02-19 10:32 UTC (permalink / raw)
  To: Jonathan Cameron, Rob Herring, Frank Rowand
  Cc: kernel, Geert Uytterhoeven, linux-iio, devicetree

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"?

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.

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: enabling a regulator before doing an ADC measurement
  2020-02-19 10:32 enabling a regulator before doing an ADC measurement Uwe Kleine-König
@ 2020-02-21 10:15 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-02-21 10:15 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Rob Herring, Frank Rowand, kernel, Geert Uytterhoeven, linux-iio,
	devicetree

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.
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-21 10:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.