Fill in PGOOD fault checking code

Fill in the code to check for a PGOOD fault.  This is where
the power sequencer device detects that one of its child devices
lost PGOOD.  A separate error log will be created for each input
that has a fault.  Each input will only have an error logged against
it once for the lifetime of the object.

Errors are detected by reading the real time status of the PGOOD input,
which is exposed as a GPIO by the device driver.

Ideally we would be able to use a summary bit in the status_word
register to see if there is an error before doing any GPIO reads,
but as the device drivers sends a clear faults every time we read
that register, and the GPI fault bits are edge triggered in the
mfr_status register that feeds status_word, we would never detect
any failures.  If this was ever fixed in the core PMBus device
driver code, we could add this functionality in and save some
CPU cycles.

Change-Id: I5000f2ebc2b22dcca946154afd2405b29734ccaf
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/power-sequencer/ucd90160.hpp b/power-sequencer/ucd90160.hpp
index 09a3abf..a24443e 100644
--- a/power-sequencer/ucd90160.hpp
+++ b/power-sequencer/ucd90160.hpp
@@ -5,6 +5,7 @@
 #include <map>
 #include <vector>
 #include "device.hpp"
+#include "gpio.hpp"
 #include "pmbus.hpp"
 #include "types.hpp"
 
@@ -136,17 +137,57 @@
         }
 
         /**
+         * Says if we've already logged a PGOOD fault
+         *
+         * The policy is only 1 of the same errors will
+         * be logged for the duration of a class instance.
+         *
+         * @param[in] input - the input to check
+         *
+         * @return bool - if we've already logged a fault against
+         *                this input
+         */
+        inline bool isPGOODFaultLogged(uint32_t input) const
+        {
+            return std::find(pgoodErrors.begin(),
+                             pgoodErrors.end(),
+                             input) != pgoodErrors.end();
+        }
+
+        /**
+         * Saves that a PGOOD fault has been logged
+         *
+         * @param[in] input - the input the error was logged against
+         */
+        inline void setPGOODFaultLogged(uint32_t input)
+        {
+            pgoodErrors.push_back(input);
+        }
+
+        /**
          * List of pages that Vout errors have
          * already been logged against
          */
         std::vector<uint32_t> voutErrors;
 
         /**
+         * List of inputs that PGOOD errors have
+         * already been logged against
+         */
+        std::vector<uint32_t> pgoodErrors;
+
+        /**
          * The read/write interface to this hardware
          */
         pmbus::PMBus interface;
 
         /**
+         * A map of GPI pin IDs to the GPIO object
+         * used to access them
+         */
+        std::map<size_t, std::unique_ptr<gpio::GPIO>> gpios;
+
+        /**
          * Keeps track of device access errors to avoid repeatedly
          * logging errors for bad hardware
          */