blob: 8a00d598ff78c965f132d6b298296ee6fae1c19d [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 Wymanbee81612017-11-01 18:24:43 -0500122 //TODO: openbmc/openbmc#2484 Three consecutive reads should be
123 // performed.
Brandon Wyman10295542017-08-09 18:20:44 -0500124 // If 3 consecutive reads are seen, log the fault.
125 // Driver gives cached value, read once a second.
126 // increment for fault on, decrement for fault off, to deglitch.
127 // If count reaches 3, we have fault. If count reaches 0, fault is
128 // cleared.
129
Brandon Wyman603cc002017-08-28 18:17:58 -0500130 checkInputFault(statusWord);
Brandon Wyman764c7972017-08-22 17:05:36 -0500131
Brandon Wyman3343e822017-11-03 16:54:11 -0500132 if (powerOn && !faultFound)
Brandon Wyman764c7972017-08-22 17:05:36 -0500133 {
Brandon Wyman12661f12017-08-31 15:28:21 -0500134 checkFanFault(statusWord);
Brandon Wyman875b3632017-09-13 18:46:03 -0500135 checkTemperatureFault(statusWord);
Brandon Wymancfa032b2017-09-25 17:37:50 -0500136 checkOutputOvervoltageFault(statusWord);
137 checkCurrentOutOverCurrentFault(statusWord);
138 checkPGOrUnitOffFault(statusWord);
Brandon Wyman442035f2017-08-08 15:58:45 -0500139 }
140 }
141 }
142 catch (ReadFailure& e)
143 {
Brandon Wymane4af9802017-11-13 15:58:33 -0600144 if (readFail < FAULT_COUNT)
145 {
146 readFail++;
147 }
148
149 if (!readFailLogged && readFail >= FAULT_COUNT)
Brandon Wyman442035f2017-08-08 15:58:45 -0500150 {
151 commit<ReadFailure>();
152 readFailLogged = true;
Brandon Wyman442035f2017-08-08 15:58:45 -0500153 }
154 }
155
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500156 return;
157}
158
Brandon Wyman10295542017-08-09 18:20:44 -0500159void PowerSupply::inventoryChanged(sdbusplus::message::message& msg)
160{
161 std::string msgSensor;
162 std::map<std::string, sdbusplus::message::variant<uint32_t, bool>> msgData;
163 msg.read(msgSensor, msgData);
164
165 // Check if it was the Present property that changed.
166 auto valPropMap = msgData.find(PRESENT_PROP);
167 if (valPropMap != msgData.end())
168 {
169 present = sdbusplus::message::variant_ns::get<bool>(valPropMap->second);
170
171 if (present)
172 {
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500173 clearFaults();
Brandon Wyman590fc282017-11-01 18:22:25 -0500174 presentTimer.start(presentInterval, Timer::TimerType::oneshot);
175 }
176 else
177 {
178 presentTimer.stop();
Brandon Wyman10295542017-08-09 18:20:44 -0500179 }
180 }
181
182 return;
183}
184
185void PowerSupply::updatePresence()
186{
187 // Use getProperty utility function to get presence status.
Brandon Wyman10295542017-08-09 18:20:44 -0500188 std::string service = "xyz.openbmc_project.Inventory.Manager";
Brandon Wyman50bb85d2017-11-01 18:36:00 -0500189 util::getProperty(INVENTORY_INTERFACE, PRESENT_PROP, inventoryPath,
190 service, bus, this->present);
Brandon Wyman10295542017-08-09 18:20:44 -0500191}
192
Brandon Wyman431fbe42017-08-18 16:22:09 -0500193void PowerSupply::powerStateChanged(sdbusplus::message::message& msg)
194{
195 int32_t state = 0;
196 std::string msgSensor;
197 std::map<std::string, sdbusplus::message::variant<int32_t, int32_t>>
198 msgData;
199 msg.read(msgSensor, msgData);
200
201 // Check if it was the Present property that changed.
202 auto valPropMap = msgData.find("state");
203 if (valPropMap != msgData.end())
204 {
205 state = sdbusplus::message::variant_ns::get<int32_t>(valPropMap->second);
206
207 // Power is on when state=1. Set the fault logged variables to false
208 // and start the power on timer when the state changes to 1.
209 if (state)
210 {
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500211 clearFaults();
Brandon Wyman431fbe42017-08-18 16:22:09 -0500212 powerOnTimer.start(powerOnInterval, Timer::TimerType::oneshot);
213 }
214 else
215 {
216 powerOnTimer.stop();
217 powerOn = false;
218 }
219 }
220
221}
222
223void PowerSupply::updatePowerState()
224{
225 // When state = 1, system is powered on
226 int32_t state = 0;
227
228 try
229 {
230 auto service = util::getService(POWER_OBJ_PATH,
231 POWER_INTERFACE,
232 bus);
233
234 // Use getProperty utility function to get power state.
235 util::getProperty<int32_t>(POWER_INTERFACE,
236 "state",
237 POWER_OBJ_PATH,
238 service,
239 bus,
240 state);
241
242 if (state)
243 {
244 powerOn = true;
245 }
246 else
247 {
248 powerOn = false;
249 }
250 }
251 catch (std::exception& e)
252 {
253 log<level::INFO>("Failed to get power state. Assuming it is off.");
254 powerOn = false;
255 }
256
257}
258
Brandon Wyman603cc002017-08-28 18:17:58 -0500259void PowerSupply::checkInputFault(const uint16_t statusWord)
260{
261 using namespace witherspoon::pmbus;
262
Brandon Wymana3c675c2017-11-14 14:54:54 -0600263 if ((inputFault < FAULT_COUNT) &&
264 ((statusWord & status_word::INPUT_FAULT_WARN) ||
265 (statusWord & status_word::VIN_UV_FAULT)))
Brandon Wyman603cc002017-08-28 18:17:58 -0500266 {
Brandon Wymana3c675c2017-11-14 14:54:54 -0600267 inputFault++;
Brandon Wyman603cc002017-08-28 18:17:58 -0500268 }
269 else
270 {
Brandon Wymana3c675c2017-11-14 14:54:54 -0600271 if ((inputFault > 0) &&
Brandon Wymand20686a2017-11-01 17:45:23 -0500272 !(statusWord & status_word::INPUT_FAULT_WARN) &&
273 !(statusWord & status_word::VIN_UV_FAULT))
Brandon Wyman603cc002017-08-28 18:17:58 -0500274 {
Brandon Wymana3c675c2017-11-14 14:54:54 -0600275 inputFault = 0;
Brandon Wyman3343e822017-11-03 16:54:11 -0500276 faultFound = false;
Brandon Wyman69591bd2017-11-01 18:07:23 -0500277
Brandon Wyman603cc002017-08-28 18:17:58 -0500278 log<level::INFO>("INPUT_FAULT_WARN cleared",
Brandon Wymana3c675c2017-11-14 14:54:54 -0600279 entry("POWERSUPPLY=%s", inventoryPath.c_str()));
Brandon Wyman69591bd2017-11-01 18:07:23 -0500280
281 if (powerOn)
282 {
283 // The power supply will not be immediately powered on after
284 // the input power is restored.
285 powerOn = false;
286 // Start up the timer that will set the state to indicate we
287 // are ready for the powered on fault checks.
288 powerOnTimer.start(powerOnInterval, Timer::TimerType::oneshot);
289 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500290 }
291 }
Brandon Wymana3c675c2017-11-14 14:54:54 -0600292
293 if (!faultFound && (inputFault >= FAULT_COUNT))
294 {
295 util::NamesValues nv;
296 nv.add("STATUS_WORD", statusWord);
297 captureCmd(nv, STATUS_INPUT, Type::Debug);
298
299 using metadata = org::open_power::Witherspoon::Fault::
300 PowerSupplyInputFault;
301
302 report<PowerSupplyInputFault>(
303 metadata::RAW_STATUS(nv.get().c_str()),
304 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
305 faultFound = true;
306 }
307
Brandon Wyman603cc002017-08-28 18:17:58 -0500308}
309
310void PowerSupply::checkPGOrUnitOffFault(const uint16_t statusWord)
311{
312 using namespace witherspoon::pmbus;
313
Brandon Wyman593d24f2017-10-13 18:15:23 -0500314 if (powerOnFault < FAULT_COUNT)
Brandon Wyman603cc002017-08-28 18:17:58 -0500315 {
Brandon Wyman593d24f2017-10-13 18:15:23 -0500316 // Check PG# and UNIT_IS_OFF
317 if ((statusWord & status_word::POWER_GOOD_NEGATED) ||
318 (statusWord & status_word::UNIT_IS_OFF))
319 {
320 log<level::INFO>("PGOOD or UNIT_IS_OFF bit bad",
321 entry("STATUS_WORD=0x%04X", statusWord));
322 powerOnFault++;
323 }
324 else
325 {
326 if (powerOnFault > 0)
327 {
328 log<level::INFO>("PGOOD and UNIT_IS_OFF bits good");
329 powerOnFault = 0;
330 }
331 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500332
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600333 if (!faultFound && (powerOnFault >= FAULT_COUNT))
Brandon Wyman593d24f2017-10-13 18:15:23 -0500334 {
Brandon Wyman3343e822017-11-03 16:54:11 -0500335 faultFound = true;
336
Brandon Wyman593d24f2017-10-13 18:15:23 -0500337 util::NamesValues nv;
338 nv.add("STATUS_WORD", statusWord);
339 captureCmd(nv, STATUS_INPUT, Type::Debug);
340 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
341 captureCmd(nv, status0Vout, Type::Debug);
342 captureCmd(nv, STATUS_IOUT, Type::Debug);
343 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wyman603cc002017-08-28 18:17:58 -0500344
Brandon Wyman593d24f2017-10-13 18:15:23 -0500345 using metadata = org::open_power::Witherspoon::Fault::
346 PowerSupplyShouldBeOn;
Brandon Wyman603cc002017-08-28 18:17:58 -0500347
Brandon Wyman593d24f2017-10-13 18:15:23 -0500348 // A power supply is OFF (or pgood low) but should be on.
349 report<PowerSupplyShouldBeOn>(
350 metadata::RAW_STATUS(nv.get().c_str()),
351 metadata::CALLOUT_INVENTORY_PATH(
352 inventoryPath.c_str()));
353 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500354 }
355
356}
357
358void PowerSupply::checkCurrentOutOverCurrentFault(const uint16_t statusWord)
359{
360 using namespace witherspoon::pmbus;
361
Brandon Wymandd61be42017-11-07 18:38:54 -0600362 if (outputOCFault < FAULT_COUNT)
Brandon Wyman603cc002017-08-28 18:17:58 -0500363 {
Brandon Wymandd61be42017-11-07 18:38:54 -0600364 // Check for an output overcurrent fault.
365 if ((statusWord & status_word::IOUT_OC_FAULT))
366 {
367 outputOCFault++;
368 }
369 else
370 {
371 if (outputOCFault > 0)
372 {
373 outputOCFault = 0;
374 }
375 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500376
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600377 if (!faultFound && (outputOCFault >= FAULT_COUNT))
Brandon Wymandd61be42017-11-07 18:38:54 -0600378 {
379 util::NamesValues nv;
380 nv.add("STATUS_WORD", statusWord);
381 captureCmd(nv, STATUS_INPUT, Type::Debug);
382 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
383 captureCmd(nv, status0Vout, Type::Debug);
384 captureCmd(nv, STATUS_IOUT, Type::Debug);
385 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wyman603cc002017-08-28 18:17:58 -0500386
Brandon Wymandd61be42017-11-07 18:38:54 -0600387 using metadata = org::open_power::Witherspoon::Fault::
388 PowerSupplyOutputOvercurrent;
Brandon Wyman603cc002017-08-28 18:17:58 -0500389
Brandon Wymandd61be42017-11-07 18:38:54 -0600390 report<PowerSupplyOutputOvercurrent>(
391 metadata::RAW_STATUS(nv.get().c_str()),
392 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
393
394 faultFound = true;
395 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500396 }
397}
398
Brandon Wymanab05c072017-08-30 18:26:41 -0500399void PowerSupply::checkOutputOvervoltageFault(const uint16_t statusWord)
400{
401 using namespace witherspoon::pmbus;
402
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600403 if (outputOVFault < FAULT_COUNT)
Brandon Wymanab05c072017-08-30 18:26:41 -0500404 {
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600405 // Check for an output overvoltage fault.
406 if (statusWord & status_word::VOUT_OV_FAULT)
407 {
408 outputOVFault++;
409 }
410 else
411 {
412 if (outputOVFault > 0)
413 {
414 outputOVFault = 0;
415 }
416 }
Brandon Wymanab05c072017-08-30 18:26:41 -0500417
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600418 if (!faultFound && (outputOVFault >= FAULT_COUNT))
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600419 {
420 util::NamesValues nv;
421 nv.add("STATUS_WORD", statusWord);
422 captureCmd(nv, STATUS_INPUT, Type::Debug);
423 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
424 captureCmd(nv, status0Vout, Type::Debug);
425 captureCmd(nv, STATUS_IOUT, Type::Debug);
426 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wymanab05c072017-08-30 18:26:41 -0500427
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600428 using metadata = org::open_power::Witherspoon::Fault::
429 PowerSupplyOutputOvervoltage;
Brandon Wymanab05c072017-08-30 18:26:41 -0500430
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600431 report<PowerSupplyOutputOvervoltage>(
432 metadata::RAW_STATUS(nv.get().c_str()),
433 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
434
435 faultFound = true;
436 }
Brandon Wymanab05c072017-08-30 18:26:41 -0500437 }
438}
439
Brandon Wyman12661f12017-08-31 15:28:21 -0500440void PowerSupply::checkFanFault(const uint16_t statusWord)
441{
442 using namespace witherspoon::pmbus;
443
Brandon Wymanba255532017-11-08 17:44:10 -0600444 if (fanFault < FAULT_COUNT)
Brandon Wyman12661f12017-08-31 15:28:21 -0500445 {
Brandon Wymanba255532017-11-08 17:44:10 -0600446 // Check for a fan fault or warning condition
447 if (statusWord & status_word::FAN_FAULT)
448 {
449 fanFault++;
450 }
451 else
452 {
453 if (fanFault > 0)
454 {
455 fanFault = 0;
456 }
457 }
Brandon Wyman12661f12017-08-31 15:28:21 -0500458
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600459 if (!faultFound && (fanFault >= FAULT_COUNT))
Brandon Wymanba255532017-11-08 17:44:10 -0600460 {
461 util::NamesValues nv;
462 nv.add("STATUS_WORD", statusWord);
463 captureCmd(nv, STATUS_MFR, Type::Debug);
464 captureCmd(nv, STATUS_TEMPERATURE, Type::Debug);
465 captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
Brandon Wyman12661f12017-08-31 15:28:21 -0500466
Brandon Wymanba255532017-11-08 17:44:10 -0600467 using metadata = org::open_power::Witherspoon::Fault::
468 PowerSupplyFanFault;
Brandon Wyman12661f12017-08-31 15:28:21 -0500469
Brandon Wymanba255532017-11-08 17:44:10 -0600470 report<PowerSupplyFanFault>(
471 metadata::RAW_STATUS(nv.get().c_str()),
472 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
473
474 faultFound = true;
475 }
Brandon Wyman12661f12017-08-31 15:28:21 -0500476 }
477}
478
Brandon Wyman875b3632017-09-13 18:46:03 -0500479void PowerSupply::checkTemperatureFault(const uint16_t statusWord)
480{
481 using namespace witherspoon::pmbus;
482
483 // Due to how the PMBus core device driver sends a clear faults command
484 // the bit in STATUS_WORD will likely be cleared when we attempt to examine
485 // it for a Thermal Fault or Warning. So, check the STATUS_WORD and the
486 // STATUS_TEMPERATURE bits. If either indicates a fault, proceed with
487 // logging the over-temperature condition.
488 std::uint8_t statusTemperature = 0;
489 statusTemperature = pmbusIntf.read(STATUS_TEMPERATURE, Type::Debug);
Brandon Wyman50044ea2017-11-08 17:58:56 -0600490 if (temperatureFault < FAULT_COUNT)
Brandon Wyman875b3632017-09-13 18:46:03 -0500491 {
Brandon Wyman50044ea2017-11-08 17:58:56 -0600492 if ((statusWord & status_word::TEMPERATURE_FAULT_WARN) ||
493 (statusTemperature & status_temperature::OT_FAULT))
494 {
495 temperatureFault++;
496 }
497 else
498 {
499 if (temperatureFault > 0)
500 {
501 temperatureFault = 0;
502 }
503 }
Brandon Wyman875b3632017-09-13 18:46:03 -0500504
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600505 if (!faultFound && (temperatureFault >= FAULT_COUNT))
Brandon Wyman50044ea2017-11-08 17:58:56 -0600506 {
507 // The power supply has had an over-temperature condition.
508 // This may not result in a shutdown if experienced for a short
509 // duration.
510 // This should not occur under normal conditions.
511 // The power supply may be faulty, or the paired supply may be
512 // putting out less current.
513 // Capture command responses with potentially relevant information,
514 // and call out the power supply reporting the condition.
515 util::NamesValues nv;
516 nv.add("STATUS_WORD", statusWord);
517 captureCmd(nv, STATUS_MFR, Type::Debug);
518 captureCmd(nv, STATUS_IOUT, Type::Debug);
519 nv.add("STATUS_TEMPERATURE", statusTemperature);
520 captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
Brandon Wyman875b3632017-09-13 18:46:03 -0500521
Brandon Wyman50044ea2017-11-08 17:58:56 -0600522 using metadata = org::open_power::Witherspoon::Fault::
523 PowerSupplyTemperatureFault;
Brandon Wyman875b3632017-09-13 18:46:03 -0500524
Brandon Wyman50044ea2017-11-08 17:58:56 -0600525 report<PowerSupplyTemperatureFault>(
526 metadata::RAW_STATUS(nv.get().c_str()),
527 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
528
529 faultFound = true;
530 }
Brandon Wyman875b3632017-09-13 18:46:03 -0500531 }
532}
533
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500534void PowerSupply::clearFaults()
535{
Brandon Wymane4af9802017-11-13 15:58:33 -0600536 readFail = 0;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500537 readFailLogged = false;
Brandon Wymana3c675c2017-11-14 14:54:54 -0600538 inputFault = 0;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500539 powerOnFault = 0;
Brandon Wymandd61be42017-11-07 18:38:54 -0600540 outputOCFault = 0;
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600541 outputOVFault = 0;
Brandon Wymanba255532017-11-08 17:44:10 -0600542 fanFault = 0;
Brandon Wyman50044ea2017-11-08 17:58:56 -0600543 temperatureFault = 0;
Brandon Wyman3343e822017-11-03 16:54:11 -0500544 faultFound = false;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500545
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500546 return;
547}
548
Brandon Wyman24e422f2017-07-25 19:40:14 -0500549}
550}
551}