summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaptor Engineering Development Team <support@raptorengineering.com>2018-01-15 19:21:39 -0600
committerRaptor Engineering Development Team <support@raptorengineering.com>2019-04-19 13:22:37 +0000
commit52c34ee61a1c292f1226cc61a10dd90e611e6d63 (patch)
tree73fc6e1ef0efffc7db36f4c66009cb7c5c939f08
parent5c014d2bb76f6f6d51aecf31bea95cb9ed9b1953 (diff)
downloadphosphor-hwmon-52c34ee61a1c292f1226cc61a10dd90e611e6d63.tar.gz
phosphor-hwmon-52c34ee61a1c292f1226cc61a10dd90e611e6d63.zip
Enable raw PWM control mode for systems without known fan types
-rw-r--r--fan_speed.cpp33
-rw-r--r--hwmon.hpp2
2 files changed, 33 insertions, 2 deletions
diff --git a/fan_speed.cpp b/fan_speed.cpp
index 65e5655..c6a9162 100644
--- a/fan_speed.cpp
+++ b/fan_speed.cpp
@@ -16,15 +16,44 @@ namespace hwmon
uint64_t FanSpeed::target(uint64_t value)
{
+ auto directPWM = false;
auto curValue = FanSpeedObject::target();
+ auto enable = env::getEnv("ENABLE", _type, _id);
+ if (!enable.empty())
+ {
+ auto val = std::stoul(enable);
+ if (val == 1)
+ {
+ directPWM = true;
+ }
+ }
if (curValue != value)
{
// Write target out to sysfs
try
{
- _ioAccess->write(value, _type, _id, entry::target, hwmonio::retries,
- hwmonio::delay);
+ if (directPWM)
+ {
+ _ioAccess->write(
+ (value * 255) / 100,
+ type::pwm,
+ _id,
+ entry::rawpwm,
+ hwmonio::retries,
+ hwmonio::delay);
+ }
+ else
+ {
+ _ioAccess->write(
+ value,
+ _type,
+ _id,
+ entry::target,
+ hwmonio::retries,
+ hwmonio::delay);
+ }
+
}
catch (const std::system_error& e)
{
diff --git a/hwmon.hpp b/hwmon.hpp
index 4f4545c..6f85f5c 100644
--- a/hwmon.hpp
+++ b/hwmon.hpp
@@ -14,12 +14,14 @@ static constexpr auto clabel = "label";
static constexpr auto ctarget = "target";
static constexpr auto cenable = "enable";
static constexpr auto cfault = "fault";
+static constexpr auto crawpwm = "";
static const std::string input = cinput;
static const std::string label = clabel;
static const std::string target = ctarget;
static const std::string enable = cenable;
static const std::string fault = cfault;
+static const std::string rawpwm = crawpwm;
} // namespace entry
namespace type
OpenPOWER on IntegriCloud