blob: f463595af0c6b35484b0f7fc97c954e98e33eee7 [file] [log] [blame]
Brandon Wyman24e422f2017-07-25 19:40:14 -05001/**
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 Wyman442035f2017-08-08 15:58:45 -050016#include <phosphor-logging/log.hpp>
17#include <phosphor-logging/elog.hpp>
Brandon Wymane0eb45c2017-10-06 12:58:42 -050018#include <org/open_power/Witherspoon/Fault/error.hpp>
Matt Spinlerceacf942017-10-05 13:55:02 -050019#include <xyz/openbmc_project/Common/Device/error.hpp>
Brandon Wyman442035f2017-08-08 15:58:45 -050020#include "elog-errors.hpp"
Brandon Wyman10295542017-08-09 18:20:44 -050021#include "names_values.hpp"
Brandon Wyman24e422f2017-07-25 19:40:14 -050022#include "power_supply.hpp"
Brandon Wyman442035f2017-08-08 15:58:45 -050023#include "pmbus.hpp"
24#include "utility.hpp"
25
26using namespace phosphor::logging;
Brandon Wymane0eb45c2017-10-06 12:58:42 -050027using namespace sdbusplus::org::open_power::Witherspoon::Fault::Error;
Matt Spinlerceacf942017-10-05 13:55:02 -050028using namespace sdbusplus::xyz::openbmc_project::Common::Device::Error;
Brandon Wyman24e422f2017-07-25 19:40:14 -050029
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050030namespace witherspoon
Brandon Wyman24e422f2017-07-25 19:40:14 -050031{
32namespace power
33{
34namespace psu
35{
36
Brandon Wyman10295542017-08-09 18:20:44 -050037constexpr auto INVENTORY_OBJ_PATH = "/xyz/openbmc_project/inventory";
38constexpr auto INVENTORY_INTERFACE = "xyz.openbmc_project.Inventory.Item";
39constexpr auto PRESENT_PROP = "Present";
Brandon Wyman431fbe42017-08-18 16:22:09 -050040constexpr auto POWER_OBJ_PATH = "/org/openbmc/control/power0";
41constexpr auto POWER_INTERFACE = "org.openbmc.control.Power";
Brandon Wyman10295542017-08-09 18:20:44 -050042
43PowerSupply::PowerSupply(const std::string& name, size_t inst,
Brandon Wyman431fbe42017-08-18 16:22:09 -050044 const std::string& objpath,
45 const std::string& invpath,
46 sdbusplus::bus::bus& bus,
47 event::Event& e,
Brandon Wyman590fc282017-11-01 18:22:25 -050048 std::chrono::seconds& t,
49 std::chrono::seconds& p)
Brandon Wyman431fbe42017-08-18 16:22:09 -050050 : Device(name, inst), monitorPath(objpath), pmbusIntf(objpath),
Brandon Wyman50bb85d2017-11-01 18:36:00 -050051 inventoryPath(INVENTORY_OBJ_PATH + invpath), bus(bus), event(e),
52 presentInterval(p),
Brandon Wyman590fc282017-11-01 18:22:25 -050053 presentTimer(e, [this]()
54 {
Brandon Wyman2877add2017-11-10 17:44:19 -060055 // The hwmon path may have changed.
56 pmbusIntf.findHwmonDir();
Brandon Wyman590fc282017-11-01 18:22:25 -050057 this->present = true;
58 }),
59 powerOnInterval(t),
Brandon Wyman431fbe42017-08-18 16:22:09 -050060 powerOnTimer(e, [this]()
61 {
62 this->powerOn = true;
63 })
Brandon Wyman10295542017-08-09 18:20:44 -050064{
Brandon Wyman10295542017-08-09 18:20:44 -050065 using namespace sdbusplus::bus;
Brandon Wyman10295542017-08-09 18:20:44 -050066 presentMatch = std::make_unique<match_t>(bus,
67 match::rules::propertiesChanged(
Brandon Wyman50bb85d2017-11-01 18:36:00 -050068 inventoryPath,
Brandon Wyman10295542017-08-09 18:20:44 -050069 INVENTORY_INTERFACE),
70 [this](auto& msg)
Brandon Wyman431fbe42017-08-18 16:22:09 -050071 {
72 this->inventoryChanged(msg);
73 });
74 // Get initial presence state.
Brandon Wyman253dc9b2017-08-12 13:45:52 -050075 updatePresence();
Brandon Wyman431fbe42017-08-18 16:22:09 -050076
77 // Subscribe to power state changes
78 powerOnMatch = std::make_unique<match_t>(bus,
79 match::rules::propertiesChanged(
80 POWER_OBJ_PATH,
81 POWER_INTERFACE),
82 [this](auto& msg)
83 {
84 this->powerStateChanged(msg);
85 });
86 // Get initial power state.
87 updatePowerState();
Brandon Wyman10295542017-08-09 18:20:44 -050088}
Brandon Wyman442035f2017-08-08 15:58:45 -050089
Brandon Wymana1e96342017-09-25 16:47:44 -050090void PowerSupply::captureCmd(util::NamesValues& nv, const std::string& cmd,
91 witherspoon::pmbus::Type type)
92{
93 if (pmbusIntf.exists(cmd, type))
94 {
95 try
96 {
97 auto val = pmbusIntf.read(cmd, type);
98 nv.add(cmd, val);
99 }
100 catch (std::exception& e)
101 {
102 log<level::INFO>("Unable to capture metadata", entry("CMD=%s",
103 cmd));
104 }
105 }
106}
Brandon Wyman431fbe42017-08-18 16:22:09 -0500107
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500108void PowerSupply::analyze()
109{
Brandon Wyman442035f2017-08-08 15:58:45 -0500110 using namespace witherspoon::pmbus;
111
112 try
113 {
Brandon Wyman10295542017-08-09 18:20:44 -0500114 if (present)
Brandon Wyman442035f2017-08-08 15:58:45 -0500115 {
Brandon Wyman764c7972017-08-22 17:05:36 -0500116 std::uint16_t statusWord = 0;
Brandon Wyman764c7972017-08-22 17:05:36 -0500117
118 // Read the 2 byte STATUS_WORD value to check for faults.
119 statusWord = pmbusIntf.read(STATUS_WORD, Type::Debug);
Brandon Wymane4af9802017-11-13 15:58:33 -0600120 readFail = 0;
Brandon Wyman764c7972017-08-22 17:05:36 -0500121
Brandon Wyman603cc002017-08-28 18:17:58 -0500122 checkInputFault(statusWord);
Brandon Wyman764c7972017-08-22 17:05:36 -0500123
Brandon Wyman3343e822017-11-03 16:54:11 -0500124 if (powerOn && !faultFound)
Brandon Wyman764c7972017-08-22 17:05:36 -0500125 {
Brandon Wyman12661f12017-08-31 15:28:21 -0500126 checkFanFault(statusWord);
Brandon Wyman875b3632017-09-13 18:46:03 -0500127 checkTemperatureFault(statusWord);
Brandon Wymancfa032b2017-09-25 17:37:50 -0500128 checkOutputOvervoltageFault(statusWord);
129 checkCurrentOutOverCurrentFault(statusWord);
130 checkPGOrUnitOffFault(statusWord);
Brandon Wyman442035f2017-08-08 15:58:45 -0500131 }
132 }
133 }
134 catch (ReadFailure& e)
135 {
Brandon Wymane4af9802017-11-13 15:58:33 -0600136 if (readFail < FAULT_COUNT)
137 {
138 readFail++;
139 }
140
141 if (!readFailLogged && readFail >= FAULT_COUNT)
Brandon Wyman442035f2017-08-08 15:58:45 -0500142 {
143 commit<ReadFailure>();
144 readFailLogged = true;
Brandon Wyman442035f2017-08-08 15:58:45 -0500145 }
146 }
147
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500148 return;
149}
150
Brandon Wyman10295542017-08-09 18:20:44 -0500151void PowerSupply::inventoryChanged(sdbusplus::message::message& msg)
152{
153 std::string msgSensor;
154 std::map<std::string, sdbusplus::message::variant<uint32_t, bool>> msgData;
155 msg.read(msgSensor, msgData);
156
157 // Check if it was the Present property that changed.
158 auto valPropMap = msgData.find(PRESENT_PROP);
159 if (valPropMap != msgData.end())
160 {
Brandon Wyman2ef48cf2017-11-21 15:43:54 -0600161 if (sdbusplus::message::variant_ns::get<bool>(valPropMap->second))
Brandon Wyman10295542017-08-09 18:20:44 -0500162 {
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500163 clearFaults();
Brandon Wyman590fc282017-11-01 18:22:25 -0500164 presentTimer.start(presentInterval, Timer::TimerType::oneshot);
165 }
166 else
167 {
Brandon Wyman2ef48cf2017-11-21 15:43:54 -0600168 present = false;
Brandon Wyman590fc282017-11-01 18:22:25 -0500169 presentTimer.stop();
Brandon Wyman10295542017-08-09 18:20:44 -0500170 }
171 }
172
173 return;
174}
175
176void PowerSupply::updatePresence()
177{
178 // Use getProperty utility function to get presence status.
Brandon Wyman10295542017-08-09 18:20:44 -0500179 std::string service = "xyz.openbmc_project.Inventory.Manager";
Brandon Wyman50bb85d2017-11-01 18:36:00 -0500180 util::getProperty(INVENTORY_INTERFACE, PRESENT_PROP, inventoryPath,
181 service, bus, this->present);
Brandon Wyman10295542017-08-09 18:20:44 -0500182}
183
Brandon Wyman431fbe42017-08-18 16:22:09 -0500184void PowerSupply::powerStateChanged(sdbusplus::message::message& msg)
185{
186 int32_t state = 0;
187 std::string msgSensor;
188 std::map<std::string, sdbusplus::message::variant<int32_t, int32_t>>
189 msgData;
190 msg.read(msgSensor, msgData);
191
192 // Check if it was the Present property that changed.
193 auto valPropMap = msgData.find("state");
194 if (valPropMap != msgData.end())
195 {
196 state = sdbusplus::message::variant_ns::get<int32_t>(valPropMap->second);
197
198 // Power is on when state=1. Set the fault logged variables to false
199 // and start the power on timer when the state changes to 1.
200 if (state)
201 {
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500202 clearFaults();
Brandon Wyman431fbe42017-08-18 16:22:09 -0500203 powerOnTimer.start(powerOnInterval, Timer::TimerType::oneshot);
204 }
205 else
206 {
207 powerOnTimer.stop();
208 powerOn = false;
209 }
210 }
211
212}
213
214void PowerSupply::updatePowerState()
215{
216 // When state = 1, system is powered on
217 int32_t state = 0;
218
219 try
220 {
221 auto service = util::getService(POWER_OBJ_PATH,
222 POWER_INTERFACE,
223 bus);
224
225 // Use getProperty utility function to get power state.
226 util::getProperty<int32_t>(POWER_INTERFACE,
227 "state",
228 POWER_OBJ_PATH,
229 service,
230 bus,
231 state);
232
233 if (state)
234 {
235 powerOn = true;
236 }
237 else
238 {
239 powerOn = false;
240 }
241 }
242 catch (std::exception& e)
243 {
244 log<level::INFO>("Failed to get power state. Assuming it is off.");
245 powerOn = false;
246 }
247
248}
249
Brandon Wyman603cc002017-08-28 18:17:58 -0500250void PowerSupply::checkInputFault(const uint16_t statusWord)
251{
252 using namespace witherspoon::pmbus;
253
Brandon Wymana3c675c2017-11-14 14:54:54 -0600254 if ((inputFault < FAULT_COUNT) &&
255 ((statusWord & status_word::INPUT_FAULT_WARN) ||
256 (statusWord & status_word::VIN_UV_FAULT)))
Brandon Wyman603cc002017-08-28 18:17:58 -0500257 {
Brandon Wymana3c675c2017-11-14 14:54:54 -0600258 inputFault++;
Brandon Wyman603cc002017-08-28 18:17:58 -0500259 }
260 else
261 {
Brandon Wymana3c675c2017-11-14 14:54:54 -0600262 if ((inputFault > 0) &&
Brandon Wymand20686a2017-11-01 17:45:23 -0500263 !(statusWord & status_word::INPUT_FAULT_WARN) &&
264 !(statusWord & status_word::VIN_UV_FAULT))
Brandon Wyman603cc002017-08-28 18:17:58 -0500265 {
Brandon Wymana3c675c2017-11-14 14:54:54 -0600266 inputFault = 0;
Brandon Wyman3343e822017-11-03 16:54:11 -0500267 faultFound = false;
Brandon Wyman69591bd2017-11-01 18:07:23 -0500268
Brandon Wyman603cc002017-08-28 18:17:58 -0500269 log<level::INFO>("INPUT_FAULT_WARN cleared",
Brandon Wymana3c675c2017-11-14 14:54:54 -0600270 entry("POWERSUPPLY=%s", inventoryPath.c_str()));
Brandon Wyman69591bd2017-11-01 18:07:23 -0500271
272 if (powerOn)
273 {
274 // The power supply will not be immediately powered on after
275 // the input power is restored.
276 powerOn = false;
277 // Start up the timer that will set the state to indicate we
278 // are ready for the powered on fault checks.
279 powerOnTimer.start(powerOnInterval, Timer::TimerType::oneshot);
280 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500281 }
282 }
Brandon Wymana3c675c2017-11-14 14:54:54 -0600283
284 if (!faultFound && (inputFault >= FAULT_COUNT))
285 {
286 util::NamesValues nv;
287 nv.add("STATUS_WORD", statusWord);
288 captureCmd(nv, STATUS_INPUT, Type::Debug);
289
290 using metadata = org::open_power::Witherspoon::Fault::
291 PowerSupplyInputFault;
292
293 report<PowerSupplyInputFault>(
294 metadata::RAW_STATUS(nv.get().c_str()),
295 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
296 faultFound = true;
297 }
298
Brandon Wyman603cc002017-08-28 18:17:58 -0500299}
300
301void PowerSupply::checkPGOrUnitOffFault(const uint16_t statusWord)
302{
303 using namespace witherspoon::pmbus;
304
Brandon Wyman593d24f2017-10-13 18:15:23 -0500305 if (powerOnFault < FAULT_COUNT)
Brandon Wyman603cc002017-08-28 18:17:58 -0500306 {
Brandon Wyman593d24f2017-10-13 18:15:23 -0500307 // Check PG# and UNIT_IS_OFF
308 if ((statusWord & status_word::POWER_GOOD_NEGATED) ||
309 (statusWord & status_word::UNIT_IS_OFF))
310 {
311 log<level::INFO>("PGOOD or UNIT_IS_OFF bit bad",
312 entry("STATUS_WORD=0x%04X", statusWord));
313 powerOnFault++;
314 }
315 else
316 {
317 if (powerOnFault > 0)
318 {
319 log<level::INFO>("PGOOD and UNIT_IS_OFF bits good");
320 powerOnFault = 0;
321 }
322 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500323
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600324 if (!faultFound && (powerOnFault >= FAULT_COUNT))
Brandon Wyman593d24f2017-10-13 18:15:23 -0500325 {
Brandon Wyman3343e822017-11-03 16:54:11 -0500326 faultFound = true;
327
Brandon Wyman593d24f2017-10-13 18:15:23 -0500328 util::NamesValues nv;
329 nv.add("STATUS_WORD", statusWord);
330 captureCmd(nv, STATUS_INPUT, Type::Debug);
331 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
332 captureCmd(nv, status0Vout, Type::Debug);
333 captureCmd(nv, STATUS_IOUT, Type::Debug);
334 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wyman603cc002017-08-28 18:17:58 -0500335
Brandon Wyman593d24f2017-10-13 18:15:23 -0500336 using metadata = org::open_power::Witherspoon::Fault::
337 PowerSupplyShouldBeOn;
Brandon Wyman603cc002017-08-28 18:17:58 -0500338
Brandon Wyman593d24f2017-10-13 18:15:23 -0500339 // A power supply is OFF (or pgood low) but should be on.
340 report<PowerSupplyShouldBeOn>(
341 metadata::RAW_STATUS(nv.get().c_str()),
342 metadata::CALLOUT_INVENTORY_PATH(
343 inventoryPath.c_str()));
344 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500345 }
346
347}
348
349void PowerSupply::checkCurrentOutOverCurrentFault(const uint16_t statusWord)
350{
351 using namespace witherspoon::pmbus;
352
Brandon Wymandd61be42017-11-07 18:38:54 -0600353 if (outputOCFault < FAULT_COUNT)
Brandon Wyman603cc002017-08-28 18:17:58 -0500354 {
Brandon Wymandd61be42017-11-07 18:38:54 -0600355 // Check for an output overcurrent fault.
356 if ((statusWord & status_word::IOUT_OC_FAULT))
357 {
358 outputOCFault++;
359 }
360 else
361 {
362 if (outputOCFault > 0)
363 {
364 outputOCFault = 0;
365 }
366 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500367
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600368 if (!faultFound && (outputOCFault >= FAULT_COUNT))
Brandon Wymandd61be42017-11-07 18:38:54 -0600369 {
370 util::NamesValues nv;
371 nv.add("STATUS_WORD", statusWord);
372 captureCmd(nv, STATUS_INPUT, Type::Debug);
373 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
374 captureCmd(nv, status0Vout, Type::Debug);
375 captureCmd(nv, STATUS_IOUT, Type::Debug);
376 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wyman603cc002017-08-28 18:17:58 -0500377
Brandon Wymandd61be42017-11-07 18:38:54 -0600378 using metadata = org::open_power::Witherspoon::Fault::
379 PowerSupplyOutputOvercurrent;
Brandon Wyman603cc002017-08-28 18:17:58 -0500380
Brandon Wymandd61be42017-11-07 18:38:54 -0600381 report<PowerSupplyOutputOvercurrent>(
382 metadata::RAW_STATUS(nv.get().c_str()),
383 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
384
385 faultFound = true;
386 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500387 }
388}
389
Brandon Wymanab05c072017-08-30 18:26:41 -0500390void PowerSupply::checkOutputOvervoltageFault(const uint16_t statusWord)
391{
392 using namespace witherspoon::pmbus;
393
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600394 if (outputOVFault < FAULT_COUNT)
Brandon Wymanab05c072017-08-30 18:26:41 -0500395 {
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600396 // Check for an output overvoltage fault.
397 if (statusWord & status_word::VOUT_OV_FAULT)
398 {
399 outputOVFault++;
400 }
401 else
402 {
403 if (outputOVFault > 0)
404 {
405 outputOVFault = 0;
406 }
407 }
Brandon Wymanab05c072017-08-30 18:26:41 -0500408
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600409 if (!faultFound && (outputOVFault >= FAULT_COUNT))
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600410 {
411 util::NamesValues nv;
412 nv.add("STATUS_WORD", statusWord);
413 captureCmd(nv, STATUS_INPUT, Type::Debug);
414 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
415 captureCmd(nv, status0Vout, Type::Debug);
416 captureCmd(nv, STATUS_IOUT, Type::Debug);
417 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wymanab05c072017-08-30 18:26:41 -0500418
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600419 using metadata = org::open_power::Witherspoon::Fault::
420 PowerSupplyOutputOvervoltage;
Brandon Wymanab05c072017-08-30 18:26:41 -0500421
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600422 report<PowerSupplyOutputOvervoltage>(
423 metadata::RAW_STATUS(nv.get().c_str()),
424 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
425
426 faultFound = true;
427 }
Brandon Wymanab05c072017-08-30 18:26:41 -0500428 }
429}
430
Brandon Wyman12661f12017-08-31 15:28:21 -0500431void PowerSupply::checkFanFault(const uint16_t statusWord)
432{
433 using namespace witherspoon::pmbus;
434
Brandon Wymanba255532017-11-08 17:44:10 -0600435 if (fanFault < FAULT_COUNT)
Brandon Wyman12661f12017-08-31 15:28:21 -0500436 {
Brandon Wymanba255532017-11-08 17:44:10 -0600437 // Check for a fan fault or warning condition
438 if (statusWord & status_word::FAN_FAULT)
439 {
440 fanFault++;
441 }
442 else
443 {
444 if (fanFault > 0)
445 {
446 fanFault = 0;
447 }
448 }
Brandon Wyman12661f12017-08-31 15:28:21 -0500449
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600450 if (!faultFound && (fanFault >= FAULT_COUNT))
Brandon Wymanba255532017-11-08 17:44:10 -0600451 {
452 util::NamesValues nv;
453 nv.add("STATUS_WORD", statusWord);
454 captureCmd(nv, STATUS_MFR, Type::Debug);
455 captureCmd(nv, STATUS_TEMPERATURE, Type::Debug);
456 captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
Brandon Wyman12661f12017-08-31 15:28:21 -0500457
Brandon Wymanba255532017-11-08 17:44:10 -0600458 using metadata = org::open_power::Witherspoon::Fault::
459 PowerSupplyFanFault;
Brandon Wyman12661f12017-08-31 15:28:21 -0500460
Brandon Wymanba255532017-11-08 17:44:10 -0600461 report<PowerSupplyFanFault>(
462 metadata::RAW_STATUS(nv.get().c_str()),
463 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
464
465 faultFound = true;
466 }
Brandon Wyman12661f12017-08-31 15:28:21 -0500467 }
468}
469
Brandon Wyman875b3632017-09-13 18:46:03 -0500470void PowerSupply::checkTemperatureFault(const uint16_t statusWord)
471{
472 using namespace witherspoon::pmbus;
473
474 // Due to how the PMBus core device driver sends a clear faults command
475 // the bit in STATUS_WORD will likely be cleared when we attempt to examine
476 // it for a Thermal Fault or Warning. So, check the STATUS_WORD and the
477 // STATUS_TEMPERATURE bits. If either indicates a fault, proceed with
478 // logging the over-temperature condition.
479 std::uint8_t statusTemperature = 0;
480 statusTemperature = pmbusIntf.read(STATUS_TEMPERATURE, Type::Debug);
Brandon Wyman50044ea2017-11-08 17:58:56 -0600481 if (temperatureFault < FAULT_COUNT)
Brandon Wyman875b3632017-09-13 18:46:03 -0500482 {
Brandon Wyman50044ea2017-11-08 17:58:56 -0600483 if ((statusWord & status_word::TEMPERATURE_FAULT_WARN) ||
484 (statusTemperature & status_temperature::OT_FAULT))
485 {
486 temperatureFault++;
487 }
488 else
489 {
490 if (temperatureFault > 0)
491 {
492 temperatureFault = 0;
493 }
494 }
Brandon Wyman875b3632017-09-13 18:46:03 -0500495
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600496 if (!faultFound && (temperatureFault >= FAULT_COUNT))
Brandon Wyman50044ea2017-11-08 17:58:56 -0600497 {
498 // The power supply has had an over-temperature condition.
499 // This may not result in a shutdown if experienced for a short
500 // duration.
501 // This should not occur under normal conditions.
502 // The power supply may be faulty, or the paired supply may be
503 // putting out less current.
504 // Capture command responses with potentially relevant information,
505 // and call out the power supply reporting the condition.
506 util::NamesValues nv;
507 nv.add("STATUS_WORD", statusWord);
508 captureCmd(nv, STATUS_MFR, Type::Debug);
509 captureCmd(nv, STATUS_IOUT, Type::Debug);
510 nv.add("STATUS_TEMPERATURE", statusTemperature);
511 captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
Brandon Wyman875b3632017-09-13 18:46:03 -0500512
Brandon Wyman50044ea2017-11-08 17:58:56 -0600513 using metadata = org::open_power::Witherspoon::Fault::
514 PowerSupplyTemperatureFault;
Brandon Wyman875b3632017-09-13 18:46:03 -0500515
Brandon Wyman50044ea2017-11-08 17:58:56 -0600516 report<PowerSupplyTemperatureFault>(
517 metadata::RAW_STATUS(nv.get().c_str()),
518 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
519
520 faultFound = true;
521 }
Brandon Wyman875b3632017-09-13 18:46:03 -0500522 }
523}
524
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500525void PowerSupply::clearFaults()
526{
Brandon Wymane4af9802017-11-13 15:58:33 -0600527 readFail = 0;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500528 readFailLogged = false;
Brandon Wymana3c675c2017-11-14 14:54:54 -0600529 inputFault = 0;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500530 powerOnFault = 0;
Brandon Wymandd61be42017-11-07 18:38:54 -0600531 outputOCFault = 0;
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600532 outputOVFault = 0;
Brandon Wymanba255532017-11-08 17:44:10 -0600533 fanFault = 0;
Brandon Wyman50044ea2017-11-08 17:58:56 -0600534 temperatureFault = 0;
Brandon Wyman3343e822017-11-03 16:54:11 -0500535 faultFound = false;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500536
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500537 return;
538}
539
Brandon Wyman24e422f2017-07-25 19:40:14 -0500540}
541}
542}