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