chassis-psu: Enhance PSU function state management

Introduced new utility functions to enhance PSU handling in
Multi-Chassis environment.

- Read initial chassis power state (on/off, pgood) and sets up
  monitoring when power is on.
- Validate supported PSU configurations.
- Validate all present PSUs have same model.
- Validate number of PSUs against supported configuration.
- Validate each PSU reports an input voltage within range.
- Set Power Config GPIO based on the system supported configuration.
- Adding D-Bus call to report PSU errors setPowerSupplyError()
- Clears PSU fault status bit and resets to a clean state during PSU
  presence or power state changes.
- Implemented "onOffConfig()" to write PMBus ON_OFF_CONFIG command to
  all PSUs to ensure consistent PSU control.

Test:
  The following tests were done in simulated environment:
  - Verified `initialize()` retrieved and set current BMC state.
  - Validated supported configuration had all the PSUs present and had
    same model.Validated that mismatching PSUs models reported an
    unsupported configuration error.
  - Confirmed that setPowerSupplyError() was invoked when mismatches
    occurred.
  - Validated all present PSUs reported voltage in the supported range.

Change-Id: I5a7a6e40140829e6252e7c0ec0a04be369e3d445
Signed-off-by: Faisal Awada <faisal@us.ibm.com>
diff --git a/phosphor-power-supply/chassis.hpp b/phosphor-power-supply/chassis.hpp
index 6471f26..48bdefd 100644
--- a/phosphor-power-supply/chassis.hpp
+++ b/phosphor-power-supply/chassis.hpp
@@ -305,7 +305,7 @@
      * @brief Initializes the chassis.
      *
      */
-    void initialize() {}; // TODO
+    void initialize();
 
     /**
      * @brief Perform power supply configuration validation.
@@ -393,6 +393,76 @@
      * @breif Attempt to create GPIO
      */
     void attemptToCreatePowerConfigGPIO();
+
+    /**
+     * Write PMBus ON_OFF_CONFIG
+     *
+     * This function will be called to cause the PMBus device driver to send the
+     * ON_OFF_CONFIG command. Takes one byte of data.
+     */
+    void onOffConfig(const uint8_t data)
+    {
+        for (auto& psu : psus)
+        {
+            psu->onOffConfig(data);
+        }
+    }
+
+    /**
+     * This function will be called in various situations in order to clear
+     * any fault status bits that may have been set, in order to start over
+     * with a clean state. Presence changes and power state changes will want
+     * to clear any faults logged.
+     */
+    void clearFaults()
+    {
+        setPowerSupplyError("");
+        for (auto& psu : psus)
+        {
+            psu->clearFaults();
+        }
+    }
+
+    /**
+     * Let power control/sequencer application know of PSU error(s).
+     *
+     * @param[in] psuErrorString - string for power supply error
+     */
+    void setPowerSupplyError(const std::string& psuErrorString);
+
+    /**
+     * @brief Set the power-config-full-load GPIO depending on the EM full load
+     *        property value.
+     */
+    void setPowerConfigGPIO();
+
+    /**
+     * @brief Helper function to validate that all PSUs have the same model name
+     *
+     * @param[out] model - The model name. Empty if there is a mismatch.
+     * @param[out] additionalData - If there is a mismatch, it contains debug
+     *             information such as the mismatched model name.
+     * @return true if all the PSUs have the same model name, false otherwise.
+     */
+    bool validateModelName(std::string& model,
+                           std::map<std::string, std::string>& additionalData);
+
+    /**
+     * @brief Returns the number of PSUs that are required to be present.
+     */
+    unsigned int getRequiredPSUCount()
+    {
+        // TODO
+        return 1;
+    }
+
+    /**
+     * @brief Returns whether the specified PSU is required to be present.
+     *
+     * @param[in] psu - Power supply to check
+     * @return true if PSU is required, false otherwise.
+     */
+    bool isRequiredPSU(const PowerSupply& psu);
 };
 
 } // namespace phosphor::power::chassis