Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Brandon Wyman | 8d19577 | 2020-01-27 15:03:51 -0600 | [diff] [blame] | 3 | #include "pmbus.hpp" |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 4 | #include "types.hpp" |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 5 | #include "util.hpp" |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 6 | #include "utility.hpp" |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 7 | |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 8 | #include <gpiod.hpp> |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 9 | #include <sdbusplus/bus/match.hpp> |
| 10 | |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 11 | #include <filesystem> |
Brandon Wyman | 1d7a7df | 2020-03-26 10:14:05 -0500 | [diff] [blame] | 12 | #include <stdexcept> |
| 13 | |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 14 | namespace phosphor::power::psu |
| 15 | { |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 16 | |
Chanh Nguyen | c12c53b | 2021-04-06 17:24:47 +0700 | [diff] [blame] | 17 | #if IBM_VPD |
Brandon Wyman | 1d7a7df | 2020-03-26 10:14:05 -0500 | [diff] [blame] | 18 | // PMBus device driver "file name" to read for CCIN value. |
| 19 | constexpr auto CCIN = "ccin"; |
| 20 | constexpr auto PART_NUMBER = "part_number"; |
| 21 | constexpr auto FRU_NUMBER = "fru"; |
| 22 | constexpr auto SERIAL_HEADER = "header"; |
| 23 | constexpr auto SERIAL_NUMBER = "serial_number"; |
| 24 | constexpr auto FW_VERSION = "fw_version"; |
| 25 | |
| 26 | // The D-Bus property name to update with the CCIN value. |
| 27 | constexpr auto MODEL_PROP = "Model"; |
| 28 | constexpr auto PN_PROP = "PartNumber"; |
| 29 | constexpr auto SN_PROP = "SerialNumber"; |
| 30 | constexpr auto VERSION_PROP = "Version"; |
| 31 | |
| 32 | // ipzVPD Keyword sizes |
| 33 | static constexpr auto FL_KW_SIZE = 20; |
| 34 | #endif |
| 35 | |
Brandon Wyman | f65c406 | 2020-08-19 13:15:53 -0500 | [diff] [blame] | 36 | constexpr auto LOG_LIMIT = 3; |
Brandon Wyman | 06ca459 | 2021-12-06 22:52:23 +0000 | [diff] [blame] | 37 | constexpr auto DEGLITCH_LIMIT = 3; |
Brandon Wyman | f65c406 | 2020-08-19 13:15:53 -0500 | [diff] [blame] | 38 | |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 39 | /** |
| 40 | * @class PowerSupply |
| 41 | * Represents a PMBus power supply device. |
| 42 | */ |
| 43 | class PowerSupply |
| 44 | { |
| 45 | public: |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 46 | PowerSupply() = delete; |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 47 | PowerSupply(const PowerSupply&) = delete; |
| 48 | PowerSupply(PowerSupply&&) = delete; |
| 49 | PowerSupply& operator=(const PowerSupply&) = delete; |
| 50 | PowerSupply& operator=(PowerSupply&&) = delete; |
| 51 | ~PowerSupply() = default; |
| 52 | |
| 53 | /** |
Brandon Wyman | c63941c | 2020-01-27 16:49:33 -0600 | [diff] [blame] | 54 | * @param[in] invpath - String for inventory path to use |
| 55 | * @param[in] i2cbus - The bus number this power supply is on |
| 56 | * @param[in] i2caddr - The 16-bit I2C address of the power supply |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 57 | * @param[in] gpioLineName - The gpio-line-name to read for presence. See |
| 58 | * https://github.com/openbmc/docs/blob/master/designs/device-tree-gpio-naming.md |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 59 | */ |
Brandon Wyman | c63941c | 2020-01-27 16:49:33 -0600 | [diff] [blame] | 60 | PowerSupply(sdbusplus::bus::bus& bus, const std::string& invpath, |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 61 | std::uint8_t i2cbus, const std::uint16_t i2caddr, |
| 62 | const std::string& gpioLineName); |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 63 | |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 64 | phosphor::pmbus::PMBusBase& getPMBus() |
| 65 | { |
| 66 | return *pmbusIntf; |
| 67 | } |
| 68 | |
Adriana Kobylak | 3ca062a | 2021-10-20 15:27:23 +0000 | [diff] [blame] | 69 | GPIOInterfaceBase* getPresenceGPIO() |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 70 | { |
| 71 | return presenceGPIO.get(); |
| 72 | } |
| 73 | |
B. J. Wyman | d8b8cb1 | 2021-07-15 22:03:34 +0000 | [diff] [blame] | 74 | std::string getPresenceGPIOName() const |
| 75 | { |
| 76 | if (presenceGPIO != nullptr) |
| 77 | { |
| 78 | return presenceGPIO->getName(); |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | return std::string(); |
| 83 | } |
| 84 | } |
| 85 | |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 86 | /** |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 87 | * Power supply specific function to analyze for faults/errors. |
| 88 | * |
| 89 | * Various PMBus status bits will be checked for fault conditions. |
| 90 | * If a certain fault bits are on, the appropriate error will be |
| 91 | * committed. |
| 92 | */ |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 93 | void analyze(); |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 94 | |
| 95 | /** |
Brandon Wyman | 59a3579 | 2020-06-04 12:37:40 -0500 | [diff] [blame] | 96 | * Write PMBus ON_OFF_CONFIG |
| 97 | * |
| 98 | * This function will be called to cause the PMBus device driver to send the |
| 99 | * ON_OFF_CONFIG command. Takes one byte of data. |
| 100 | * |
| 101 | * @param[in] data - The ON_OFF_CONFIG data byte mask. |
| 102 | */ |
| 103 | void onOffConfig(uint8_t data); |
| 104 | |
| 105 | /** |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 106 | * Write PMBus CLEAR_FAULTS |
| 107 | * |
| 108 | * This function will be called in various situations in order to clear |
| 109 | * any fault status bits that may have been set, in order to start over |
| 110 | * with a clean state. Presence changes and power state changes will |
| 111 | * want to clear any faults logged. |
| 112 | */ |
Brandon Wyman | 3c20846 | 2020-05-13 16:25:58 -0500 | [diff] [blame] | 113 | void clearFaults(); |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * @brief Adds properties to the inventory. |
| 117 | * |
| 118 | * Reads the values from the device and writes them to the |
| 119 | * associated power supply D-Bus inventory object. |
| 120 | * |
| 121 | * This needs to be done on startup, and each time the presence |
| 122 | * state changes. |
| 123 | * |
| 124 | * Properties added: |
| 125 | * - Serial Number |
| 126 | * - Part Number |
| 127 | * - CCIN (Customer Card Identification Number) - added as the Model |
| 128 | * - Firmware version |
| 129 | */ |
Brandon Wyman | 1d7a7df | 2020-03-26 10:14:05 -0500 | [diff] [blame] | 130 | void updateInventory(); |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 131 | |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 132 | /** |
| 133 | * @brief Accessor function to indicate present status |
| 134 | */ |
| 135 | bool isPresent() const |
| 136 | { |
| 137 | return present; |
| 138 | } |
| 139 | |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 140 | /** |
Brandon Wyman | fed0ba2 | 2020-09-26 20:02:51 -0500 | [diff] [blame] | 141 | * @brief Returns the last read value from STATUS_WORD. |
| 142 | */ |
| 143 | uint64_t getStatusWord() const |
| 144 | { |
| 145 | return statusWord; |
| 146 | } |
| 147 | |
| 148 | /** |
Brandon Wyman | f07bc79 | 2021-10-12 19:00:35 +0000 | [diff] [blame] | 149 | * @brief Returns the last read value from STATUS_INPUT. |
| 150 | */ |
| 151 | uint64_t getStatusInput() const |
| 152 | { |
| 153 | return statusInput; |
| 154 | } |
| 155 | |
| 156 | /** |
Jay Meyer | 10d9405 | 2020-11-30 14:41:21 -0600 | [diff] [blame] | 157 | * @brief Returns the last read value from STATUS_MFR. |
| 158 | */ |
| 159 | uint64_t getMFRFault() const |
| 160 | { |
| 161 | return statusMFR; |
| 162 | } |
| 163 | |
| 164 | /** |
Brandon Wyman | 85c7bf4 | 2021-10-19 22:28:48 +0000 | [diff] [blame] | 165 | * @brief Returns the last read value from STATUS_CML. |
| 166 | */ |
| 167 | uint64_t getStatusCML() const |
| 168 | { |
| 169 | return statusCML; |
| 170 | } |
| 171 | |
| 172 | /** |
Brandon Wyman | 6710ba2 | 2021-10-27 17:39:31 +0000 | [diff] [blame] | 173 | * @brief Returns the last read value from STATUS_VOUT. |
| 174 | */ |
| 175 | uint64_t getStatusVout() const |
| 176 | { |
| 177 | return statusVout; |
| 178 | } |
| 179 | |
| 180 | /** |
Brandon Wyman | b10b3be | 2021-11-09 22:12:15 +0000 | [diff] [blame] | 181 | * @brief Returns the last value read from STATUS_IOUT. |
| 182 | */ |
| 183 | uint64_t getStatusIout() const |
| 184 | { |
| 185 | return statusIout; |
| 186 | } |
| 187 | |
| 188 | /** |
Brandon Wyman | 7ee4d7e | 2021-11-19 20:48:23 +0000 | [diff] [blame] | 189 | * @brief Returns the last value read from STATUS_FANS_1_2. |
| 190 | */ |
| 191 | uint64_t getStatusFans12() const |
| 192 | { |
| 193 | return statusFans12; |
| 194 | } |
| 195 | |
| 196 | /** |
Brandon Wyman | 96893a4 | 2021-11-05 19:56:57 +0000 | [diff] [blame] | 197 | * @brief Returns the last value read from STATUS_TEMPERATURE. |
| 198 | */ |
| 199 | uint64_t getStatusTemperature() const |
| 200 | { |
| 201 | return statusTemperature; |
| 202 | } |
| 203 | |
| 204 | /** |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 205 | * @brief Returns true if a fault was found. |
| 206 | */ |
| 207 | bool isFaulted() const |
| 208 | { |
Brandon Wyman | 9ddc622 | 2021-10-28 17:28:01 +0000 | [diff] [blame] | 209 | return (hasCommFault() || vinUVFault || inputFault || voutOVFault || |
Brandon Wyman | 7ee4d7e | 2021-11-19 20:48:23 +0000 | [diff] [blame] | 210 | ioutOCFault || voutUVFault || fanFault || tempFault || |
Brandon Wyman | 06ca459 | 2021-12-06 22:52:23 +0000 | [diff] [blame] | 211 | (pgoodFault >= DEGLITCH_LIMIT) || mfrFault); |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | /** |
Brandon Wyman | b76ab24 | 2020-09-16 18:06:06 -0500 | [diff] [blame] | 215 | * @brief Return whether a fault has been logged for this power supply |
| 216 | */ |
| 217 | bool isFaultLogged() const |
| 218 | { |
| 219 | return faultLogged; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * @brief Called when a fault for this power supply has been logged. |
| 224 | */ |
| 225 | void setFaultLogged() |
| 226 | { |
| 227 | faultLogged = true; |
| 228 | } |
| 229 | |
| 230 | /** |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 231 | * @brief Returns true if INPUT fault occurred. |
| 232 | */ |
| 233 | bool hasInputFault() const |
| 234 | { |
| 235 | return inputFault; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * @brief Returns true if MFRSPECIFIC occurred. |
| 240 | */ |
| 241 | bool hasMFRFault() const |
| 242 | { |
| 243 | return mfrFault; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * @brief Returns true if VIN_UV_FAULT occurred. |
| 248 | */ |
| 249 | bool hasVINUVFault() const |
| 250 | { |
| 251 | return vinUVFault; |
| 252 | } |
| 253 | |
Brandon Wyman | c9efe41 | 2020-10-09 15:42:50 -0500 | [diff] [blame] | 254 | /** |
Brandon Wyman | 6710ba2 | 2021-10-27 17:39:31 +0000 | [diff] [blame] | 255 | * @brief Returns true if VOUT_OV_FAULT occurred. |
| 256 | */ |
| 257 | bool hasVoutOVFault() const |
| 258 | { |
| 259 | return voutOVFault; |
| 260 | } |
| 261 | |
| 262 | /** |
Brandon Wyman | b10b3be | 2021-11-09 22:12:15 +0000 | [diff] [blame] | 263 | * @brief Returns true if IOUT_OC fault occurred (bit 4 STATUS_BYTE). |
| 264 | */ |
| 265 | bool hasIoutOCFault() const |
| 266 | { |
| 267 | return ioutOCFault; |
| 268 | } |
| 269 | |
| 270 | /** |
Brandon Wyman | 2cf4694 | 2021-10-28 19:09:16 +0000 | [diff] [blame] | 271 | * @brief Returns true if VOUT_UV_FAULT occurred. |
| 272 | */ |
| 273 | bool hasVoutUVFault() const |
| 274 | { |
| 275 | return voutUVFault; |
| 276 | } |
| 277 | |
| 278 | /** |
Brandon Wyman | 7ee4d7e | 2021-11-19 20:48:23 +0000 | [diff] [blame] | 279 | *@brief Returns true if fan fault occurred. |
| 280 | */ |
| 281 | bool hasFanFault() const |
| 282 | { |
| 283 | return fanFault; |
| 284 | } |
| 285 | |
| 286 | /** |
Brandon Wyman | 96893a4 | 2021-11-05 19:56:57 +0000 | [diff] [blame] | 287 | * @brief Returns true if TEMPERATURE fault occurred. |
| 288 | */ |
| 289 | bool hasTempFault() const |
| 290 | { |
| 291 | return tempFault; |
| 292 | } |
| 293 | |
| 294 | /** |
Brandon Wyman | 2916ea5 | 2021-11-06 03:31:18 +0000 | [diff] [blame] | 295 | * @brief Returns true if there is a PGood fault (PGOOD# inactive, or OFF |
| 296 | * bit on). |
| 297 | */ |
| 298 | bool hasPgoodFault() const |
| 299 | { |
Brandon Wyman | 06ca459 | 2021-12-06 22:52:23 +0000 | [diff] [blame] | 300 | return (pgoodFault >= DEGLITCH_LIMIT); |
Brandon Wyman | 2916ea5 | 2021-11-06 03:31:18 +0000 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | /** |
Brandon Wyman | c9efe41 | 2020-10-09 15:42:50 -0500 | [diff] [blame] | 304 | * @brief Returns the device path |
| 305 | * |
| 306 | * This can be used for error call outs. |
| 307 | * Example: /sys/bus/i2c/devices/3-0068 |
| 308 | */ |
Brandon Wyman | 4176d6b | 2020-10-07 17:41:06 -0500 | [diff] [blame] | 309 | const std::string getDevicePath() const |
| 310 | { |
| 311 | return pmbusIntf->path(); |
| 312 | } |
| 313 | |
Brandon Wyman | c9efe41 | 2020-10-09 15:42:50 -0500 | [diff] [blame] | 314 | /** |
| 315 | * @brief Returns this power supplies inventory path. |
| 316 | * |
| 317 | * This can be used for error call outs. |
| 318 | * Example: |
| 319 | * /xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply1 |
| 320 | */ |
Brandon Wyman | 7e49527 | 2020-09-26 19:57:46 -0500 | [diff] [blame] | 321 | const std::string& getInventoryPath() const |
| 322 | { |
| 323 | return inventoryPath; |
| 324 | } |
| 325 | |
Brandon Wyman | c9efe41 | 2020-10-09 15:42:50 -0500 | [diff] [blame] | 326 | /** |
| 327 | * @brief Returns the firmware revision version read from the power supply |
| 328 | */ |
| 329 | const std::string& getFWVersion() const |
| 330 | { |
| 331 | return fwVersion; |
| 332 | } |
| 333 | |
Adriana Kobylak | 572a905 | 2021-03-30 15:58:07 +0000 | [diff] [blame] | 334 | /** |
| 335 | * @brief Returns the model name of the power supply |
| 336 | */ |
| 337 | const std::string& getModelName() const |
| 338 | { |
| 339 | return modelName; |
| 340 | } |
| 341 | |
Brandon Wyman | f65c406 | 2020-08-19 13:15:53 -0500 | [diff] [blame] | 342 | /** @brief Returns true if the number of failed reads exceeds limit |
| 343 | * TODO: or CML bit on. |
| 344 | */ |
| 345 | bool hasCommFault() const |
| 346 | { |
Brandon Wyman | 85c7bf4 | 2021-10-19 22:28:48 +0000 | [diff] [blame] | 347 | return ((readFail >= LOG_LIMIT) || (cmlFault)); |
Brandon Wyman | f65c406 | 2020-08-19 13:15:53 -0500 | [diff] [blame] | 348 | } |
| 349 | |
Adriana Kobylak | 4175ffb | 2021-08-02 14:51:05 +0000 | [diff] [blame] | 350 | /** |
| 351 | * @brief Reads the pmbus input voltage and returns that actual voltage |
| 352 | * reading and the calculated input voltage based on thresholds. |
| 353 | * @param[out] actualInputVoltage - The actual voltage reading, in Volts. |
| 354 | * @param[out] inputVoltage - A rounded up/down value of the actual input |
| 355 | * voltage based on thresholds, in Volts. |
| 356 | */ |
| 357 | void getInputVoltage(double& actualInputVoltage, int& inputVoltage) const; |
| 358 | |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 359 | private: |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 360 | /** @brief systemd bus member */ |
| 361 | sdbusplus::bus::bus& bus; |
| 362 | |
Brandon Wyman | 9564e94 | 2020-11-10 14:01:42 -0600 | [diff] [blame] | 363 | /** @brief Will be updated to the latest/lastvalue read from STATUS_WORD.*/ |
Brandon Wyman | fed0ba2 | 2020-09-26 20:02:51 -0500 | [diff] [blame] | 364 | uint64_t statusWord = 0; |
| 365 | |
Brandon Wyman | f07bc79 | 2021-10-12 19:00:35 +0000 | [diff] [blame] | 366 | /** @brief Will be updated to the latest/lastvalue read from STATUS_INPUT.*/ |
| 367 | uint64_t statusInput = 0; |
| 368 | |
Jay Meyer | 10d9405 | 2020-11-30 14:41:21 -0600 | [diff] [blame] | 369 | /** @brief Will be updated to the latest/lastvalue read from STATUS_MFR.*/ |
| 370 | uint64_t statusMFR = 0; |
| 371 | |
Brandon Wyman | 85c7bf4 | 2021-10-19 22:28:48 +0000 | [diff] [blame] | 372 | /** @brief Will be updated to the latest/last value read from STATUS_CML.*/ |
| 373 | uint64_t statusCML = 0; |
| 374 | |
Brandon Wyman | 6710ba2 | 2021-10-27 17:39:31 +0000 | [diff] [blame] | 375 | /** @brief Will be updated to the latest/last value read from STATUS_VOUT.*/ |
| 376 | uint64_t statusVout = 0; |
| 377 | |
Brandon Wyman | b10b3be | 2021-11-09 22:12:15 +0000 | [diff] [blame] | 378 | /** @brief Will be updated to the latest/last value read from STATUS_IOUT.*/ |
| 379 | uint64_t statusIout = 0; |
| 380 | |
Brandon Wyman | 96893a4 | 2021-11-05 19:56:57 +0000 | [diff] [blame] | 381 | /** @brief Will be updated to the latest/last value read from |
Brandon Wyman | 7ee4d7e | 2021-11-19 20:48:23 +0000 | [diff] [blame] | 382 | * STATUS_FANS_1_2. */ |
| 383 | uint64_t statusFans12 = 0; |
| 384 | |
| 385 | /** @brief Will be updated to the latest/last value read from |
Brandon Wyman | 96893a4 | 2021-11-05 19:56:57 +0000 | [diff] [blame] | 386 | * STATUS_TEMPERATURE.*/ |
| 387 | uint64_t statusTemperature = 0; |
| 388 | |
Brandon Wyman | b76ab24 | 2020-09-16 18:06:06 -0500 | [diff] [blame] | 389 | /** @brief True if an error for a fault has already been logged. */ |
| 390 | bool faultLogged = false; |
| 391 | |
Brandon Wyman | 96893a4 | 2021-11-05 19:56:57 +0000 | [diff] [blame] | 392 | /** @brief True if bit 1 of STATUS_WORD low byte is on. */ |
Brandon Wyman | 85c7bf4 | 2021-10-19 22:28:48 +0000 | [diff] [blame] | 393 | bool cmlFault = false; |
| 394 | |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 395 | /** @brief True if bit 5 of STATUS_WORD high byte is on. */ |
| 396 | bool inputFault = false; |
| 397 | |
| 398 | /** @brief True if bit 4 of STATUS_WORD high byte is on. */ |
| 399 | bool mfrFault = false; |
| 400 | |
| 401 | /** @brief True if bit 3 of STATUS_WORD low byte is on. */ |
| 402 | bool vinUVFault = false; |
| 403 | |
Brandon Wyman | 6710ba2 | 2021-10-27 17:39:31 +0000 | [diff] [blame] | 404 | /** @brief True if bit 5 of STATUS_WORD low byte is on. */ |
| 405 | bool voutOVFault = false; |
| 406 | |
Brandon Wyman | b10b3be | 2021-11-09 22:12:15 +0000 | [diff] [blame] | 407 | /** @brief True if bit 4 of STATUS_WORD low byte is on. */ |
| 408 | bool ioutOCFault = false; |
| 409 | |
Brandon Wyman | 2cf4694 | 2021-10-28 19:09:16 +0000 | [diff] [blame] | 410 | /** @brief True if bit 7 of STATUS_WORD high byte is on and bit 5 (VOUT_OV) |
| 411 | * of low byte is off. */ |
| 412 | bool voutUVFault = false; |
| 413 | |
Brandon Wyman | 7ee4d7e | 2021-11-19 20:48:23 +0000 | [diff] [blame] | 414 | /** @brief True if FANS fault/warn bit on in STATUS_WORD. */ |
| 415 | bool fanFault = false; |
| 416 | |
Brandon Wyman | 96893a4 | 2021-11-05 19:56:57 +0000 | [diff] [blame] | 417 | /** @brief True if bit 2 of STATUS_WORD low byte is on. */ |
| 418 | bool tempFault = false; |
| 419 | |
Brandon Wyman | 2cf4694 | 2021-10-28 19:09:16 +0000 | [diff] [blame] | 420 | /** |
Brandon Wyman | 06ca459 | 2021-12-06 22:52:23 +0000 | [diff] [blame] | 421 | * @brief Incremented if bit 11 or 6 of STATUS_WORD is on. PGOOD# is |
| 422 | * inactive, or the unit is off. |
| 423 | * |
| 424 | * Considered faulted if reaches DEGLITCH_LIMIT. |
Brandon Wyman | 2916ea5 | 2021-11-06 03:31:18 +0000 | [diff] [blame] | 425 | */ |
Brandon Wyman | 06ca459 | 2021-12-06 22:52:23 +0000 | [diff] [blame] | 426 | int pgoodFault = 0; |
Brandon Wyman | 2916ea5 | 2021-11-06 03:31:18 +0000 | [diff] [blame] | 427 | |
Brandon Wyman | f65c406 | 2020-08-19 13:15:53 -0500 | [diff] [blame] | 428 | /** @brief Count of the number of read failures. */ |
| 429 | size_t readFail = 0; |
| 430 | |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 431 | /** |
| 432 | * @brief D-Bus path to use for this power supply's inventory status. |
| 433 | **/ |
| 434 | std::string inventoryPath; |
| 435 | |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 436 | /** |
| 437 | * @brief The libgpiod object for monitoring PSU presence |
| 438 | */ |
Adriana Kobylak | 3ca062a | 2021-10-20 15:27:23 +0000 | [diff] [blame] | 439 | std::unique_ptr<GPIOInterfaceBase> presenceGPIO = nullptr; |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 440 | |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 441 | /** @brief True if the power supply is present. */ |
| 442 | bool present = false; |
| 443 | |
Adriana Kobylak | 572a905 | 2021-03-30 15:58:07 +0000 | [diff] [blame] | 444 | /** @brief Power supply model name. */ |
| 445 | std::string modelName; |
| 446 | |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 447 | /** @brief D-Bus match variable used to subscribe to Present property |
| 448 | * changes. |
| 449 | **/ |
| 450 | std::unique_ptr<sdbusplus::bus::match_t> presentMatch; |
| 451 | |
| 452 | /** @brief D-Bus match variable used to subscribe for Present property |
| 453 | * interface added. |
| 454 | */ |
| 455 | std::unique_ptr<sdbusplus::bus::match_t> presentAddedMatch; |
| 456 | |
| 457 | /** |
Brandon Wyman | 8d19577 | 2020-01-27 15:03:51 -0600 | [diff] [blame] | 458 | * @brief Pointer to the PMBus interface |
| 459 | * |
| 460 | * Used to read or write to/from PMBus power supply devices. |
| 461 | */ |
Brandon Wyman | 9564e94 | 2020-11-10 14:01:42 -0600 | [diff] [blame] | 462 | std::unique_ptr<phosphor::pmbus::PMBusBase> pmbusIntf = nullptr; |
Brandon Wyman | 8d19577 | 2020-01-27 15:03:51 -0600 | [diff] [blame] | 463 | |
Brandon Wyman | c9efe41 | 2020-10-09 15:42:50 -0500 | [diff] [blame] | 464 | /** @brief Stored copy of the firmware version/revision string */ |
| 465 | std::string fwVersion; |
| 466 | |
Brandon Wyman | 8d19577 | 2020-01-27 15:03:51 -0600 | [diff] [blame] | 467 | /** |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 468 | * @brief The file system path used for binding the device driver. |
| 469 | */ |
| 470 | const std::filesystem::path bindPath; |
| 471 | |
| 472 | /* @brief The string to pass in for binding the device driver. */ |
| 473 | std::string bindDevice; |
| 474 | |
| 475 | /** |
| 476 | * @brief Binds or unbinds the power supply device driver |
| 477 | * |
| 478 | * Called when a presence change is detected to either bind the device |
| 479 | * driver for the power supply when it is installed, or unbind the device |
| 480 | * driver when the power supply is removed. |
| 481 | * |
| 482 | * Writes <device> to <path>/bind (or unbind) |
| 483 | * |
| 484 | * @param present - when true, will bind the device driver |
| 485 | * when false, will unbind the device driver |
| 486 | */ |
| 487 | void bindOrUnbindDriver(bool present); |
| 488 | |
| 489 | /** |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 490 | * @brief Updates the presence status by querying D-Bus |
| 491 | * |
| 492 | * The D-Bus inventory properties for this power supply will be read to |
| 493 | * determine if the power supply is present or not and update this |
| 494 | * object's present member variable to reflect current status. |
| 495 | **/ |
| 496 | void updatePresence(); |
| 497 | |
| 498 | /** |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 499 | * @brief Updates the power supply presence by reading the GPIO line. |
| 500 | */ |
| 501 | void updatePresenceGPIO(); |
| 502 | |
| 503 | /** |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 504 | * @brief Callback for inventory property changes |
| 505 | * |
| 506 | * Process change of Present property for power supply. |
| 507 | * |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 508 | * This is used if we are watching the D-Bus properties instead of reading |
| 509 | * the GPIO presence line ourselves. |
| 510 | * |
Brandon Wyman | aed1f75 | 2019-11-25 18:10:52 -0600 | [diff] [blame] | 511 | * @param[in] msg - Data associated with Present change signal |
| 512 | **/ |
| 513 | void inventoryChanged(sdbusplus::message::message& msg); |
Brandon Wyman | 9a507db | 2021-02-25 16:15:22 -0600 | [diff] [blame] | 514 | |
| 515 | /** |
| 516 | * @brief Callback for inventory property added. |
| 517 | * |
| 518 | * Process add of the interface with the Present property for power supply. |
| 519 | * |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 520 | * This is used if we are watching the D-Bus properties instead of reading |
| 521 | * the GPIO presence line ourselves. |
| 522 | * |
Brandon Wyman | 9a507db | 2021-02-25 16:15:22 -0600 | [diff] [blame] | 523 | * @param[in] msg - Data associated with Present add signal |
| 524 | **/ |
| 525 | void inventoryAdded(sdbusplus::message::message& msg); |
Brandon Wyman | a0f33ce | 2019-10-17 18:32:29 -0500 | [diff] [blame] | 526 | }; |
| 527 | |
| 528 | } // namespace phosphor::power::psu |