psu-ng: INPUT_HISTORY syncHistory

Add in the function that syncs the power supply input history data
between all the installed power supplies.

Use the GPIO line name instead of gpiochip and number. Use libgpiod via
helper utility. Create a toggleLowHigh() to use for synchronizing the
input history.

Add in indicator and helper functions to indicate a syncHistory is
needed if a power supply goes from missing to present.

Trace when syncHistory is called. This should be infrequent enough that
I do not think it would be a problem.

Initial testing on Rainier 2S2U did not need a lengthy delay between
lowering and raising the power-ffs-sync-history GPIO, but testing on
Rainier 2S4u required a longer delay.

Depends-On: Ib1ac2456f7f715360d089dfa4b6b379b516439ab

Change-Id: I022806155139d70fb4a42cc27eb9f279f6a3aedc
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index b81599b..566deec 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -488,6 +488,26 @@
         }
     }
 
+    /**
+     * @brief Returns true when INPUT_HISTORY sync is required.
+     */
+    bool isSyncHistoryRequired() const
+    {
+        return syncHistoryRequired;
+    }
+
+    /**
+     * @brief Clears the indicator that sync required for INPUT_HISTORY.
+     *
+     * Sets variable to false to indicate that the sync is no longer required.
+     * This can be used after the PSUManager has reacted to the need for the
+     * INPUT_HISTORY data to be synchronized.
+     */
+    void clearSyncHistoryRequired()
+    {
+        syncHistoryRequired = false;
+    }
+
   private:
     /** @brief systemd bus member */
     sdbusplus::bus::bus& bus;
@@ -858,6 +878,15 @@
     bool inputHistorySupported{false};
 
     /**
+     * @brief Set to true when INPUT_HISTORY sync is required.
+     *
+     * A power supply will need to synchronize its INPUT_HISTORY data with the
+     * other power supplies installed in the system when it goes from missing to
+     * present.
+     */
+    bool syncHistoryRequired{false};
+
+    /**
      * @brief Class that manages the input power history records.
      **/
     std::unique_ptr<history::RecordManager> recordManager;