Sensor value calculation formula

Milton Miller II miltonm at us.ibm.com
Sat Mar 9 03:34:01 AEDT 2019


On  03/06/2019 around 11:36PM in some timezone,  Deng Tyler wrote:

>Hi Emily
>    I found it hardcoded in phosphor-hwmon for different sensor type.
>I think that scale value may be customized for more flexible to fit
>custom platform. 

Assuming that the sensor is exposed though a kernel sysfs hwmon
file, you should be looking to specify a gain for the file in sysfs instead.
Many sense devices already support a scale in the device tree.

>
>Tyler
>Emily Shaffer <emilyshaffer at google.com> 於 2019年3月7日 週四 下午1:22寫道:
>Tyler,
>
>Sorry that I forgot. Yes, the scale is hardcoded for certain sensor
>types, ie voltage is always millivolts. I have asked about this
>before but maybe someone else on the list can give a better answer
>why that's the case.
>

The Linux kernel hwmon API specifies the units for different sensors
as they are exposed in sysfs.  Hence the hwmon to dbus bridge can
hard code the unit for a given type of sensor.

The hwmon API is documented at 
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface
or 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/hwmon/sysfs-interface

The above spec is linked as "HWMon interface" under the headings
"D-BUS" then "Path Definitions" headings in
https://github.com/openbmc/docs/blob/master/sensor-architecture.md

milton

Speaking for myself only.



More information about the openbmc mailing list