psu-ng: Add in detection of fan faults

If the FANS bit in the STATUS_WORD turns on (A fan or airflow fault or
warning has occurred), set a fan fault indicator in the power supply
object. During analysis of the power supplies, if a fan fault has
occurred, prioritize that over a temperature fault, include the
STATUS_TEMPERATURE and STATUS_FANS_1_2 command responses in the error
created. Call out the power supply with the fault.

Tested:
   Verify no faults detected or logged on real hardware (Rainier 2S4U).
   Simulate fan 1 fault on Rainier 2S2U, 110015FF PEL created.

Change-Id: Ifff5b4d96efe44b081a33caa01d70fdb578e57e3
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 149d81f..cf4c2bb 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -185,6 +185,14 @@
     }
 
     /**
+     * @brief Returns the last value read from STATUS_FANS_1_2.
+     */
+    uint64_t getStatusFans12() const
+    {
+        return statusFans12;
+    }
+
+    /**
      * @brief Returns the last value read from STATUS_TEMPERATURE.
      */
     uint64_t getStatusTemperature() const
@@ -198,8 +206,8 @@
     bool isFaulted() const
     {
         return (hasCommFault() || vinUVFault || inputFault || voutOVFault ||
-                ioutOCFault || voutUVFault || tempFault || pgoodFault ||
-                mfrFault);
+                ioutOCFault || voutUVFault || fanFault || tempFault ||
+                pgoodFault || mfrFault);
     }
 
     /**
@@ -267,6 +275,14 @@
     }
 
     /**
+     *@brief Returns true if fan fault occurred.
+     */
+    bool hasFanFault() const
+    {
+        return fanFault;
+    }
+
+    /**
      * @brief Returns true if TEMPERATURE fault occurred.
      */
     bool hasTempFault() const
@@ -362,6 +378,10 @@
     uint64_t statusIout = 0;
 
     /** @brief Will be updated to the latest/last value read from
+     * STATUS_FANS_1_2. */
+    uint64_t statusFans12 = 0;
+
+    /** @brief Will be updated to the latest/last value read from
      * STATUS_TEMPERATURE.*/
     uint64_t statusTemperature = 0;
 
@@ -390,6 +410,9 @@
      * of low byte is off. */
     bool voutUVFault = false;
 
+    /** @brief True if FANS fault/warn bit on in STATUS_WORD. */
+    bool fanFault = false;
+
     /** @brief True if bit 2 of STATUS_WORD low byte is on. */
     bool tempFault = false;