blob: 331b4bad2ef5bf5d199a67d6f1bcb44a54db7cfd [file] [log] [blame]
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001#include "config.h"
2
Brandon Wymanaed1f752019-11-25 18:10:52 -06003#include "power_supply.hpp"
4
5#include "types.hpp"
Brandon Wyman3f1242f2020-01-28 13:11:25 -06006#include "util.hpp"
Brandon Wymanaed1f752019-11-25 18:10:52 -06007
Anwaar Hadib64228d2025-05-30 23:55:26 +00008#include <phosphor-logging/lg2.hpp>
Brandon Wyman3f1242f2020-01-28 13:11:25 -06009#include <xyz/openbmc_project/Common/Device/error.hpp>
10
Patrick Williams48781ae2023-05-10 07:50:50 -050011#include <chrono> // sleep_for()
Brandon Wyman4fc191f2022-03-10 23:07:13 +000012#include <cmath>
Brandon Wyman1d7a7df2020-03-26 10:14:05 -050013#include <cstdint> // uint8_t...
Shawn McCarney768d2262024-07-09 15:02:59 -050014#include <format>
B. J. Wyman681b2a32021-04-20 22:31:22 +000015#include <fstream>
Brandon Wyman056935c2022-06-24 23:05:09 +000016#include <regex>
B. J. Wyman681b2a32021-04-20 22:31:22 +000017#include <thread> // sleep_for()
Brandon Wyman1d7a7df2020-03-26 10:14:05 -050018
Brandon Wyman3f1242f2020-01-28 13:11:25 -060019namespace phosphor::power::psu
Brandon Wymanaed1f752019-11-25 18:10:52 -060020{
B. J. Wyman681b2a32021-04-20 22:31:22 +000021// Amount of time in milliseconds to delay between power supply going from
22// missing to present before running the bind command(s).
23constexpr auto bindDelay = 1000;
Brandon Wymanaed1f752019-11-25 18:10:52 -060024
25using namespace phosphor::logging;
Brandon Wyman3f1242f2020-01-28 13:11:25 -060026using namespace sdbusplus::xyz::openbmc_project::Common::Device::Error;
Brandon Wymanaed1f752019-11-25 18:10:52 -060027
Patrick Williamsf5402192024-08-16 15:20:53 -040028PowerSupply::PowerSupply(
29 sdbusplus::bus_t& bus, const std::string& invpath, std::uint8_t i2cbus,
30 std::uint16_t i2caddr, const std::string& driver,
31 const std::string& gpioLineName, std::function<bool()>&& callback) :
32 bus(bus), inventoryPath(invpath),
33 bindPath("/sys/bus/i2c/drivers/" + driver), isPowerOn(std::move(callback)),
34 driverName(driver)
Brandon Wyman510acaa2020-11-05 18:32:04 -060035{
36 if (inventoryPath.empty())
37 {
38 throw std::invalid_argument{"Invalid empty inventoryPath"};
39 }
40
B. J. Wyman681b2a32021-04-20 22:31:22 +000041 if (gpioLineName.empty())
42 {
43 throw std::invalid_argument{"Invalid empty gpioLineName"};
44 }
Brandon Wyman510acaa2020-11-05 18:32:04 -060045
Brandon Wyman321a6152022-03-19 00:11:44 +000046 shortName = findShortName(inventoryPath);
47
Anwaar Hadib64228d2025-05-30 23:55:26 +000048 lg2::debug("{SHORT_NAME} gpioLineName: {GPIO_LINE_NAME}", "SHORT_NAME",
49 shortName, "GPIO_LINE_NAME", gpioLineName);
B. J. Wyman681b2a32021-04-20 22:31:22 +000050 presenceGPIO = createGPIO(gpioLineName);
Brandon Wyman510acaa2020-11-05 18:32:04 -060051
52 std::ostringstream ss;
53 ss << std::hex << std::setw(4) << std::setfill('0') << i2caddr;
54 std::string addrStr = ss.str();
B. J. Wyman681b2a32021-04-20 22:31:22 +000055 std::string busStr = std::to_string(i2cbus);
56 bindDevice = busStr;
57 bindDevice.append("-");
58 bindDevice.append(addrStr);
59
Brandon Wyman510acaa2020-11-05 18:32:04 -060060 pmbusIntf = phosphor::pmbus::createPMBus(i2cbus, addrStr);
61
62 // Get the current state of the Present property.
B. J. Wyman681b2a32021-04-20 22:31:22 +000063 try
64 {
65 updatePresenceGPIO();
66 }
67 catch (...)
68 {
69 // If the above attempt to use the GPIO failed, it likely means that the
70 // GPIOs are in use by the kernel, meaning it is using gpio-keys.
71 // So, I should rely on phosphor-gpio-presence to update D-Bus, and
72 // work that way for power supply presence.
73 presenceGPIO = nullptr;
74 // Setup the functions to call when the D-Bus inventory path for the
75 // Present property changes.
76 presentMatch = std::make_unique<sdbusplus::bus::match_t>(
77 bus,
78 sdbusplus::bus::match::rules::propertiesChanged(inventoryPath,
79 INVENTORY_IFACE),
80 [this](auto& msg) { this->inventoryChanged(msg); });
81
82 presentAddedMatch = std::make_unique<sdbusplus::bus::match_t>(
83 bus,
84 sdbusplus::bus::match::rules::interfacesAdded() +
85 sdbusplus::bus::match::rules::argNpath(0, inventoryPath),
86 [this](auto& msg) { this->inventoryAdded(msg); });
87
88 updatePresence();
89 updateInventory();
Matt Spinler592bd272023-08-30 11:00:01 -050090 setupSensors();
B. J. Wyman681b2a32021-04-20 22:31:22 +000091 }
Matt Spinlera068f422023-03-10 13:06:49 -060092
93 setInputVoltageRating();
B. J. Wyman681b2a32021-04-20 22:31:22 +000094}
95
96void PowerSupply::bindOrUnbindDriver(bool present)
97{
Faisal Awadab7131a12023-10-26 19:38:45 -050098 // Symbolic link to the device will exist if the driver is bound.
99 // So exit no action required if both the link and PSU are present
100 // or neither is present.
101 namespace fs = std::filesystem;
102 fs::path path;
B. J. Wyman681b2a32021-04-20 22:31:22 +0000103 auto action = (present) ? "bind" : "unbind";
B. J. Wyman681b2a32021-04-20 22:31:22 +0000104
Faisal Awadab7131a12023-10-26 19:38:45 -0500105 // This case should not happen, if no device driver name return.
106 if (driverName.empty())
107 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000108 lg2::info("No device driver name found");
Faisal Awadab7131a12023-10-26 19:38:45 -0500109 return;
110 }
111 if (bindPath.string().find(driverName) != std::string::npos)
112 {
113 // bindPath has driver name
114 path = bindPath / action;
115 }
116 else
117 {
118 // Add driver name to bindPath
119 path = bindPath / driverName / action;
120 bindPath = bindPath / driverName;
121 }
122
123 if ((std::filesystem::exists(bindPath / bindDevice) && present) ||
124 (!std::filesystem::exists(bindPath / bindDevice) && !present))
125 {
126 return;
127 }
B. J. Wyman681b2a32021-04-20 22:31:22 +0000128 if (present)
129 {
Brandon Wymanb1ee60f2022-03-22 22:37:12 +0000130 std::this_thread::sleep_for(std::chrono::milliseconds(bindDelay));
Anwaar Hadib64228d2025-05-30 23:55:26 +0000131 lg2::info("Binding device driver. path: {PATH} device: {BIND_DEVICE}",
132 "PATH", path, "BIND_DEVICE", bindDevice);
B. J. Wyman681b2a32021-04-20 22:31:22 +0000133 }
134 else
135 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000136 lg2::info("Unbinding device driver. path: {PATH} device: {BIND_DEVICE}",
137 "PATH", path, "BIND_DEVICE", bindDevice);
B. J. Wyman681b2a32021-04-20 22:31:22 +0000138 }
139
140 std::ofstream file;
141
142 file.exceptions(std::ofstream::failbit | std::ofstream::badbit |
143 std::ofstream::eofbit);
144
145 try
146 {
147 file.open(path);
148 file << bindDevice;
149 file.close();
150 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -0500151 catch (const std::exception& e)
B. J. Wyman681b2a32021-04-20 22:31:22 +0000152 {
153 auto err = errno;
154
Anwaar Hadib64228d2025-05-30 23:55:26 +0000155 lg2::error("Failed binding or unbinding device. errno={ERRNO}", "ERRNO",
156 err);
B. J. Wyman681b2a32021-04-20 22:31:22 +0000157 }
Brandon Wyman510acaa2020-11-05 18:32:04 -0600158}
159
Brandon Wymanaed1f752019-11-25 18:10:52 -0600160void PowerSupply::updatePresence()
161{
162 try
163 {
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600164 present = getPresence(bus, inventoryPath);
Brandon Wymanaed1f752019-11-25 18:10:52 -0600165 }
Patrick Williams7354ce62022-07-22 19:26:56 -0500166 catch (const sdbusplus::exception_t& e)
Brandon Wymanaed1f752019-11-25 18:10:52 -0600167 {
168 // Relying on property change or interface added to retry.
169 // Log an informational trace to the journal.
Anwaar Hadib64228d2025-05-30 23:55:26 +0000170 lg2::info("D-Bus property {INVENTORY_PATH} access failure exception",
171 "INVENTORY_PATH", inventoryPath);
Brandon Wymanaed1f752019-11-25 18:10:52 -0600172 }
173}
174
B. J. Wyman681b2a32021-04-20 22:31:22 +0000175void PowerSupply::updatePresenceGPIO()
176{
177 bool presentOld = present;
178
179 try
180 {
181 if (presenceGPIO->read() > 0)
182 {
183 present = true;
184 }
185 else
186 {
187 present = false;
188 }
189 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -0500190 catch (const std::exception& e)
B. J. Wyman681b2a32021-04-20 22:31:22 +0000191 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000192 lg2::error("presenceGPIO read fail: {ERROR}", "ERROR", e);
B. J. Wyman681b2a32021-04-20 22:31:22 +0000193 throw;
194 }
195
196 if (presentOld != present)
197 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000198 lg2::debug("{SHORT_NAME} presentOld: {PRESENT_OLD} present: {PRESENT}",
199 "SHORT_NAME", shortName, "PRESENT_OLD", presentOld,
200 "PRESENT", present);
Matt Spinlerca1e9ea2022-02-18 14:03:08 -0600201
202 auto invpath = inventoryPath.substr(strlen(INVENTORY_OBJ_PATH));
Brandon Wyman90d529a2022-03-22 23:02:54 +0000203
204 bindOrUnbindDriver(present);
205 if (present)
206 {
207 // If the power supply was present, then missing, and present again,
208 // the hwmon path may have changed. We will need the correct/updated
209 // path before any reads or writes are attempted.
210 pmbusIntf->findHwmonDir();
211 }
212
Brandon Wyman321a6152022-03-19 00:11:44 +0000213 setPresence(bus, invpath, present, shortName);
Matt Spinler592bd272023-08-30 11:00:01 -0500214 setupSensors();
Matt Spinlerca1e9ea2022-02-18 14:03:08 -0600215 updateInventory();
216
Brandon Wyman90d529a2022-03-22 23:02:54 +0000217 // Need Functional to already be correct before calling this.
Matt Spinlerca1e9ea2022-02-18 14:03:08 -0600218 checkAvailability();
219
B. J. Wyman681b2a32021-04-20 22:31:22 +0000220 if (present)
221 {
B. J. Wyman681b2a32021-04-20 22:31:22 +0000222 onOffConfig(phosphor::pmbus::ON_OFF_CONFIG_CONTROL_PIN_ONLY);
223 clearFaults();
Brandon Wyman18a24d92022-04-19 22:48:34 +0000224 // Indicate that the input history data and timestamps between all
225 // the power supplies that are present in the system need to be
226 // synchronized.
227 syncHistoryRequired = true;
B. J. Wyman681b2a32021-04-20 22:31:22 +0000228 }
Matt Spinler592bd272023-08-30 11:00:01 -0500229 else
230 {
231 setSensorsNotAvailable();
232 }
B. J. Wyman681b2a32021-04-20 22:31:22 +0000233 }
234}
235
Brandon Wymanc2203432021-12-21 23:09:48 +0000236void PowerSupply::analyzeCMLFault()
237{
238 if (statusWord & phosphor::pmbus::status_word::CML_FAULT)
239 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000240 if (cmlFault < DEGLITCH_LIMIT)
Brandon Wymanc2203432021-12-21 23:09:48 +0000241 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000242 if (statusWord != statusWordOld)
243 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000244 lg2::error(
245 "{SHORT_NAME} CML fault: STATUS_WORD = {STATUS_WORD}, "
246 "STATUS_CML = {STATUS_CML}",
247 "SHORT_NAME", shortName, "STATUS_WORD",
248 lg2::hex | lg2::field16, statusWord, "STATUS_CML",
249 lg2::hex | lg2::field8, statusCML);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000250 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000251 cmlFault++;
252 }
253 }
254 else
255 {
256 cmlFault = 0;
Brandon Wymanc2203432021-12-21 23:09:48 +0000257 }
258}
259
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000260void PowerSupply::analyzeInputFault()
261{
262 if (statusWord & phosphor::pmbus::status_word::INPUT_FAULT_WARN)
263 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000264 if (inputFault < DEGLITCH_LIMIT)
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000265 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000266 if (statusWord != statusWordOld)
267 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000268 lg2::error(
269 "{SHORT_NAME} INPUT fault: STATUS_WORD = {STATUS_WORD}, "
270 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
271 "STATUS_INPUT = {STATUS_INPUT}",
272 "SHORT_NAME", shortName, "STATUS_WORD",
273 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
274 lg2::hex | lg2::field8, statusMFR, "STATUS_INPUT",
275 lg2::hex | lg2::field8, statusInput);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000276 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000277 inputFault++;
278 }
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000279 }
Brandon Wyman82affd92021-11-24 19:12:49 +0000280
281 // If had INPUT/VIN_UV fault, and now off.
282 // Trace that odd behavior.
283 if (inputFault &&
284 !(statusWord & phosphor::pmbus::status_word::INPUT_FAULT_WARN))
285 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000286 lg2::info(
287 "{SHORT_NAME} INPUT fault cleared: STATUS_WORD = {STATUS_WORD}, "
288 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
289 "STATUS_INPUT = {STATUS_INPUT}",
290 "SHORT_NAME", shortName, "STATUS_WORD", lg2::hex | lg2::field16,
291 statusWord, "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
292 statusMFR, "STATUS_INPUT", lg2::hex | lg2::field8, statusInput);
Brandon Wymanc2906f42021-12-21 20:14:56 +0000293 inputFault = 0;
Brandon Wyman82affd92021-11-24 19:12:49 +0000294 }
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000295}
296
Brandon Wymanc2c87132021-12-21 23:22:18 +0000297void PowerSupply::analyzeVoutOVFault()
298{
299 if (statusWord & phosphor::pmbus::status_word::VOUT_OV_FAULT)
300 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000301 if (voutOVFault < DEGLITCH_LIMIT)
Brandon Wymanc2c87132021-12-21 23:22:18 +0000302 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000303 if (statusWord != statusWordOld)
304 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000305 lg2::error(
306 "{SHORT_NAME} VOUT_OV_FAULT fault: STATUS_WORD = {STATUS_WORD}, "
307 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
308 "STATUS_VOUT = {STATUS_VOUT}",
309 "SHORT_NAME", shortName, "STATUS_WORD",
310 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
311 lg2::hex | lg2::field8, statusMFR, "STATUS_VOUT",
312 lg2::hex | lg2::field8, statusVout);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000313 }
Brandon Wymanc2c87132021-12-21 23:22:18 +0000314
Brandon Wymanc2906f42021-12-21 20:14:56 +0000315 voutOVFault++;
316 }
317 }
318 else
319 {
320 voutOVFault = 0;
Brandon Wymanc2c87132021-12-21 23:22:18 +0000321 }
322}
323
Brandon Wymana00e7302021-12-21 23:28:29 +0000324void PowerSupply::analyzeIoutOCFault()
325{
326 if (statusWord & phosphor::pmbus::status_word::IOUT_OC_FAULT)
327 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000328 if (ioutOCFault < DEGLITCH_LIMIT)
Brandon Wymana00e7302021-12-21 23:28:29 +0000329 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000330 if (statusWord != statusWordOld)
331 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000332 lg2::error(
333 "{SHORT_NAME} IOUT fault: STATUS_WORD = {STATUS_WORD}, "
334 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
335 "STATUS_IOUT = {STATUS_IOUT}",
336 "SHORT_NAME", shortName, "STATUS_WORD",
337 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
338 lg2::hex | lg2::field8, statusMFR, "STATUS_IOUT",
339 lg2::hex | lg2::field8, statusIout);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000340 }
Brandon Wymana00e7302021-12-21 23:28:29 +0000341
Brandon Wymanc2906f42021-12-21 20:14:56 +0000342 ioutOCFault++;
343 }
344 }
345 else
346 {
347 ioutOCFault = 0;
Brandon Wymana00e7302021-12-21 23:28:29 +0000348 }
349}
350
Brandon Wyman08378782021-12-21 23:48:15 +0000351void PowerSupply::analyzeVoutUVFault()
352{
353 if ((statusWord & phosphor::pmbus::status_word::VOUT_FAULT) &&
354 !(statusWord & phosphor::pmbus::status_word::VOUT_OV_FAULT))
355 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000356 if (voutUVFault < DEGLITCH_LIMIT)
Brandon Wyman08378782021-12-21 23:48:15 +0000357 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000358 if (statusWord != statusWordOld)
359 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000360 lg2::error(
361 "{SHORT_NAME} VOUT_UV_FAULT fault: STATUS_WORD = {STATUS_WORD}, "
362 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
363 "STATUS_VOUT = {STATUS_VOUT}",
364 "SHORT_NAME", shortName, "STATUS_WORD",
365 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
366 lg2::hex | lg2::field8, statusMFR, "STATUS_VOUT",
367 lg2::hex | lg2::field8, statusVout);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000368 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000369 voutUVFault++;
370 }
371 }
372 else
373 {
374 voutUVFault = 0;
Brandon Wyman08378782021-12-21 23:48:15 +0000375 }
376}
377
Brandon Wymand5d9a222021-12-21 23:59:05 +0000378void PowerSupply::analyzeFanFault()
379{
380 if (statusWord & phosphor::pmbus::status_word::FAN_FAULT)
381 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000382 if (fanFault < DEGLITCH_LIMIT)
Brandon Wymand5d9a222021-12-21 23:59:05 +0000383 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000384 if (statusWord != statusWordOld)
385 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000386 lg2::error("{SHORT_NAME} FANS fault/warning: "
387 "STATUS_WORD = {STATUS_WORD}, "
388 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
389 "STATUS_FANS_1_2 = {STATUS_FANS_1_2}",
390 "SHORT_NAME", shortName, "STATUS_WORD",
391 lg2::hex | lg2::field16, statusWord,
392 "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
393 statusMFR, "STATUS_FANS_1_2", lg2::hex | lg2::field8,
394 statusFans12);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000395 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000396 fanFault++;
397 }
398 }
399 else
400 {
401 fanFault = 0;
Brandon Wymand5d9a222021-12-21 23:59:05 +0000402 }
403}
404
Brandon Wyman52cb3f22021-12-21 23:02:47 +0000405void PowerSupply::analyzeTemperatureFault()
406{
407 if (statusWord & phosphor::pmbus::status_word::TEMPERATURE_FAULT_WARN)
408 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000409 if (tempFault < DEGLITCH_LIMIT)
Brandon Wyman52cb3f22021-12-21 23:02:47 +0000410 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000411 if (statusWord != statusWordOld)
412 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000413 lg2::error("{SHORT_NAME} TEMPERATURE fault/warning: "
414 "STATUS_WORD = {STATUS_WORD}, "
415 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
416 "STATUS_TEMPERATURE = {STATUS_TEMPERATURE}",
417 "SHORT_NAME", shortName, "STATUS_WORD",
418 lg2::hex | lg2::field16, statusWord,
419 "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
420 statusMFR, "STATUS_TEMPERATURE",
421 lg2::hex | lg2::field8, statusTemperature);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000422 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000423 tempFault++;
424 }
425 }
426 else
427 {
428 tempFault = 0;
Brandon Wyman52cb3f22021-12-21 23:02:47 +0000429 }
430}
431
Brandon Wyman993b5542021-12-21 22:55:16 +0000432void PowerSupply::analyzePgoodFault()
433{
434 if ((statusWord & phosphor::pmbus::status_word::POWER_GOOD_NEGATED) ||
435 (statusWord & phosphor::pmbus::status_word::UNIT_IS_OFF))
436 {
Brandon Wyman6d469fd2022-06-15 16:58:21 +0000437 if (pgoodFault < PGOOD_DEGLITCH_LIMIT)
Brandon Wyman993b5542021-12-21 22:55:16 +0000438 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000439 if (statusWord != statusWordOld)
440 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000441 lg2::error("{SHORT_NAME} PGOOD fault: "
442 "STATUS_WORD = {STATUS_WORD}, "
443 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}",
444 "SHORT_NAME", shortName, "STATUS_WORD",
445 lg2::hex | lg2::field16, statusWord,
446 "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
447 statusMFR);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000448 }
Brandon Wyman993b5542021-12-21 22:55:16 +0000449 pgoodFault++;
450 }
451 }
452 else
453 {
454 pgoodFault = 0;
455 }
456}
457
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000458void PowerSupply::determineMFRFault()
459{
Faisal Awadab66ae502023-04-01 18:30:32 -0500460 if (bindPath.string().find(IBMCFFPS_DD_NAME) != std::string::npos)
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000461 {
462 // IBM MFR_SPECIFIC[4] is PS_Kill fault
463 if (statusMFR & 0x10)
464 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000465 if (psKillFault < DEGLITCH_LIMIT)
466 {
467 psKillFault++;
468 }
469 }
470 else
471 {
472 psKillFault = 0;
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000473 }
474 // IBM MFR_SPECIFIC[6] is 12Vcs fault.
475 if (statusMFR & 0x40)
476 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000477 if (ps12VcsFault < DEGLITCH_LIMIT)
478 {
479 ps12VcsFault++;
480 }
481 }
482 else
483 {
484 ps12VcsFault = 0;
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000485 }
486 // IBM MFR_SPECIFIC[7] is 12V Current-Share fault.
487 if (statusMFR & 0x80)
488 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000489 if (psCS12VFault < DEGLITCH_LIMIT)
490 {
491 psCS12VFault++;
492 }
493 }
494 else
495 {
496 psCS12VFault = 0;
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000497 }
498 }
499}
500
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000501void PowerSupply::analyzeMFRFault()
502{
503 if (statusWord & phosphor::pmbus::status_word::MFR_SPECIFIC_FAULT)
504 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000505 if (mfrFault < DEGLITCH_LIMIT)
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000506 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000507 if (statusWord != statusWordOld)
508 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000509 lg2::error("{SHORT_NAME} MFR fault: "
510 "STATUS_WORD = {STATUS_WORD} "
511 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}",
512 "SHORT_NAME", shortName, "STATUS_WORD",
513 lg2::hex | lg2::field16, statusWord,
514 "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
515 statusMFR);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000516 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000517 mfrFault++;
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000518 }
519
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000520 determineMFRFault();
521 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000522 else
523 {
524 mfrFault = 0;
525 }
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000526}
527
Brandon Wymanf087f472021-12-22 00:04:27 +0000528void PowerSupply::analyzeVinUVFault()
529{
530 if (statusWord & phosphor::pmbus::status_word::VIN_UV_FAULT)
531 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000532 if (vinUVFault < DEGLITCH_LIMIT)
Brandon Wymanf087f472021-12-22 00:04:27 +0000533 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000534 if (statusWord != statusWordOld)
535 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000536 lg2::error(
537 "{SHORT_NAME} VIN_UV fault: STATUS_WORD = {STATUS_WORD}, "
538 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
539 "STATUS_INPUT = {STATUS_INPUT}",
540 "SHORT_NAME", shortName, "STATUS_WORD",
541 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
542 lg2::hex | lg2::field8, statusMFR, "STATUS_INPUT",
543 lg2::hex | lg2::field8, statusInput);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000544 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000545 vinUVFault++;
Brandon Wymanf087f472021-12-22 00:04:27 +0000546 }
Jim Wright4ab86562022-11-18 14:05:46 -0600547 // Remember that this PSU has seen an AC fault
548 acFault = AC_FAULT_LIMIT;
Brandon Wymanf087f472021-12-22 00:04:27 +0000549 }
Jim Wright7f9288c2022-12-08 11:57:04 -0600550 else
Brandon Wyman82affd92021-11-24 19:12:49 +0000551 {
Jim Wright7f9288c2022-12-08 11:57:04 -0600552 if (vinUVFault != 0)
553 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000554 lg2::info(
555 "{SHORT_NAME} VIN_UV fault cleared: STATUS_WORD = {STATUS_WORD}, "
556 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
557 "STATUS_INPUT = {STATUS_INPUT}",
558 "SHORT_NAME", shortName, "STATUS_WORD", lg2::hex | lg2::field16,
559 statusWord, "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
560 statusMFR, "STATUS_INPUT", lg2::hex | lg2::field8, statusInput);
Jim Wright7f9288c2022-12-08 11:57:04 -0600561 vinUVFault = 0;
562 }
Jim Wright4ab86562022-11-18 14:05:46 -0600563 // No AC fail, decrement counter
Jim Wright7f9288c2022-12-08 11:57:04 -0600564 if (acFault != 0)
Jim Wright4ab86562022-11-18 14:05:46 -0600565 {
566 --acFault;
567 }
Brandon Wyman82affd92021-11-24 19:12:49 +0000568 }
Brandon Wymanf087f472021-12-22 00:04:27 +0000569}
570
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600571void PowerSupply::analyze()
572{
573 using namespace phosphor::pmbus;
574
B. J. Wyman681b2a32021-04-20 22:31:22 +0000575 if (presenceGPIO)
576 {
577 updatePresenceGPIO();
578 }
579
Brandon Wyman32453e92021-12-15 19:00:14 +0000580 if (present)
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600581 {
582 try
583 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000584 statusWordOld = statusWord;
Brandon Wyman32453e92021-12-15 19:00:14 +0000585 statusWord = pmbusIntf->read(STATUS_WORD, Type::Debug,
586 (readFail < LOG_LIMIT));
Brandon Wymanf65c4062020-08-19 13:15:53 -0500587 // Read worked, reset the fail count.
588 readFail = 0;
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600589
590 if (statusWord)
591 {
Brandon Wymanf07bc792021-10-12 19:00:35 +0000592 statusInput = pmbusIntf->read(STATUS_INPUT, Type::Debug);
Faisal Awadab66ae502023-04-01 18:30:32 -0500593 if (bindPath.string().find(IBMCFFPS_DD_NAME) !=
594 std::string::npos)
595 {
596 statusMFR = pmbusIntf->read(STATUS_MFR, Type::Debug);
597 }
Brandon Wyman85c7bf42021-10-19 22:28:48 +0000598 statusCML = pmbusIntf->read(STATUS_CML, Type::Debug);
Brandon Wyman6710ba22021-10-27 17:39:31 +0000599 auto status0Vout = pmbusIntf->insertPageNum(STATUS_VOUT, 0);
600 statusVout = pmbusIntf->read(status0Vout, Type::Debug);
Brandon Wymanb10b3be2021-11-09 22:12:15 +0000601 statusIout = pmbusIntf->read(STATUS_IOUT, Type::Debug);
Brandon Wyman7ee4d7e2021-11-19 20:48:23 +0000602 statusFans12 = pmbusIntf->read(STATUS_FANS_1_2, Type::Debug);
Patrick Williamsf5402192024-08-16 15:20:53 -0400603 statusTemperature =
604 pmbusIntf->read(STATUS_TEMPERATURE, Type::Debug);
Brandon Wyman9ddc6222021-10-28 17:28:01 +0000605
Brandon Wymanc2203432021-12-21 23:09:48 +0000606 analyzeCMLFault();
Brandon Wyman85c7bf42021-10-19 22:28:48 +0000607
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000608 analyzeInputFault();
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600609
Brandon Wymanc2c87132021-12-21 23:22:18 +0000610 analyzeVoutOVFault();
Brandon Wyman6710ba22021-10-27 17:39:31 +0000611
Brandon Wymana00e7302021-12-21 23:28:29 +0000612 analyzeIoutOCFault();
Brandon Wymanb10b3be2021-11-09 22:12:15 +0000613
Brandon Wyman08378782021-12-21 23:48:15 +0000614 analyzeVoutUVFault();
Brandon Wyman2cf46942021-10-28 19:09:16 +0000615
Brandon Wymand5d9a222021-12-21 23:59:05 +0000616 analyzeFanFault();
Brandon Wyman7ee4d7e2021-11-19 20:48:23 +0000617
Brandon Wyman52cb3f22021-12-21 23:02:47 +0000618 analyzeTemperatureFault();
Brandon Wyman96893a42021-11-05 19:56:57 +0000619
Brandon Wyman993b5542021-12-21 22:55:16 +0000620 analyzePgoodFault();
Brandon Wyman2916ea52021-11-06 03:31:18 +0000621
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000622 analyzeMFRFault();
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600623
Brandon Wymanf087f472021-12-22 00:04:27 +0000624 analyzeVinUVFault();
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600625 }
626 else
627 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000628 if (statusWord != statusWordOld)
629 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000630 lg2::info("{SHORT_NAME} STATUS_WORD = {STATUS_WORD}",
631 "SHORT_NAME", shortName, "STATUS_WORD",
632 lg2::hex | lg2::field16, statusWord);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000633 }
634
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000635 // if INPUT/VIN_UV fault was on, it cleared, trace it.
636 if (inputFault)
637 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000638 lg2::info(
639 "{SHORT_NAME} INPUT fault cleared: STATUS_WORD = {STATUS_WORD}",
640 "SHORT_NAME", shortName, "STATUS_WORD",
641 lg2::hex | lg2::field16, statusWord);
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000642 }
643
644 if (vinUVFault)
645 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000646 lg2::info(
647 "{SHORT_NAME} VIN_UV cleared: STATUS_WORD = {STATUS_WORD}",
648 "SHORT_NAME", shortName, "STATUS_WORD",
649 lg2::hex | lg2::field16, statusWord);
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000650 }
651
Brandon Wyman06ca4592021-12-06 22:52:23 +0000652 if (pgoodFault > 0)
Brandon Wyman4aecc292021-11-10 22:40:41 +0000653 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000654 lg2::info("{SHORT_NAME} pgoodFault cleared", "SHORT_NAME",
655 shortName);
Brandon Wyman4aecc292021-11-10 22:40:41 +0000656 }
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000657
658 clearFaultFlags();
Jim Wright4ab86562022-11-18 14:05:46 -0600659 // No AC fail, decrement counter
Jim Wright7f9288c2022-12-08 11:57:04 -0600660 if (acFault != 0)
Jim Wright4ab86562022-11-18 14:05:46 -0600661 {
662 --acFault;
663 }
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600664 }
Brandon Wyman82affd92021-11-24 19:12:49 +0000665
666 // Save off old inputVoltage value.
667 // Get latest inputVoltage.
668 // If voltage went from below minimum, and now is not, clear faults.
669 // Note: getInputVoltage() has its own try/catch.
670 int inputVoltageOld = inputVoltage;
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000671 double actualInputVoltageOld = actualInputVoltage;
Brandon Wyman82affd92021-11-24 19:12:49 +0000672 getInputVoltage(actualInputVoltage, inputVoltage);
673 if ((inputVoltageOld == in_input::VIN_VOLTAGE_0) &&
674 (inputVoltage != in_input::VIN_VOLTAGE_0))
675 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000676 lg2::info(
677 "{SHORT_NAME} READ_VIN back in range: actualInputVoltageOld = {ACTUAL_INPUT_VOLTAGE_OLD} "
678 "actualInputVoltage = {ACTUAL_INPUT_VOLTAGE}",
679 "SHORT_NAME", shortName, "ACTUAL_INPUT_VOLTAGE_OLD",
680 actualInputVoltageOld, "ACTUAL_INPUT_VOLTAGE",
681 actualInputVoltage);
Brandon Wyman3225a452022-03-18 18:51:49 +0000682 clearVinUVFault();
Brandon Wyman82affd92021-11-24 19:12:49 +0000683 }
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000684 else if (vinUVFault && (inputVoltage != in_input::VIN_VOLTAGE_0))
685 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000686 lg2::info(
687 "{SHORT_NAME} CLEAR_FAULTS: vinUVFault {VIN_UV_FAULT} actualInputVoltage {ACTUAL_INPUT_VOLTAGE}",
688 "SHORT_NAME", shortName, "VIN_UV_FAULT", vinUVFault,
689 "ACTUAL_INPUT_VOLTAGE", actualInputVoltage);
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000690 // Do we have a VIN_UV fault latched that can now be cleared
Jim Wright4ab86562022-11-18 14:05:46 -0600691 // due to voltage back in range? Attempt to clear the
692 // fault(s), re-check faults on next call.
Brandon Wyman3225a452022-03-18 18:51:49 +0000693 clearVinUVFault();
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000694 }
Brandon Wymanae35ac52022-05-23 22:33:40 +0000695 else if (std::abs(actualInputVoltageOld - actualInputVoltage) >
696 10.0)
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000697 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000698 lg2::info(
699 "{SHORT_NAME} actualInputVoltageOld = {ACTUAL_INPUT_VOLTAGE_OLD} actualInputVoltage = {ACTUAL_INPUT_VOLTAGE}",
700 "SHORT_NAME", shortName, "ACTUAL_INPUT_VOLTAGE_OLD",
701 actualInputVoltageOld, "ACTUAL_INPUT_VOLTAGE",
702 actualInputVoltage);
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000703 }
Matt Spinler0975eaf2022-02-14 15:38:30 -0600704
Matt Spinler592bd272023-08-30 11:00:01 -0500705 monitorSensors();
706
Matt Spinler0975eaf2022-02-14 15:38:30 -0600707 checkAvailability();
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600708 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -0500709 catch (const ReadFailure& e)
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600710 {
Brandon Wyman32453e92021-12-15 19:00:14 +0000711 if (readFail < SIZE_MAX)
712 {
713 readFail++;
714 }
715 if (readFail == LOG_LIMIT)
716 {
717 phosphor::logging::commit<ReadFailure>();
718 }
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600719 }
720 }
721}
722
Brandon Wyman59a35792020-06-04 12:37:40 -0500723void PowerSupply::onOffConfig(uint8_t data)
724{
725 using namespace phosphor::pmbus;
726
Faisal Awada9582d9c2023-07-11 09:31:22 -0500727 if (present && driverName != ACBEL_FSG032_DD_NAME)
Brandon Wyman59a35792020-06-04 12:37:40 -0500728 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000729 lg2::info("ON_OFF_CONFIG write: DATA={DATA}", "DATA",
730 lg2::hex | lg2::field8, data);
Brandon Wyman59a35792020-06-04 12:37:40 -0500731 try
732 {
733 std::vector<uint8_t> configData{data};
734 pmbusIntf->writeBinary(ON_OFF_CONFIG, configData,
735 Type::HwmonDeviceDebug);
736 }
737 catch (...)
738 {
739 // The underlying code in writeBinary will log a message to the
B. J. Wyman681b2a32021-04-20 22:31:22 +0000740 // journal if the write fails. If the ON_OFF_CONFIG is not setup
741 // as desired, later fault detection and analysis code should
742 // catch any of the fall out. We should not need to terminate
743 // the application if this write fails.
Brandon Wyman59a35792020-06-04 12:37:40 -0500744 }
745 }
746}
747
Brandon Wyman3225a452022-03-18 18:51:49 +0000748void PowerSupply::clearVinUVFault()
749{
750 // Read in1_lcrit_alarm to clear bits 3 and 4 of STATUS_INPUT.
751 // The fault bits in STAUTS_INPUT roll-up to STATUS_WORD. Clearing those
752 // bits in STATUS_INPUT should result in the corresponding STATUS_WORD bits
753 // also clearing.
754 //
755 // Do not care about return value. Should be 1 if active, 0 if not.
Faisal Awada9582d9c2023-07-11 09:31:22 -0500756 if (driverName != ACBEL_FSG032_DD_NAME)
757 {
758 static_cast<void>(
759 pmbusIntf->read("in1_lcrit_alarm", phosphor::pmbus::Type::Hwmon));
760 }
761 else
762 {
763 static_cast<void>(
764 pmbusIntf->read("curr1_crit_alarm", phosphor::pmbus::Type::Hwmon));
765 }
Brandon Wyman3225a452022-03-18 18:51:49 +0000766 vinUVFault = 0;
767}
768
Brandon Wyman3c208462020-05-13 16:25:58 -0500769void PowerSupply::clearFaults()
770{
Anwaar Hadib64228d2025-05-30 23:55:26 +0000771 lg2::debug("clearFaults() inventoryPath: {INVENTORY_PATH}",
772 "INVENTORY_PATH", inventoryPath);
Brandon Wyman5474c912021-02-23 14:39:43 -0600773 faultLogged = false;
Brandon Wyman3c208462020-05-13 16:25:58 -0500774 // The PMBus device driver does not allow for writing CLEAR_FAULTS
775 // directly. However, the pmbus hwmon device driver code will send a
776 // CLEAR_FAULTS after reading from any of the hwmon "files" in sysfs, so
777 // reading in1_input should result in clearing the fault bits in
778 // STATUS_BYTE/STATUS_WORD.
779 // I do not care what the return value is.
Brandon Wyman11151532020-11-10 13:45:57 -0600780 if (present)
Brandon Wyman3c208462020-05-13 16:25:58 -0500781 {
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000782 clearFaultFlags();
Matt Spinler0975eaf2022-02-14 15:38:30 -0600783 checkAvailability();
Brandon Wyman9564e942020-11-10 14:01:42 -0600784 readFail = 0;
Brandon Wyman9564e942020-11-10 14:01:42 -0600785
Brandon Wyman11151532020-11-10 13:45:57 -0600786 try
787 {
Brandon Wyman3225a452022-03-18 18:51:49 +0000788 clearVinUVFault();
Brandon Wyman11151532020-11-10 13:45:57 -0600789 static_cast<void>(
790 pmbusIntf->read("in1_input", phosphor::pmbus::Type::Hwmon));
791 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -0500792 catch (const ReadFailure& e)
Brandon Wyman11151532020-11-10 13:45:57 -0600793 {
794 // Since I do not care what the return value is, I really do not
B. J. Wyman681b2a32021-04-20 22:31:22 +0000795 // care much if it gets a ReadFailure either. However, this
796 // should not prevent the application from continuing to run, so
797 // catching the read failure.
Brandon Wyman11151532020-11-10 13:45:57 -0600798 }
Brandon Wyman3c208462020-05-13 16:25:58 -0500799 }
800}
801
Patrick Williams7354ce62022-07-22 19:26:56 -0500802void PowerSupply::inventoryChanged(sdbusplus::message_t& msg)
Brandon Wymanaed1f752019-11-25 18:10:52 -0600803{
804 std::string msgSensor;
Patrick Williamsabe49412020-05-13 17:59:47 -0500805 std::map<std::string, std::variant<uint32_t, bool>> msgData;
Brandon Wymanaed1f752019-11-25 18:10:52 -0600806 msg.read(msgSensor, msgData);
807
808 // Check if it was the Present property that changed.
809 auto valPropMap = msgData.find(PRESENT_PROP);
810 if (valPropMap != msgData.end())
811 {
812 if (std::get<bool>(valPropMap->second))
813 {
814 present = true;
B. J. Wyman681b2a32021-04-20 22:31:22 +0000815 // TODO: Immediately trying to read or write the "files" causes
816 // read or write failures.
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500817 using namespace std::chrono_literals;
818 std::this_thread::sleep_for(20ms);
Brandon Wyman9564e942020-11-10 14:01:42 -0600819 pmbusIntf->findHwmonDir();
Brandon Wyman59a35792020-06-04 12:37:40 -0500820 onOffConfig(phosphor::pmbus::ON_OFF_CONFIG_CONTROL_PIN_ONLY);
Brandon Wymanaed1f752019-11-25 18:10:52 -0600821 clearFaults();
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500822 updateInventory();
Brandon Wymanaed1f752019-11-25 18:10:52 -0600823 }
824 else
825 {
826 present = false;
827
828 // Clear out the now outdated inventory properties
829 updateInventory();
830 }
Matt Spinler0975eaf2022-02-14 15:38:30 -0600831 checkAvailability();
Brandon Wymanaed1f752019-11-25 18:10:52 -0600832 }
833}
834
Patrick Williams7354ce62022-07-22 19:26:56 -0500835void PowerSupply::inventoryAdded(sdbusplus::message_t& msg)
Brandon Wyman9a507db2021-02-25 16:15:22 -0600836{
837 sdbusplus::message::object_path path;
838 msg.read(path);
839 // Make sure the signal is for the PSU inventory path
840 if (path == inventoryPath)
841 {
842 std::map<std::string, std::map<std::string, std::variant<bool>>>
843 interfaces;
844 // Get map of interfaces and their properties
845 msg.read(interfaces);
846
847 auto properties = interfaces.find(INVENTORY_IFACE);
848 if (properties != interfaces.end())
849 {
850 auto property = properties->second.find(PRESENT_PROP);
851 if (property != properties->second.end())
852 {
853 present = std::get<bool>(property->second);
854
Anwaar Hadib64228d2025-05-30 23:55:26 +0000855 lg2::info("Power Supply {INVENTORY_PATH} Present {PRESENT}",
856 "INVENTORY_PATH", inventoryPath, "PRESENT", present);
Brandon Wyman9a507db2021-02-25 16:15:22 -0600857
858 updateInventory();
Matt Spinler0975eaf2022-02-14 15:38:30 -0600859 checkAvailability();
Brandon Wyman9a507db2021-02-25 16:15:22 -0600860 }
861 }
862 }
863}
864
Brandon Wyman8393f462022-06-28 16:06:46 +0000865auto PowerSupply::readVPDValue(const std::string& vpdName,
866 const phosphor::pmbus::Type& type,
867 const std::size_t& vpdSize)
868{
869 std::string vpdValue;
Patrick Williamsf5402192024-08-16 15:20:53 -0400870 const std::regex illegalVPDRegex =
871 std::regex("[^[:alnum:]]", std::regex::basic);
Brandon Wyman8393f462022-06-28 16:06:46 +0000872
873 try
874 {
875 vpdValue = pmbusIntf->readString(vpdName, type);
876 }
877 catch (const ReadFailure& e)
878 {
879 // Ignore the read failure, let pmbus code indicate failure,
880 // path...
881 // TODO - ibm918
882 // https://github.com/openbmc/docs/blob/master/designs/vpd-collection.md
883 // The BMC must log errors if any of the VPD cannot be properly
884 // parsed or fails ECC checks.
885 }
886
887 if (vpdValue.size() != vpdSize)
888 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000889 lg2::info("{SHORT_NAME} {VPD_NAME} resize needed. size: {SIZE}",
890 "SHORT_NAME", shortName, "VPD_NAME", vpdName, "SIZE",
891 vpdValue.size());
Brandon Wyman8393f462022-06-28 16:06:46 +0000892 vpdValue.resize(vpdSize, ' ');
893 }
894
Brandon Wyman056935c2022-06-24 23:05:09 +0000895 // Replace any illegal values with space(s).
896 std::regex_replace(vpdValue.begin(), vpdValue.begin(), vpdValue.end(),
897 illegalVPDRegex, " ");
898
Brandon Wyman8393f462022-06-28 16:06:46 +0000899 return vpdValue;
900}
901
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500902void PowerSupply::updateInventory()
903{
904 using namespace phosphor::pmbus;
905
Chanh Nguyenc12c53b2021-04-06 17:24:47 +0700906#if IBM_VPD
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500907 std::string pn;
908 std::string fn;
909 std::string header;
910 std::string sn;
Brandon Wyman8393f462022-06-28 16:06:46 +0000911 // The IBM power supply splits the full serial number into two parts.
912 // Each part is 6 bytes long, which should match up with SN_KW_SIZE.
913 const auto HEADER_SIZE = 6;
914 const auto SERIAL_SIZE = 6;
915 // The IBM PSU firmware version size is a bit complicated. It was originally
916 // 1-byte, per command. It was later expanded to 2-bytes per command, then
917 // up to 8-bytes per command. The device driver only reads up to 2 bytes per
918 // command, but combines all three of the 2-byte reads, or all 4 of the
919 // 1-byte reads into one string. So, the maximum size expected is 6 bytes.
Shawn McCarney983c9892022-10-12 10:49:47 -0500920 // However, it is formatted by the driver as a hex string with two ASCII
921 // characters per byte. So the maximum ASCII string size is 12.
Faisal Awada9582d9c2023-07-11 09:31:22 -0500922 const auto IBMCFFPS_FW_VERSION_SIZE = 12;
923 const auto ACBEL_FSG032_FW_VERSION_SIZE = 6;
Brandon Wyman8393f462022-06-28 16:06:46 +0000924
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500925 using PropertyMap =
George Liu070c1bc2020-10-12 11:28:01 +0800926 std::map<std::string,
927 std::variant<std::string, std::vector<uint8_t>, bool>>;
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500928 PropertyMap assetProps;
George Liu070c1bc2020-10-12 11:28:01 +0800929 PropertyMap operProps;
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500930 PropertyMap versionProps;
931 PropertyMap ipzvpdDINFProps;
932 PropertyMap ipzvpdVINIProps;
933 using InterfaceMap = std::map<std::string, PropertyMap>;
934 InterfaceMap interfaces;
935 using ObjectMap = std::map<sdbusplus::message::object_path, InterfaceMap>;
936 ObjectMap object;
937#endif
Anwaar Hadib64228d2025-05-30 23:55:26 +0000938 lg2::debug("updateInventory() inventoryPath: {INVENTORY_PATH}",
939 "INVENTORY_PATH", inventoryPath);
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500940
941 if (present)
942 {
943 // TODO: non-IBM inventory updates?
944
Chanh Nguyenc12c53b2021-04-06 17:24:47 +0700945#if IBM_VPD
Faisal Awada9582d9c2023-07-11 09:31:22 -0500946 if (driverName == ACBEL_FSG032_DD_NAME)
faisaladed7a02023-05-10 14:59:01 -0500947 {
948 getPsuVpdFromDbus("CC", modelName);
949 getPsuVpdFromDbus("PN", pn);
950 getPsuVpdFromDbus("FN", fn);
951 getPsuVpdFromDbus("SN", sn);
952 assetProps.emplace(SN_PROP, sn);
Faisal Awada9582d9c2023-07-11 09:31:22 -0500953 fwVersion = readVPDValue(FW_VERSION, Type::Debug,
954 ACBEL_FSG032_FW_VERSION_SIZE);
955 versionProps.emplace(VERSION_PROP, fwVersion);
faisaladed7a02023-05-10 14:59:01 -0500956 }
957 else
958 {
959 modelName = readVPDValue(CCIN, Type::HwmonDeviceDebug, CC_KW_SIZE);
960 pn = readVPDValue(PART_NUMBER, Type::Debug, PN_KW_SIZE);
961 fn = readVPDValue(FRU_NUMBER, Type::Debug, FN_KW_SIZE);
962
963 header = readVPDValue(SERIAL_HEADER, Type::Debug, HEADER_SIZE);
964 sn = readVPDValue(SERIAL_NUMBER, Type::Debug, SERIAL_SIZE);
965 assetProps.emplace(SN_PROP, header + sn);
Faisal Awada9582d9c2023-07-11 09:31:22 -0500966 fwVersion = readVPDValue(FW_VERSION, Type::HwmonDeviceDebug,
967 IBMCFFPS_FW_VERSION_SIZE);
968 versionProps.emplace(VERSION_PROP, fwVersion);
faisaladed7a02023-05-10 14:59:01 -0500969 }
970
Brandon Wyman8393f462022-06-28 16:06:46 +0000971 assetProps.emplace(MODEL_PROP, modelName);
Brandon Wyman8393f462022-06-28 16:06:46 +0000972 assetProps.emplace(PN_PROP, pn);
Brandon Wyman8393f462022-06-28 16:06:46 +0000973 assetProps.emplace(SPARE_PN_PROP, fn);
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500974
Brandon Wyman8393f462022-06-28 16:06:46 +0000975 ipzvpdVINIProps.emplace(
976 "CC", std::vector<uint8_t>(modelName.begin(), modelName.end()));
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500977 ipzvpdVINIProps.emplace("PN",
978 std::vector<uint8_t>(pn.begin(), pn.end()));
979 ipzvpdVINIProps.emplace("FN",
980 std::vector<uint8_t>(fn.begin(), fn.end()));
Brandon Wyman33d492f2022-03-23 20:45:17 +0000981 std::string header_sn = header + sn;
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500982 ipzvpdVINIProps.emplace(
983 "SN", std::vector<uint8_t>(header_sn.begin(), header_sn.end()));
984 std::string description = "IBM PS";
985 ipzvpdVINIProps.emplace(
986 "DR", std::vector<uint8_t>(description.begin(), description.end()));
987
Ben Tynerf8d8c462022-01-27 16:09:45 -0600988 // Populate the VINI Resource Type (RT) keyword
989 ipzvpdVINIProps.emplace("RT", std::vector<uint8_t>{'V', 'I', 'N', 'I'});
990
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500991 // Update the Resource Identifier (RI) keyword
992 // 2 byte FRC: 0x0003
993 // 2 byte RID: 0x1000, 0x1001...
994 std::uint8_t num = std::stoul(
995 inventoryPath.substr(inventoryPath.size() - 1, 1), nullptr, 0);
996 std::vector<uint8_t> ri{0x00, 0x03, 0x10, num};
997 ipzvpdDINFProps.emplace("RI", ri);
998
999 // Fill in the FRU Label (FL) keyword.
1000 std::string fl = "E";
1001 fl.push_back(inventoryPath.back());
1002 fl.resize(FL_KW_SIZE, ' ');
1003 ipzvpdDINFProps.emplace("FL",
1004 std::vector<uint8_t>(fl.begin(), fl.end()));
1005
Ben Tynerf8d8c462022-01-27 16:09:45 -06001006 // Populate the DINF Resource Type (RT) keyword
1007 ipzvpdDINFProps.emplace("RT", std::vector<uint8_t>{'D', 'I', 'N', 'F'});
1008
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001009 interfaces.emplace(ASSET_IFACE, std::move(assetProps));
1010 interfaces.emplace(VERSION_IFACE, std::move(versionProps));
1011 interfaces.emplace(DINF_IFACE, std::move(ipzvpdDINFProps));
1012 interfaces.emplace(VINI_IFACE, std::move(ipzvpdVINIProps));
1013
George Liu070c1bc2020-10-12 11:28:01 +08001014 // Update the Functional
1015 operProps.emplace(FUNCTIONAL_PROP, present);
1016 interfaces.emplace(OPERATIONAL_STATE_IFACE, std::move(operProps));
1017
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001018 auto path = inventoryPath.substr(strlen(INVENTORY_OBJ_PATH));
1019 object.emplace(path, std::move(interfaces));
1020
1021 try
1022 {
Patrick Williamsf5402192024-08-16 15:20:53 -04001023 auto service =
1024 util::getService(INVENTORY_OBJ_PATH, INVENTORY_MGR_IFACE, bus);
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001025
1026 if (service.empty())
1027 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001028 lg2::error("Unable to get inventory manager service");
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001029 return;
1030 }
1031
Patrick Williamsf5402192024-08-16 15:20:53 -04001032 auto method =
1033 bus.new_method_call(service.c_str(), INVENTORY_OBJ_PATH,
1034 INVENTORY_MGR_IFACE, "Notify");
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001035
1036 method.append(std::move(object));
1037
1038 auto reply = bus.call(method);
1039 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -05001040 catch (const std::exception& e)
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001041 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001042 lg2::error(
1043 "Exception in updateInventory(): {ERROR}, PATH={INVENTORY_PATH}",
1044 "ERROR", e, "INVENTORY_PATH", inventoryPath);
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001045 }
1046#endif
1047 }
1048}
1049
Brandon Wymanae35ac52022-05-23 22:33:40 +00001050auto PowerSupply::getMaxPowerOut() const
1051{
1052 using namespace phosphor::pmbus;
1053
1054 auto maxPowerOut = 0;
1055
1056 if (present)
1057 {
1058 try
1059 {
1060 // Read max_power_out, should be direct format
Patrick Williamsf5402192024-08-16 15:20:53 -04001061 auto maxPowerOutStr =
1062 pmbusIntf->readString(MFR_POUT_MAX, Type::HwmonDeviceDebug);
Anwaar Hadib64228d2025-05-30 23:55:26 +00001063 lg2::info("{SHORT_NAME} MFR_POUT_MAX read {MAX_POWER_OUT_STR}",
1064 "SHORT_NAME", shortName, "MAX_POWER_OUT_STR",
1065 maxPowerOutStr);
Brandon Wymanae35ac52022-05-23 22:33:40 +00001066 maxPowerOut = std::stod(maxPowerOutStr);
1067 }
1068 catch (const std::exception& e)
1069 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001070 lg2::error("{SHORT_NAME} MFR_POUT_MAX read error: {ERROR}",
1071 "SHORT_NAME", shortName, "ERROR", e);
Brandon Wymanae35ac52022-05-23 22:33:40 +00001072 }
1073 }
1074
1075 return maxPowerOut;
1076}
1077
Matt Spinler592bd272023-08-30 11:00:01 -05001078void PowerSupply::setupSensors()
1079{
1080 setupInputPowerPeakSensor();
1081}
1082
1083void PowerSupply::setupInputPowerPeakSensor()
1084{
1085 if (peakInputPowerSensor || !present ||
1086 (bindPath.string().find(IBMCFFPS_DD_NAME) == std::string::npos))
1087 {
1088 return;
1089 }
1090
1091 // This PSU has problems with the input_history command
1092 if (getMaxPowerOut() == phosphor::pmbus::IBM_CFFPS_1400W)
1093 {
1094 return;
1095 }
1096
1097 auto sensorPath =
Shawn McCarney768d2262024-07-09 15:02:59 -05001098 std::format("/xyz/openbmc_project/sensors/power/ps{}_input_power_peak",
Matt Spinler592bd272023-08-30 11:00:01 -05001099 shortName.back());
1100
1101 peakInputPowerSensor = std::make_unique<PowerSensorObject>(
1102 bus, sensorPath.c_str(), PowerSensorObject::action::defer_emit);
1103
1104 // The others can remain at the defaults.
1105 peakInputPowerSensor->functional(true, true);
1106 peakInputPowerSensor->available(true, true);
1107 peakInputPowerSensor->value(0, true);
1108 peakInputPowerSensor->unit(
1109 sdbusplus::xyz::openbmc_project::Sensor::server::Value::Unit::Watts,
1110 true);
1111
1112 auto associations = getSensorAssociations();
1113 peakInputPowerSensor->associations(associations, true);
1114
1115 peakInputPowerSensor->emit_object_added();
1116}
1117
1118void PowerSupply::setSensorsNotAvailable()
1119{
1120 if (peakInputPowerSensor)
1121 {
1122 peakInputPowerSensor->value(std::numeric_limits<double>::quiet_NaN());
1123 peakInputPowerSensor->available(false);
1124 }
1125}
1126
Matt Spinler592bd272023-08-30 11:00:01 -05001127void PowerSupply::monitorSensors()
1128{
1129 monitorPeakInputPowerSensor();
1130}
1131
1132void PowerSupply::monitorPeakInputPowerSensor()
1133{
1134 if (!peakInputPowerSensor)
1135 {
1136 return;
1137 }
1138
1139 constexpr size_t recordSize = 5;
1140 std::vector<uint8_t> data;
1141
1142 // Get the peak input power with input history command.
1143 // New data only shows up every 30s, but just try to read it every 1s
1144 // anyway so we always have the most up to date value.
1145 try
1146 {
1147 data = pmbusIntf->readBinary(INPUT_HISTORY,
1148 pmbus::Type::HwmonDeviceDebug, recordSize);
1149 }
1150 catch (const ReadFailure& e)
1151 {
1152 peakInputPowerSensor->value(std::numeric_limits<double>::quiet_NaN());
1153 peakInputPowerSensor->functional(false);
1154 throw;
1155 }
1156
1157 if (data.size() != recordSize)
1158 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001159 lg2::debug(
1160 "Input history command returned {DATA_SIZE} bytes instead of 5",
1161 "DATA_SIZE", data.size());
Matt Spinler592bd272023-08-30 11:00:01 -05001162 peakInputPowerSensor->value(std::numeric_limits<double>::quiet_NaN());
1163 peakInputPowerSensor->functional(false);
1164 return;
1165 }
1166
1167 // The format is SSAAAAPPPP:
1168 // SS = packet sequence number
1169 // AAAA = average power (linear format, little endian)
1170 // PPPP = peak power (linear format, little endian)
1171 auto peak = static_cast<uint16_t>(data[4]) << 8 | data[3];
1172 auto peakPower = linearToInteger(peak);
1173
1174 peakInputPowerSensor->value(peakPower);
1175 peakInputPowerSensor->functional(true);
1176 peakInputPowerSensor->available(true);
1177}
1178
Adriana Kobylak4175ffb2021-08-02 14:51:05 +00001179void PowerSupply::getInputVoltage(double& actualInputVoltage,
1180 int& inputVoltage) const
1181{
1182 using namespace phosphor::pmbus;
1183
1184 actualInputVoltage = in_input::VIN_VOLTAGE_0;
1185 inputVoltage = in_input::VIN_VOLTAGE_0;
1186
1187 if (present)
1188 {
1189 try
1190 {
1191 // Read input voltage in millivolts
1192 auto inputVoltageStr = pmbusIntf->readString(READ_VIN, Type::Hwmon);
1193
1194 // Convert to volts
1195 actualInputVoltage = std::stod(inputVoltageStr) / 1000;
1196
1197 // Calculate the voltage based on voltage thresholds
1198 if (actualInputVoltage < in_input::VIN_VOLTAGE_MIN)
1199 {
1200 inputVoltage = in_input::VIN_VOLTAGE_0;
1201 }
1202 else if (actualInputVoltage < in_input::VIN_VOLTAGE_110_THRESHOLD)
1203 {
1204 inputVoltage = in_input::VIN_VOLTAGE_110;
1205 }
1206 else
1207 {
1208 inputVoltage = in_input::VIN_VOLTAGE_220;
1209 }
1210 }
1211 catch (const std::exception& e)
1212 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001213 lg2::error("{SHORT_NAME} READ_VIN read error: {ERROR}",
1214 "SHORT_NAME", shortName, "ERROR", e);
Adriana Kobylak4175ffb2021-08-02 14:51:05 +00001215 }
1216 }
1217}
1218
Matt Spinler0975eaf2022-02-14 15:38:30 -06001219void PowerSupply::checkAvailability()
1220{
1221 bool origAvailability = available;
George Liu9464c422023-02-27 14:30:27 +08001222 bool faulted = isPowerOn() && (hasPSKillFault() || hasIoutOCFault());
1223 available = present && !hasInputFault() && !hasVINUVFault() && !faulted;
Matt Spinler0975eaf2022-02-14 15:38:30 -06001224
1225 if (origAvailability != available)
1226 {
1227 auto invpath = inventoryPath.substr(strlen(INVENTORY_OBJ_PATH));
1228 phosphor::power::psu::setAvailable(bus, invpath, available);
Matt Spinlerca1e9ea2022-02-18 14:03:08 -06001229
1230 // Check if the health rollup needs to change based on the
1231 // new availability value.
1232 phosphor::power::psu::handleChassisHealthRollup(bus, inventoryPath,
1233 !available);
Matt Spinler0975eaf2022-02-14 15:38:30 -06001234 }
1235}
1236
Matt Spinlera068f422023-03-10 13:06:49 -06001237void PowerSupply::setInputVoltageRating()
1238{
1239 if (!present)
1240 {
Matt Spinler1aaf9f82023-03-22 09:52:22 -05001241 if (inputVoltageRatingIface)
1242 {
1243 inputVoltageRatingIface->value(0);
1244 inputVoltageRatingIface.reset();
1245 }
Matt Spinlera068f422023-03-10 13:06:49 -06001246 return;
1247 }
1248
1249 double inputVoltageValue{};
1250 int inputVoltageRating{};
1251 getInputVoltage(inputVoltageValue, inputVoltageRating);
1252
1253 if (!inputVoltageRatingIface)
1254 {
Shawn McCarney768d2262024-07-09 15:02:59 -05001255 auto path = std::format(
Matt Spinlera068f422023-03-10 13:06:49 -06001256 "/xyz/openbmc_project/sensors/voltage/ps{}_input_voltage_rating",
1257 shortName.back());
1258
1259 inputVoltageRatingIface = std::make_unique<SensorObject>(
1260 bus, path.c_str(), SensorObject::action::defer_emit);
1261
1262 // Leave other properties at their defaults
1263 inputVoltageRatingIface->unit(SensorInterface::Unit::Volts, true);
1264 inputVoltageRatingIface->value(static_cast<double>(inputVoltageRating),
1265 true);
1266
1267 inputVoltageRatingIface->emit_object_added();
1268 }
1269 else
1270 {
1271 inputVoltageRatingIface->value(static_cast<double>(inputVoltageRating));
1272 }
1273}
1274
faisaladed7a02023-05-10 14:59:01 -05001275void PowerSupply::getPsuVpdFromDbus(const std::string& keyword,
1276 std::string& vpdStr)
1277{
1278 try
1279 {
1280 std::vector<uint8_t> value;
1281 vpdStr.clear();
1282 util::getProperty(VINI_IFACE, keyword, inventoryPath,
1283 INVENTORY_MGR_IFACE, bus, value);
1284 for (char c : value)
1285 {
1286 vpdStr += c;
1287 }
1288 }
1289 catch (const sdbusplus::exception_t& e)
1290 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001291 lg2::error("Failed getProperty error: {ERROR}", "ERROR", e);
faisaladed7a02023-05-10 14:59:01 -05001292 }
1293}
Matt Spinler592bd272023-08-30 11:00:01 -05001294
1295double PowerSupply::linearToInteger(uint16_t data)
1296{
1297 // The exponent is the first 5 bits, followed by 11 bits of mantissa.
1298 int8_t exponent = (data & 0xF800) >> 11;
1299 int16_t mantissa = (data & 0x07FF);
1300
1301 // If exponent's MSB on, then it's negative.
1302 // Convert from two's complement.
1303 if (exponent & 0x10)
1304 {
1305 exponent = (~exponent) & 0x1F;
1306 exponent = (exponent + 1) * -1;
1307 }
1308
1309 // If mantissa's MSB on, then it's negative.
1310 // Convert from two's complement.
1311 if (mantissa & 0x400)
1312 {
1313 mantissa = (~mantissa) & 0x07FF;
1314 mantissa = (mantissa + 1) * -1;
1315 }
1316
1317 auto value = static_cast<double>(mantissa) * pow(2, exponent);
1318 return value;
1319}
1320
1321std::vector<AssociationTuple> PowerSupply::getSensorAssociations()
1322{
1323 std::vector<AssociationTuple> associations;
1324
1325 associations.emplace_back("inventory", "sensors", inventoryPath);
1326
1327 auto chassis = getChassis(bus, inventoryPath);
1328 associations.emplace_back("chassis", "all_sensors", std::move(chassis));
1329
1330 return associations;
1331}
1332
Brandon Wyman3f1242f2020-01-28 13:11:25 -06001333} // namespace phosphor::power::psu