blob: 7eb456940e90e928f49297ae9c453dd442c1eced [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 {
Brandon Wyman2ef48cf2017-11-21 15:43:54 -0600169 if (sdbusplus::message::variant_ns::get<bool>(valPropMap->second))
Brandon Wyman10295542017-08-09 18:20:44 -0500170 {
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500171 clearFaults();
Brandon Wyman590fc282017-11-01 18:22:25 -0500172 presentTimer.start(presentInterval, Timer::TimerType::oneshot);
173 }
174 else
175 {
Brandon Wyman2ef48cf2017-11-21 15:43:54 -0600176 present = false;
Brandon Wyman590fc282017-11-01 18:22:25 -0500177 presentTimer.stop();
Brandon Wyman10295542017-08-09 18:20:44 -0500178 }
179 }
180
181 return;
182}
183
184void PowerSupply::updatePresence()
185{
186 // Use getProperty utility function to get presence status.
Brandon Wyman10295542017-08-09 18:20:44 -0500187 std::string service = "xyz.openbmc_project.Inventory.Manager";
Brandon Wyman50bb85d2017-11-01 18:36:00 -0500188 util::getProperty(INVENTORY_INTERFACE, PRESENT_PROP, inventoryPath,
189 service, bus, this->present);
Brandon Wyman10295542017-08-09 18:20:44 -0500190}
191
Brandon Wyman431fbe42017-08-18 16:22:09 -0500192void PowerSupply::powerStateChanged(sdbusplus::message::message& msg)
193{
194 int32_t state = 0;
195 std::string msgSensor;
196 std::map<std::string, sdbusplus::message::variant<int32_t, int32_t>>
197 msgData;
198 msg.read(msgSensor, msgData);
199
200 // Check if it was the Present property that changed.
201 auto valPropMap = msgData.find("state");
202 if (valPropMap != msgData.end())
203 {
204 state = sdbusplus::message::variant_ns::get<int32_t>(valPropMap->second);
205
206 // Power is on when state=1. Set the fault logged variables to false
207 // and start the power on timer when the state changes to 1.
208 if (state)
209 {
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500210 clearFaults();
Brandon Wyman431fbe42017-08-18 16:22:09 -0500211 powerOnTimer.start(powerOnInterval, Timer::TimerType::oneshot);
212 }
213 else
214 {
215 powerOnTimer.stop();
216 powerOn = false;
217 }
218 }
219
220}
221
222void PowerSupply::updatePowerState()
223{
224 // When state = 1, system is powered on
225 int32_t state = 0;
226
227 try
228 {
229 auto service = util::getService(POWER_OBJ_PATH,
230 POWER_INTERFACE,
231 bus);
232
233 // Use getProperty utility function to get power state.
234 util::getProperty<int32_t>(POWER_INTERFACE,
235 "state",
236 POWER_OBJ_PATH,
237 service,
238 bus,
239 state);
240
241 if (state)
242 {
243 powerOn = true;
244 }
245 else
246 {
247 powerOn = false;
248 }
249 }
250 catch (std::exception& e)
251 {
252 log<level::INFO>("Failed to get power state. Assuming it is off.");
253 powerOn = false;
254 }
255
256}
257
Brandon Wyman603cc002017-08-28 18:17:58 -0500258void PowerSupply::checkInputFault(const uint16_t statusWord)
259{
260 using namespace witherspoon::pmbus;
261
Brandon Wymana3c675c2017-11-14 14:54:54 -0600262 if ((inputFault < FAULT_COUNT) &&
263 ((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++;
Brandon Wyman603cc002017-08-28 18:17:58 -0500267 }
268 else
269 {
Brandon Wymana3c675c2017-11-14 14:54:54 -0600270 if ((inputFault > 0) &&
Brandon Wymand20686a2017-11-01 17:45:23 -0500271 !(statusWord & status_word::INPUT_FAULT_WARN) &&
272 !(statusWord & status_word::VIN_UV_FAULT))
Brandon Wyman603cc002017-08-28 18:17:58 -0500273 {
Brandon Wymana3c675c2017-11-14 14:54:54 -0600274 inputFault = 0;
Brandon Wyman3343e822017-11-03 16:54:11 -0500275 faultFound = false;
Brandon Wyman69591bd2017-11-01 18:07:23 -0500276
Brandon Wyman603cc002017-08-28 18:17:58 -0500277 log<level::INFO>("INPUT_FAULT_WARN cleared",
Brandon Wymana3c675c2017-11-14 14:54:54 -0600278 entry("POWERSUPPLY=%s", inventoryPath.c_str()));
Brandon Wyman69591bd2017-11-01 18:07:23 -0500279
280 if (powerOn)
281 {
282 // The power supply will not be immediately powered on after
283 // the input power is restored.
284 powerOn = false;
285 // Start up the timer that will set the state to indicate we
286 // are ready for the powered on fault checks.
287 powerOnTimer.start(powerOnInterval, Timer::TimerType::oneshot);
288 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500289 }
290 }
Brandon Wymana3c675c2017-11-14 14:54:54 -0600291
292 if (!faultFound && (inputFault >= FAULT_COUNT))
293 {
294 util::NamesValues nv;
295 nv.add("STATUS_WORD", statusWord);
296 captureCmd(nv, STATUS_INPUT, Type::Debug);
297
298 using metadata = org::open_power::Witherspoon::Fault::
299 PowerSupplyInputFault;
300
301 report<PowerSupplyInputFault>(
302 metadata::RAW_STATUS(nv.get().c_str()),
303 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
304 faultFound = true;
305 }
306
Brandon Wyman603cc002017-08-28 18:17:58 -0500307}
308
309void PowerSupply::checkPGOrUnitOffFault(const uint16_t statusWord)
310{
311 using namespace witherspoon::pmbus;
312
Brandon Wyman593d24f2017-10-13 18:15:23 -0500313 if (powerOnFault < FAULT_COUNT)
Brandon Wyman603cc002017-08-28 18:17:58 -0500314 {
Brandon Wyman593d24f2017-10-13 18:15:23 -0500315 // Check PG# and UNIT_IS_OFF
316 if ((statusWord & status_word::POWER_GOOD_NEGATED) ||
317 (statusWord & status_word::UNIT_IS_OFF))
318 {
319 log<level::INFO>("PGOOD or UNIT_IS_OFF bit bad",
320 entry("STATUS_WORD=0x%04X", statusWord));
321 powerOnFault++;
322 }
323 else
324 {
325 if (powerOnFault > 0)
326 {
327 log<level::INFO>("PGOOD and UNIT_IS_OFF bits good");
328 powerOnFault = 0;
329 }
330 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500331
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600332 if (!faultFound && (powerOnFault >= FAULT_COUNT))
Brandon Wyman593d24f2017-10-13 18:15:23 -0500333 {
Brandon Wyman3343e822017-11-03 16:54:11 -0500334 faultFound = true;
335
Brandon Wyman593d24f2017-10-13 18:15:23 -0500336 util::NamesValues nv;
337 nv.add("STATUS_WORD", statusWord);
338 captureCmd(nv, STATUS_INPUT, Type::Debug);
339 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
340 captureCmd(nv, status0Vout, Type::Debug);
341 captureCmd(nv, STATUS_IOUT, Type::Debug);
342 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wyman603cc002017-08-28 18:17:58 -0500343
Brandon Wyman593d24f2017-10-13 18:15:23 -0500344 using metadata = org::open_power::Witherspoon::Fault::
345 PowerSupplyShouldBeOn;
Brandon Wyman603cc002017-08-28 18:17:58 -0500346
Brandon Wyman593d24f2017-10-13 18:15:23 -0500347 // A power supply is OFF (or pgood low) but should be on.
348 report<PowerSupplyShouldBeOn>(
349 metadata::RAW_STATUS(nv.get().c_str()),
350 metadata::CALLOUT_INVENTORY_PATH(
351 inventoryPath.c_str()));
352 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500353 }
354
355}
356
357void PowerSupply::checkCurrentOutOverCurrentFault(const uint16_t statusWord)
358{
359 using namespace witherspoon::pmbus;
360
Brandon Wymandd61be42017-11-07 18:38:54 -0600361 if (outputOCFault < FAULT_COUNT)
Brandon Wyman603cc002017-08-28 18:17:58 -0500362 {
Brandon Wymandd61be42017-11-07 18:38:54 -0600363 // Check for an output overcurrent fault.
364 if ((statusWord & status_word::IOUT_OC_FAULT))
365 {
366 outputOCFault++;
367 }
368 else
369 {
370 if (outputOCFault > 0)
371 {
372 outputOCFault = 0;
373 }
374 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500375
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600376 if (!faultFound && (outputOCFault >= FAULT_COUNT))
Brandon Wymandd61be42017-11-07 18:38:54 -0600377 {
378 util::NamesValues nv;
379 nv.add("STATUS_WORD", statusWord);
380 captureCmd(nv, STATUS_INPUT, Type::Debug);
381 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
382 captureCmd(nv, status0Vout, Type::Debug);
383 captureCmd(nv, STATUS_IOUT, Type::Debug);
384 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wyman603cc002017-08-28 18:17:58 -0500385
Brandon Wymandd61be42017-11-07 18:38:54 -0600386 using metadata = org::open_power::Witherspoon::Fault::
387 PowerSupplyOutputOvercurrent;
Brandon Wyman603cc002017-08-28 18:17:58 -0500388
Brandon Wymandd61be42017-11-07 18:38:54 -0600389 report<PowerSupplyOutputOvercurrent>(
390 metadata::RAW_STATUS(nv.get().c_str()),
391 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
392
393 faultFound = true;
394 }
Brandon Wyman603cc002017-08-28 18:17:58 -0500395 }
396}
397
Brandon Wymanab05c072017-08-30 18:26:41 -0500398void PowerSupply::checkOutputOvervoltageFault(const uint16_t statusWord)
399{
400 using namespace witherspoon::pmbus;
401
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600402 if (outputOVFault < FAULT_COUNT)
Brandon Wymanab05c072017-08-30 18:26:41 -0500403 {
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600404 // Check for an output overvoltage fault.
405 if (statusWord & status_word::VOUT_OV_FAULT)
406 {
407 outputOVFault++;
408 }
409 else
410 {
411 if (outputOVFault > 0)
412 {
413 outputOVFault = 0;
414 }
415 }
Brandon Wymanab05c072017-08-30 18:26:41 -0500416
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600417 if (!faultFound && (outputOVFault >= FAULT_COUNT))
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600418 {
419 util::NamesValues nv;
420 nv.add("STATUS_WORD", statusWord);
421 captureCmd(nv, STATUS_INPUT, Type::Debug);
422 auto status0Vout = pmbusIntf.insertPageNum(STATUS_VOUT, 0);
423 captureCmd(nv, status0Vout, Type::Debug);
424 captureCmd(nv, STATUS_IOUT, Type::Debug);
425 captureCmd(nv, STATUS_MFR, Type::Debug);
Brandon Wymanab05c072017-08-30 18:26:41 -0500426
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600427 using metadata = org::open_power::Witherspoon::Fault::
428 PowerSupplyOutputOvervoltage;
Brandon Wymanab05c072017-08-30 18:26:41 -0500429
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600430 report<PowerSupplyOutputOvervoltage>(
431 metadata::RAW_STATUS(nv.get().c_str()),
432 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
433
434 faultFound = true;
435 }
Brandon Wymanab05c072017-08-30 18:26:41 -0500436 }
437}
438
Brandon Wyman12661f12017-08-31 15:28:21 -0500439void PowerSupply::checkFanFault(const uint16_t statusWord)
440{
441 using namespace witherspoon::pmbus;
442
Brandon Wymanba255532017-11-08 17:44:10 -0600443 if (fanFault < FAULT_COUNT)
Brandon Wyman12661f12017-08-31 15:28:21 -0500444 {
Brandon Wymanba255532017-11-08 17:44:10 -0600445 // Check for a fan fault or warning condition
446 if (statusWord & status_word::FAN_FAULT)
447 {
448 fanFault++;
449 }
450 else
451 {
452 if (fanFault > 0)
453 {
454 fanFault = 0;
455 }
456 }
Brandon Wyman12661f12017-08-31 15:28:21 -0500457
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600458 if (!faultFound && (fanFault >= FAULT_COUNT))
Brandon Wymanba255532017-11-08 17:44:10 -0600459 {
460 util::NamesValues nv;
461 nv.add("STATUS_WORD", statusWord);
462 captureCmd(nv, STATUS_MFR, Type::Debug);
463 captureCmd(nv, STATUS_TEMPERATURE, Type::Debug);
464 captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
Brandon Wyman12661f12017-08-31 15:28:21 -0500465
Brandon Wymanba255532017-11-08 17:44:10 -0600466 using metadata = org::open_power::Witherspoon::Fault::
467 PowerSupplyFanFault;
Brandon Wyman12661f12017-08-31 15:28:21 -0500468
Brandon Wymanba255532017-11-08 17:44:10 -0600469 report<PowerSupplyFanFault>(
470 metadata::RAW_STATUS(nv.get().c_str()),
471 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
472
473 faultFound = true;
474 }
Brandon Wyman12661f12017-08-31 15:28:21 -0500475 }
476}
477
Brandon Wyman875b3632017-09-13 18:46:03 -0500478void PowerSupply::checkTemperatureFault(const uint16_t statusWord)
479{
480 using namespace witherspoon::pmbus;
481
482 // Due to how the PMBus core device driver sends a clear faults command
483 // the bit in STATUS_WORD will likely be cleared when we attempt to examine
484 // it for a Thermal Fault or Warning. So, check the STATUS_WORD and the
485 // STATUS_TEMPERATURE bits. If either indicates a fault, proceed with
486 // logging the over-temperature condition.
487 std::uint8_t statusTemperature = 0;
488 statusTemperature = pmbusIntf.read(STATUS_TEMPERATURE, Type::Debug);
Brandon Wyman50044ea2017-11-08 17:58:56 -0600489 if (temperatureFault < FAULT_COUNT)
Brandon Wyman875b3632017-09-13 18:46:03 -0500490 {
Brandon Wyman50044ea2017-11-08 17:58:56 -0600491 if ((statusWord & status_word::TEMPERATURE_FAULT_WARN) ||
492 (statusTemperature & status_temperature::OT_FAULT))
493 {
494 temperatureFault++;
495 }
496 else
497 {
498 if (temperatureFault > 0)
499 {
500 temperatureFault = 0;
501 }
502 }
Brandon Wyman875b3632017-09-13 18:46:03 -0500503
Brandon Wymane2fc7aa2017-11-13 17:37:10 -0600504 if (!faultFound && (temperatureFault >= FAULT_COUNT))
Brandon Wyman50044ea2017-11-08 17:58:56 -0600505 {
506 // The power supply has had an over-temperature condition.
507 // This may not result in a shutdown if experienced for a short
508 // duration.
509 // This should not occur under normal conditions.
510 // The power supply may be faulty, or the paired supply may be
511 // putting out less current.
512 // Capture command responses with potentially relevant information,
513 // and call out the power supply reporting the condition.
514 util::NamesValues nv;
515 nv.add("STATUS_WORD", statusWord);
516 captureCmd(nv, STATUS_MFR, Type::Debug);
517 captureCmd(nv, STATUS_IOUT, Type::Debug);
518 nv.add("STATUS_TEMPERATURE", statusTemperature);
519 captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
Brandon Wyman875b3632017-09-13 18:46:03 -0500520
Brandon Wyman50044ea2017-11-08 17:58:56 -0600521 using metadata = org::open_power::Witherspoon::Fault::
522 PowerSupplyTemperatureFault;
Brandon Wyman875b3632017-09-13 18:46:03 -0500523
Brandon Wyman50044ea2017-11-08 17:58:56 -0600524 report<PowerSupplyTemperatureFault>(
525 metadata::RAW_STATUS(nv.get().c_str()),
526 metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
527
528 faultFound = true;
529 }
Brandon Wyman875b3632017-09-13 18:46:03 -0500530 }
531}
532
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500533void PowerSupply::clearFaults()
534{
Brandon Wymane4af9802017-11-13 15:58:33 -0600535 readFail = 0;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500536 readFailLogged = false;
Brandon Wymana3c675c2017-11-14 14:54:54 -0600537 inputFault = 0;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500538 powerOnFault = 0;
Brandon Wymandd61be42017-11-07 18:38:54 -0600539 outputOCFault = 0;
Brandon Wyman2ab319b2017-11-08 17:34:59 -0600540 outputOVFault = 0;
Brandon Wymanba255532017-11-08 17:44:10 -0600541 fanFault = 0;
Brandon Wyman50044ea2017-11-08 17:58:56 -0600542 temperatureFault = 0;
Brandon Wyman3343e822017-11-03 16:54:11 -0500543 faultFound = false;
Brandon Wyman6ccce0b2017-10-26 15:13:10 -0500544
Brandon Wyman1db9a9e2017-07-26 18:50:22 -0500545 return;
546}
547
Brandon Wyman24e422f2017-07-25 19:40:14 -0500548}
549}
550}