All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bitan Biswas <bbiswas@nvidia.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "khali@linux-fr.org" <khali@linux-fr.org>,
	"guenter.roeck@ericsson.com" <guenter.roeck@ericsson.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	Stephen Warren <swarren@nvidia.com>
Subject: Re: [lm-sensors] hwmon : raw reading -> temperature conversion
Date: Mon, 13 Aug 2012 07:39:03 +0000	[thread overview]
Message-ID: <5028AC47.8080108@nvidia.com> (raw)
In-Reply-To: <20120810184326.GA4625@roeck-us.net>

Hi Guenter,

  Thank you for the guidance.

>>
>> But looking at the hwmon linux documentation, seems the sensor
>> kernel drivers should report only raw readings.
>> The raw readings can be converted into required output,
>> e.g. temperature in this case, by respective user space implementation.
>>
> "raw" means the value as reported to the sensor. For example, for an ADC, the
> raw value means the voltage in mV as seen on the sensor's input pins. This
> voltage is the voltage to be reported. Converting it to a "real" voltage as,
> typically, determined by a set of voltage divider resistors should be done in
> user space.
>
> For temperature sensors this is a bit more tricky. Presumably you get readings
> from a thermistor or similar. The hwmon subsystem includes a driver for NTC
> thermistors; maybe you can get some ideas from it. Maybe you can even use
> it and/or extend it to support your hardware.

The sensor is Tegra3 integrated thermal sensor. It is not a thermistor, 
but gives a counter reading. The expressions to convert the counter to 
temperature use characterization data and certain initialization 
parameters. I looked at the NTC thermistor driver. The expressions I 
need to use to convert counter value to temperature would need floating 
point arguments.

>
>> However because of my driver clients being in kernel space, I am
>> thinking of doing fixed point calculations in the sensor driver
>> and get the temperature corresponding to raw sensor readings.
>>
>> Please let me know if this a correct approach?
>>
> Question is really what chip you are using, and how exactly your hardware looks
> like. Do you use a generic ADC ? If so, is it already supported in the kernel ?
> How are the thermistor readings converted and reported to SW ?

I think this is somewhat like an ADC but I need to implement the 
expressions to convert the counter readings to temperature. Using fixed 
point approximations instead of the floating point operands, the 
expressions can be implemented in kernel. The expressions to be used for 
calculation are specific to chip and I could not find a existing driver 
that could support this sensor.

  There are expressions that can convert the counter readings to 
temperature and vice-versa.
1) SW could call the driver callbacks and get the temperature.
2) SW could also request temperature thresholds to be configured for 
thermal monitoring.

The software that may need to use the temperature are some other kernel 
drivers.

Is it not allowed to implement the counter raw readings to temperature 
in the hwmon sensor driver?


>
> Thanks,
> Guenter
>


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

WARNING: multiple messages have this Message-ID (diff)
From: Bitan Biswas <bbiswas@nvidia.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "khali@linux-fr.org" <khali@linux-fr.org>,
	"guenter.roeck@ericsson.com" <guenter.roeck@ericsson.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	Stephen Warren <swarren@nvidia.com>
Subject: Re: [lm-sensors] hwmon : raw reading -> temperature conversion
Date: Mon, 13 Aug 2012 12:57:03 +0530	[thread overview]
Message-ID: <5028AC47.8080108@nvidia.com> (raw)
In-Reply-To: <20120810184326.GA4625@roeck-us.net>

Hi Guenter,

  Thank you for the guidance.

>>
>> But looking at the hwmon linux documentation, seems the sensor
>> kernel drivers should report only raw readings.
>> The raw readings can be converted into required output,
>> e.g. temperature in this case, by respective user space implementation.
>>
> "raw" means the value as reported to the sensor. For example, for an ADC, the
> raw value means the voltage in mV as seen on the sensor's input pins. This
> voltage is the voltage to be reported. Converting it to a "real" voltage as,
> typically, determined by a set of voltage divider resistors should be done in
> user space.
>
> For temperature sensors this is a bit more tricky. Presumably you get readings
> from a thermistor or similar. The hwmon subsystem includes a driver for NTC
> thermistors; maybe you can get some ideas from it. Maybe you can even use
> it and/or extend it to support your hardware.

The sensor is Tegra3 integrated thermal sensor. It is not a thermistor, 
but gives a counter reading. The expressions to convert the counter to 
temperature use characterization data and certain initialization 
parameters. I looked at the NTC thermistor driver. The expressions I 
need to use to convert counter value to temperature would need floating 
point arguments.

>
>> However because of my driver clients being in kernel space, I am
>> thinking of doing fixed point calculations in the sensor driver
>> and get the temperature corresponding to raw sensor readings.
>>
>> Please let me know if this a correct approach?
>>
> Question is really what chip you are using, and how exactly your hardware looks
> like. Do you use a generic ADC ? If so, is it already supported in the kernel ?
> How are the thermistor readings converted and reported to SW ?

I think this is somewhat like an ADC but I need to implement the 
expressions to convert the counter readings to temperature. Using fixed 
point approximations instead of the floating point operands, the 
expressions can be implemented in kernel. The expressions to be used for 
calculation are specific to chip and I could not find a existing driver 
that could support this sensor.

  There are expressions that can convert the counter readings to 
temperature and vice-versa.
1) SW could call the driver callbacks and get the temperature.
2) SW could also request temperature thresholds to be configured for 
thermal monitoring.

The software that may need to use the temperature are some other kernel 
drivers.

Is it not allowed to implement the counter raw readings to temperature 
in the hwmon sensor driver?


>
> Thanks,
> Guenter
>


  reply	other threads:[~2012-08-13  7:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 14:18 hwmon : raw reading -> temperature conversion Bitan Biswas
2012-08-10 14:30 ` [lm-sensors] " Bitan Biswas
2012-08-10 18:43 ` Guenter Roeck
2012-08-10 18:43   ` Guenter Roeck
2012-08-13  7:27   ` Bitan Biswas [this message]
2012-08-13  7:39     ` Bitan Biswas
2012-08-13 13:44     ` Guenter Roeck
2012-08-13 13:44       ` Guenter Roeck

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=5028AC47.8080108@nvidia.com \
    --to=bbiswas@nvidia.com \
    --cc=guenter.roeck@ericsson.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    --cc=swarren@nvidia.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 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.