xref: /openbmc/phosphor-power/phosphor-power-supply/psu_manager.hpp (revision b7131a12ee603264a90b55dd7afde929434424e9)
12bac8609SBrandon Wyman #pragma once
22bac8609SBrandon Wyman 
3a0f33ce3SBrandon Wyman #include "power_supply.hpp"
4a0f33ce3SBrandon Wyman #include "types.hpp"
5a0f33ce3SBrandon Wyman #include "utility.hpp"
6a0f33ce3SBrandon Wyman 
7a0f33ce3SBrandon Wyman #include <phosphor-logging/log.hpp>
82bac8609SBrandon Wyman #include <sdbusplus/bus/match.hpp>
9c9b05736SAdriana Kobylak #include <sdbusplus/server/manager.hpp>
10c9b05736SAdriana Kobylak #include <sdbusplus/server/object.hpp>
112bac8609SBrandon Wyman #include <sdeventplus/event.hpp>
122bac8609SBrandon Wyman #include <sdeventplus/utility/timer.hpp>
13c9b05736SAdriana Kobylak #include <xyz/openbmc_project/State/Decorator/PowerSystemInputs/server.hpp>
142bac8609SBrandon Wyman 
15aed1f75dSBrandon Wyman struct sys_properties
16aed1f75dSBrandon Wyman {
17d3a70d98SAdriana Kobylak     int powerSupplyCount;
18d3a70d98SAdriana Kobylak     std::vector<uint64_t> inputVoltage;
19886574cdSAdriana Kobylak     bool powerConfigFullLoad;
20aed1f75dSBrandon Wyman };
21aed1f75dSBrandon Wyman 
22a0f33ce3SBrandon Wyman using namespace phosphor::power::psu;
23a0f33ce3SBrandon Wyman using namespace phosphor::logging;
24a0f33ce3SBrandon Wyman 
2563ea78b9SBrandon Wyman namespace phosphor::power::manager
262bac8609SBrandon Wyman {
272bac8609SBrandon Wyman 
28c9b05736SAdriana Kobylak using PowerSystemInputsInterface = sdbusplus::xyz::openbmc_project::State::
29c9b05736SAdriana Kobylak     Decorator::server::PowerSystemInputs;
30c9b05736SAdriana Kobylak using PowerSystemInputsObject =
31c9b05736SAdriana Kobylak     sdbusplus::server::object_t<PowerSystemInputsInterface>;
32c9b05736SAdriana Kobylak 
339ef7a043SFaisal Awada // Validation timeout. Allow 30s to detect if new EM interfaces show up in D-Bus
342aba2b25SAdriana Kobylak // before performing the validation.
359ef7a043SFaisal Awada // Previously the timer was set to 10 seconds was too short, it results in
369ef7a043SFaisal Awada // incorrect errors being logged, but no real consequence of longer timeout.
379ef7a043SFaisal Awada constexpr auto validationTimeout = std::chrono::seconds(30);
38a4d38fadSAdriana Kobylak 
392bac8609SBrandon Wyman /**
40c9b05736SAdriana Kobylak  * @class PowerSystemInputs
41c9b05736SAdriana Kobylak  * @brief A concrete implementation for the PowerSystemInputs interface.
42c9b05736SAdriana Kobylak  */
43c9b05736SAdriana Kobylak class PowerSystemInputs : public PowerSystemInputsObject
44c9b05736SAdriana Kobylak {
45c9b05736SAdriana Kobylak   public:
PowerSystemInputs(sdbusplus::bus_t & bus,const std::string & path)467354ce62SPatrick Williams     PowerSystemInputs(sdbusplus::bus_t& bus, const std::string& path) :
47c9b05736SAdriana Kobylak         PowerSystemInputsObject(bus, path.c_str())
48c9b05736SAdriana Kobylak     {}
49c9b05736SAdriana Kobylak };
50c9b05736SAdriana Kobylak 
51c9b05736SAdriana Kobylak /**
522bac8609SBrandon Wyman  * @class PSUManager
532bac8609SBrandon Wyman  *
542bac8609SBrandon Wyman  * This class will create an object used to manage and monitor a list of power
552bac8609SBrandon Wyman  * supply devices.
562bac8609SBrandon Wyman  */
572bac8609SBrandon Wyman class PSUManager
582bac8609SBrandon Wyman {
592bac8609SBrandon Wyman   public:
602bac8609SBrandon Wyman     PSUManager() = delete;
612bac8609SBrandon Wyman     ~PSUManager() = default;
622bac8609SBrandon Wyman     PSUManager(const PSUManager&) = delete;
632bac8609SBrandon Wyman     PSUManager& operator=(const PSUManager&) = delete;
642bac8609SBrandon Wyman     PSUManager(PSUManager&&) = delete;
652bac8609SBrandon Wyman     PSUManager& operator=(PSUManager&&) = delete;
662bac8609SBrandon Wyman 
672bac8609SBrandon Wyman     /**
68510acaabSBrandon Wyman      * Constructor to read configuration from D-Bus.
69510acaabSBrandon Wyman      *
70510acaabSBrandon Wyman      * @param[in] bus - D-Bus bus object
71510acaabSBrandon Wyman      * @param[in] e - event object
72510acaabSBrandon Wyman      */
737354ce62SPatrick Williams     PSUManager(sdbusplus::bus_t& bus, const sdeventplus::Event& e);
74510acaabSBrandon Wyman 
75510acaabSBrandon Wyman     /**
76510acaabSBrandon Wyman      * Get PSU properties from D-Bus, use that to build a power supply
77510acaabSBrandon Wyman      * object.
78510acaabSBrandon Wyman      *
79510acaabSBrandon Wyman      * @param[in] properties - A map of property names and values
80510acaabSBrandon Wyman      *
81510acaabSBrandon Wyman      */
82510acaabSBrandon Wyman     void getPSUProperties(util::DbusPropertyMap& properties);
83510acaabSBrandon Wyman 
84510acaabSBrandon Wyman     /**
85510acaabSBrandon Wyman      * Get PSU configuration from D-Bus
86510acaabSBrandon Wyman      */
87510acaabSBrandon Wyman     void getPSUConfiguration();
88510acaabSBrandon Wyman 
89510acaabSBrandon Wyman     /**
909bab9e10SAdriana Kobylak      * @brief Initialize the system properties from the Supported Configuration
919bab9e10SAdriana Kobylak      *        D-Bus object provided by Entity Manager.
929bab9e10SAdriana Kobylak      */
939bab9e10SAdriana Kobylak     void getSystemProperties();
949bab9e10SAdriana Kobylak 
959bab9e10SAdriana Kobylak     /**
962bac8609SBrandon Wyman      * Initializes the manager.
972bac8609SBrandon Wyman      *
982bac8609SBrandon Wyman      * Get current BMC state, ...
992bac8609SBrandon Wyman      */
100aca86d05SJim Wright     void initialize();
1012bac8609SBrandon Wyman 
1022bac8609SBrandon Wyman     /**
1032bac8609SBrandon Wyman      * Starts the timer to start monitoring the list of devices.
1042bac8609SBrandon Wyman      */
run()1052bac8609SBrandon Wyman     int run()
1062bac8609SBrandon Wyman     {
1072fe5186eSBrandon Wyman         return timer->get_event().loop();
1082bac8609SBrandon Wyman     }
1092bac8609SBrandon Wyman 
1102bac8609SBrandon Wyman     /**
11159a35793SBrandon Wyman      * Write PMBus ON_OFF_CONFIG
11259a35793SBrandon Wyman      *
11359a35793SBrandon Wyman      * This function will be called to cause the PMBus device driver to send the
11459a35793SBrandon Wyman      * ON_OFF_CONFIG command. Takes one byte of data.
11559a35793SBrandon Wyman      */
onOffConfig(const uint8_t data)11659a35793SBrandon Wyman     void onOffConfig(const uint8_t data)
11759a35793SBrandon Wyman     {
11859a35793SBrandon Wyman         for (auto& psu : psus)
11959a35793SBrandon Wyman         {
12059a35793SBrandon Wyman             psu->onOffConfig(data);
12159a35793SBrandon Wyman         }
12259a35793SBrandon Wyman     }
12359a35793SBrandon Wyman 
12459a35793SBrandon Wyman     /**
1252bac8609SBrandon Wyman      * This function will be called in various situations in order to clear
1262bac8609SBrandon Wyman      * any fault status bits that may have been set, in order to start over
1272bac8609SBrandon Wyman      * with a clean state. Presence changes and power state changes will want
1282bac8609SBrandon Wyman      * to clear any faults logged.
1292bac8609SBrandon Wyman      */
clearFaults()1302bac8609SBrandon Wyman     void clearFaults()
1312bac8609SBrandon Wyman     {
13210fc6e87SBrandon Wyman         setPowerSupplyError("");
133a0f33ce3SBrandon Wyman         for (auto& psu : psus)
134a0f33ce3SBrandon Wyman         {
135aed1f75dSBrandon Wyman             psu->clearFaults();
136a0f33ce3SBrandon Wyman         }
1372bac8609SBrandon Wyman     }
1382bac8609SBrandon Wyman 
1399464c429SGeorge Liu     /**
1409464c429SGeorge Liu      * Get the status of Power on.
1419464c429SGeorge Liu      */
isPowerOn()1429464c429SGeorge Liu     bool isPowerOn()
1439464c429SGeorge Liu     {
1449464c429SGeorge Liu         return powerOn;
1459464c429SGeorge Liu     }
1469464c429SGeorge Liu 
1472bac8609SBrandon Wyman   private:
1482bac8609SBrandon Wyman     /**
1492bac8609SBrandon Wyman      * The D-Bus object
1502bac8609SBrandon Wyman      */
1517354ce62SPatrick Williams     sdbusplus::bus_t& bus;
1522bac8609SBrandon Wyman 
1532bac8609SBrandon Wyman     /**
1542bac8609SBrandon Wyman      * The timer that runs to periodically check the power supplies.
1552bac8609SBrandon Wyman      */
1562fe5186eSBrandon Wyman     std::unique_ptr<
1572fe5186eSBrandon Wyman         sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
1582fe5186eSBrandon Wyman         timer;
1592bac8609SBrandon Wyman 
1602bac8609SBrandon Wyman     /**
161a4d38fadSAdriana Kobylak      * The timer that performs power supply validation as the entity manager
162a4d38fadSAdriana Kobylak      * interfaces show up in d-bus.
163a4d38fadSAdriana Kobylak      */
164a4d38fadSAdriana Kobylak     std::unique_ptr<
165a4d38fadSAdriana Kobylak         sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
166a4d38fadSAdriana Kobylak         validationTimer;
167a4d38fadSAdriana Kobylak 
168a4d38fadSAdriana Kobylak     /**
16910fc6e87SBrandon Wyman      * Let power control/sequencer application know of PSU error(s).
17010fc6e87SBrandon Wyman      *
17110fc6e87SBrandon Wyman      * @param[in] psuErrorString - string for power supply error
17210fc6e87SBrandon Wyman      */
17310fc6e87SBrandon Wyman     void setPowerSupplyError(const std::string& psuErrorString);
17410fc6e87SBrandon Wyman 
17510fc6e87SBrandon Wyman     /**
176b76ab249SBrandon Wyman      * Create an error
177b76ab249SBrandon Wyman      *
178b76ab249SBrandon Wyman      * @param[in] faultName - 'name' message for the BMC error log entry
1798b66288aSBrandon Wyman      * @param[in,out] additionalData - The AdditionalData property for the error
180b76ab249SBrandon Wyman      */
181b76ab249SBrandon Wyman     void createError(const std::string& faultName,
1828b66288aSBrandon Wyman                      std::map<std::string, std::string>& additionalData);
183b76ab249SBrandon Wyman 
184b76ab249SBrandon Wyman     /**
1852bac8609SBrandon Wyman      * Analyze the status of each of the power supplies.
186b76ab249SBrandon Wyman      *
187b76ab249SBrandon Wyman      * Log errors for faults, when and where appropriate.
1882bac8609SBrandon Wyman      */
18963ea78b9SBrandon Wyman     void analyze();
1902bac8609SBrandon Wyman 
1917f9288ceSJim Wright     /**
1927f9288ceSJim Wright      * @brief Analyze the set of the power supplies for a brownout failure. Log
1937f9288ceSJim Wright      * error when necessary, clear brownout condition when window has passed.
1947f9288ceSJim Wright      */
1957f9288ceSJim Wright     void analyzeBrownout();
1967f9288ceSJim Wright 
1972bac8609SBrandon Wyman     /** @brief True if the power is on. */
1982bac8609SBrandon Wyman     bool powerOn = false;
1992bac8609SBrandon Wyman 
200aca86d05SJim Wright     /** @brief True if power control is in the window between chassis pgood loss
201aca86d05SJim Wright      * and power off. */
202aca86d05SJim Wright     bool powerFaultOccurring = false;
203aca86d05SJim Wright 
2042549d792SAdriana Kobylak     /** @brief True if an error for a brownout has already been logged. */
2052549d792SAdriana Kobylak     bool brownoutLogged = false;
2062549d792SAdriana Kobylak 
207a0f33ce3SBrandon Wyman     /** @brief Used as part of subscribing to power on state changes*/
208a0f33ce3SBrandon Wyman     std::string powerService;
209a0f33ce3SBrandon Wyman 
2102bac8609SBrandon Wyman     /** @brief Used to subscribe to D-Bus power on state changes */
2112bac8609SBrandon Wyman     std::unique_ptr<sdbusplus::bus::match_t> powerOnMatch;
2122bac8609SBrandon Wyman 
2139ba38235SAdriana Kobylak     /** @brief Used to subscribe to D-Bus power supply presence changes */
2149ba38235SAdriana Kobylak     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> presenceMatches;
2159ba38235SAdriana Kobylak 
2169bab9e10SAdriana Kobylak     /** @brief Used to subscribe to Entity Manager interfaces added */
2179bab9e10SAdriana Kobylak     std::unique_ptr<sdbusplus::bus::match_t> entityManagerIfacesAddedMatch;
2189bab9e10SAdriana Kobylak 
2192bac8609SBrandon Wyman     /**
2202bac8609SBrandon Wyman      * @brief Callback for power state property changes
2212bac8609SBrandon Wyman      *
2222bac8609SBrandon Wyman      * Process changes to the powered on state property for the system.
2232bac8609SBrandon Wyman      *
2242bac8609SBrandon Wyman      * @param[in] msg - Data associated with the power state signal
2252bac8609SBrandon Wyman      */
2267354ce62SPatrick Williams     void powerStateChanged(sdbusplus::message_t& msg);
2272bac8609SBrandon Wyman 
2282bac8609SBrandon Wyman     /**
2299ba38235SAdriana Kobylak      * @brief Callback for inventory property changes
2309ba38235SAdriana Kobylak      *
2319ba38235SAdriana Kobylak      * Process change of the Present property for power supply.
2329ba38235SAdriana Kobylak      *
2339ba38235SAdriana Kobylak      * @param[in]  msg - Data associated with the Present change signal
2349ba38235SAdriana Kobylak      **/
2357354ce62SPatrick Williams     void presenceChanged(sdbusplus::message_t& msg);
2369ba38235SAdriana Kobylak 
2379ba38235SAdriana Kobylak     /**
2383e42913fSBrandon Wyman      * @brief Callback for entity-manager interface added
2399bab9e10SAdriana Kobylak      *
2403e42913fSBrandon Wyman      * Process the information from the supported configuration and or IBM CFFPS
2413e42913fSBrandon Wyman      * Connector interface being added.
2429bab9e10SAdriana Kobylak      *
2439bab9e10SAdriana Kobylak      * @param[in] msg - Data associated with the interfaces added signal
2449bab9e10SAdriana Kobylak      */
2457354ce62SPatrick Williams     void entityManagerIfaceAdded(sdbusplus::message_t& msg);
2469bab9e10SAdriana Kobylak 
2479bab9e10SAdriana Kobylak     /**
2482bac8609SBrandon Wyman      * @brief Adds properties to the inventory.
2492bac8609SBrandon Wyman      *
2502bac8609SBrandon Wyman      * Reads the values from the devices and writes them to the associated
2512bac8609SBrandon Wyman      * power supply D-Bus inventory objects.
2522bac8609SBrandon Wyman      *
2532bac8609SBrandon Wyman      * This needs to be done on startup, and each time the presence state
2542bac8609SBrandon Wyman      * changes.
2552bac8609SBrandon Wyman      */
updateInventory()256a0f33ce3SBrandon Wyman     void updateInventory()
257a0f33ce3SBrandon Wyman     {
258a0f33ce3SBrandon Wyman         for (auto& psu : psus)
259a0f33ce3SBrandon Wyman         {
260aed1f75dSBrandon Wyman             psu->updateInventory();
261a0f33ce3SBrandon Wyman         }
262a0f33ce3SBrandon Wyman     }
263a0f33ce3SBrandon Wyman 
264a0f33ce3SBrandon Wyman     /**
265e1074d8eSAdriana Kobylak      * @brief Helper function to populate the system properties
266e1074d8eSAdriana Kobylak      *
267e1074d8eSAdriana Kobylak      * @param[in] properties - A map of property names and values
268e1074d8eSAdriana Kobylak      */
269e1074d8eSAdriana Kobylak     void populateSysProperties(const util::DbusPropertyMap& properties);
270e1074d8eSAdriana Kobylak 
271e1074d8eSAdriana Kobylak     /**
27264e9775dSBrandon Wyman      * @brief Update inventory for missing required power supplies
27364e9775dSBrandon Wyman      */
27464e9775dSBrandon Wyman     void updateMissingPSUs();
27564e9775dSBrandon Wyman 
27664e9775dSBrandon Wyman     /**
2778f16fb5eSAdriana Kobylak      * @brief Perform power supply configuration validation.
2788f16fb5eSAdriana Kobylak      * @details Validates if the existing power supply properties are a
2798f16fb5eSAdriana Kobylak      * supported configuration, and acts on its findings such as logging errors.
2808f16fb5eSAdriana Kobylak      */
2818f16fb5eSAdriana Kobylak     void validateConfig();
2828f16fb5eSAdriana Kobylak 
2838f16fb5eSAdriana Kobylak     /**
2848f16fb5eSAdriana Kobylak      * @brief Flag to indicate if the validateConfig() function should be run.
2858f16fb5eSAdriana Kobylak      * Set to false once the configuration has been validated to avoid running
2868f16fb5eSAdriana Kobylak      * multiple times due to interfaces added signal. Set to true during power
2878f16fb5eSAdriana Kobylak      * off to trigger the validation on power on.
2888f16fb5eSAdriana Kobylak      */
2898f16fb5eSAdriana Kobylak     bool runValidateConfig = true;
2908f16fb5eSAdriana Kobylak 
2918f16fb5eSAdriana Kobylak     /**
2924d9aaf91SAdriana Kobylak      * @brief Check that all PSUs have the same model name and that the system
2934d9aaf91SAdriana Kobylak      * has the required number of PSUs present as specified in the Supported
2944d9aaf91SAdriana Kobylak      * Configuration interface.
2954d9aaf91SAdriana Kobylak      *
2964d9aaf91SAdriana Kobylak      * @param[out] additionalData - Contains debug information on why the check
2974d9aaf91SAdriana Kobylak      *             might have failed. Can be used to fill in error logs.
2984d9aaf91SAdriana Kobylak      * @return true if all the required PSUs are present, false otherwise.
2994d9aaf91SAdriana Kobylak      */
3004d9aaf91SAdriana Kobylak     bool hasRequiredPSUs(std::map<std::string, std::string>& additionalData);
3014d9aaf91SAdriana Kobylak 
3024d9aaf91SAdriana Kobylak     /**
3039252b7e3SShawn McCarney      * @brief Returns the number of PSUs that are required to be present.
3049252b7e3SShawn McCarney      *
3059252b7e3SShawn McCarney      * @return required number of PSUs, or 0 if the number could not be
3069252b7e3SShawn McCarney      *         determined.
3079252b7e3SShawn McCarney      */
3089252b7e3SShawn McCarney     unsigned int getRequiredPSUCount();
3099252b7e3SShawn McCarney 
3109252b7e3SShawn McCarney     /**
3119252b7e3SShawn McCarney      * @brief Returns whether the specified PSU is required to be present.
3129252b7e3SShawn McCarney      *
3139252b7e3SShawn McCarney      * @param[in] psu - Power supply to check
3149252b7e3SShawn McCarney      * @return true if PSU is required, false otherwise.
3159252b7e3SShawn McCarney      */
3169252b7e3SShawn McCarney     bool isRequiredPSU(const PowerSupply& psu);
3179252b7e3SShawn McCarney 
3189252b7e3SShawn McCarney     /**
319523704d0SAdriana Kobylak      * @brief Helper function to validate that all PSUs have the same model name
320523704d0SAdriana Kobylak      *
321523704d0SAdriana Kobylak      * @param[out] model - The model name. Empty if there is a mismatch.
322523704d0SAdriana Kobylak      * @param[out] additionalData - If there is a mismatch, it contains debug
323523704d0SAdriana Kobylak      *             information such as the mismatched model name.
324523704d0SAdriana Kobylak      * @return true if all the PSUs have the same model name, false otherwise.
325523704d0SAdriana Kobylak      */
326523704d0SAdriana Kobylak     bool validateModelName(std::string& model,
327523704d0SAdriana Kobylak                            std::map<std::string, std::string>& additionalData);
328523704d0SAdriana Kobylak 
329523704d0SAdriana Kobylak     /**
330c0a07580SAdriana Kobylak      * @brief Set the power-config-full-load GPIO depending on the EM full load
331c0a07580SAdriana Kobylak      *        property value.
332c0a07580SAdriana Kobylak      */
333c0a07580SAdriana Kobylak     void setPowerConfigGPIO();
334c0a07580SAdriana Kobylak 
335c0a07580SAdriana Kobylak     /**
3369ea66a67SAdriana Kobylak      * @brief Map of supported PSU configurations that include the model name
3379ea66a67SAdriana Kobylak      * and their properties.
338aed1f75dSBrandon Wyman      */
339d3a70d98SAdriana Kobylak     std::map<std::string, sys_properties> supportedConfigs;
340aed1f75dSBrandon Wyman 
341aed1f75dSBrandon Wyman     /**
342a0f33ce3SBrandon Wyman      * @brief The vector for power supplies.
343a0f33ce3SBrandon Wyman      */
344aed1f75dSBrandon Wyman     std::vector<std::unique_ptr<PowerSupply>> psus;
345c0a07580SAdriana Kobylak 
346c0a07580SAdriana Kobylak     /**
347c0a07580SAdriana Kobylak      * @brief The libgpiod object for setting the power supply config
348c0a07580SAdriana Kobylak      */
349c0a07580SAdriana Kobylak     std::unique_ptr<GPIOInterfaceBase> powerConfigGPIO = nullptr;
350c9b05736SAdriana Kobylak 
351c9b05736SAdriana Kobylak     /**
352c9b05736SAdriana Kobylak      * @brief PowerSystemInputs object
353c9b05736SAdriana Kobylak      */
354c9b05736SAdriana Kobylak     PowerSystemInputs powerSystemInputs;
355c9b05736SAdriana Kobylak 
356c9b05736SAdriana Kobylak     /**
357c3324424SBrandon Wyman      * @brief Implement the ObjectManager for PowerSystemInputs object.
358c3324424SBrandon Wyman      *
359c3324424SBrandon Wyman      * Implements the org.freedesktop.DBus.ObjectManager interface used to
360c3324424SBrandon Wyman      * communicate updates to the PowerSystemInputs object on the
361c3324424SBrandon Wyman      * /xyz/openbmc_project/power/power_supplies root D-Bus path.
362c9b05736SAdriana Kobylak      */
363c9b05736SAdriana Kobylak     sdbusplus::server::manager_t objectManager;
364c3324424SBrandon Wyman 
365c3324424SBrandon Wyman     /**
366a068f424SMatt Spinler      * @brief Implement the ObjectManager for the input voltage rating.
367a068f424SMatt Spinler      *
368a068f424SMatt Spinler      * Implements the org.freedesktop.DBus.ObjectManager interface used to
369a068f424SMatt Spinler      * communicate updates to the input voltage ratings on the
370a068f424SMatt Spinler      * /xyz/openbmc_project/sensors root D-Bus path.
371a068f424SMatt Spinler      */
372a068f424SMatt Spinler     sdbusplus::server::manager_t sensorsObjManager;
373a068f424SMatt Spinler 
374a068f424SMatt Spinler     /**
37518a24d92SBrandon Wyman      * @brief GPIO to toggle to 'sync' power supply input history.
37618a24d92SBrandon Wyman      */
37718a24d92SBrandon Wyman     std::unique_ptr<GPIOInterfaceBase> syncHistoryGPIO = nullptr;
37818a24d92SBrandon Wyman 
37918a24d92SBrandon Wyman     /**
38018a24d92SBrandon Wyman      * @brief Toggles the GPIO to sync power supply input history readings
38118a24d92SBrandon Wyman      *
38218a24d92SBrandon Wyman      * This GPIO is connected to all supplies.  This will clear the
38318a24d92SBrandon Wyman      * previous readings out of the supplies and restart them both at the
38418a24d92SBrandon Wyman      * same time zero and at record ID 0.  The supplies will return 0
38518a24d92SBrandon Wyman      * bytes of data for the input history command right after this until
38618a24d92SBrandon Wyman      * a new entry shows up.
38718a24d92SBrandon Wyman      *
38818a24d92SBrandon Wyman      * This will cause the code to delete all previous history data and
38918a24d92SBrandon Wyman      * start fresh.
39018a24d92SBrandon Wyman      */
39118a24d92SBrandon Wyman     void syncHistory();
392a068f424SMatt Spinler 
393a068f424SMatt Spinler     /**
394a068f424SMatt Spinler      * @brief Tells each PSU to set its power supply input
395a068f424SMatt Spinler      *        voltage rating D-Bus property.
396a068f424SMatt Spinler      */
setInputVoltageRating()397a068f424SMatt Spinler     inline void setInputVoltageRating()
398a068f424SMatt Spinler     {
399a068f424SMatt Spinler         for (auto& psu : psus)
400a068f424SMatt Spinler         {
401a068f424SMatt Spinler             psu->setInputVoltageRating();
402a068f424SMatt Spinler         }
403a068f424SMatt Spinler     }
404b66ae50aSFaisal Awada 
405b66ae50aSFaisal Awada     /**
406b66ae50aSFaisal Awada      * @brief Build the device driver name for the power supply.
407b66ae50aSFaisal Awada      *
408b66ae50aSFaisal Awada      * @param[in] i2cbus - i2c bus
409b66ae50aSFaisal Awada      * @param[in] i2caddr - i2c bus address
410b66ae50aSFaisal Awada      */
411b66ae50aSFaisal Awada     void buildDriverName(uint64_t i2cbus, uint64_t i2caddr);
412b66ae50aSFaisal Awada 
413b66ae50aSFaisal Awada     /**
414*b7131a12SFaisal Awada      * @brief Find PSU with device driver name, then populate the device
415*b7131a12SFaisal Awada      *        driver name to all PSUs (including missing PSUs).
416*b7131a12SFaisal Awada      */
417*b7131a12SFaisal Awada     void populateDriverName();
418*b7131a12SFaisal Awada 
419*b7131a12SFaisal Awada     /**
420b66ae50aSFaisal Awada      * @brief The device driver name for all power supplies.
421b66ae50aSFaisal Awada      */
422b66ae50aSFaisal Awada     std::string driverName;
4232bac8609SBrandon Wyman };
4242bac8609SBrandon Wyman 
42563ea78b9SBrandon Wyman } // namespace phosphor::power::manager
426