blob: af611f02b8745f09a01d331807073a42a9d59aaa [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
Brandon Wyman08b05712017-11-30 17:53:56 -0600272 resolveError(inventoryPath,
273 std::string(PowerSupplyInputFault::errName));
274
Brandon Wyman69591bd2017-11-01 18:07:23 -0500275 if (powerOn)
276 {
277 // The power supply will not be immediately powered on after
278 // the input power is restored.
279 powerOn = false;
280 // Start up the timer that will set the state to indicate we
281 // are ready for the powered on fault checks.
282 powerOnTimer.start(powerOnInterval, Timer::TimerType::oneshot);
283 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500284 }
285 }
Brandon Wymana3c675c2017-11-14 14:54:54 -0600286
287 if (!faultFound && (inputFault >= FAULT_COUNT))
288 {
289 util::NamesValues nv;
290 nv.add("STATUS_WORD", statusWord);
291 captureCmd(nv, STATUS_INPUT, Type::Debug);
292
293 using metadata = org::open_power::Witherspoon::Fault::
294 PowerSupplyInputFault;
295
296 report<PowerSupplyInputFault>(
297 metadata::RAW_STATUS(nv.get().c_str()),
298 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
299 faultFound = true;
300 }
301
Brandon Wyman603cc002017-08-28 18:17:58 -0500302}
303
304void PowerSupply::checkPGOrUnitOffFault(const uint16_t statusWord)
305{
306 using namespace witherspoon::pmbus;
307
Brandon Wyman593d24f2017-10-13 18:15:23 -0500308 if (powerOnFault < FAULT_COUNT)
Brandon Wyman603cc002017-08-28 18:17:58 -0500309 {
Brandon Wyman593d24f2017-10-13 18:15:23 -0500310 // Check PG# and UNIT_IS_OFF
311 if ((statusWord & status_word::POWER_GOOD_NEGATED) ||
312 (statusWord & status_word::UNIT_IS_OFF))
313 {
314 log<level::INFO>("PGOOD or UNIT_IS_OFF bit bad",
315 entry("STATUS_WORD=0x%04X", statusWord));
316 powerOnFault++;
317 }
318 else
319 {
320 if (powerOnFault > 0)
321 {
322 log<level::INFO>("PGOOD and UNIT_IS_OFF bits good");
323 powerOnFault = 0;
324 }
325 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500326
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600327 if (!faultFound && (powerOnFault >= FAULT_COUNT))
Brandon Wyman593d24f2017-10-13 18:15:23 -0500328 {
Brandon Wyman3343e822017-11-03 16:54:11 -0500329 faultFound = true;
330
Brandon Wyman593d24f2017-10-13 18:15:23 -0500331 util::NamesValues nv;
332 nv.add("STATUS_WORD", statusWord);
333 captureCmd(nv, STATUS_INPUT, Type::Debug);
334 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
335 captureCmd(nv, status0Vout, Type::Debug);
336 captureCmd(nv, STATUS_IOUT, Type::Debug);
337 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wyman603cc002017-08-28 18:17:58 -0500338
Brandon Wyman593d24f2017-10-13 18:15:23 -0500339 using metadata = org::open_power::Witherspoon::Fault::
340 PowerSupplyShouldBeOn;
Brandon Wyman603cc002017-08-28 18:17:58 -0500341
Brandon Wyman593d24f2017-10-13 18:15:23 -0500342 // A power supply is OFF (or pgood low) but should be on.
343 report<PowerSupplyShouldBeOn>(
344 metadata::RAW_STATUS(nv.get().c_str()),
345 metadata::CALLOUT_INVENTORY_PATH(
346 inventoryPath.c_str()));
347 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500348 }
349
350}
351
352void PowerSupply::checkCurrentOutOverCurrentFault(const uint16_t statusWord)
353{
354 using namespace witherspoon::pmbus;
355
Brandon Wymandd61be42017-11-07 18:38:54 -0600356 if (outputOCFault < FAULT_COUNT)
Brandon Wyman603cc002017-08-28 18:17:58 -0500357 {
Brandon Wymandd61be42017-11-07 18:38:54 -0600358 // Check for an output overcurrent fault.
359 if ((statusWord & status_word::IOUT_OC_FAULT))
360 {
361 outputOCFault++;
362 }
363 else
364 {
365 if (outputOCFault > 0)
366 {
367 outputOCFault = 0;
368 }
369 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500370
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600371 if (!faultFound && (outputOCFault >= FAULT_COUNT))
Brandon Wymandd61be42017-11-07 18:38:54 -0600372 {
373 util::NamesValues nv;
374 nv.add("STATUS_WORD", statusWord);
375 captureCmd(nv, STATUS_INPUT, Type::Debug);
376 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
377 captureCmd(nv, status0Vout, Type::Debug);
378 captureCmd(nv, STATUS_IOUT, Type::Debug);
379 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wyman603cc002017-08-28 18:17:58 -0500380
Brandon Wymandd61be42017-11-07 18:38:54 -0600381 using metadata = org::open_power::Witherspoon::Fault::
382 PowerSupplyOutputOvercurrent;
Brandon Wyman603cc002017-08-28 18:17:58 -0500383
Brandon Wymandd61be42017-11-07 18:38:54 -0600384 report<PowerSupplyOutputOvercurrent>(
385 metadata::RAW_STATUS(nv.get().c_str()),
386 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
387
388 faultFound = true;
389 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500390 }
391}
392
Brandon Wymanab05c072017-08-30 18:26:41 -0500393void PowerSupply::checkOutputOvervoltageFault(const uint16_t statusWord)
394{
395 using namespace witherspoon::pmbus;
396
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600397 if (outputOVFault < FAULT_COUNT)
Brandon Wymanab05c072017-08-30 18:26:41 -0500398 {
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600399 // Check for an output overvoltage fault.
400 if (statusWord & status_word::VOUT_OV_FAULT)
401 {
402 outputOVFault++;
403 }
404 else
405 {
406 if (outputOVFault > 0)
407 {
408 outputOVFault = 0;
409 }
410 }
Brandon Wymanab05c072017-08-30 18:26:41 -0500411
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600412 if (!faultFound && (outputOVFault >= FAULT_COUNT))
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600413 {
414 util::NamesValues nv;
415 nv.add("STATUS_WORD", statusWord);
416 captureCmd(nv, STATUS_INPUT, Type::Debug);
417 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
418 captureCmd(nv, status0Vout, Type::Debug);
419 captureCmd(nv, STATUS_IOUT, Type::Debug);
420 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wymanab05c072017-08-30 18:26:41 -0500421
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600422 using metadata = org::open_power::Witherspoon::Fault::
423 PowerSupplyOutputOvervoltage;
Brandon Wymanab05c072017-08-30 18:26:41 -0500424
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600425 report<PowerSupplyOutputOvervoltage>(
426 metadata::RAW_STATUS(nv.get().c_str()),
427 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
428
429 faultFound = true;
430 }
Brandon Wymanab05c072017-08-30 18:26:41 -0500431 }
432}
433
Brandon Wyman12661f12017-08-31 15:28:21 -0500434void PowerSupply::checkFanFault(const uint16_t statusWord)
435{
436 using namespace witherspoon::pmbus;
437
Brandon Wymanba255532017-11-08 17:44:10 -0600438 if (fanFault < FAULT_COUNT)
Brandon Wyman12661f12017-08-31 15:28:21 -0500439 {
Brandon Wymanba255532017-11-08 17:44:10 -0600440 // Check for a fan fault or warning condition
441 if (statusWord & status_word::FAN_FAULT)
442 {
443 fanFault++;
444 }
445 else
446 {
447 if (fanFault > 0)
448 {
449 fanFault = 0;
450 }
451 }
Brandon Wyman12661f12017-08-31 15:28:21 -0500452
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600453 if (!faultFound && (fanFault >= FAULT_COUNT))
Brandon Wymanba255532017-11-08 17:44:10 -0600454 {
455 util::NamesValues nv;
456 nv.add("STATUS_WORD", statusWord);
457 captureCmd(nv, STATUS_MFR, Type::Debug);
458 captureCmd(nv, STATUS_TEMPERATURE, Type::Debug);
459 captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
Brandon Wyman12661f12017-08-31 15:28:21 -0500460
Brandon Wymanba255532017-11-08 17:44:10 -0600461 using metadata = org::open_power::Witherspoon::Fault::
462 PowerSupplyFanFault;
Brandon Wyman12661f12017-08-31 15:28:21 -0500463
Brandon Wymanba255532017-11-08 17:44:10 -0600464 report<PowerSupplyFanFault>(
465 metadata::RAW_STATUS(nv.get().c_str()),
466 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
467
468 faultFound = true;
469 }
Brandon Wyman12661f12017-08-31 15:28:21 -0500470 }
471}
472
Brandon Wyman875b3632017-09-13 18:46:03 -0500473void PowerSupply::checkTemperatureFault(const uint16_t statusWord)
474{
475 using namespace witherspoon::pmbus;
476
477 // Due to how the PMBus core device driver sends a clear faults command
478 // the bit in STATUS_WORD will likely be cleared when we attempt to examine
479 // it for a Thermal Fault or Warning. So, check the STATUS_WORD and the
480 // STATUS_TEMPERATURE bits. If either indicates a fault, proceed with
481 // logging the over-temperature condition.
482 std::uint8_t statusTemperature = 0;
483 statusTemperature = pmbusIntf.read(STATUS_TEMPERATURE, Type::Debug);
Brandon Wyman50044ea2017-11-08 17:58:56 -0600484 if (temperatureFault < FAULT_COUNT)
Brandon Wyman875b3632017-09-13 18:46:03 -0500485 {
Brandon Wyman50044ea2017-11-08 17:58:56 -0600486 if ((statusWord & status_word::TEMPERATURE_FAULT_WARN) ||
487 (statusTemperature & status_temperature::OT_FAULT))
488 {
489 temperatureFault++;
490 }
491 else
492 {
493 if (temperatureFault > 0)
494 {
495 temperatureFault = 0;
496 }
497 }
Brandon Wyman875b3632017-09-13 18:46:03 -0500498
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600499 if (!faultFound && (temperatureFault >= FAULT_COUNT))
Brandon Wyman50044ea2017-11-08 17:58:56 -0600500 {
501 // The power supply has had an over-temperature condition.
502 // This may not result in a shutdown if experienced for a short
503 // duration.
504 // This should not occur under normal conditions.
505 // The power supply may be faulty, or the paired supply may be
506 // putting out less current.
507 // Capture command responses with potentially relevant information,
508 // and call out the power supply reporting the condition.
509 util::NamesValues nv;
510 nv.add("STATUS_WORD", statusWord);
511 captureCmd(nv, STATUS_MFR, Type::Debug);
512 captureCmd(nv, STATUS_IOUT, Type::Debug);
513 nv.add("STATUS_TEMPERATURE", statusTemperature);
514 captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
Brandon Wyman875b3632017-09-13 18:46:03 -0500515
Brandon Wyman50044ea2017-11-08 17:58:56 -0600516 using metadata = org::open_power::Witherspoon::Fault::
517 PowerSupplyTemperatureFault;
Brandon Wyman875b3632017-09-13 18:46:03 -0500518
Brandon Wyman50044ea2017-11-08 17:58:56 -0600519 report<PowerSupplyTemperatureFault>(
520 metadata::RAW_STATUS(nv.get().c_str()),
521 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
522
523 faultFound = true;
524 }
Brandon Wyman875b3632017-09-13 18:46:03 -0500525 }
526}
527
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500528void PowerSupply::clearFaults()
529{
Brandon Wymane4af9802017-11-13 15:58:33 -0600530 readFail = 0;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500531 readFailLogged = false;
Brandon Wymana3c675c2017-11-14 14:54:54 -0600532 inputFault = 0;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500533 powerOnFault = 0;
Brandon Wymandd61be42017-11-07 18:38:54 -0600534 outputOCFault = 0;
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600535 outputOVFault = 0;
Brandon Wymanba255532017-11-08 17:44:10 -0600536 fanFault = 0;
Brandon Wyman50044ea2017-11-08 17:58:56 -0600537 temperatureFault = 0;
Brandon Wyman3343e822017-11-03 16:54:11 -0500538 faultFound = false;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500539
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500540 return;
541}
542
Brandon Wyman43ce2082017-11-30 17:24:01 -0600543void PowerSupply::resolveError(const std::string& callout,
544 const std::string& message)
545{
546 // to be filled in.
547 return;
548}
549
Brandon Wyman24e422f2017-07-25 19:40:14 -0500550}
551}
552}