sensor: Implement sensor "PRIORITY"

This commit introduces the `xyz.openbmc_project.Common.Priority`
interface to define the priority of sensors. If a sensor's priority
attribute is specified, this interface is created with the 'priority'
attribute. However, if the priority attribute is not specified, this
interface is not created.

The `xyz.openbmc_project.Common.Priority` interface is used to indicate
the priority level of fan sensors. It provides information about
primary and secondary RPM sensors for dual rotor fans, allowing for a
more specific description of the sensor's priority.

phosphor-dbus-interfaces commit:
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/66779

Tested: Build phosphor-hwmon successfully

'''
1. Retrieve the priority level of the secondary sensor

busctl introspect xyz.openbmc_project.Hwmon-xxx .Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_1  xyz.openbmc_project.Common.Priority

NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
.Priority                           property  u         1            emits-change writable

2. If the "PRIORITY" is not specified in the sensor's configuration file

busctl introspect xyz.openbmc_project.Hwmon-xxx .Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_0  xyz.openbmc_project.Common.Priority
NAME TYPE SIGNATURE RESULT/VALUE FLAGS

3. Change the sensor priority

busctl set-property xyz.openbmc_project.Hwmon-xxx.Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_1 xyz.openbmc_project.Common.Priority \
 Priority u 0

busctl introspect xyz.openbmc_project.Hwmon-xxx .Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_1  xyz.openbmc_project.Common.Priority
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
.Priority                           property  u         0            emits-change writable
'''

Change-Id: I7a226cf105756bc32e04f6724428d93e84dfb72a
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
5 files changed
tree: 7b3db87acdcbbeef7ec8b9eb2678b9cada5528a5
  1. msl/
  2. subprojects/
  3. test/
  4. tools/
  5. .clang-format
  6. .gitignore
  7. .lcovrc
  8. .shellcheck
  9. 70-hwmon.rules
  10. 70-iio.rules
  11. average.cpp
  12. average.hpp
  13. env.cpp
  14. env.hpp
  15. fan_pwm.cpp
  16. fan_pwm.hpp
  17. fan_speed.cpp
  18. fan_speed.hpp
  19. gpio_handle.cpp
  20. gpio_handle.hpp
  21. hwmon.cpp
  22. hwmon.hpp
  23. hwmonio.cpp
  24. hwmonio.hpp
  25. interface.hpp
  26. LICENSE
  27. mainloop.cpp
  28. mainloop.hpp
  29. meson.build
  30. meson.options
  31. OWNERS
  32. phosphor-hwmon.conf
  33. readd.cpp
  34. README.iio.md
  35. README.md
  36. sensor.cpp
  37. sensor.hpp
  38. sensorset.cpp
  39. sensorset.hpp
  40. start_hwmon.sh.in
  41. sysfs.cpp
  42. sysfs.hpp
  43. targets.hpp
  44. thresholds.hpp
  45. types.hpp
  46. util.hpp
  47. xyz.openbmc_project.Hwmon@.service
README.md

phosphor-hwmon

Exposes generic hwmon entries as DBus objects. More information can be found at Sensor Architecture

To Build

To build this package, do the following steps:

  1. meson setup build
  2. ninja -C build

To clean the repository run rm -rf build.

D-Bus bus names

To enable the use of Linux features like cgroups prioritization and udev/systemd control, one instance of phosphor-hwmon is intended to be run per hwmon sysfs class instance.

This requires an algorithm for selecting a stable, well-known D-Bus busname.

The algorithm is <PREFIX>-<ID>.Hwmon<N> where PREFIX is a meson configurable prefix (BUSNAME_PREFIX=xyz.openbmc_project by default), ID is either a std::hash of the /sys/devices path backing the hwmon class instance or provided suffix value from the command line, and N is the implemented phosphor-hwmon D-Bus API version.