summaryrefslogtreecommitdiffstats
path: root/control
diff options
context:
space:
mode:
authorRaptor Engineering Development Team <support@raptorengineering.com>2018-01-24 21:59:42 -0600
committerRaptor Engineering Development Team <support@raptorengineering.com>2019-04-19 22:07:46 +0000
commita964223bba361d62e14621137b353daaf3dacdc8 (patch)
treec24cdeeed2c0f69bbfdd38da3cfad22fb9fdea00 /control
parent26a78ab15690be7421bb000bc473cd0bdfd8ad15 (diff)
downloadphosphor-fan-presence-a964223bba361d62e14621137b353daaf3dacdc8.tar.gz
phosphor-fan-presence-a964223bba361d62e14621137b353daaf3dacdc8.zip
Add fan shutdown option to stop rotors after chassis powerdown
Diffstat (limited to 'control')
-rw-r--r--control/argument.cpp5
-rw-r--r--control/fan.cpp10
-rw-r--r--control/fan.hpp5
-rw-r--r--control/main.cpp10
-rw-r--r--control/manager.cpp9
-rw-r--r--control/manager.hpp6
-rw-r--r--control/zone.cpp9
-rw-r--r--control/zone.hpp10
8 files changed, 62 insertions, 2 deletions
diff --git a/control/argument.cpp b/control/argument.cpp
index e014453..e46200f 100644
--- a/control/argument.cpp
+++ b/control/argument.cpp
@@ -1,5 +1,6 @@
/**
* Copyright © 2017 IBM Corporation
+ * Copyright © 2017-2018 Raptor Engineering, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,6 +70,7 @@ void ArgumentParser::usage(char** argv)
std::cerr << " --help Print this menu\n";
std::cerr << " --init Sets fans to full speed, delays, exits\n";
std::cerr << " --control Start fan control algorithm\n";
+ std::cerr << " --shutdown Shut down fan control algorithm *and* fans. ONLY use after chassis powerdown!\n";
std::cerr << std::flush;
}
@@ -76,11 +78,12 @@ const option ArgumentParser::options[] =
{
{ "init", no_argument, NULL, 'i' },
{ "control", no_argument, NULL, 'c' },
+ { "shutdown", no_argument, NULL, 's' },
{ "help", no_argument, NULL, 'h' },
{ 0, 0, 0, 0},
};
-const char* ArgumentParser::optionstr = "ich?";
+const char* ArgumentParser::optionstr = "icsh?";
const std::string ArgumentParser::true_string = "true";
const std::string ArgumentParser::empty_string = "";
diff --git a/control/fan.cpp b/control/fan.cpp
index c86186f..50d1469 100644
--- a/control/fan.cpp
+++ b/control/fan.cpp
@@ -1,5 +1,6 @@
/**
* Copyright © 2017 IBM Corporation
+ * Copyright © 2017-2018 Raptor Engineering, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -89,6 +90,15 @@ void Fan::setSpeed(uint64_t speed)
_targetSpeed = speed;
}
+void Fan::disableRotor()
+{
+ // TODO
+ // This should set the enable value of the hwmon PWM entry
+ // For now, just set the fan speed to 0
+
+ setSpeed(0);
+}
+
}
}
}
diff --git a/control/fan.hpp b/control/fan.hpp
index 3e05e16..65fff4b 100644
--- a/control/fan.hpp
+++ b/control/fan.hpp
@@ -56,6 +56,11 @@ class Fan
return _targetSpeed;
}
+ /**
+ * Disables the fan, stopping the rotor
+ */
+ void disableRotor();
+
private:
/**
diff --git a/control/main.cpp b/control/main.cpp
index 4420488..10492b8 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -1,5 +1,6 @@
/**
* Copyright © 2017 IBM Corporation
+ * Copyright © 2017-2018 Raptor Engineering, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,6 +46,10 @@ int main(int argc, char* argv[])
{
mode = Mode::control;
}
+ else if (args["shutdown"] == "true")
+ {
+ mode = Mode::shutdown;
+ }
else
{
args.usage(argv);
@@ -65,6 +70,11 @@ int main(int argc, char* argv[])
manager.doInit();
return 0;
}
+ else if (mode == Mode::shutdown)
+ {
+ manager.doShutdown();
+ return 0;
+ }
return event.loop();
}
diff --git a/control/manager.cpp b/control/manager.cpp
index 360239c..cbcb1d3 100644
--- a/control/manager.cpp
+++ b/control/manager.cpp
@@ -1,5 +1,6 @@
/**
* Copyright © 2017 IBM Corporation
+ * Copyright © 2017-2018 Raptor Engineering, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -147,6 +148,14 @@ void Manager::doInit()
"replace");
}
+void Manager::doShutdown()
+{
+ for (auto& z : _zones)
+ {
+ z.second->disableRotors();
+ }
+}
+
} // namespace control
} // namespace fan
} // namespace phosphor
diff --git a/control/manager.hpp b/control/manager.hpp
index c87d0d8..5e831f5 100644
--- a/control/manager.hpp
+++ b/control/manager.hpp
@@ -51,6 +51,12 @@ class Manager
*/
void doInit();
+ /**
+ * Does the fan control and chassis fan shutdown, which
+ * disables the fans entirely (stops all rotors)
+ */
+ void doShutdown();
+
private:
/**
diff --git a/control/zone.cpp b/control/zone.cpp
index fddca53..468a605 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -1,5 +1,6 @@
/**
* Copyright © 2017 IBM Corporation
+ * Copyright © 2017-2018 Raptor Engineering, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -123,6 +124,14 @@ void Zone::setFullSpeed()
}
}
+void Zone::disableRotors()
+{
+ for (auto& fan : _fans)
+ {
+ fan->disableRotor();
+ }
+}
+
void Zone::setActiveAllow(const Group* group, bool isActiveAllow)
{
_active[*(group)] = isActiveAllow;
diff --git a/control/zone.hpp b/control/zone.hpp
index 6da3091..ec0d9bb 100644
--- a/control/zone.hpp
+++ b/control/zone.hpp
@@ -24,11 +24,13 @@ using ThermalObject = sdbusplus::server::object::object<
* The mode fan control will run in:
* - init - only do the initialization steps
* - control - run normal control algorithms
+ * - init - shutdown fans, stopping all rotors
*/
enum class Mode
{
init,
- control
+ control,
+ shutdown
};
/**
@@ -77,6 +79,12 @@ class Zone : public ThermalObject
void setFullSpeed();
/**
+ * Disables the zone and stops all zone fans regardless of
+ * zone's active state
+ */
+ void disableRotors();
+
+ /**
* @brief Sets the automatic fan control allowed active state
*
* @param[in] group - A group that affects the active state
OpenPOWER on IntegriCloud