Fix PSU pwm issue.
PSU pwm value range is 0-100, which is not same with
system fan 0-255.
There is an issue when PID to change the PSU pwm
based on percentage.
Tested:
PSU pwm just allowed 0-100.
PSU fan speed is runing as expected based on the percentage.
Change-Id: I3ae591828f5b0d85ab6358af666e4f2ab2e0a447
Signed-off-by: Kuiying Wang <kuiying.wang@intel.com>
diff --git a/include/PwmSensor.hpp b/include/PwmSensor.hpp
index 22614e6..69a35c4 100644
--- a/include/PwmSensor.hpp
+++ b/include/PwmSensor.hpp
@@ -22,6 +22,7 @@
std::shared_ptr<sdbusplus::asio::dbus_interface> sensorInterface;
std::shared_ptr<sdbusplus::asio::dbus_interface> controlInterface;
std::shared_ptr<sdbusplus::asio::dbus_interface> association;
+ size_t pwmMax;
void setValue(uint32_t value);
uint32_t getValue(bool errThrow = true);
};
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index 3e5c8a1..0c5d439 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -24,7 +24,8 @@
#include <stdexcept>
#include <string>
-static constexpr size_t pwmMax = 255;
+static constexpr size_t sysPwmMax = 255;
+static constexpr size_t psuPwmMax = 100;
static constexpr double defaultPwm = 30.0;
PwmSensor::PwmSensor(const std::string& name, const std::string& sysPath,
@@ -41,6 +42,15 @@
"/xyz/openbmc_project/sensors/fan_pwm/" + name,
"xyz.openbmc_project.Sensor.Value");
uint32_t pwmValue = getValue(false);
+ if (sensorType == "PSU")
+ {
+ pwmMax = psuPwmMax;
+ }
+ else
+ {
+ pwmMax = sysPwmMax;
+ }
+
if (!pwmValue)
{
// default pwm to non 0