summaryrefslogtreecommitdiff
path: root/meta-quanta/meta-gbs/recipes-phosphor/fans
diff options
context:
space:
mode:
Diffstat (limited to 'meta-quanta/meta-gbs/recipes-phosphor/fans')
-rw-r--r--meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/0001-Advertise-failSafePercent-on-dbus.patch117
-rw-r--r--meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/config.json.in (renamed from meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/config-sku.json)12
-rw-r--r--meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-default-speed.sh6
-rw-r--r--meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-reboot-control.service12
-rw-r--r--meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh17
-rw-r--r--meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/phosphor-pid-control.service2
-rw-r--r--meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control_%.bbappend21
7 files changed, 140 insertions, 47 deletions
diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/0001-Advertise-failSafePercent-on-dbus.patch b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/0001-Advertise-failSafePercent-on-dbus.patch
new file mode 100644
index 000000000..050c8b43c
--- /dev/null
+++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/0001-Advertise-failSafePercent-on-dbus.patch
@@ -0,0 +1,117 @@
+From c9b6d4589620275a625121b0ea9f4cc4c93b608a Mon Sep 17 00:00:00 2001
+From: Ian Goegebuer <goegebuer@google.com>
+Date: Tue, 10 Nov 2020 14:20:47 -0800
+Subject: [PATCH] pid/zone: Add the ability to dynamically set the failSafe
+ percent
+
+This change advertises the failSafe percent as a FanSpeed interface
+added to the the FanCtrl object generated by the config.json file.
+
+The target method added in this case sets the failSafePerecent
+out of 255 with 255 being 100% and 0 being 0%.
+
+Example:
+`busctl set-property xyz.openbmc_project.State.FanCtrl /xyz/openbmc_project/settings/fanctrl/zone1 xyz.openbmc_project.Control.FanSpeed Target t 178`
+Sets the failSafePercent to 69.8% or ~70%
+`busctl set-property xyz.openbmc_project.State.FanCtrl /xyz/openbmc_project/settings/fanctrl/zone1 xyz.openbmc_project.Control.FanSpeed Target t 250`
+Sets the failSafePercent to 98%
+
+Signed-off-by: Ian Goegebuer <goegebuer@google.com>
+Change-Id: Ief538d865dc1c654427ed9792496ab368e8803e2
+---
+ pid/zone.cpp | 11 +++++++++++
+ pid/zone.hpp | 11 +++++++++--
+ pid/zone_interface.hpp | 1 +
+ 3 files changed, 21 insertions(+), 2 deletions(-)
+
+diff --git a/pid/zone.cpp b/pid/zone.cpp
+index 441031a..24f6e84 100644
+--- a/pid/zone.cpp
++++ b/pid/zone.cpp
+@@ -120,6 +120,11 @@ double DbusPidZone::getFailSafePercent(void) const
+ return _failSafePercent;
+ }
+
++void DbusPidZone::setFailSafePercent(double newFailSafe)
++{
++ _failSafePercent = newFailSafe;
++}
++
+ double DbusPidZone::getMinThermalSetpoint(void) const
+ {
+ return _minThermalOutputSetPt;
+@@ -459,4 +464,10 @@ bool DbusPidZone::failSafe() const
+ return getFailSafeMode();
+ }
+
++uint64_t DbusPidZone::target(uint64_t value)
++{
++ setFailSafePercent(((double)value / 255) * 100.0);
++ return ModeObject::target(value);
++}
++
+ } // namespace pid_control
+diff --git a/pid/zone.hpp b/pid/zone.hpp
+index 3bea9c2..c0d1d22 100644
+--- a/pid/zone.hpp
++++ b/pid/zone.hpp
+@@ -10,6 +10,7 @@
+
+ #include <sdbusplus/bus.hpp>
+ #include <sdbusplus/server.hpp>
++#include <xyz/openbmc_project/Control/FanSpeed/server.hpp>
+ #include <xyz/openbmc_project/Control/Mode/server.hpp>
+
+ #include <fstream>
+@@ -22,7 +23,9 @@
+ template <typename... T>
+ using ServerObject = typename sdbusplus::server::object::object<T...>;
+ using ModeInterface = sdbusplus::xyz::openbmc_project::Control::server::Mode;
+-using ModeObject = ServerObject<ModeInterface>;
++using FanSpeedInterface =
++ sdbusplus::xyz::openbmc_project::Control::server::FanSpeed;
++using ModeObject = ServerObject<ModeInterface, FanSpeedInterface>;
+
+ namespace pid_control
+ {
+@@ -63,6 +66,7 @@ class DbusPidZone : public ZoneInterface, public ModeObject
+ void clearSetPoints(void) override;
+ void clearRPMCeilings(void) override;
+ double getFailSafePercent(void) const override;
++ void setFailSafePercent(double) override;
+ double getMinThermalSetpoint(void) const;
+
+ Sensor* getSensor(const std::string& name) override;
+@@ -88,6 +92,9 @@ class DbusPidZone : public ZoneInterface, public ModeObject
+ /* Method for reading whether in fail-safe mode over dbus */
+ bool failSafe() const override;
+
++ /* Method for setting the failSafePercent over dbus */
++ uint64_t target(uint64_t value) override;
++
+ private:
+ std::ofstream _log;
+
+@@ -95,7 +102,7 @@ class DbusPidZone : public ZoneInterface, public ModeObject
+ double _maximumSetPoint = 0;
+ bool _manualMode = false;
+ const double _minThermalOutputSetPt;
+- const double _failSafePercent;
++ double _failSafePercent;
+
+ std::set<std::string> _failSafeSensors;
+
+diff --git a/pid/zone_interface.hpp b/pid/zone_interface.hpp
+index a024c0e..9ea89c1 100644
+--- a/pid/zone_interface.hpp
++++ b/pid/zone_interface.hpp
+@@ -70,6 +70,7 @@ class ZoneInterface
+ * fail safe.
+ */
+ virtual double getFailSafePercent() const = 0;
++ virtual void setFailSafePercent(double newFailSafe) = 0;
+
+ /** Return if the zone is set to manual mode. false equates to automatic
+ * mode (the default).
+--
+2.29.2.222.g5d2a92d10f8-goog
diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/config-sku.json b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/config.json.in
index e5040ca1c..21ba368df 100644
--- a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/config-sku.json
+++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/config.json.in
@@ -1,11 +1,11 @@
{
- "version": "R04",
+ "version": "R05",
"sensors": [
{
"name": "fan0",
"type": "fan",
"readPath": "/xyz/openbmc_project/sensors/fan_tach/fan0",
- "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/Fan_0_To_4_Hwmon/pwm1",
+ "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/@Fan_0_To_4_Hwmon@/pwm1",
"min": 0,
"max": 255
},
@@ -13,7 +13,7 @@
"name": "fan1",
"type": "fan",
"readPath": "/xyz/openbmc_project/sensors/fan_tach/fan1",
- "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/Fan_0_To_4_Hwmon/pwm2",
+ "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/@Fan_0_To_4_Hwmon@/pwm2",
"min": 0,
"max": 255
},
@@ -21,7 +21,7 @@
"name": "fb_fan0",
"type": "fan",
"readPath": "/xyz/openbmc_project/sensors/fan_tach/fb_fan0",
- "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/Fan_0_To_4_Hwmon/pwm3",
+ "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/@Fan_0_To_4_Hwmon@/pwm3",
"min": 0,
"max": 255
},
@@ -29,7 +29,7 @@
"name": "fb_fan1",
"type": "fan",
"readPath": "/xyz/openbmc_project/sensors/fan_tach/fb_fan1",
- "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/Fan_0_To_4_Hwmon/pwm4",
+ "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/@Fan_0_To_4_Hwmon@/pwm4",
"min": 0,
"max": 255
},
@@ -37,7 +37,7 @@
"name": "fb_fan2",
"type": "fan",
"readPath": "/xyz/openbmc_project/sensors/fan_tach/fb_fan2",
- "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/Fan_0_To_4_Hwmon/pwm5",
+ "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/@Fan_0_To_4_Hwmon@/pwm5",
"min": 0,
"max": 255
},
diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-default-speed.sh b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-default-speed.sh
deleted file mode 100644
index 22cfab582..000000000
--- a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-default-speed.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-for i in {1..5};
-do
- echo 255 > /sys/class/hwmon/*/pwm${i}
-done
diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-reboot-control.service b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-reboot-control.service
deleted file mode 100644
index 681bdbe00..000000000
--- a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-reboot-control.service
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Set Fan to Default Duty as Rebooting
-DefaultDependencies=no
-After=shutdown.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=true
-ExecStart=/usr/bin/fan-default-speed.sh
-
-[Install]
-WantedBy=shutdown.target
diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh
index 68b699e0f..9617d0da4 100644
--- a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh
+++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh
@@ -1,10 +1,8 @@
#!/bin/bash
-FAN_TABLE_SKU_FILE="/usr/share/swampd/config-sku.json"
-FAN_TABLE_FILE="/usr/share/swampd/config.json"
-
-# determine sku
-cp $FAN_TABLE_SKU_FILE $FAN_TABLE_FILE
+FAN_TABLE_FILE_IN="/usr/share/swampd/config.json.in"
+TEMP_FILE="$(mktemp)"
+cp "$FAN_TABLE_FILE_IN" "$TEMP_FILE"
# wait for fan dbus
mapper wait /xyz/openbmc_project/sensors/fan_tach/fan0
@@ -13,15 +11,16 @@ mapper wait /xyz/openbmc_project/sensors/fan_tach/fb_fan0
mapper wait /xyz/openbmc_project/sensors/fan_tach/fb_fan1
mapper wait /xyz/openbmc_project/sensors/fan_tach/fb_fan2
-/usr/bin/fan-default-speed.sh
-
# generate fan table writePath
-Fan_0_To_4_Hwmon="$(ls -la /sys/class/hwmon |grep pwm | head -n 1| tail -n +1|cut -d '/' -f 9)"
+Fan_0_To_4_Hwmon="$(ls /sys/devices/platform/ahb/ahb\:*/*pwm-fan-controller/hwmon/)"
if [[ "$Fan_0_To_4_Hwmon" != "" ]]; then
- sed -i "s/Fan_0_To_4_Hwmon/$Fan_0_To_4_Hwmon/g" $FAN_TABLE_FILE
+ sed -i "s/@Fan_0_To_4_Hwmon@/$Fan_0_To_4_Hwmon/g" $TEMP_FILE
fi
+# Use shell parameter expansion to trim the ".in" suffix
+mv "$TEMP_FILE" "${FAN_TABLE_FILE_IN%".in"}"
+
# start read margin temp wait
/usr/bin/read-margin-temp-wait.sh &
diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/phosphor-pid-control.service b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/phosphor-pid-control.service
index 33a441928..1c47761f1 100644
--- a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/phosphor-pid-control.service
+++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/phosphor-pid-control.service
@@ -1,6 +1,7 @@
[Unit]
Description=Swampd Margin-based Fan Control Daemon
After=xyz.openbmc_project.Hwmon@-ahb-apb-pwm\x2dfan\x2dcontroller\x40103000.service
+After=xyz.openbmc_project.nvme.manager.service
[Service]
Type=simple
@@ -9,7 +10,6 @@ ExecStart=/usr/bin/swampd
Restart=always
RestartSec=5
StartLimitInterval=0
-ExecStopPost=/usr/bin/fan-default-speed.sh
[Install]
WantedBy=basic.target
diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control_%.bbappend b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control_%.bbappend
index 4f21d3bcf..7acd44c70 100644
--- a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control_%.bbappend
+++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control_%.bbappend
@@ -1,31 +1,26 @@
FILESEXTRAPATHS_prepend_gbs := "${THISDIR}/${PN}:"
-SRC_URI_append_gbs = " file://config-sku.json"
-SRC_URI_append_gbs = " file://fan-table-init.sh"
-SRC_URI_append_gbs = " file://fan-default-speed.sh"
-SRC_URI_append_gbs = " file://phosphor-pid-control.service"
-SRC_URI_append_gbs = " file://fan-reboot-control.service"
+SRC_URI_append_gbs = " file://config.json.in \
+ file://fan-table-init.sh \
+ file://phosphor-pid-control.service \
+ file://0001-Advertise-failSafePercent-on-dbus.patch \
+ "
-FILES_${PN}_append_gbs = " ${datadir}/swampd/config-sku.json"
-FILES_${PN}_append_gbs = " ${bindir}/fan-default-speed.sh"
+FILES_${PN}_append_gbs = " ${datadir}/swampd/config.json.in"
FILES_${PN}_append_gbs = " ${bindir}/fan-table-init.sh"
RDEPENDS_${PN} += "bash"
SYSTEMD_SERVICE_${PN}_append_gbs = " phosphor-pid-control.service"
-SYSTEMD_SERVICE_${PN}_append_gbs = " fan-reboot-control.service"
do_install_append_gbs() {
install -d ${D}/${bindir}
- install -m 0755 ${WORKDIR}/fan-default-speed.sh ${D}/${bindir}
install -m 0755 ${WORKDIR}/fan-table-init.sh ${D}/${bindir}
install -d ${D}${datadir}/swampd
- install -m 0644 -D ${WORKDIR}/config-sku.json \
- ${D}${datadir}/swampd/config-sku.json
+ install -m 0644 -D ${WORKDIR}/config.json.in \
+ ${D}${datadir}/swampd/
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/phosphor-pid-control.service \
${D}${systemd_system_unitdir}
- install -m 0644 ${WORKDIR}/fan-reboot-control.service \
- ${D}${systemd_system_unitdir}
}