wspoon: Script to help start MAX31785 hwmon daemon
The phosphor-hwmon instance for the MAX31785 fan controller
chip needs to use different config files based on if the system
is air or water cooled, since different numbers of fans are used.
This script will check the cooling type, link in the correct file
based on that cooling type, and then start the actual hwmon
service.
Tested: Tested as part of end to end testing of this feature.
Change-Id: Ie3efee5d3c6671911b505223152d32f3f5c5c259
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon%.bbappend b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon%.bbappend
index 1b88196..16c8d61 100644
--- a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon%.bbappend
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon%.bbappend
@@ -1,5 +1,9 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+SRC_URI += " \
+ file://start_max31785_hwmon.sh \
+ "
+
WSPOON_CHIPS = " \
i2c@1e78a000/i2c-bus@100/bmp280@77 \
i2c@1e78a000/i2c-bus@100/dps310@76 \
@@ -28,3 +32,8 @@
SYSTEMD_ENVIRONMENT_FILE_max31785-msl += "obmc/hwmon-max31785/wspoon.conf"
SYSTEMD_LINK_max31785-msl += "../phosphor-max31785-msl@.service:${SYSTEMD_DEFAULT_TARGET}.wants/phosphor-max31785-msl@wspoon.service"
+
+do_install_append() {
+ install -d ${D}${bindir}
+ install -m 0755 ${WORKDIR}/start_max31785_hwmon.sh ${D}${bindir}
+}
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon%/start_max31785_hwmon.sh b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon%/start_max31785_hwmon.sh
new file mode 100755
index 0000000..1270427
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon%/start_max31785_hwmon.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Link in the correct MAX31785 phosphor-hwmon config file to use based on the
+# WaterCooled property, and then start the hwmon service.
+
+# $1: The OF_FULLNAME udev attribute for the MAX31785
+
+base="/etc/default/obmc/hwmon/"$1
+target=$base".conf"
+
+service=$(mapper get-service /xyz/openbmc_project/inventory/system/chassis)
+
+if [ $(busctl get-property $service \
+ /xyz/openbmc_project/inventory/system/chassis \
+ xyz.openbmc_project.Inventory.Decorator.CoolingType \
+ WaterCooled | grep true | wc -l) != 0 ];
+then
+ source=$base'_water.conf'
+else
+ source=$base'_air.conf'
+fi
+
+ln -sf $source $target
+
+instance=$(systemd-escape $1)
+systemctl start xyz.openbmc_project.Hwmon@$instance.service