Update analyze function to check STATUS_WORD

The STATUS_WORD PMBus command response will be the start of the power
supply fault analysis. Update the analyze() function to read its value
and process (select) fault bits.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: If7274ad237c0604a56008676ae64804a5fd2854e
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index c3ff051..30fbf74 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -2,11 +2,13 @@
 
 #include "pmbus.hpp"
 #include "types.hpp"
+#include "utility.hpp"
 
 #include <sdbusplus/bus/match.hpp>
 
 namespace phosphor::power::psu
 {
+
 /**
  * @class PowerSupply
  * Represents a PMBus power supply device.
@@ -48,6 +50,11 @@
         updatePresence();
     }
 
+    phosphor::pmbus::PMBusBase& getPMBus()
+    {
+        return *pmbusIntf;
+    }
+
     /**
      * Power supply specific function to analyze for faults/errors.
      *
@@ -55,9 +62,7 @@
      * If a certain fault bits are on, the appropriate error will be
      * committed.
      */
-    void analyze()
-    {
-    }
+    void analyze();
 
     /**
      * Write PMBus CLEAR_FAULTS
@@ -69,6 +74,10 @@
      */
     void clearFaults()
     {
+        faultFound = false;
+        inputFault = false;
+        mfrFault = false;
+        vinUVFault = false;
     }
 
     /**
@@ -98,6 +107,38 @@
         return present;
     }
 
+    /**
+     * @brief Returns true if a fault was found.
+     */
+    bool isFaulted() const
+    {
+        return faultFound;
+    }
+
+    /**
+     * @brief Returns true if INPUT fault occurred.
+     */
+    bool hasInputFault() const
+    {
+        return inputFault;
+    }
+
+    /**
+     * @brief Returns true if MFRSPECIFIC occurred.
+     */
+    bool hasMFRFault() const
+    {
+        return mfrFault;
+    }
+
+    /**
+     * @brief Returns true if VIN_UV_FAULT occurred.
+     */
+    bool hasVINUVFault() const
+    {
+        return vinUVFault;
+    }
+
   private:
     /** @brief systemd bus member */
     sdbusplus::bus::bus& bus;
@@ -105,6 +146,15 @@
     /** @brief True if a fault has already been found and not cleared */
     bool faultFound = false;
 
+    /** @brief True if bit 5 of STATUS_WORD high byte is on. */
+    bool inputFault = false;
+
+    /** @brief True if bit 4 of STATUS_WORD high byte is on. */
+    bool mfrFault = false;
+
+    /** @brief True if bit 3 of STATUS_WORD low byte is on. */
+    bool vinUVFault = false;
+
     /**
      * @brief D-Bus path to use for this power supply's inventory status.
      **/