Jim Wright | 539b608 | 2021-08-02 14:50:23 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include <sdbusplus/message.hpp> |
| 5 | #include <sdbusplus/server/object.hpp> |
| 6 | #include <sdeventplus/event.hpp> |
| 7 | #include <sdeventplus/utility/timer.hpp> |
| 8 | |
| 9 | #include <chrono> |
| 10 | |
| 11 | namespace phosphor::power::sequencer |
| 12 | { |
| 13 | |
| 14 | /** |
| 15 | * @class PowerControl |
| 16 | * This class implements GPIO control of power on / off, and monitoring of the |
| 17 | * chassis power good. |
| 18 | */ |
| 19 | class PowerControl |
| 20 | { |
| 21 | public: |
| 22 | PowerControl() = delete; |
| 23 | PowerControl(const PowerControl&) = delete; |
| 24 | PowerControl& operator=(const PowerControl&) = delete; |
| 25 | PowerControl(PowerControl&&) = delete; |
| 26 | PowerControl& operator=(PowerControl&&) = delete; |
| 27 | ~PowerControl() = default; |
| 28 | |
| 29 | /** |
| 30 | * Creates a controller object for power on and off. |
| 31 | * @param[in] bus D-Bus bus object |
| 32 | * @param[in] event event object |
| 33 | */ |
| 34 | PowerControl(sdbusplus::bus::bus& bus, const sdeventplus::Event& event); |
| 35 | |
| 36 | private: |
| 37 | /** |
| 38 | * The D-Bus bus object |
| 39 | */ |
| 40 | sdbusplus::bus::bus& bus; |
| 41 | |
| 42 | /** |
| 43 | * Event to loop on |
| 44 | */ |
| 45 | sdeventplus::Event eventLoop; |
| 46 | |
| 47 | /** |
| 48 | * Timer to poll the pgood |
| 49 | */ |
| 50 | sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> timer; |
| 51 | |
| 52 | /** |
| 53 | * Poll interval constant |
| 54 | */ |
| 55 | static constexpr int pollInterval{3000}; // Milliseconds |
| 56 | |
| 57 | /** |
| 58 | * Polling method for monitoring the system power good |
| 59 | */ |
| 60 | void pollPgood(); |
| 61 | }; |
| 62 | |
| 63 | } // namespace phosphor::power::sequencer |