Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 1 | #pragma once |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 2 | #include "device.hpp" |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame^] | 3 | #include "pmbus.hpp" |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 4 | |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 5 | namespace witherspoon |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 6 | { |
| 7 | namespace power |
| 8 | { |
| 9 | namespace psu |
| 10 | { |
| 11 | |
| 12 | /** |
| 13 | * @class PowerSupply |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 14 | * Represents a PMBus power supply device. |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 15 | */ |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 16 | class PowerSupply : public Device |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 17 | { |
| 18 | public: |
| 19 | PowerSupply() = delete; |
| 20 | PowerSupply(const PowerSupply&) = delete; |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 21 | PowerSupply(PowerSupply&&) = default; |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 22 | PowerSupply& operator=(const PowerSupply&) = default; |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 23 | PowerSupply& operator=(PowerSupply&&) = default; |
| 24 | ~PowerSupply() = default; |
| 25 | |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 26 | /** |
| 27 | * Constructor |
| 28 | * |
| 29 | * @param[in] name - the device name |
| 30 | * @param[in] inst - the device instance |
| 31 | * @param[in] objpath - the path to monitor |
| 32 | * @param[in] invpath - the inventory path to use |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame^] | 33 | * @param[in] bus - D-Bus bus object |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 34 | */ |
| 35 | PowerSupply(const std::string& name, size_t inst, |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame^] | 36 | const std::string& objpath, |
| 37 | const std::string& invpath, |
| 38 | sdbusplus::bus::bus& bus) |
| 39 | : Device(name, inst), monitorPath(objpath), inventoryPath(invpath), |
| 40 | bus(bus), pmbusIntf(objpath) |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 41 | { |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Power supply specific function to analyze for faults/errors. |
| 46 | * |
| 47 | * Various PMBus status bits will be checked for fault conditions. |
| 48 | * If a certain fault bits are on, the appropriate error will be |
| 49 | * committed. |
| 50 | */ |
| 51 | void analyze() override; |
| 52 | |
| 53 | /** |
| 54 | * Write PMBus CLEAR_FAULTS |
| 55 | * |
| 56 | * This function will be called in various situations in order to clear |
| 57 | * any fault status bits that may have been set, in order to start over |
| 58 | * with a clean state. Presence changes and power state changes will |
| 59 | * want to clear any faults logged. |
| 60 | */ |
| 61 | void clearFaults() override; |
| 62 | |
| 63 | private: |
| 64 | /** |
| 65 | * The path to use for reading various PMBus bits/words. |
| 66 | */ |
| 67 | std::string monitorPath; |
| 68 | |
| 69 | /** |
| 70 | * The D-Bus path to use for this power supply's inventory status. |
| 71 | */ |
| 72 | std::string inventoryPath; |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame^] | 73 | |
| 74 | /** @brief Connection for sdbusplus bus */ |
| 75 | sdbusplus::bus::bus& bus; |
| 76 | |
| 77 | /** |
| 78 | * @brief Pointer to the PMBus interface |
| 79 | * |
| 80 | * Used to read out of or write to the /sysfs tree(s) containing files |
| 81 | * that a device driver monitors the PMBus interface to the power |
| 82 | * supplies. |
| 83 | */ |
| 84 | witherspoon::pmbus::PMBus pmbusIntf; |
| 85 | |
| 86 | /** |
| 87 | * @brief Has a PMBus read failure already been logged? |
| 88 | */ |
| 89 | bool readFailLogged = false; |
| 90 | |
| 91 | /** |
| 92 | * @brief Set to true when a VIN UV fault has been detected |
| 93 | * |
| 94 | * This is the VIN_UV_FAULT bit in the low byte from the STATUS_WORD |
| 95 | * command response. |
| 96 | */ |
| 97 | bool vinUVFault = false; |
| 98 | |
| 99 | /** |
| 100 | * @brief Set to true when an input fault or warning is detected |
| 101 | * |
| 102 | * This is the "INPUT FAULT OR WARNING" bit in the high byte from the |
| 103 | * STATUS_WORD command response. |
| 104 | */ |
| 105 | bool inputFault = false; |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | } |
| 109 | } |
| 110 | } |