Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2017 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame] | 16 | #include <phosphor-logging/log.hpp> |
| 17 | #include <phosphor-logging/elog.hpp> |
Brandon Wyman | e0eb45c | 2017-10-06 12:58:42 -0500 | [diff] [blame] | 18 | #include <org/open_power/Witherspoon/Fault/error.hpp> |
Matt Spinler | ceacf94 | 2017-10-05 13:55:02 -0500 | [diff] [blame] | 19 | #include <xyz/openbmc_project/Common/Device/error.hpp> |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame] | 20 | #include "elog-errors.hpp" |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 21 | #include "names_values.hpp" |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 22 | #include "power_supply.hpp" |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame] | 23 | #include "pmbus.hpp" |
| 24 | #include "utility.hpp" |
| 25 | |
| 26 | using namespace phosphor::logging; |
Brandon Wyman | e0eb45c | 2017-10-06 12:58:42 -0500 | [diff] [blame] | 27 | using namespace sdbusplus::org::open_power::Witherspoon::Fault::Error; |
Matt Spinler | ceacf94 | 2017-10-05 13:55:02 -0500 | [diff] [blame] | 28 | using namespace sdbusplus::xyz::openbmc_project::Common::Device::Error; |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 29 | |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 30 | namespace witherspoon |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 31 | { |
| 32 | namespace power |
| 33 | { |
| 34 | namespace psu |
| 35 | { |
| 36 | |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 37 | constexpr auto INVENTORY_OBJ_PATH = "/xyz/openbmc_project/inventory"; |
| 38 | constexpr auto INVENTORY_INTERFACE = "xyz.openbmc_project.Inventory.Item"; |
| 39 | constexpr auto PRESENT_PROP = "Present"; |
Brandon Wyman | 431fbe4 | 2017-08-18 16:22:09 -0500 | [diff] [blame] | 40 | constexpr auto POWER_OBJ_PATH = "/org/openbmc/control/power0"; |
| 41 | constexpr auto POWER_INTERFACE = "org.openbmc.control.Power"; |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 42 | |
| 43 | PowerSupply::PowerSupply(const std::string& name, size_t inst, |
Brandon Wyman | 431fbe4 | 2017-08-18 16:22:09 -0500 | [diff] [blame] | 44 | const std::string& objpath, |
| 45 | const std::string& invpath, |
| 46 | sdbusplus::bus::bus& bus, |
| 47 | event::Event& e, |
| 48 | std::chrono::seconds& t) |
| 49 | : Device(name, inst), monitorPath(objpath), pmbusIntf(objpath), |
| 50 | inventoryPath(invpath), bus(bus), event(e), powerOnInterval(t), |
| 51 | powerOnTimer(e, [this]() |
| 52 | { |
| 53 | this->powerOn = true; |
| 54 | }) |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 55 | { |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 56 | using namespace sdbusplus::bus; |
| 57 | auto present_obj_path = INVENTORY_OBJ_PATH + inventoryPath; |
| 58 | presentMatch = std::make_unique<match_t>(bus, |
| 59 | match::rules::propertiesChanged( |
| 60 | present_obj_path, |
| 61 | INVENTORY_INTERFACE), |
| 62 | [this](auto& msg) |
Brandon Wyman | 431fbe4 | 2017-08-18 16:22:09 -0500 | [diff] [blame] | 63 | { |
| 64 | this->inventoryChanged(msg); |
| 65 | }); |
| 66 | // Get initial presence state. |
Brandon Wyman | 253dc9b | 2017-08-12 13:45:52 -0500 | [diff] [blame] | 67 | updatePresence(); |
Brandon Wyman | 431fbe4 | 2017-08-18 16:22:09 -0500 | [diff] [blame] | 68 | |
| 69 | // Subscribe to power state changes |
| 70 | powerOnMatch = std::make_unique<match_t>(bus, |
| 71 | match::rules::propertiesChanged( |
| 72 | POWER_OBJ_PATH, |
| 73 | POWER_INTERFACE), |
| 74 | [this](auto& msg) |
| 75 | { |
| 76 | this->powerStateChanged(msg); |
| 77 | }); |
| 78 | // Get initial power state. |
| 79 | updatePowerState(); |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 80 | } |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame] | 81 | |
Brandon Wyman | a1e9634 | 2017-09-25 16:47:44 -0500 | [diff] [blame] | 82 | void PowerSupply::captureCmd(util::NamesValues& nv, const std::string& cmd, |
| 83 | witherspoon::pmbus::Type type) |
| 84 | { |
| 85 | if (pmbusIntf.exists(cmd, type)) |
| 86 | { |
| 87 | try |
| 88 | { |
| 89 | auto val = pmbusIntf.read(cmd, type); |
| 90 | nv.add(cmd, val); |
| 91 | } |
| 92 | catch (std::exception& e) |
| 93 | { |
| 94 | log<level::INFO>("Unable to capture metadata", entry("CMD=%s", |
| 95 | cmd)); |
| 96 | } |
| 97 | } |
| 98 | } |
Brandon Wyman | 431fbe4 | 2017-08-18 16:22:09 -0500 | [diff] [blame] | 99 | |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 100 | void PowerSupply::analyze() |
| 101 | { |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame] | 102 | using namespace witherspoon::pmbus; |
| 103 | |
| 104 | try |
| 105 | { |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 106 | if (present) |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame] | 107 | { |
Brandon Wyman | 764c797 | 2017-08-22 17:05:36 -0500 | [diff] [blame] | 108 | std::uint16_t statusWord = 0; |
Brandon Wyman | 764c797 | 2017-08-22 17:05:36 -0500 | [diff] [blame] | 109 | |
| 110 | // Read the 2 byte STATUS_WORD value to check for faults. |
| 111 | statusWord = pmbusIntf.read(STATUS_WORD, Type::Debug); |
| 112 | |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 113 | //TODO: 3 consecutive reads should be performed. |
| 114 | // If 3 consecutive reads are seen, log the fault. |
| 115 | // Driver gives cached value, read once a second. |
| 116 | // increment for fault on, decrement for fault off, to deglitch. |
| 117 | // If count reaches 3, we have fault. If count reaches 0, fault is |
| 118 | // cleared. |
| 119 | |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 120 | checkInputFault(statusWord); |
Brandon Wyman | 764c797 | 2017-08-22 17:05:36 -0500 | [diff] [blame] | 121 | |
Brandon Wyman | d20686a | 2017-11-01 17:45:23 -0500 | [diff] [blame] | 122 | if (powerOn && !inputFault) |
Brandon Wyman | 764c797 | 2017-08-22 17:05:36 -0500 | [diff] [blame] | 123 | { |
Brandon Wyman | 12661f1 | 2017-08-31 15:28:21 -0500 | [diff] [blame] | 124 | checkFanFault(statusWord); |
Brandon Wyman | 875b363 | 2017-09-13 18:46:03 -0500 | [diff] [blame] | 125 | checkTemperatureFault(statusWord); |
Brandon Wyman | cfa032b | 2017-09-25 17:37:50 -0500 | [diff] [blame] | 126 | checkOutputOvervoltageFault(statusWord); |
| 127 | checkCurrentOutOverCurrentFault(statusWord); |
| 128 | checkPGOrUnitOffFault(statusWord); |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame] | 129 | } |
| 130 | } |
| 131 | } |
| 132 | catch (ReadFailure& e) |
| 133 | { |
| 134 | if (!readFailLogged) |
| 135 | { |
| 136 | commit<ReadFailure>(); |
| 137 | readFailLogged = true; |
Brandon Wyman | 442035f | 2017-08-08 15:58:45 -0500 | [diff] [blame] | 138 | } |
| 139 | } |
| 140 | |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 141 | return; |
| 142 | } |
| 143 | |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 144 | void PowerSupply::inventoryChanged(sdbusplus::message::message& msg) |
| 145 | { |
| 146 | std::string msgSensor; |
| 147 | std::map<std::string, sdbusplus::message::variant<uint32_t, bool>> msgData; |
| 148 | msg.read(msgSensor, msgData); |
| 149 | |
| 150 | // Check if it was the Present property that changed. |
| 151 | auto valPropMap = msgData.find(PRESENT_PROP); |
| 152 | if (valPropMap != msgData.end()) |
| 153 | { |
| 154 | present = sdbusplus::message::variant_ns::get<bool>(valPropMap->second); |
| 155 | |
| 156 | if (present) |
| 157 | { |
Brandon Wyman | 6ccce0b | 2017-10-26 15:13:10 -0500 | [diff] [blame] | 158 | clearFaults(); |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | void PowerSupply::updatePresence() |
| 166 | { |
| 167 | // Use getProperty utility function to get presence status. |
| 168 | std::string path = INVENTORY_OBJ_PATH + inventoryPath; |
| 169 | std::string service = "xyz.openbmc_project.Inventory.Manager"; |
Brandon Wyman | 8731a30 | 2017-08-16 16:15:34 -0500 | [diff] [blame] | 170 | |
Brandon Wyman | 800e01b | 2017-10-02 17:30:37 -0500 | [diff] [blame] | 171 | util::getProperty(INVENTORY_INTERFACE, PRESENT_PROP, path,service, bus, |
| 172 | this->present); |
Brandon Wyman | 1029554 | 2017-08-09 18:20:44 -0500 | [diff] [blame] | 173 | } |
| 174 | |
Brandon Wyman | 431fbe4 | 2017-08-18 16:22:09 -0500 | [diff] [blame] | 175 | void PowerSupply::powerStateChanged(sdbusplus::message::message& msg) |
| 176 | { |
| 177 | int32_t state = 0; |
| 178 | std::string msgSensor; |
| 179 | std::map<std::string, sdbusplus::message::variant<int32_t, int32_t>> |
| 180 | msgData; |
| 181 | msg.read(msgSensor, msgData); |
| 182 | |
| 183 | // Check if it was the Present property that changed. |
| 184 | auto valPropMap = msgData.find("state"); |
| 185 | if (valPropMap != msgData.end()) |
| 186 | { |
| 187 | state = sdbusplus::message::variant_ns::get<int32_t>(valPropMap->second); |
| 188 | |
| 189 | // Power is on when state=1. Set the fault logged variables to false |
| 190 | // and start the power on timer when the state changes to 1. |
| 191 | if (state) |
| 192 | { |
Brandon Wyman | 6ccce0b | 2017-10-26 15:13:10 -0500 | [diff] [blame] | 193 | clearFaults(); |
Brandon Wyman | 431fbe4 | 2017-08-18 16:22:09 -0500 | [diff] [blame] | 194 | powerOnTimer.start(powerOnInterval, Timer::TimerType::oneshot); |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | powerOnTimer.stop(); |
| 199 | powerOn = false; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | } |
| 204 | |
| 205 | void PowerSupply::updatePowerState() |
| 206 | { |
| 207 | // When state = 1, system is powered on |
| 208 | int32_t state = 0; |
| 209 | |
| 210 | try |
| 211 | { |
| 212 | auto service = util::getService(POWER_OBJ_PATH, |
| 213 | POWER_INTERFACE, |
| 214 | bus); |
| 215 | |
| 216 | // Use getProperty utility function to get power state. |
| 217 | util::getProperty<int32_t>(POWER_INTERFACE, |
| 218 | "state", |
| 219 | POWER_OBJ_PATH, |
| 220 | service, |
| 221 | bus, |
| 222 | state); |
| 223 | |
| 224 | if (state) |
| 225 | { |
| 226 | powerOn = true; |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | powerOn = false; |
| 231 | } |
| 232 | } |
| 233 | catch (std::exception& e) |
| 234 | { |
| 235 | log<level::INFO>("Failed to get power state. Assuming it is off."); |
| 236 | powerOn = false; |
| 237 | } |
| 238 | |
| 239 | } |
| 240 | |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 241 | void PowerSupply::checkInputFault(const uint16_t statusWord) |
| 242 | { |
| 243 | using namespace witherspoon::pmbus; |
| 244 | |
| 245 | std::uint8_t statusInput = 0; |
| 246 | |
Brandon Wyman | d20686a | 2017-11-01 17:45:23 -0500 | [diff] [blame] | 247 | if (!inputFault && ((statusWord & status_word::INPUT_FAULT_WARN) || |
| 248 | (statusWord & status_word::VIN_UV_FAULT))) |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 249 | { |
| 250 | inputFault = true; |
| 251 | |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 252 | util::NamesValues nv; |
| 253 | nv.add("STATUS_WORD", statusWord); |
Brandon Wyman | a1e9634 | 2017-09-25 16:47:44 -0500 | [diff] [blame] | 254 | captureCmd(nv, STATUS_INPUT, Type::Debug); |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 255 | |
Brandon Wyman | e0eb45c | 2017-10-06 12:58:42 -0500 | [diff] [blame] | 256 | using metadata = org::open_power::Witherspoon::Fault:: |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 257 | PowerSupplyInputFault; |
| 258 | |
| 259 | report<PowerSupplyInputFault>( |
Brandon Wyman | ea358c9 | 2017-10-27 17:34:07 -0500 | [diff] [blame] | 260 | metadata::RAW_STATUS(nv.get().c_str()), |
| 261 | metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str())); |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 262 | } |
| 263 | else |
| 264 | { |
| 265 | if ((inputFault) && |
Brandon Wyman | d20686a | 2017-11-01 17:45:23 -0500 | [diff] [blame] | 266 | !(statusWord & status_word::INPUT_FAULT_WARN) && |
| 267 | !(statusWord & status_word::VIN_UV_FAULT)) |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 268 | { |
| 269 | inputFault = false; |
| 270 | statusInput = pmbusIntf.read(STATUS_INPUT, Type::Debug); |
| 271 | |
| 272 | log<level::INFO>("INPUT_FAULT_WARN cleared", |
| 273 | entry("POWERSUPPLY=%s", inventoryPath.c_str()), |
| 274 | entry("STATUS_WORD=0x%04X", statusWord), |
| 275 | entry("STATUS_INPUT=0x%02X", statusInput)); |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | void PowerSupply::checkPGOrUnitOffFault(const uint16_t statusWord) |
| 281 | { |
| 282 | using namespace witherspoon::pmbus; |
| 283 | |
Brandon Wyman | 593d24f | 2017-10-13 18:15:23 -0500 | [diff] [blame] | 284 | if (powerOnFault < FAULT_COUNT) |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 285 | { |
Brandon Wyman | 593d24f | 2017-10-13 18:15:23 -0500 | [diff] [blame] | 286 | // Check PG# and UNIT_IS_OFF |
| 287 | if ((statusWord & status_word::POWER_GOOD_NEGATED) || |
| 288 | (statusWord & status_word::UNIT_IS_OFF)) |
| 289 | { |
| 290 | log<level::INFO>("PGOOD or UNIT_IS_OFF bit bad", |
| 291 | entry("STATUS_WORD=0x%04X", statusWord)); |
| 292 | powerOnFault++; |
| 293 | } |
| 294 | else |
| 295 | { |
| 296 | if (powerOnFault > 0) |
| 297 | { |
| 298 | log<level::INFO>("PGOOD and UNIT_IS_OFF bits good"); |
| 299 | powerOnFault = 0; |
| 300 | } |
| 301 | } |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 302 | |
Brandon Wyman | 593d24f | 2017-10-13 18:15:23 -0500 | [diff] [blame] | 303 | if (powerOnFault >= FAULT_COUNT) |
| 304 | { |
| 305 | util::NamesValues nv; |
| 306 | nv.add("STATUS_WORD", statusWord); |
| 307 | captureCmd(nv, STATUS_INPUT, Type::Debug); |
| 308 | auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0); |
| 309 | captureCmd(nv, status0Vout, Type::Debug); |
| 310 | captureCmd(nv, STATUS_IOUT, Type::Debug); |
| 311 | captureCmd(nv, STATUS_MFR, Type::Debug); |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 312 | |
Brandon Wyman | 593d24f | 2017-10-13 18:15:23 -0500 | [diff] [blame] | 313 | using metadata = org::open_power::Witherspoon::Fault:: |
| 314 | PowerSupplyShouldBeOn; |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 315 | |
Brandon Wyman | 593d24f | 2017-10-13 18:15:23 -0500 | [diff] [blame] | 316 | // A power supply is OFF (or pgood low) but should be on. |
| 317 | report<PowerSupplyShouldBeOn>( |
| 318 | metadata::RAW_STATUS(nv.get().c_str()), |
| 319 | metadata::CALLOUT_INVENTORY_PATH( |
| 320 | inventoryPath.c_str())); |
| 321 | } |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | } |
| 325 | |
| 326 | void PowerSupply::checkCurrentOutOverCurrentFault(const uint16_t statusWord) |
| 327 | { |
| 328 | using namespace witherspoon::pmbus; |
| 329 | |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 330 | // Check for an output overcurrent fault. |
| 331 | if ((statusWord & status_word::IOUT_OC_FAULT) && |
| 332 | !outputOCFault) |
| 333 | { |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 334 | util::NamesValues nv; |
| 335 | nv.add("STATUS_WORD", statusWord); |
Brandon Wyman | a1e9634 | 2017-09-25 16:47:44 -0500 | [diff] [blame] | 336 | captureCmd(nv, STATUS_INPUT, Type::Debug); |
| 337 | auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0); |
| 338 | captureCmd(nv, status0Vout, Type::Debug); |
| 339 | captureCmd(nv, STATUS_IOUT, Type::Debug); |
| 340 | captureCmd(nv, STATUS_MFR, Type::Debug); |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 341 | |
Brandon Wyman | e0eb45c | 2017-10-06 12:58:42 -0500 | [diff] [blame] | 342 | using metadata = org::open_power::Witherspoon::Fault:: |
Brandon Wyman | 603cc00 | 2017-08-28 18:17:58 -0500 | [diff] [blame] | 343 | PowerSupplyOutputOvercurrent; |
| 344 | |
| 345 | report<PowerSupplyOutputOvercurrent>(metadata::RAW_STATUS( |
| 346 | nv.get().c_str()), |
| 347 | metadata::CALLOUT_INVENTORY_PATH( |
| 348 | inventoryPath.c_str())); |
| 349 | |
| 350 | outputOCFault = true; |
| 351 | } |
| 352 | } |
| 353 | |
Brandon Wyman | ab05c07 | 2017-08-30 18:26:41 -0500 | [diff] [blame] | 354 | void PowerSupply::checkOutputOvervoltageFault(const uint16_t statusWord) |
| 355 | { |
| 356 | using namespace witherspoon::pmbus; |
| 357 | |
Brandon Wyman | ab05c07 | 2017-08-30 18:26:41 -0500 | [diff] [blame] | 358 | // Check for an output overvoltage fault. |
| 359 | if ((statusWord & status_word::VOUT_OV_FAULT) && |
| 360 | !outputOVFault) |
| 361 | { |
Brandon Wyman | ab05c07 | 2017-08-30 18:26:41 -0500 | [diff] [blame] | 362 | util::NamesValues nv; |
| 363 | nv.add("STATUS_WORD", statusWord); |
Brandon Wyman | a1e9634 | 2017-09-25 16:47:44 -0500 | [diff] [blame] | 364 | captureCmd(nv, STATUS_INPUT, Type::Debug); |
| 365 | auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0); |
| 366 | captureCmd(nv, status0Vout, Type::Debug); |
| 367 | captureCmd(nv, STATUS_IOUT, Type::Debug); |
| 368 | captureCmd(nv, STATUS_MFR, Type::Debug); |
Brandon Wyman | ab05c07 | 2017-08-30 18:26:41 -0500 | [diff] [blame] | 369 | |
Brandon Wyman | e0eb45c | 2017-10-06 12:58:42 -0500 | [diff] [blame] | 370 | using metadata = org::open_power::Witherspoon::Fault:: |
Brandon Wyman | ab05c07 | 2017-08-30 18:26:41 -0500 | [diff] [blame] | 371 | PowerSupplyOutputOvervoltage; |
| 372 | |
| 373 | report<PowerSupplyOutputOvervoltage>(metadata::RAW_STATUS( |
| 374 | nv.get().c_str()), |
| 375 | metadata::CALLOUT_INVENTORY_PATH( |
| 376 | inventoryPath.c_str())); |
| 377 | |
| 378 | outputOVFault = true; |
| 379 | } |
| 380 | } |
| 381 | |
Brandon Wyman | 12661f1 | 2017-08-31 15:28:21 -0500 | [diff] [blame] | 382 | void PowerSupply::checkFanFault(const uint16_t statusWord) |
| 383 | { |
| 384 | using namespace witherspoon::pmbus; |
| 385 | |
Brandon Wyman | 875b363 | 2017-09-13 18:46:03 -0500 | [diff] [blame] | 386 | // Check for a fan fault or warning condition |
Brandon Wyman | 12661f1 | 2017-08-31 15:28:21 -0500 | [diff] [blame] | 387 | if ((statusWord & status_word::FAN_FAULT) && |
| 388 | !fanFault) |
| 389 | { |
Brandon Wyman | 12661f1 | 2017-08-31 15:28:21 -0500 | [diff] [blame] | 390 | util::NamesValues nv; |
| 391 | nv.add("STATUS_WORD", statusWord); |
Brandon Wyman | a1e9634 | 2017-09-25 16:47:44 -0500 | [diff] [blame] | 392 | captureCmd(nv, STATUS_MFR, Type::Debug); |
| 393 | captureCmd(nv, STATUS_TEMPERATURE, Type::Debug); |
| 394 | captureCmd(nv, STATUS_FANS_1_2, Type::Debug); |
Brandon Wyman | 12661f1 | 2017-08-31 15:28:21 -0500 | [diff] [blame] | 395 | |
Brandon Wyman | e0eb45c | 2017-10-06 12:58:42 -0500 | [diff] [blame] | 396 | using metadata = org::open_power::Witherspoon::Fault:: |
Brandon Wyman | 12661f1 | 2017-08-31 15:28:21 -0500 | [diff] [blame] | 397 | PowerSupplyFanFault; |
| 398 | |
| 399 | report<PowerSupplyFanFault>( |
| 400 | metadata::RAW_STATUS(nv.get().c_str()), |
| 401 | metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str())); |
| 402 | |
| 403 | fanFault = true; |
| 404 | } |
| 405 | } |
| 406 | |
Brandon Wyman | 875b363 | 2017-09-13 18:46:03 -0500 | [diff] [blame] | 407 | void PowerSupply::checkTemperatureFault(const uint16_t statusWord) |
| 408 | { |
| 409 | using namespace witherspoon::pmbus; |
| 410 | |
| 411 | // Due to how the PMBus core device driver sends a clear faults command |
| 412 | // the bit in STATUS_WORD will likely be cleared when we attempt to examine |
| 413 | // it for a Thermal Fault or Warning. So, check the STATUS_WORD and the |
| 414 | // STATUS_TEMPERATURE bits. If either indicates a fault, proceed with |
| 415 | // logging the over-temperature condition. |
| 416 | std::uint8_t statusTemperature = 0; |
| 417 | statusTemperature = pmbusIntf.read(STATUS_TEMPERATURE, Type::Debug); |
| 418 | if (((statusWord & status_word::TEMPERATURE_FAULT_WARN) || |
| 419 | (statusTemperature & status_temperature::OT_FAULT)) && |
| 420 | !temperatureFault) |
| 421 | { |
| 422 | // The power supply has had an over-temperature condition. |
| 423 | // This may not result in a shutdown if experienced for a short |
| 424 | // duration. |
| 425 | // This should not occur under normal conditions. |
| 426 | // The power supply may be faulty, or the paired supply may be putting |
| 427 | // out less current. |
| 428 | // Capture command responses with potentially relevant information, |
| 429 | // and call out the power supply reporting the condition. |
Brandon Wyman | 875b363 | 2017-09-13 18:46:03 -0500 | [diff] [blame] | 430 | util::NamesValues nv; |
| 431 | nv.add("STATUS_WORD", statusWord); |
Brandon Wyman | a1e9634 | 2017-09-25 16:47:44 -0500 | [diff] [blame] | 432 | captureCmd(nv, STATUS_MFR, Type::Debug); |
| 433 | captureCmd(nv, STATUS_IOUT, Type::Debug); |
Brandon Wyman | 875b363 | 2017-09-13 18:46:03 -0500 | [diff] [blame] | 434 | nv.add("STATUS_TEMPERATURE", statusTemperature); |
Brandon Wyman | a1e9634 | 2017-09-25 16:47:44 -0500 | [diff] [blame] | 435 | captureCmd(nv, STATUS_FANS_1_2, Type::Debug); |
Brandon Wyman | 875b363 | 2017-09-13 18:46:03 -0500 | [diff] [blame] | 436 | |
Brandon Wyman | e0eb45c | 2017-10-06 12:58:42 -0500 | [diff] [blame] | 437 | using metadata = org::open_power::Witherspoon::Fault:: |
Brandon Wyman | 875b363 | 2017-09-13 18:46:03 -0500 | [diff] [blame] | 438 | PowerSupplyTemperatureFault; |
| 439 | |
| 440 | report<PowerSupplyTemperatureFault>( |
| 441 | metadata::RAW_STATUS(nv.get().c_str()), |
| 442 | metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str())); |
| 443 | |
| 444 | temperatureFault = true; |
| 445 | } |
| 446 | } |
| 447 | |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 448 | void PowerSupply::clearFaults() |
| 449 | { |
Brandon Wyman | 6ccce0b | 2017-10-26 15:13:10 -0500 | [diff] [blame] | 450 | readFailLogged = false; |
Brandon Wyman | 6ccce0b | 2017-10-26 15:13:10 -0500 | [diff] [blame] | 451 | inputFault = false; |
| 452 | powerOnFault = 0; |
| 453 | outputOCFault = false; |
| 454 | outputOVFault = false; |
| 455 | fanFault = false; |
| 456 | temperatureFault = false; |
| 457 | |
Brandon Wyman | 1db9a9e | 2017-07-26 18:50:22 -0500 | [diff] [blame] | 458 | return; |
| 459 | } |
| 460 | |
Brandon Wyman | 24e422f | 2017-07-25 19:40:14 -0500 | [diff] [blame] | 461 | } |
| 462 | } |
| 463 | } |