diff options
9 files changed, 696 insertions, 0 deletions
diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/config.json b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/config.json new file mode 100644 index 000000000..e28ac9c8f --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/config.json @@ -0,0 +1,238 @@ +{ + "version" : "R00", + "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", + "min": 0, + "max": 255 + }, + { + "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", + "min": 0, + "max": 255 + }, + { + "name": "fan2", + "type": "fan", + "readPath": "/xyz/openbmc_project/sensors/fan_tach/fan2", + "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/Fan_0_To_4_Hwmon/pwm3", + "min": 0, + "max": 255 + }, + { + "name": "fan3", + "type": "fan", + "readPath": "/xyz/openbmc_project/sensors/fan_tach/fan3", + "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/Fan_0_To_4_Hwmon/pwm4", + "min": 0, + "max": 255 + }, + { + "name": "fan4", + "type": "fan", + "readPath": "/xyz/openbmc_project/sensors/fan_tach/fan4", + "writePath": "/sys/devices/platform/ahb/ahb:apb/f0103000.pwm-fan-controller/hwmon/Fan_0_To_4_Hwmon/pwm5", + "min": 0, + "max": 255 + }, + { + "name": "fleeting0", + "type": "margin", + "readPath": "/xyz/openbmc_project/extsensors/margin/fleeting0", + "writePath": "", + "min": 0, + "max": 0, + "ignoreDbusMinMax": true, + "timeout": 0 + }, + { + "name": "fleeting1", + "type": "margin", + "readPath": "/xyz/openbmc_project/extsensors/margin/fleeting1", + "writePath": "", + "min": 0, + "max": 0, + "ignoreDbusMinMax": true, + "timeout": 0 + }, + { + "name": "real_fleeting0", + "type": "margin", + "readPath": "/xyz/openbmc_project/extsensors/margin/real_fleeting0", + "writePath": "", + "min": 0, + "max": 0, + "ignoreDbusMinMax": true, + "timeout": 0 + }, + { + "name": "real_fleeting1", + "type": "margin", + "readPath": "/xyz/openbmc_project/extsensors/margin/real_fleeting1", + "writePath": "", + "min": 0, + "max": 0, + "ignoreDbusMinMax": true, + "timeout": 0 + } + ], + "zones" : [ + { + "id": 0, + "minThermalOutput": 0.0, + "failsafePercent": 100.0, + "pids": [ + { + "name": "fan0", + "type": "fan", + "inputs": ["fan0"], + "setpoint": 0.0, + "pid": { + "samplePeriod": 0.1, + "proportionalCoeff": 0.0, + "integralCoeff": 0.0, + "feedFwdOffsetCoeff": 0.0, + "feedFwdGainCoeff": 0.0056, + "integralLimit_min": 0.0, + "integralLimit_max": 0.0, + "outLim_min": 20.0, + "outLim_max": 100.0, + "slewNeg": 0.0, + "slewPos": 0.0 + } + }, + { + "name": "fan1", + "type": "fan", + "inputs": ["fan1"], + "setpoint": 0.0, + "pid": { + "samplePeriod": 0.1, + "proportionalCoeff": 0.0, + "integralCoeff": 0.0, + "feedFwdOffsetCoeff": 0.0, + "feedFwdGainCoeff": 0.0056, + "integralLimit_min": 0.0, + "integralLimit_max": 0.0, + "outLim_min": 20.0, + "outLim_max": 100.0, + "slewNeg": 0.0, + "slewPos": 0.0 + } + }, + { + "name": "real_fleeting0", + "type": "margin", + "inputs": ["real_fleeting0"], + "setpoint": 10.0, + "pid": { + "samplePeriod": 1.0, + "proportionalCoeff": 225.0, + "integralCoeff": 45.0, + "feedFwdOffsetCoeff": 0.0, + "feedFwdGainCoeff": 0.0, + "integralLimit_min": 2500.0, + "integralLimit_max": 18000.0, + "outLim_min": 2500.0, + "outLim_max": 18000.0, + "slewNeg": 0.0, + "slewPos": 0.0, + "positiveHysteresis": 0.0, + "negativeHysteresis": 0.0 + } + } + ] + }, + { + "id": 1, + "minThermalOutput": 0.0, + "failsafePercent": 100.0, + "pids": [ + { + "name": "fan2", + "type": "fan", + "inputs": ["fan2"], + "setpoint": 0.0, + "pid": { + "samplePeriod": 0.1, + "proportionalCoeff": 0.0, + "integralCoeff": 0.0, + "feedFwdOffsetCoeff": 0.0, + "feedFwdGainCoeff": 0.0056, + "integralLimit_min": 0.0, + "integralLimit_max": 0.0, + "outLim_min": 20.0, + "outLim_max": 100.0, + "slewNeg": 0.0, + "slewPos": 0.0 + } + }, + { + "name": "fan3", + "type": "fan", + "inputs": ["fan3"], + "setpoint": 0.0, + "pid": { + "samplePeriod": 0.1, + "proportionalCoeff": 0.0, + "integralCoeff": 0.0, + "feedFwdOffsetCoeff": 0.0, + "feedFwdGainCoeff": 0.0056, + "integralLimit_min": 0.0, + "integralLimit_max": 0.0, + "outLim_min": 20.0, + "outLim_max": 100.0, + "slewNeg": 0.0, + "slewPos": 0.0 + } + }, + { + "name": "fan4", + "type": "fan", + "inputs": ["fan4"], + "setpoint": 0.0, + "pid": { + "samplePeriod": 0.1, + "proportionalCoeff": 0.0, + "integralCoeff": 0.0, + "feedFwdOffsetCoeff": 0.0, + "feedFwdGainCoeff": 0.0056, + "integralLimit_min": 0.0, + "integralLimit_max": 0.0, + "outLim_min": 20.0, + "outLim_max": 100.0, + "slewNeg": 0.0, + "slewPos": 0.0 + } + }, + { + "name": "real_fleeting1", + "type": "margin", + "inputs": ["real_fleeting1"], + "setpoint": 10.0, + "pid": { + "samplePeriod": 1.0, + "proportionalCoeff": 225.0, + "integralCoeff": 45.0, + "feedFwdOffsetCoeff": 0.0, + "feedFwdGainCoeff": 0.0, + "integralLimit_min": 2500.0, + "integralLimit_max": 18000.0, + "outLim_min": 2500.0, + "outLim_max": 18000.0, + "slewNeg": 0.0, + "slewPos": 0.0, + "positiveHysteresis": 0.0, + "negativeHysteresis": 0.0 + } + } + ] + } + ] +} 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 new file mode 100644 index 000000000..22cfab582 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-default-speed.sh @@ -0,0 +1,6 @@ +#!/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 new file mode 100644 index 000000000..681bdbe00 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-reboot-control.service @@ -0,0 +1,12 @@ +[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 new file mode 100644 index 000000000..06914afd0 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/fan-table-init.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# wait for fan dbus +mapper wait /xyz/openbmc_project/sensors/fan_tach/fan0 +mapper wait /xyz/openbmc_project/sensors/fan_tach/fan1 +mapper wait /xyz/openbmc_project/sensors/fan_tach/fan2 +mapper wait /xyz/openbmc_project/sensors/fan_tach/fan3 +mapper wait /xyz/openbmc_project/sensors/fan_tach/fan4 + +/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)" + +if [[ "$Fan_0_To_4_Hwmon" != "" ]] +then + sed -i "s/Fan_0_To_4_Hwmon/$Fan_0_To_4_Hwmon/g" /usr/share/swampd/config.json +fi + +# start read margin temp wait +/usr/bin/read-margin-temp-wait.sh & + +exit 0 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 new file mode 100644 index 000000000..33a441928 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control/phosphor-pid-control.service @@ -0,0 +1,15 @@ +[Unit] +Description=Swampd Margin-based Fan Control Daemon +After=xyz.openbmc_project.Hwmon@-ahb-apb-pwm\x2dfan\x2dcontroller\x40103000.service + +[Service] +Type=simple +ExecStartPre=/usr/bin/fan-table-init.sh +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 new file mode 100644 index 000000000..f87a49394 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/phosphor-pid-control_%.bbappend @@ -0,0 +1,31 @@ +FILESEXTRAPATHS_prepend_gbs := "${THISDIR}/${PN}:" +SRC_URI_append_gbs = " file://config.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" + +FILES_${PN}_append_gbs = " ${datadir}/swampd/config.json" +FILES_${PN}_append_gbs = " ${bindir}/fan-default-speed.sh" +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.json \ + ${D}${datadir}/swampd/config.json + + 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} +} diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/read-margin-temp/config-margin.json b/meta-quanta/meta-gbs/recipes-phosphor/fans/read-margin-temp/config-margin.json new file mode 100644 index 000000000..6b73e34b8 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/read-margin-temp/config-margin.json @@ -0,0 +1,308 @@ +{ + "sensors" : [ + { + "name": "cputemp", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/cputemp", + "parameters": { + "type": "file", + "maxTemp": -1, + "path": "/sys/devices/platform/ahb/ahb:apb/f0082000.i2c/i2c-2/2-004c/hwmon/cpu_hwmon/temp1_max", + "sysLabel": "", + "targetTemp": -1, + "targetTempOffset": -10000, + "scalar": 1.0 + } + }, + { + "name": "nvme0", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme0", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme1", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme1", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme2", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme2", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme3", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme3", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme4", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme4", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme5", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme5", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme6", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme6", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme7", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme7", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme8", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme8", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme9", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme9", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme10", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme10", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme11", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme11", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme12", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme12", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme13", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme13", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme14", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme14", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "nvme15", + "unit": "millidegree", + "type": "dbus", + "path": "/xyz/openbmc_project/sensors/temperature/nvme15", + "parameters": { + "type": "", + "maxTemp": 70000, + "path": "", + "sysLabel": "", + "targetTemp": 60000, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "fleeting0", + "unit": "millimargin", + "type": "dbus", + "path": "/xyz/openbmc_project/extsensors/margin/fleeting0", + "parameters": { + "type": "", + "maxTemp": 0, + "path": "", + "sysLabel": "", + "targetTemp": 0, + "targetTempOffset": 0, + "scalar": 1.0 + } + }, + { + "name": "fleeting1", + "unit": "millimargin", + "type": "dbus", + "path": "/xyz/openbmc_project/extsensors/margin/fleeting1", + "parameters": { + "type": "", + "maxTemp": 0, + "path": "", + "sysLabel": "", + "targetTemp": 0, + "targetTempOffset": 0, + "scalar": 1.0 + } + } + ], + "skus" : [ + { + "num": 1, + "zones": [ + { + "id": 0, + "zoneSetpoint": 10000, + "target": "/xyz/openbmc_project/extsensors/margin/real_fleeting0", + "components": ["cputemp", "fleeting0"] + }, + { + "id": 1, + "zoneSetpoint": 10000, + "target": "/xyz/openbmc_project/extsensors/margin/real_fleeting1", + "components": ["nvme0", "nvme1", "nvme2", "nvme3", "nvme4", "nvme5", "nvme6", "nvme7", "nvme8", "nvme9", "nvme10", "nvme11", "nvme12", "nvme13", "nvme14", "nvme15"] + } + ] + } + ] +} diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/read-margin-temp/read-margin-temp-wait.sh b/meta-quanta/meta-gbs/recipes-phosphor/fans/read-margin-temp/read-margin-temp-wait.sh new file mode 100644 index 000000000..2e44479f6 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/read-margin-temp/read-margin-temp-wait.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +MARGIN_TABLE_FILE="/usr/share/read-margin-temp/config-margin.json" + +target_num="$(cat $MARGIN_TABLE_FILE | grep '"target"' | wc -l)" + +cpu_hwmon="$(ls -la /sys/class/hwmon | grep f0082000 | head -n 1 | tail -n +1 | cut -d '/' -f 11)" + +# replace by the real cpu temperature hwmon path in runtime +if [[ "$cpu_hwmon" != "" ]] +then + sed -i "s/cpu_hwmon/$cpu_hwmon/g" $MARGIN_TABLE_FILE +fi + +# wait target dbus +for ((i=0; i<$target_num; i++)) +do + line_num=$((i+1)) + path="$(cat $MARGIN_TABLE_FILE | grep '"target"' | head -n ${line_num} | tail -n +${line_num} | cut -d '"' -f 4)" + mapper wait $path +done + +# start read margin temp +/usr/bin/read-margin-temp & + +exit 0 diff --git a/meta-quanta/meta-gbs/recipes-phosphor/fans/read-margin-temp_git.bb b/meta-quanta/meta-gbs/recipes-phosphor/fans/read-margin-temp_git.bb new file mode 100644 index 000000000..525dab223 --- /dev/null +++ b/meta-quanta/meta-gbs/recipes-phosphor/fans/read-margin-temp_git.bb @@ -0,0 +1,37 @@ +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = "git://github.com/quanta-bmc/read-margin-temp.git" +SRCREV = "1a74891c996725dd4c94397d2588d840da07c548" +S = "${WORKDIR}/git" + +SRC_URI += " file://config-margin.json \ + file://read-margin-temp-wait.sh \ + " + +inherit autotools pkgconfig +inherit meson + +DEPENDS += " nlohmann-json" +DEPENDS += " sdbusplus" +DEPENDS += " sdbusplus-native" +DEPENDS += " sdeventplus" +DEPENDS += " phosphor-dbus-interfaces" + +RDEPENDS_${PN} += " bash" + +FILES_${PN} = "${bindir}/read-margin-temp" +FILES_${PN} += " ${bindir}/read-margin-temp-wait.sh" +FILES_${PN} += " ${datadir}/read-margin-temp/config-margin.json" + +do_install() { + install -d ${D}${bindir} + install -m 0755 read-margin-temp ${D}${bindir} + install -m 0755 ${WORKDIR}/read-margin-temp-wait.sh ${D}/${bindir} + + install -d ${D}${datadir}/read-margin-temp + install -m 0644 -D ${WORKDIR}/config-margin.json \ + ${D}${datadir}/read-margin-temp/config-margin.json + +} |