Shutdown system on GPU over-temps

Resolves openbmc/openbmc#1726

Change-Id: If3263678bc03df7714f31aa097f38ee6c09389f4
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/power-sequencer/ucd90160.cpp b/power-sequencer/ucd90160.cpp
index 715dcd1..2e2578f 100644
--- a/power-sequencer/ucd90160.cpp
+++ b/power-sequencer/ucd90160.cpp
@@ -23,6 +23,7 @@
 #include <xyz/openbmc_project/Power/Fault/error.hpp>
 #include "names_values.hpp"
 #include "ucd90160.hpp"
+#include "utility.hpp"
 
 namespace witherspoon
 {
@@ -45,13 +46,14 @@
 using namespace sdbusplus::xyz::openbmc_project::Sensor::Device::Error;
 using namespace sdbusplus::xyz::openbmc_project::Power::Fault::Error;
 
-UCD90160::UCD90160(size_t instance) :
+UCD90160::UCD90160(size_t instance, sdbusplus::bus::bus& bus) :
         Device(DEVICE_NAME, instance),
         interface(std::get<ucd90160::pathField>(
                           deviceMap.find(instance)->second),
                   DRIVER_NAME,
                   instance),
-        gpioDevice(findGPIODevice(interface.path()))
+        gpioDevice(findGPIODevice(interface.path())),
+        bus(bus)
 {
 }
 
@@ -309,6 +311,7 @@
 bool UCD90160::doGPIOAnalysis(ucd90160::extraAnalysisType type)
 {
     bool errorFound = false;
+    bool shutdown = false;
 
     const auto& analysisConfig = std::get<ucd90160::gpioAnalysisField>(
             deviceMap.find(getInstance())->second);
@@ -379,9 +382,24 @@
 
             //Save the part callout so we don't call it out again
             setPartCallout(callout);
+
+            //Some errors (like overtemps) require a shutdown
+            auto actions = static_cast<uint32_t>(
+                    std::get<ucd90160::optionFlagsField>(gpioConfig->second));
+
+            if (actions & static_cast<decltype(actions)>(
+                        ucd90160::optionFlags::shutdownOnFault))
+            {
+                shutdown = true;
+            }
         }
     }
 
+    if (shutdown)
+    {
+        util::powerOff(bus);
+    }
+
     return errorFound;
 }