1*b54357f6SMatt Spinler #pragma once 2*b54357f6SMatt Spinler 3*b54357f6SMatt Spinler #include <algorithm> 4*b54357f6SMatt Spinler #include <map> 5*b54357f6SMatt Spinler #include <vector> 6*b54357f6SMatt Spinler #include "device.hpp" 7*b54357f6SMatt Spinler #include "pmbus.hpp" 8*b54357f6SMatt Spinler #include "types.hpp" 9*b54357f6SMatt Spinler 10*b54357f6SMatt Spinler namespace witherspoon 11*b54357f6SMatt Spinler { 12*b54357f6SMatt Spinler namespace power 13*b54357f6SMatt Spinler { 14*b54357f6SMatt Spinler 15*b54357f6SMatt Spinler /** 16*b54357f6SMatt Spinler * @class UCD90160 17*b54357f6SMatt Spinler * 18*b54357f6SMatt Spinler * This class implements fault analysis for the UCD90160 19*b54357f6SMatt Spinler * power sequencer device. 20*b54357f6SMatt Spinler * 21*b54357f6SMatt Spinler */ 22*b54357f6SMatt Spinler class UCD90160 : public Device 23*b54357f6SMatt Spinler { 24*b54357f6SMatt Spinler public: 25*b54357f6SMatt Spinler 26*b54357f6SMatt Spinler UCD90160() = delete; 27*b54357f6SMatt Spinler ~UCD90160() = default; 28*b54357f6SMatt Spinler UCD90160(const UCD90160&) = delete; 29*b54357f6SMatt Spinler UCD90160& operator=(const UCD90160&) = delete; 30*b54357f6SMatt Spinler UCD90160(UCD90160&&) = default; 31*b54357f6SMatt Spinler UCD90160& operator=(UCD90160&&) = default; 32*b54357f6SMatt Spinler 33*b54357f6SMatt Spinler /** 34*b54357f6SMatt Spinler * Constructor 35*b54357f6SMatt Spinler * 36*b54357f6SMatt Spinler * @param[in] instance - the device instance number 37*b54357f6SMatt Spinler */ 38*b54357f6SMatt Spinler UCD90160(size_t instance); 39*b54357f6SMatt Spinler 40*b54357f6SMatt Spinler /** 41*b54357f6SMatt Spinler * Analyzes the device for errors when the device is 42*b54357f6SMatt Spinler * known to be in an error state. A log will be created. 43*b54357f6SMatt Spinler */ 44*b54357f6SMatt Spinler void onFailure() override; 45*b54357f6SMatt Spinler 46*b54357f6SMatt Spinler /** 47*b54357f6SMatt Spinler * Checks the device for errors and only creates a log 48*b54357f6SMatt Spinler * if one is found. 49*b54357f6SMatt Spinler */ 50*b54357f6SMatt Spinler void analyze() override; 51*b54357f6SMatt Spinler 52*b54357f6SMatt Spinler /** 53*b54357f6SMatt Spinler * Clears faults in the device 54*b54357f6SMatt Spinler */ 55*b54357f6SMatt Spinler void clearFaults() override; 56*b54357f6SMatt Spinler 57*b54357f6SMatt Spinler private: 58*b54357f6SMatt Spinler 59*b54357f6SMatt Spinler /** 60*b54357f6SMatt Spinler * Checks for VOUT faults on the device. 61*b54357f6SMatt Spinler * 62*b54357f6SMatt Spinler * This device can monitor voltages of its dependent 63*b54357f6SMatt Spinler * devices, and VOUT faults are voltage faults 64*b54357f6SMatt Spinler * on these devices. 65*b54357f6SMatt Spinler * 66*b54357f6SMatt Spinler * @return bool - true if an error log was created 67*b54357f6SMatt Spinler */ 68*b54357f6SMatt Spinler bool checkVOUTFaults(); 69*b54357f6SMatt Spinler 70*b54357f6SMatt Spinler /** 71*b54357f6SMatt Spinler * Checks for PGOOD faults on the device. 72*b54357f6SMatt Spinler * 73*b54357f6SMatt Spinler * This device can monitor the PGOOD signals of its dependent 74*b54357f6SMatt Spinler * devices, and this check will look for faults of 75*b54357f6SMatt Spinler * those PGOODs. 76*b54357f6SMatt Spinler * 77*b54357f6SMatt Spinler * @param[in] polling - If this is running while polling for errors, 78*b54357f6SMatt Spinler * as opposing to analyzing a fail condition. 79*b54357f6SMatt Spinler * 80*b54357f6SMatt Spinler * @return bool - true if an error log was created 81*b54357f6SMatt Spinler */ 82*b54357f6SMatt Spinler bool checkPGOODFaults(bool polling); 83*b54357f6SMatt Spinler 84*b54357f6SMatt Spinler /** 85*b54357f6SMatt Spinler * Creates an error log when the device has an error 86*b54357f6SMatt Spinler * but it isn't a PGOOD or voltage failure. 87*b54357f6SMatt Spinler */ 88*b54357f6SMatt Spinler void createPowerFaultLog(); 89*b54357f6SMatt Spinler 90*b54357f6SMatt Spinler /** 91*b54357f6SMatt Spinler * The read/write interface to this hardware 92*b54357f6SMatt Spinler */ 93*b54357f6SMatt Spinler pmbus::PMBus interface; 94*b54357f6SMatt Spinler 95*b54357f6SMatt Spinler /** 96*b54357f6SMatt Spinler * Keeps track of device access errors to avoid repeatedly 97*b54357f6SMatt Spinler * logging errors for bad hardware 98*b54357f6SMatt Spinler */ 99*b54357f6SMatt Spinler bool accessError = false; 100*b54357f6SMatt Spinler 101*b54357f6SMatt Spinler /** 102*b54357f6SMatt Spinler * Map of device instance to the instance specific data 103*b54357f6SMatt Spinler */ 104*b54357f6SMatt Spinler static const ucd90160::DeviceMap deviceMap; 105*b54357f6SMatt Spinler }; 106*b54357f6SMatt Spinler 107*b54357f6SMatt Spinler } 108*b54357f6SMatt Spinler } 109