summaryrefslogtreecommitdiffstats
path: root/monitor/fan.cpp
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2018-01-26 17:14:00 +0800
committerLei YU <mine260309@gmail.com>2018-02-26 10:34:14 +0800
commit8e5d197b840d4498dcb714b60cc1d38202a7a7a7 (patch)
treec08a4579fea557beda1f80023298eab22cf7e0ce /monitor/fan.cpp
parent0a9fe160d600ece0c5797741042d0e6f975ab101 (diff)
downloadphosphor-fan-presence-8e5d197b840d4498dcb714b60cc1d38202a7a7a7.tar.gz
phosphor-fan-presence-8e5d197b840d4498dcb714b60cc1d38202a7a7a7.zip
Add factor and offset for fan monitor
For fans controlled via pwm, the fan target and speed are different, where the fan target is pwm and the speed is rpm. Usually it is a linear mapping from pwm to rpm. So this commit defines the optional configs, factor and offset for calculating the expected fan speed from target, e.g. - name: fan0 has_target: true factor: 21 offset: 1600 The fan monitor service will calculate expected fan speed as: target * factor + offset The default value is 1 for factor and 0 for offset if they are not defined. Tested: Use this config together with the following commit's changes, test on Romulus and ensures the fan monitor works OK; Without this config, fan monitor always mark fans as non-functional due to the fan speed does not match the pwm value. Change-Id: If5e25368b4530df7a7face9377efb58804db21df Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'monitor/fan.cpp')
-rw-r--r--monitor/fan.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index b1aa233..81d27e0 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -53,6 +53,8 @@ Fan::Fan(Mode mode,
*this,
std::get<sensorNameField>(s),
std::get<hasTargetField>(s),
+ std::get<factorField>(s),
+ std::get<offsetField>(s),
std::get<timeoutField>(def),
events));
@@ -172,10 +174,17 @@ bool Fan::outOfRange(const TachSensor& sensor)
{
auto actual = static_cast<uint64_t>(sensor.getInput());
auto target = sensor.getTarget();
+ auto factor = sensor.getFactor();
+ auto offset = sensor.getOffset();
uint64_t min = target * (100 - _deviation) / 100;
uint64_t max = target * (100 + _deviation) / 100;
+ // TODO: openbmc/openbmc#2937 enhance this function
+ // either by making it virtual, or by predefining different
+ // outOfRange ops and selecting by yaml config
+ min = min * factor + offset;
+ max = max * factor + offset;
if ((actual < min) || (actual > max))
{
return true;
OpenPOWER on IntegriCloud