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>2018-01-15 20:30:11 -0600
commit0d816e340dd6dbe04389daea1a0aa14f0b5d294f (patch)
tree47f65cec590f6f1b4e58ee1c6cfc47f8caff0ee0
parent26d21731c292a02ec71480fade9a06658160eafb (diff)
downloadphosphor-hwmon-03-26-2018.tar.gz
phosphor-hwmon-03-26-2018.zip
Enable raw PWM control mode for systems without known fan types03-26-2018
-rw-r--r--fan_speed.cpp37
-rw-r--r--hwmon.hpp2
-rw-r--r--sysfs.hpp9
3 files changed, 40 insertions, 8 deletions
diff --git a/fan_speed.cpp b/fan_speed.cpp
index 2652f8d..079d456 100644
--- a/fan_speed.cpp
+++ b/fan_speed.cpp
@@ -13,20 +13,43 @@ namespace hwmon
uint64_t FanSpeed::target(uint64_t value)
{
+ auto directPWM = false;
auto curValue = FanSpeedObject::target();
+ auto enable = 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,
- sysfs::hwmonio::retries,
- sysfs::hwmonio::delay);
+ if (directPWM)
+ {
+ ioAccess.write(
+ (value * 255) / 100,
+ type::pwm,
+ id,
+ entry::rawpwm,
+ sysfs::hwmonio::retries,
+ sysfs::hwmonio::delay);
+ }
+ else
+ {
+ ioAccess.write(
+ value,
+ type,
+ id,
+ entry::target,
+ sysfs::hwmonio::retries,
+ sysfs::hwmonio::delay);
+ }
}
catch (const std::system_error& e)
diff --git a/hwmon.hpp b/hwmon.hpp
index 5a4744c..39b0d54 100644
--- a/hwmon.hpp
+++ b/hwmon.hpp
@@ -10,11 +10,13 @@ static constexpr auto cinput = "input";
static constexpr auto clabel = "label";
static constexpr auto ctarget = "target";
static constexpr auto cenable = "enable";
+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 rawpwm = crawpwm;
}
namespace type
diff --git a/sysfs.hpp b/sysfs.hpp
index e3090c3..15a13f4 100644
--- a/sysfs.hpp
+++ b/sysfs.hpp
@@ -14,7 +14,14 @@ inline std::string make_sysfs_path(const std::string& path,
{
using namespace std::literals;
- return path + "/"s + type + id + "_"s + entry;
+ if (entry.length() < 1)
+ {
+ return path + "/"s + type + id;
+ }
+ else
+ {
+ return path + "/"s + type + id + "_"s + entry;
+ }
}
/** @brief Return the path to the phandle file matching value in io-channels.
OpenPOWER on IntegriCloud