xref: /openbmc/phosphor-pid-control/conf.hpp (revision 3484bedaf611a106eeaf418b6cede2c2e42095c8)
1e620656cSPatrick Venture #pragma once
2e620656cSPatrick Venture 
3da4a5dd1SPatrick Venture #include "pid/ec/pid.hpp"
422c257abSJames Feist #include "pid/ec/stepwise.hpp"
5da4a5dd1SPatrick Venture 
6e620656cSPatrick Venture #include <map>
7e620656cSPatrick Venture #include <string>
8e620656cSPatrick Venture #include <vector>
9e620656cSPatrick Venture 
1075eb769dSJames Feist namespace conf
1175eb769dSJames Feist {
1275eb769dSJames Feist constexpr int64_t inheritValueFromDbus = std::numeric_limits<int64_t>::lowest();
1375eb769dSJames Feist } // namespace conf
1475eb769dSJames Feist 
15e620656cSPatrick Venture /*
16e620656cSPatrick Venture  * General sensor structure used for configuration.
17e620656cSPatrick Venture  */
18f3252315SPatrick Venture struct SensorConfig
19e620656cSPatrick Venture {
2069c51061SPatrick Venture     /* Used for listen if readPath is passive. */
21e620656cSPatrick Venture     std::string type;
22e620656cSPatrick Venture     /* Can be a sensor path or a dbus path. */
2369c51061SPatrick Venture     std::string readPath;
2469c51061SPatrick Venture     std::string writePath;
25e620656cSPatrick Venture     /* min/max values for writing a percentage or error checking. */
26e620656cSPatrick Venture     int64_t min;
27e620656cSPatrick Venture     int64_t max;
28e620656cSPatrick Venture     int64_t timeout;
29e620656cSPatrick Venture };
30e620656cSPatrick Venture 
31e620656cSPatrick Venture /*
32e620656cSPatrick Venture  * Structure for holding the configuration of a PID.
33e620656cSPatrick Venture  */
34f3252315SPatrick Venture struct ControllerInfo
35e620656cSPatrick Venture {
36e620656cSPatrick Venture     std::string type;                // fan or margin or temp?
37e620656cSPatrick Venture     std::vector<std::string> inputs; // one or more sensors.
385f59c0fdSPatrick Venture     double setpoint;                 // initial setpoint for thermal.
3922c257abSJames Feist     union
4022c257abSJames Feist     {
4122c257abSJames Feist         ec::pidinfo pidInfo; // pid details
4222c257abSJames Feist         ec::StepwiseInfo stepwiseInfo;
4322c257abSJames Feist     };
44e620656cSPatrick Venture };
45e620656cSPatrick Venture 
46e620656cSPatrick Venture /*
47e620656cSPatrick Venture  * General zone structure used for configuration.  A zone is a list of PIDs
48e620656cSPatrick Venture  * and a set of configuration settings.  This structure gets filled out with
49e620656cSPatrick Venture  * the zone configuration settings and not the PID details.
50e620656cSPatrick Venture  */
51f3252315SPatrick Venture struct ZoneConfig
52e620656cSPatrick Venture {
53e620656cSPatrick Venture     /* The minimum RPM value we would ever want. */
54*3484bedaSJames Feist     double minThermalOutput;
55e620656cSPatrick Venture 
56e620656cSPatrick Venture     /* If the sensors are in fail-safe mode, this is the percentage to use. */
578e2fdb34SPatrick Venture     double failsafePercent;
58e620656cSPatrick Venture };
59e620656cSPatrick Venture 
60f3252315SPatrick Venture using PIDConf = std::map<std::string, struct ControllerInfo>;
61