blob: 65e7b62dac993c4f631678e3f65691d02dd29c21 [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
Brandon Wyman3f1242f2020-01-28 13:11:25 -060025using namespace sdbusplus::xyz::openbmc_project::Common::Device::Error;
Brandon Wymanaed1f752019-11-25 18:10:52 -060026
Patrick Williamsf5402192024-08-16 15:20:53 -040027PowerSupply::PowerSupply(
28 sdbusplus::bus_t& bus, const std::string& invpath, std::uint8_t i2cbus,
29 std::uint16_t i2caddr, const std::string& driver,
30 const std::string& gpioLineName, std::function<bool()>&& callback) :
31 bus(bus), inventoryPath(invpath),
32 bindPath("/sys/bus/i2c/drivers/" + driver), isPowerOn(std::move(callback)),
33 driverName(driver)
Brandon Wyman510acaa2020-11-05 18:32:04 -060034{
35 if (inventoryPath.empty())
36 {
37 throw std::invalid_argument{"Invalid empty inventoryPath"};
38 }
39
B. J. Wyman681b2a32021-04-20 22:31:22 +000040 if (gpioLineName.empty())
41 {
42 throw std::invalid_argument{"Invalid empty gpioLineName"};
43 }
Brandon Wyman510acaa2020-11-05 18:32:04 -060044
Brandon Wyman321a6152022-03-19 00:11:44 +000045 shortName = findShortName(inventoryPath);
46
Anwaar Hadib64228d2025-05-30 23:55:26 +000047 lg2::debug("{SHORT_NAME} gpioLineName: {GPIO_LINE_NAME}", "SHORT_NAME",
48 shortName, "GPIO_LINE_NAME", gpioLineName);
B. J. Wyman681b2a32021-04-20 22:31:22 +000049 presenceGPIO = createGPIO(gpioLineName);
Brandon Wyman510acaa2020-11-05 18:32:04 -060050
51 std::ostringstream ss;
52 ss << std::hex << std::setw(4) << std::setfill('0') << i2caddr;
53 std::string addrStr = ss.str();
B. J. Wyman681b2a32021-04-20 22:31:22 +000054 std::string busStr = std::to_string(i2cbus);
55 bindDevice = busStr;
56 bindDevice.append("-");
57 bindDevice.append(addrStr);
58
Brandon Wyman510acaa2020-11-05 18:32:04 -060059 pmbusIntf = phosphor::pmbus::createPMBus(i2cbus, addrStr);
60
61 // Get the current state of the Present property.
B. J. Wyman681b2a32021-04-20 22:31:22 +000062 try
63 {
64 updatePresenceGPIO();
65 }
66 catch (...)
67 {
68 // If the above attempt to use the GPIO failed, it likely means that the
69 // GPIOs are in use by the kernel, meaning it is using gpio-keys.
70 // So, I should rely on phosphor-gpio-presence to update D-Bus, and
71 // work that way for power supply presence.
72 presenceGPIO = nullptr;
73 // Setup the functions to call when the D-Bus inventory path for the
74 // Present property changes.
75 presentMatch = std::make_unique<sdbusplus::bus::match_t>(
76 bus,
77 sdbusplus::bus::match::rules::propertiesChanged(inventoryPath,
78 INVENTORY_IFACE),
79 [this](auto& msg) { this->inventoryChanged(msg); });
80
81 presentAddedMatch = std::make_unique<sdbusplus::bus::match_t>(
82 bus,
83 sdbusplus::bus::match::rules::interfacesAdded() +
84 sdbusplus::bus::match::rules::argNpath(0, inventoryPath),
85 [this](auto& msg) { this->inventoryAdded(msg); });
86
87 updatePresence();
88 updateInventory();
Matt Spinler592bd272023-08-30 11:00:01 -050089 setupSensors();
B. J. Wyman681b2a32021-04-20 22:31:22 +000090 }
Matt Spinlera068f422023-03-10 13:06:49 -060091
92 setInputVoltageRating();
B. J. Wyman681b2a32021-04-20 22:31:22 +000093}
94
95void PowerSupply::bindOrUnbindDriver(bool present)
96{
Faisal Awadab7131a12023-10-26 19:38:45 -050097 // Symbolic link to the device will exist if the driver is bound.
98 // So exit no action required if both the link and PSU are present
99 // or neither is present.
100 namespace fs = std::filesystem;
101 fs::path path;
B. J. Wyman681b2a32021-04-20 22:31:22 +0000102 auto action = (present) ? "bind" : "unbind";
B. J. Wyman681b2a32021-04-20 22:31:22 +0000103
Faisal Awadab7131a12023-10-26 19:38:45 -0500104 // This case should not happen, if no device driver name return.
105 if (driverName.empty())
106 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000107 lg2::info("No device driver name found");
Faisal Awadab7131a12023-10-26 19:38:45 -0500108 return;
109 }
110 if (bindPath.string().find(driverName) != std::string::npos)
111 {
112 // bindPath has driver name
113 path = bindPath / action;
114 }
115 else
116 {
117 // Add driver name to bindPath
118 path = bindPath / driverName / action;
119 bindPath = bindPath / driverName;
120 }
121
122 if ((std::filesystem::exists(bindPath / bindDevice) && present) ||
123 (!std::filesystem::exists(bindPath / bindDevice) && !present))
124 {
125 return;
126 }
B. J. Wyman681b2a32021-04-20 22:31:22 +0000127 if (present)
128 {
Brandon Wymanb1ee60f2022-03-22 22:37:12 +0000129 std::this_thread::sleep_for(std::chrono::milliseconds(bindDelay));
Anwaar Hadib64228d2025-05-30 23:55:26 +0000130 lg2::info("Binding device driver. path: {PATH} device: {BIND_DEVICE}",
131 "PATH", path, "BIND_DEVICE", bindDevice);
B. J. Wyman681b2a32021-04-20 22:31:22 +0000132 }
133 else
134 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000135 lg2::info("Unbinding device driver. path: {PATH} device: {BIND_DEVICE}",
136 "PATH", path, "BIND_DEVICE", bindDevice);
B. J. Wyman681b2a32021-04-20 22:31:22 +0000137 }
138
139 std::ofstream file;
140
141 file.exceptions(std::ofstream::failbit | std::ofstream::badbit |
142 std::ofstream::eofbit);
143
144 try
145 {
146 file.open(path);
147 file << bindDevice;
148 file.close();
149 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -0500150 catch (const std::exception& e)
B. J. Wyman681b2a32021-04-20 22:31:22 +0000151 {
152 auto err = errno;
153
Anwaar Hadib64228d2025-05-30 23:55:26 +0000154 lg2::error("Failed binding or unbinding device. errno={ERRNO}", "ERRNO",
155 err);
B. J. Wyman681b2a32021-04-20 22:31:22 +0000156 }
Brandon Wyman510acaa2020-11-05 18:32:04 -0600157}
158
Brandon Wymanaed1f752019-11-25 18:10:52 -0600159void PowerSupply::updatePresence()
160{
161 try
162 {
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600163 present = getPresence(bus, inventoryPath);
Brandon Wymanaed1f752019-11-25 18:10:52 -0600164 }
Patrick Williams7354ce62022-07-22 19:26:56 -0500165 catch (const sdbusplus::exception_t& e)
Brandon Wymanaed1f752019-11-25 18:10:52 -0600166 {
167 // Relying on property change or interface added to retry.
168 // Log an informational trace to the journal.
Anwaar Hadib64228d2025-05-30 23:55:26 +0000169 lg2::info("D-Bus property {INVENTORY_PATH} access failure exception",
170 "INVENTORY_PATH", inventoryPath);
Brandon Wymanaed1f752019-11-25 18:10:52 -0600171 }
172}
173
B. J. Wyman681b2a32021-04-20 22:31:22 +0000174void PowerSupply::updatePresenceGPIO()
175{
176 bool presentOld = present;
177
178 try
179 {
180 if (presenceGPIO->read() > 0)
181 {
182 present = true;
183 }
184 else
185 {
186 present = false;
187 }
188 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -0500189 catch (const std::exception& e)
B. J. Wyman681b2a32021-04-20 22:31:22 +0000190 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000191 lg2::error("presenceGPIO read fail: {ERROR}", "ERROR", e);
B. J. Wyman681b2a32021-04-20 22:31:22 +0000192 throw;
193 }
194
195 if (presentOld != present)
196 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000197 lg2::debug("{SHORT_NAME} presentOld: {PRESENT_OLD} present: {PRESENT}",
198 "SHORT_NAME", shortName, "PRESENT_OLD", presentOld,
199 "PRESENT", present);
Matt Spinlerca1e9ea2022-02-18 14:03:08 -0600200
201 auto invpath = inventoryPath.substr(strlen(INVENTORY_OBJ_PATH));
Brandon Wyman90d529a2022-03-22 23:02:54 +0000202
203 bindOrUnbindDriver(present);
204 if (present)
205 {
206 // If the power supply was present, then missing, and present again,
207 // the hwmon path may have changed. We will need the correct/updated
208 // path before any reads or writes are attempted.
209 pmbusIntf->findHwmonDir();
210 }
211
Brandon Wyman321a6152022-03-19 00:11:44 +0000212 setPresence(bus, invpath, present, shortName);
Matt Spinler592bd272023-08-30 11:00:01 -0500213 setupSensors();
Matt Spinlerca1e9ea2022-02-18 14:03:08 -0600214 updateInventory();
215
Brandon Wyman90d529a2022-03-22 23:02:54 +0000216 // Need Functional to already be correct before calling this.
Matt Spinlerca1e9ea2022-02-18 14:03:08 -0600217 checkAvailability();
218
B. J. Wyman681b2a32021-04-20 22:31:22 +0000219 if (present)
220 {
B. J. Wyman681b2a32021-04-20 22:31:22 +0000221 onOffConfig(phosphor::pmbus::ON_OFF_CONFIG_CONTROL_PIN_ONLY);
222 clearFaults();
Brandon Wyman18a24d92022-04-19 22:48:34 +0000223 // Indicate that the input history data and timestamps between all
224 // the power supplies that are present in the system need to be
225 // synchronized.
226 syncHistoryRequired = true;
B. J. Wyman681b2a32021-04-20 22:31:22 +0000227 }
Matt Spinler592bd272023-08-30 11:00:01 -0500228 else
229 {
230 setSensorsNotAvailable();
231 }
B. J. Wyman681b2a32021-04-20 22:31:22 +0000232 }
233}
234
Brandon Wymanc2203432021-12-21 23:09:48 +0000235void PowerSupply::analyzeCMLFault()
236{
237 if (statusWord & phosphor::pmbus::status_word::CML_FAULT)
238 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000239 if (cmlFault < DEGLITCH_LIMIT)
Brandon Wymanc2203432021-12-21 23:09:48 +0000240 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000241 if (statusWord != statusWordOld)
242 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000243 lg2::error(
244 "{SHORT_NAME} CML fault: STATUS_WORD = {STATUS_WORD}, "
245 "STATUS_CML = {STATUS_CML}",
246 "SHORT_NAME", shortName, "STATUS_WORD",
247 lg2::hex | lg2::field16, statusWord, "STATUS_CML",
248 lg2::hex | lg2::field8, statusCML);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000249 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000250 cmlFault++;
251 }
252 }
253 else
254 {
255 cmlFault = 0;
Brandon Wymanc2203432021-12-21 23:09:48 +0000256 }
257}
258
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000259void PowerSupply::analyzeInputFault()
260{
261 if (statusWord & phosphor::pmbus::status_word::INPUT_FAULT_WARN)
262 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000263 if (inputFault < DEGLITCH_LIMIT)
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000264 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000265 if (statusWord != statusWordOld)
266 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000267 lg2::error(
268 "{SHORT_NAME} INPUT fault: STATUS_WORD = {STATUS_WORD}, "
269 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
270 "STATUS_INPUT = {STATUS_INPUT}",
271 "SHORT_NAME", shortName, "STATUS_WORD",
272 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
273 lg2::hex | lg2::field8, statusMFR, "STATUS_INPUT",
274 lg2::hex | lg2::field8, statusInput);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000275 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000276 inputFault++;
277 }
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000278 }
Brandon Wyman82affd92021-11-24 19:12:49 +0000279
280 // If had INPUT/VIN_UV fault, and now off.
281 // Trace that odd behavior.
282 if (inputFault &&
283 !(statusWord & phosphor::pmbus::status_word::INPUT_FAULT_WARN))
284 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000285 lg2::info(
286 "{SHORT_NAME} INPUT fault cleared: STATUS_WORD = {STATUS_WORD}, "
287 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
288 "STATUS_INPUT = {STATUS_INPUT}",
289 "SHORT_NAME", shortName, "STATUS_WORD", lg2::hex | lg2::field16,
290 statusWord, "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
291 statusMFR, "STATUS_INPUT", lg2::hex | lg2::field8, statusInput);
Brandon Wymanc2906f42021-12-21 20:14:56 +0000292 inputFault = 0;
Brandon Wyman82affd92021-11-24 19:12:49 +0000293 }
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000294}
295
Brandon Wymanc2c87132021-12-21 23:22:18 +0000296void PowerSupply::analyzeVoutOVFault()
297{
298 if (statusWord & phosphor::pmbus::status_word::VOUT_OV_FAULT)
299 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000300 if (voutOVFault < DEGLITCH_LIMIT)
Brandon Wymanc2c87132021-12-21 23:22:18 +0000301 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000302 if (statusWord != statusWordOld)
303 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000304 lg2::error(
305 "{SHORT_NAME} VOUT_OV_FAULT fault: STATUS_WORD = {STATUS_WORD}, "
306 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
307 "STATUS_VOUT = {STATUS_VOUT}",
308 "SHORT_NAME", shortName, "STATUS_WORD",
309 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
310 lg2::hex | lg2::field8, statusMFR, "STATUS_VOUT",
311 lg2::hex | lg2::field8, statusVout);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000312 }
Brandon Wymanc2c87132021-12-21 23:22:18 +0000313
Brandon Wymanc2906f42021-12-21 20:14:56 +0000314 voutOVFault++;
315 }
316 }
317 else
318 {
319 voutOVFault = 0;
Brandon Wymanc2c87132021-12-21 23:22:18 +0000320 }
321}
322
Brandon Wymana00e7302021-12-21 23:28:29 +0000323void PowerSupply::analyzeIoutOCFault()
324{
325 if (statusWord & phosphor::pmbus::status_word::IOUT_OC_FAULT)
326 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000327 if (ioutOCFault < DEGLITCH_LIMIT)
Brandon Wymana00e7302021-12-21 23:28:29 +0000328 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000329 if (statusWord != statusWordOld)
330 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000331 lg2::error(
332 "{SHORT_NAME} IOUT fault: STATUS_WORD = {STATUS_WORD}, "
333 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
334 "STATUS_IOUT = {STATUS_IOUT}",
335 "SHORT_NAME", shortName, "STATUS_WORD",
336 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
337 lg2::hex | lg2::field8, statusMFR, "STATUS_IOUT",
338 lg2::hex | lg2::field8, statusIout);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000339 }
Brandon Wymana00e7302021-12-21 23:28:29 +0000340
Brandon Wymanc2906f42021-12-21 20:14:56 +0000341 ioutOCFault++;
342 }
343 }
344 else
345 {
346 ioutOCFault = 0;
Brandon Wymana00e7302021-12-21 23:28:29 +0000347 }
348}
349
Brandon Wyman08378782021-12-21 23:48:15 +0000350void PowerSupply::analyzeVoutUVFault()
351{
352 if ((statusWord & phosphor::pmbus::status_word::VOUT_FAULT) &&
353 !(statusWord & phosphor::pmbus::status_word::VOUT_OV_FAULT))
354 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000355 if (voutUVFault < DEGLITCH_LIMIT)
Brandon Wyman08378782021-12-21 23:48:15 +0000356 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000357 if (statusWord != statusWordOld)
358 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000359 lg2::error(
360 "{SHORT_NAME} VOUT_UV_FAULT fault: STATUS_WORD = {STATUS_WORD}, "
361 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
362 "STATUS_VOUT = {STATUS_VOUT}",
363 "SHORT_NAME", shortName, "STATUS_WORD",
364 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
365 lg2::hex | lg2::field8, statusMFR, "STATUS_VOUT",
366 lg2::hex | lg2::field8, statusVout);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000367 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000368 voutUVFault++;
369 }
370 }
371 else
372 {
373 voutUVFault = 0;
Brandon Wyman08378782021-12-21 23:48:15 +0000374 }
375}
376
Brandon Wymand5d9a222021-12-21 23:59:05 +0000377void PowerSupply::analyzeFanFault()
378{
379 if (statusWord & phosphor::pmbus::status_word::FAN_FAULT)
380 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000381 if (fanFault < DEGLITCH_LIMIT)
Brandon Wymand5d9a222021-12-21 23:59:05 +0000382 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000383 if (statusWord != statusWordOld)
384 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000385 lg2::error("{SHORT_NAME} FANS fault/warning: "
386 "STATUS_WORD = {STATUS_WORD}, "
387 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
388 "STATUS_FANS_1_2 = {STATUS_FANS_1_2}",
389 "SHORT_NAME", shortName, "STATUS_WORD",
390 lg2::hex | lg2::field16, statusWord,
391 "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
392 statusMFR, "STATUS_FANS_1_2", lg2::hex | lg2::field8,
393 statusFans12);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000394 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000395 fanFault++;
396 }
397 }
398 else
399 {
400 fanFault = 0;
Brandon Wymand5d9a222021-12-21 23:59:05 +0000401 }
402}
403
Brandon Wyman52cb3f22021-12-21 23:02:47 +0000404void PowerSupply::analyzeTemperatureFault()
405{
406 if (statusWord & phosphor::pmbus::status_word::TEMPERATURE_FAULT_WARN)
407 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000408 if (tempFault < DEGLITCH_LIMIT)
Brandon Wyman52cb3f22021-12-21 23:02:47 +0000409 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000410 if (statusWord != statusWordOld)
411 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000412 lg2::error("{SHORT_NAME} TEMPERATURE fault/warning: "
413 "STATUS_WORD = {STATUS_WORD}, "
414 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
415 "STATUS_TEMPERATURE = {STATUS_TEMPERATURE}",
416 "SHORT_NAME", shortName, "STATUS_WORD",
417 lg2::hex | lg2::field16, statusWord,
418 "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
419 statusMFR, "STATUS_TEMPERATURE",
420 lg2::hex | lg2::field8, statusTemperature);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000421 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000422 tempFault++;
423 }
424 }
425 else
426 {
427 tempFault = 0;
Brandon Wyman52cb3f22021-12-21 23:02:47 +0000428 }
429}
430
Brandon Wyman993b5542021-12-21 22:55:16 +0000431void PowerSupply::analyzePgoodFault()
432{
433 if ((statusWord & phosphor::pmbus::status_word::POWER_GOOD_NEGATED) ||
434 (statusWord & phosphor::pmbus::status_word::UNIT_IS_OFF))
435 {
Brandon Wyman6d469fd2022-06-15 16:58:21 +0000436 if (pgoodFault < PGOOD_DEGLITCH_LIMIT)
Brandon Wyman993b5542021-12-21 22:55:16 +0000437 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000438 if (statusWord != statusWordOld)
439 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000440 lg2::error("{SHORT_NAME} PGOOD fault: "
441 "STATUS_WORD = {STATUS_WORD}, "
442 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}",
443 "SHORT_NAME", shortName, "STATUS_WORD",
444 lg2::hex | lg2::field16, statusWord,
445 "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
446 statusMFR);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000447 }
Brandon Wyman993b5542021-12-21 22:55:16 +0000448 pgoodFault++;
449 }
450 }
451 else
452 {
453 pgoodFault = 0;
454 }
455}
456
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000457void PowerSupply::determineMFRFault()
458{
Faisal Awadab66ae502023-04-01 18:30:32 -0500459 if (bindPath.string().find(IBMCFFPS_DD_NAME) != std::string::npos)
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000460 {
461 // IBM MFR_SPECIFIC[4] is PS_Kill fault
462 if (statusMFR & 0x10)
463 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000464 if (psKillFault < DEGLITCH_LIMIT)
465 {
466 psKillFault++;
467 }
468 }
469 else
470 {
471 psKillFault = 0;
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000472 }
473 // IBM MFR_SPECIFIC[6] is 12Vcs fault.
474 if (statusMFR & 0x40)
475 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000476 if (ps12VcsFault < DEGLITCH_LIMIT)
477 {
478 ps12VcsFault++;
479 }
480 }
481 else
482 {
483 ps12VcsFault = 0;
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000484 }
485 // IBM MFR_SPECIFIC[7] is 12V Current-Share fault.
486 if (statusMFR & 0x80)
487 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000488 if (psCS12VFault < DEGLITCH_LIMIT)
489 {
490 psCS12VFault++;
491 }
492 }
493 else
494 {
495 psCS12VFault = 0;
Brandon Wyman39ea02b2021-11-23 23:22:23 +0000496 }
497 }
498}
499
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000500void PowerSupply::analyzeMFRFault()
501{
502 if (statusWord & phosphor::pmbus::status_word::MFR_SPECIFIC_FAULT)
503 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000504 if (mfrFault < DEGLITCH_LIMIT)
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000505 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000506 if (statusWord != statusWordOld)
507 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000508 lg2::error("{SHORT_NAME} MFR fault: "
509 "STATUS_WORD = {STATUS_WORD} "
510 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}",
511 "SHORT_NAME", shortName, "STATUS_WORD",
512 lg2::hex | lg2::field16, statusWord,
513 "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
514 statusMFR);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000515 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000516 mfrFault++;
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000517 }
518
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000519 determineMFRFault();
520 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000521 else
522 {
523 mfrFault = 0;
524 }
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000525}
526
Brandon Wymanf087f472021-12-22 00:04:27 +0000527void PowerSupply::analyzeVinUVFault()
528{
529 if (statusWord & phosphor::pmbus::status_word::VIN_UV_FAULT)
530 {
Brandon Wymanc2906f42021-12-21 20:14:56 +0000531 if (vinUVFault < DEGLITCH_LIMIT)
Brandon Wymanf087f472021-12-22 00:04:27 +0000532 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000533 if (statusWord != statusWordOld)
534 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000535 lg2::error(
536 "{SHORT_NAME} VIN_UV fault: STATUS_WORD = {STATUS_WORD}, "
537 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
538 "STATUS_INPUT = {STATUS_INPUT}",
539 "SHORT_NAME", shortName, "STATUS_WORD",
540 lg2::hex | lg2::field16, statusWord, "STATUS_MFR_SPECIFIC",
541 lg2::hex | lg2::field8, statusMFR, "STATUS_INPUT",
542 lg2::hex | lg2::field8, statusInput);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000543 }
Brandon Wymanc2906f42021-12-21 20:14:56 +0000544 vinUVFault++;
Brandon Wymanf087f472021-12-22 00:04:27 +0000545 }
Jim Wright4ab86562022-11-18 14:05:46 -0600546 // Remember that this PSU has seen an AC fault
547 acFault = AC_FAULT_LIMIT;
Brandon Wymanf087f472021-12-22 00:04:27 +0000548 }
Jim Wright7f9288c2022-12-08 11:57:04 -0600549 else
Brandon Wyman82affd92021-11-24 19:12:49 +0000550 {
Jim Wright7f9288c2022-12-08 11:57:04 -0600551 if (vinUVFault != 0)
552 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000553 lg2::info(
554 "{SHORT_NAME} VIN_UV fault cleared: STATUS_WORD = {STATUS_WORD}, "
555 "STATUS_MFR_SPECIFIC = {STATUS_MFR_SPECIFIC}, "
556 "STATUS_INPUT = {STATUS_INPUT}",
557 "SHORT_NAME", shortName, "STATUS_WORD", lg2::hex | lg2::field16,
558 statusWord, "STATUS_MFR_SPECIFIC", lg2::hex | lg2::field8,
559 statusMFR, "STATUS_INPUT", lg2::hex | lg2::field8, statusInput);
Jim Wright7f9288c2022-12-08 11:57:04 -0600560 vinUVFault = 0;
561 }
Jim Wright4ab86562022-11-18 14:05:46 -0600562 // No AC fail, decrement counter
Jim Wright7f9288c2022-12-08 11:57:04 -0600563 if (acFault != 0)
Jim Wright4ab86562022-11-18 14:05:46 -0600564 {
565 --acFault;
566 }
Brandon Wyman82affd92021-11-24 19:12:49 +0000567 }
Brandon Wymanf087f472021-12-22 00:04:27 +0000568}
569
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600570void PowerSupply::analyze()
571{
572 using namespace phosphor::pmbus;
573
B. J. Wyman681b2a32021-04-20 22:31:22 +0000574 if (presenceGPIO)
575 {
576 updatePresenceGPIO();
577 }
578
Brandon Wyman32453e92021-12-15 19:00:14 +0000579 if (present)
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600580 {
581 try
582 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000583 statusWordOld = statusWord;
Brandon Wyman32453e92021-12-15 19:00:14 +0000584 statusWord = pmbusIntf->read(STATUS_WORD, Type::Debug,
585 (readFail < LOG_LIMIT));
Brandon Wymanf65c4062020-08-19 13:15:53 -0500586 // Read worked, reset the fail count.
587 readFail = 0;
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600588
589 if (statusWord)
590 {
Brandon Wymanf07bc792021-10-12 19:00:35 +0000591 statusInput = pmbusIntf->read(STATUS_INPUT, Type::Debug);
Faisal Awadab66ae502023-04-01 18:30:32 -0500592 if (bindPath.string().find(IBMCFFPS_DD_NAME) !=
593 std::string::npos)
594 {
595 statusMFR = pmbusIntf->read(STATUS_MFR, Type::Debug);
596 }
Brandon Wyman85c7bf42021-10-19 22:28:48 +0000597 statusCML = pmbusIntf->read(STATUS_CML, Type::Debug);
Brandon Wyman6710ba22021-10-27 17:39:31 +0000598 auto status0Vout = pmbusIntf->insertPageNum(STATUS_VOUT, 0);
599 statusVout = pmbusIntf->read(status0Vout, Type::Debug);
Brandon Wymanb10b3be2021-11-09 22:12:15 +0000600 statusIout = pmbusIntf->read(STATUS_IOUT, Type::Debug);
Brandon Wyman7ee4d7e2021-11-19 20:48:23 +0000601 statusFans12 = pmbusIntf->read(STATUS_FANS_1_2, Type::Debug);
Patrick Williamsf5402192024-08-16 15:20:53 -0400602 statusTemperature =
603 pmbusIntf->read(STATUS_TEMPERATURE, Type::Debug);
Brandon Wyman9ddc6222021-10-28 17:28:01 +0000604
Brandon Wymanc2203432021-12-21 23:09:48 +0000605 analyzeCMLFault();
Brandon Wyman85c7bf42021-10-19 22:28:48 +0000606
Brandon Wymane3b0bb02021-12-21 23:16:48 +0000607 analyzeInputFault();
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600608
Brandon Wymanc2c87132021-12-21 23:22:18 +0000609 analyzeVoutOVFault();
Brandon Wyman6710ba22021-10-27 17:39:31 +0000610
Brandon Wymana00e7302021-12-21 23:28:29 +0000611 analyzeIoutOCFault();
Brandon Wymanb10b3be2021-11-09 22:12:15 +0000612
Brandon Wyman08378782021-12-21 23:48:15 +0000613 analyzeVoutUVFault();
Brandon Wyman2cf46942021-10-28 19:09:16 +0000614
Brandon Wymand5d9a222021-12-21 23:59:05 +0000615 analyzeFanFault();
Brandon Wyman7ee4d7e2021-11-19 20:48:23 +0000616
Brandon Wyman52cb3f22021-12-21 23:02:47 +0000617 analyzeTemperatureFault();
Brandon Wyman96893a42021-11-05 19:56:57 +0000618
Brandon Wyman993b5542021-12-21 22:55:16 +0000619 analyzePgoodFault();
Brandon Wyman2916ea52021-11-06 03:31:18 +0000620
Brandon Wyman6c2ac392021-12-21 22:23:06 +0000621 analyzeMFRFault();
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600622
Brandon Wymanf087f472021-12-22 00:04:27 +0000623 analyzeVinUVFault();
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600624 }
625 else
626 {
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000627 if (statusWord != statusWordOld)
628 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000629 lg2::info("{SHORT_NAME} STATUS_WORD = {STATUS_WORD}",
630 "SHORT_NAME", shortName, "STATUS_WORD",
631 lg2::hex | lg2::field16, statusWord);
Brandon Wyman9e292ee2022-03-10 22:56:23 +0000632 }
633
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000634 // if INPUT/VIN_UV fault was on, it cleared, trace it.
635 if (inputFault)
636 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000637 lg2::info(
638 "{SHORT_NAME} INPUT fault cleared: STATUS_WORD = {STATUS_WORD}",
639 "SHORT_NAME", shortName, "STATUS_WORD",
640 lg2::hex | lg2::field16, statusWord);
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000641 }
642
643 if (vinUVFault)
644 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000645 lg2::info(
646 "{SHORT_NAME} VIN_UV cleared: STATUS_WORD = {STATUS_WORD}",
647 "SHORT_NAME", shortName, "STATUS_WORD",
648 lg2::hex | lg2::field16, statusWord);
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000649 }
650
Brandon Wyman06ca4592021-12-06 22:52:23 +0000651 if (pgoodFault > 0)
Brandon Wyman4aecc292021-11-10 22:40:41 +0000652 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000653 lg2::info("{SHORT_NAME} pgoodFault cleared", "SHORT_NAME",
654 shortName);
Brandon Wyman4aecc292021-11-10 22:40:41 +0000655 }
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000656
657 clearFaultFlags();
Jim Wright4ab86562022-11-18 14:05:46 -0600658 // No AC fail, decrement counter
Jim Wright7f9288c2022-12-08 11:57:04 -0600659 if (acFault != 0)
Jim Wright4ab86562022-11-18 14:05:46 -0600660 {
661 --acFault;
662 }
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600663 }
Brandon Wyman82affd92021-11-24 19:12:49 +0000664
665 // Save off old inputVoltage value.
666 // Get latest inputVoltage.
667 // If voltage went from below minimum, and now is not, clear faults.
668 // Note: getInputVoltage() has its own try/catch.
669 int inputVoltageOld = inputVoltage;
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000670 double actualInputVoltageOld = actualInputVoltage;
Brandon Wyman82affd92021-11-24 19:12:49 +0000671 getInputVoltage(actualInputVoltage, inputVoltage);
672 if ((inputVoltageOld == in_input::VIN_VOLTAGE_0) &&
673 (inputVoltage != in_input::VIN_VOLTAGE_0))
674 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000675 lg2::info(
676 "{SHORT_NAME} READ_VIN back in range: actualInputVoltageOld = {ACTUAL_INPUT_VOLTAGE_OLD} "
677 "actualInputVoltage = {ACTUAL_INPUT_VOLTAGE}",
678 "SHORT_NAME", shortName, "ACTUAL_INPUT_VOLTAGE_OLD",
679 actualInputVoltageOld, "ACTUAL_INPUT_VOLTAGE",
680 actualInputVoltage);
Brandon Wyman3225a452022-03-18 18:51:49 +0000681 clearVinUVFault();
Brandon Wyman82affd92021-11-24 19:12:49 +0000682 }
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000683 else if (vinUVFault && (inputVoltage != in_input::VIN_VOLTAGE_0))
684 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000685 lg2::info(
686 "{SHORT_NAME} CLEAR_FAULTS: vinUVFault {VIN_UV_FAULT} actualInputVoltage {ACTUAL_INPUT_VOLTAGE}",
687 "SHORT_NAME", shortName, "VIN_UV_FAULT", vinUVFault,
688 "ACTUAL_INPUT_VOLTAGE", actualInputVoltage);
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000689 // Do we have a VIN_UV fault latched that can now be cleared
Jim Wright4ab86562022-11-18 14:05:46 -0600690 // due to voltage back in range? Attempt to clear the
691 // fault(s), re-check faults on next call.
Brandon Wyman3225a452022-03-18 18:51:49 +0000692 clearVinUVFault();
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000693 }
Brandon Wymanae35ac52022-05-23 22:33:40 +0000694 else if (std::abs(actualInputVoltageOld - actualInputVoltage) >
695 10.0)
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000696 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000697 lg2::info(
698 "{SHORT_NAME} actualInputVoltageOld = {ACTUAL_INPUT_VOLTAGE_OLD} actualInputVoltage = {ACTUAL_INPUT_VOLTAGE}",
699 "SHORT_NAME", shortName, "ACTUAL_INPUT_VOLTAGE_OLD",
700 actualInputVoltageOld, "ACTUAL_INPUT_VOLTAGE",
701 actualInputVoltage);
Brandon Wyman4fc191f2022-03-10 23:07:13 +0000702 }
Matt Spinler0975eaf2022-02-14 15:38:30 -0600703
Matt Spinler592bd272023-08-30 11:00:01 -0500704 monitorSensors();
705
Matt Spinler0975eaf2022-02-14 15:38:30 -0600706 checkAvailability();
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600707 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -0500708 catch (const ReadFailure& e)
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600709 {
Brandon Wyman32453e92021-12-15 19:00:14 +0000710 if (readFail < SIZE_MAX)
711 {
712 readFail++;
713 }
714 if (readFail == LOG_LIMIT)
715 {
716 phosphor::logging::commit<ReadFailure>();
717 }
Brandon Wyman3f1242f2020-01-28 13:11:25 -0600718 }
719 }
720}
721
Brandon Wyman59a35792020-06-04 12:37:40 -0500722void PowerSupply::onOffConfig(uint8_t data)
723{
724 using namespace phosphor::pmbus;
725
Faisal Awada9582d9c2023-07-11 09:31:22 -0500726 if (present && driverName != ACBEL_FSG032_DD_NAME)
Brandon Wyman59a35792020-06-04 12:37:40 -0500727 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000728 lg2::info("ON_OFF_CONFIG write: DATA={DATA}", "DATA",
729 lg2::hex | lg2::field8, data);
Brandon Wyman59a35792020-06-04 12:37:40 -0500730 try
731 {
732 std::vector<uint8_t> configData{data};
733 pmbusIntf->writeBinary(ON_OFF_CONFIG, configData,
734 Type::HwmonDeviceDebug);
735 }
736 catch (...)
737 {
738 // The underlying code in writeBinary will log a message to the
B. J. Wyman681b2a32021-04-20 22:31:22 +0000739 // journal if the write fails. If the ON_OFF_CONFIG is not setup
740 // as desired, later fault detection and analysis code should
741 // catch any of the fall out. We should not need to terminate
742 // the application if this write fails.
Brandon Wyman59a35792020-06-04 12:37:40 -0500743 }
744 }
745}
746
Brandon Wyman3225a452022-03-18 18:51:49 +0000747void PowerSupply::clearVinUVFault()
748{
749 // Read in1_lcrit_alarm to clear bits 3 and 4 of STATUS_INPUT.
750 // The fault bits in STAUTS_INPUT roll-up to STATUS_WORD. Clearing those
751 // bits in STATUS_INPUT should result in the corresponding STATUS_WORD bits
752 // also clearing.
753 //
754 // Do not care about return value. Should be 1 if active, 0 if not.
Faisal Awada9582d9c2023-07-11 09:31:22 -0500755 if (driverName != ACBEL_FSG032_DD_NAME)
756 {
757 static_cast<void>(
758 pmbusIntf->read("in1_lcrit_alarm", phosphor::pmbus::Type::Hwmon));
759 }
760 else
761 {
762 static_cast<void>(
763 pmbusIntf->read("curr1_crit_alarm", phosphor::pmbus::Type::Hwmon));
764 }
Brandon Wyman3225a452022-03-18 18:51:49 +0000765 vinUVFault = 0;
766}
767
Brandon Wyman3c208462020-05-13 16:25:58 -0500768void PowerSupply::clearFaults()
769{
Anwaar Hadib64228d2025-05-30 23:55:26 +0000770 lg2::debug("clearFaults() inventoryPath: {INVENTORY_PATH}",
771 "INVENTORY_PATH", inventoryPath);
Brandon Wyman5474c912021-02-23 14:39:43 -0600772 faultLogged = false;
Brandon Wyman3c208462020-05-13 16:25:58 -0500773 // The PMBus device driver does not allow for writing CLEAR_FAULTS
774 // directly. However, the pmbus hwmon device driver code will send a
775 // CLEAR_FAULTS after reading from any of the hwmon "files" in sysfs, so
776 // reading in1_input should result in clearing the fault bits in
777 // STATUS_BYTE/STATUS_WORD.
778 // I do not care what the return value is.
Brandon Wyman11151532020-11-10 13:45:57 -0600779 if (present)
Brandon Wyman3c208462020-05-13 16:25:58 -0500780 {
Brandon Wymane3f7ad22021-12-21 20:27:45 +0000781 clearFaultFlags();
Matt Spinler0975eaf2022-02-14 15:38:30 -0600782 checkAvailability();
Brandon Wyman9564e942020-11-10 14:01:42 -0600783 readFail = 0;
Brandon Wyman9564e942020-11-10 14:01:42 -0600784
Brandon Wyman11151532020-11-10 13:45:57 -0600785 try
786 {
Brandon Wyman3225a452022-03-18 18:51:49 +0000787 clearVinUVFault();
Brandon Wyman11151532020-11-10 13:45:57 -0600788 static_cast<void>(
789 pmbusIntf->read("in1_input", phosphor::pmbus::Type::Hwmon));
790 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -0500791 catch (const ReadFailure& e)
Brandon Wyman11151532020-11-10 13:45:57 -0600792 {
793 // Since I do not care what the return value is, I really do not
B. J. Wyman681b2a32021-04-20 22:31:22 +0000794 // care much if it gets a ReadFailure either. However, this
795 // should not prevent the application from continuing to run, so
796 // catching the read failure.
Brandon Wyman11151532020-11-10 13:45:57 -0600797 }
Brandon Wyman3c208462020-05-13 16:25:58 -0500798 }
799}
800
Patrick Williams7354ce62022-07-22 19:26:56 -0500801void PowerSupply::inventoryChanged(sdbusplus::message_t& msg)
Brandon Wymanaed1f752019-11-25 18:10:52 -0600802{
803 std::string msgSensor;
Patrick Williamsabe49412020-05-13 17:59:47 -0500804 std::map<std::string, std::variant<uint32_t, bool>> msgData;
Brandon Wymanaed1f752019-11-25 18:10:52 -0600805 msg.read(msgSensor, msgData);
806
807 // Check if it was the Present property that changed.
808 auto valPropMap = msgData.find(PRESENT_PROP);
809 if (valPropMap != msgData.end())
810 {
811 if (std::get<bool>(valPropMap->second))
812 {
813 present = true;
B. J. Wyman681b2a32021-04-20 22:31:22 +0000814 // TODO: Immediately trying to read or write the "files" causes
815 // read or write failures.
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500816 using namespace std::chrono_literals;
817 std::this_thread::sleep_for(20ms);
Brandon Wyman9564e942020-11-10 14:01:42 -0600818 pmbusIntf->findHwmonDir();
Brandon Wyman59a35792020-06-04 12:37:40 -0500819 onOffConfig(phosphor::pmbus::ON_OFF_CONFIG_CONTROL_PIN_ONLY);
Brandon Wymanaed1f752019-11-25 18:10:52 -0600820 clearFaults();
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500821 updateInventory();
Brandon Wymanaed1f752019-11-25 18:10:52 -0600822 }
823 else
824 {
825 present = false;
826
827 // Clear out the now outdated inventory properties
828 updateInventory();
829 }
Matt Spinler0975eaf2022-02-14 15:38:30 -0600830 checkAvailability();
Brandon Wymanaed1f752019-11-25 18:10:52 -0600831 }
832}
833
Patrick Williams7354ce62022-07-22 19:26:56 -0500834void PowerSupply::inventoryAdded(sdbusplus::message_t& msg)
Brandon Wyman9a507db2021-02-25 16:15:22 -0600835{
836 sdbusplus::message::object_path path;
837 msg.read(path);
838 // Make sure the signal is for the PSU inventory path
839 if (path == inventoryPath)
840 {
841 std::map<std::string, std::map<std::string, std::variant<bool>>>
842 interfaces;
843 // Get map of interfaces and their properties
844 msg.read(interfaces);
845
846 auto properties = interfaces.find(INVENTORY_IFACE);
847 if (properties != interfaces.end())
848 {
849 auto property = properties->second.find(PRESENT_PROP);
850 if (property != properties->second.end())
851 {
852 present = std::get<bool>(property->second);
853
Anwaar Hadib64228d2025-05-30 23:55:26 +0000854 lg2::info("Power Supply {INVENTORY_PATH} Present {PRESENT}",
855 "INVENTORY_PATH", inventoryPath, "PRESENT", present);
Brandon Wyman9a507db2021-02-25 16:15:22 -0600856
857 updateInventory();
Matt Spinler0975eaf2022-02-14 15:38:30 -0600858 checkAvailability();
Brandon Wyman9a507db2021-02-25 16:15:22 -0600859 }
860 }
861 }
862}
863
Brandon Wyman8393f462022-06-28 16:06:46 +0000864auto PowerSupply::readVPDValue(const std::string& vpdName,
865 const phosphor::pmbus::Type& type,
866 const std::size_t& vpdSize)
867{
868 std::string vpdValue;
Patrick Williamsf5402192024-08-16 15:20:53 -0400869 const std::regex illegalVPDRegex =
870 std::regex("[^[:alnum:]]", std::regex::basic);
Brandon Wyman8393f462022-06-28 16:06:46 +0000871
872 try
873 {
874 vpdValue = pmbusIntf->readString(vpdName, type);
875 }
876 catch (const ReadFailure& e)
877 {
878 // Ignore the read failure, let pmbus code indicate failure,
879 // path...
880 // TODO - ibm918
881 // https://github.com/openbmc/docs/blob/master/designs/vpd-collection.md
882 // The BMC must log errors if any of the VPD cannot be properly
883 // parsed or fails ECC checks.
884 }
885
886 if (vpdValue.size() != vpdSize)
887 {
Anwaar Hadib64228d2025-05-30 23:55:26 +0000888 lg2::info("{SHORT_NAME} {VPD_NAME} resize needed. size: {SIZE}",
889 "SHORT_NAME", shortName, "VPD_NAME", vpdName, "SIZE",
890 vpdValue.size());
Brandon Wyman8393f462022-06-28 16:06:46 +0000891 vpdValue.resize(vpdSize, ' ');
892 }
893
Brandon Wyman056935c2022-06-24 23:05:09 +0000894 // Replace any illegal values with space(s).
895 std::regex_replace(vpdValue.begin(), vpdValue.begin(), vpdValue.end(),
896 illegalVPDRegex, " ");
897
Brandon Wyman8393f462022-06-28 16:06:46 +0000898 return vpdValue;
899}
900
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500901void PowerSupply::updateInventory()
902{
903 using namespace phosphor::pmbus;
904
Chanh Nguyenc12c53b2021-04-06 17:24:47 +0700905#if IBM_VPD
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500906 std::string pn;
907 std::string fn;
908 std::string header;
909 std::string sn;
Brandon Wyman8393f462022-06-28 16:06:46 +0000910 // The IBM power supply splits the full serial number into two parts.
911 // Each part is 6 bytes long, which should match up with SN_KW_SIZE.
912 const auto HEADER_SIZE = 6;
913 const auto SERIAL_SIZE = 6;
914 // The IBM PSU firmware version size is a bit complicated. It was originally
915 // 1-byte, per command. It was later expanded to 2-bytes per command, then
916 // up to 8-bytes per command. The device driver only reads up to 2 bytes per
917 // command, but combines all three of the 2-byte reads, or all 4 of the
918 // 1-byte reads into one string. So, the maximum size expected is 6 bytes.
Shawn McCarney983c9892022-10-12 10:49:47 -0500919 // However, it is formatted by the driver as a hex string with two ASCII
920 // characters per byte. So the maximum ASCII string size is 12.
Faisal Awada9582d9c2023-07-11 09:31:22 -0500921 const auto IBMCFFPS_FW_VERSION_SIZE = 12;
922 const auto ACBEL_FSG032_FW_VERSION_SIZE = 6;
Brandon Wyman8393f462022-06-28 16:06:46 +0000923
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500924 using PropertyMap =
George Liu070c1bc2020-10-12 11:28:01 +0800925 std::map<std::string,
926 std::variant<std::string, std::vector<uint8_t>, bool>>;
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500927 PropertyMap assetProps;
George Liu070c1bc2020-10-12 11:28:01 +0800928 PropertyMap operProps;
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500929 PropertyMap versionProps;
930 PropertyMap ipzvpdDINFProps;
931 PropertyMap ipzvpdVINIProps;
932 using InterfaceMap = std::map<std::string, PropertyMap>;
933 InterfaceMap interfaces;
934 using ObjectMap = std::map<sdbusplus::message::object_path, InterfaceMap>;
935 ObjectMap object;
936#endif
Anwaar Hadib64228d2025-05-30 23:55:26 +0000937 lg2::debug("updateInventory() inventoryPath: {INVENTORY_PATH}",
938 "INVENTORY_PATH", inventoryPath);
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500939
940 if (present)
941 {
942 // TODO: non-IBM inventory updates?
943
Chanh Nguyenc12c53b2021-04-06 17:24:47 +0700944#if IBM_VPD
Faisal Awada9582d9c2023-07-11 09:31:22 -0500945 if (driverName == ACBEL_FSG032_DD_NAME)
faisaladed7a02023-05-10 14:59:01 -0500946 {
947 getPsuVpdFromDbus("CC", modelName);
948 getPsuVpdFromDbus("PN", pn);
949 getPsuVpdFromDbus("FN", fn);
950 getPsuVpdFromDbus("SN", sn);
951 assetProps.emplace(SN_PROP, sn);
Faisal Awada9582d9c2023-07-11 09:31:22 -0500952 fwVersion = readVPDValue(FW_VERSION, Type::Debug,
953 ACBEL_FSG032_FW_VERSION_SIZE);
954 versionProps.emplace(VERSION_PROP, fwVersion);
faisaladed7a02023-05-10 14:59:01 -0500955 }
956 else
957 {
958 modelName = readVPDValue(CCIN, Type::HwmonDeviceDebug, CC_KW_SIZE);
959 pn = readVPDValue(PART_NUMBER, Type::Debug, PN_KW_SIZE);
960 fn = readVPDValue(FRU_NUMBER, Type::Debug, FN_KW_SIZE);
961
962 header = readVPDValue(SERIAL_HEADER, Type::Debug, HEADER_SIZE);
963 sn = readVPDValue(SERIAL_NUMBER, Type::Debug, SERIAL_SIZE);
964 assetProps.emplace(SN_PROP, header + sn);
Faisal Awada9582d9c2023-07-11 09:31:22 -0500965 fwVersion = readVPDValue(FW_VERSION, Type::HwmonDeviceDebug,
966 IBMCFFPS_FW_VERSION_SIZE);
967 versionProps.emplace(VERSION_PROP, fwVersion);
faisaladed7a02023-05-10 14:59:01 -0500968 }
969
Brandon Wyman8393f462022-06-28 16:06:46 +0000970 assetProps.emplace(MODEL_PROP, modelName);
Brandon Wyman8393f462022-06-28 16:06:46 +0000971 assetProps.emplace(PN_PROP, pn);
Brandon Wyman8393f462022-06-28 16:06:46 +0000972 assetProps.emplace(SPARE_PN_PROP, fn);
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500973
Brandon Wyman8393f462022-06-28 16:06:46 +0000974 ipzvpdVINIProps.emplace(
975 "CC", std::vector<uint8_t>(modelName.begin(), modelName.end()));
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500976 ipzvpdVINIProps.emplace("PN",
977 std::vector<uint8_t>(pn.begin(), pn.end()));
978 ipzvpdVINIProps.emplace("FN",
979 std::vector<uint8_t>(fn.begin(), fn.end()));
Brandon Wyman33d492f2022-03-23 20:45:17 +0000980 std::string header_sn = header + sn;
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500981 ipzvpdVINIProps.emplace(
982 "SN", std::vector<uint8_t>(header_sn.begin(), header_sn.end()));
983 std::string description = "IBM PS";
984 ipzvpdVINIProps.emplace(
985 "DR", std::vector<uint8_t>(description.begin(), description.end()));
986
Ben Tynerf8d8c462022-01-27 16:09:45 -0600987 // Populate the VINI Resource Type (RT) keyword
988 ipzvpdVINIProps.emplace("RT", std::vector<uint8_t>{'V', 'I', 'N', 'I'});
989
Brandon Wyman1d7a7df2020-03-26 10:14:05 -0500990 // Update the Resource Identifier (RI) keyword
991 // 2 byte FRC: 0x0003
992 // 2 byte RID: 0x1000, 0x1001...
993 std::uint8_t num = std::stoul(
994 inventoryPath.substr(inventoryPath.size() - 1, 1), nullptr, 0);
995 std::vector<uint8_t> ri{0x00, 0x03, 0x10, num};
996 ipzvpdDINFProps.emplace("RI", ri);
997
998 // Fill in the FRU Label (FL) keyword.
999 std::string fl = "E";
1000 fl.push_back(inventoryPath.back());
1001 fl.resize(FL_KW_SIZE, ' ');
1002 ipzvpdDINFProps.emplace("FL",
1003 std::vector<uint8_t>(fl.begin(), fl.end()));
1004
Ben Tynerf8d8c462022-01-27 16:09:45 -06001005 // Populate the DINF Resource Type (RT) keyword
1006 ipzvpdDINFProps.emplace("RT", std::vector<uint8_t>{'D', 'I', 'N', 'F'});
1007
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001008 interfaces.emplace(ASSET_IFACE, std::move(assetProps));
1009 interfaces.emplace(VERSION_IFACE, std::move(versionProps));
1010 interfaces.emplace(DINF_IFACE, std::move(ipzvpdDINFProps));
1011 interfaces.emplace(VINI_IFACE, std::move(ipzvpdVINIProps));
1012
George Liu070c1bc2020-10-12 11:28:01 +08001013 // Update the Functional
1014 operProps.emplace(FUNCTIONAL_PROP, present);
1015 interfaces.emplace(OPERATIONAL_STATE_IFACE, std::move(operProps));
1016
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001017 auto path = inventoryPath.substr(strlen(INVENTORY_OBJ_PATH));
1018 object.emplace(path, std::move(interfaces));
1019
1020 try
1021 {
Patrick Williamsf5402192024-08-16 15:20:53 -04001022 auto service =
1023 util::getService(INVENTORY_OBJ_PATH, INVENTORY_MGR_IFACE, bus);
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001024
1025 if (service.empty())
1026 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001027 lg2::error("Unable to get inventory manager service");
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001028 return;
1029 }
1030
Patrick Williamsf5402192024-08-16 15:20:53 -04001031 auto method =
1032 bus.new_method_call(service.c_str(), INVENTORY_OBJ_PATH,
1033 INVENTORY_MGR_IFACE, "Notify");
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001034
1035 method.append(std::move(object));
1036
1037 auto reply = bus.call(method);
1038 }
Patrick Williamsc1d4de52021-10-06 12:45:57 -05001039 catch (const std::exception& e)
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001040 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001041 lg2::error(
1042 "Exception in updateInventory(): {ERROR}, PATH={INVENTORY_PATH}",
1043 "ERROR", e, "INVENTORY_PATH", inventoryPath);
Brandon Wyman1d7a7df2020-03-26 10:14:05 -05001044 }
1045#endif
1046 }
1047}
1048
Brandon Wymanae35ac52022-05-23 22:33:40 +00001049auto PowerSupply::getMaxPowerOut() const
1050{
1051 using namespace phosphor::pmbus;
1052
1053 auto maxPowerOut = 0;
1054
1055 if (present)
1056 {
1057 try
1058 {
1059 // Read max_power_out, should be direct format
Patrick Williamsf5402192024-08-16 15:20:53 -04001060 auto maxPowerOutStr =
1061 pmbusIntf->readString(MFR_POUT_MAX, Type::HwmonDeviceDebug);
Anwaar Hadib64228d2025-05-30 23:55:26 +00001062 lg2::info("{SHORT_NAME} MFR_POUT_MAX read {MAX_POWER_OUT_STR}",
1063 "SHORT_NAME", shortName, "MAX_POWER_OUT_STR",
1064 maxPowerOutStr);
Brandon Wymanae35ac52022-05-23 22:33:40 +00001065 maxPowerOut = std::stod(maxPowerOutStr);
1066 }
1067 catch (const std::exception& e)
1068 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001069 lg2::error("{SHORT_NAME} MFR_POUT_MAX read error: {ERROR}",
1070 "SHORT_NAME", shortName, "ERROR", e);
Brandon Wymanae35ac52022-05-23 22:33:40 +00001071 }
1072 }
1073
1074 return maxPowerOut;
1075}
1076
Matt Spinler592bd272023-08-30 11:00:01 -05001077void PowerSupply::setupSensors()
1078{
1079 setupInputPowerPeakSensor();
1080}
1081
1082void PowerSupply::setupInputPowerPeakSensor()
1083{
1084 if (peakInputPowerSensor || !present ||
1085 (bindPath.string().find(IBMCFFPS_DD_NAME) == std::string::npos))
1086 {
1087 return;
1088 }
1089
1090 // This PSU has problems with the input_history command
1091 if (getMaxPowerOut() == phosphor::pmbus::IBM_CFFPS_1400W)
1092 {
1093 return;
1094 }
1095
1096 auto sensorPath =
Shawn McCarney768d2262024-07-09 15:02:59 -05001097 std::format("/xyz/openbmc_project/sensors/power/ps{}_input_power_peak",
Matt Spinler592bd272023-08-30 11:00:01 -05001098 shortName.back());
1099
1100 peakInputPowerSensor = std::make_unique<PowerSensorObject>(
1101 bus, sensorPath.c_str(), PowerSensorObject::action::defer_emit);
1102
1103 // The others can remain at the defaults.
1104 peakInputPowerSensor->functional(true, true);
1105 peakInputPowerSensor->available(true, true);
1106 peakInputPowerSensor->value(0, true);
1107 peakInputPowerSensor->unit(
1108 sdbusplus::xyz::openbmc_project::Sensor::server::Value::Unit::Watts,
1109 true);
1110
1111 auto associations = getSensorAssociations();
1112 peakInputPowerSensor->associations(associations, true);
1113
1114 peakInputPowerSensor->emit_object_added();
1115}
1116
1117void PowerSupply::setSensorsNotAvailable()
1118{
1119 if (peakInputPowerSensor)
1120 {
1121 peakInputPowerSensor->value(std::numeric_limits<double>::quiet_NaN());
1122 peakInputPowerSensor->available(false);
1123 }
1124}
1125
Matt Spinler592bd272023-08-30 11:00:01 -05001126void PowerSupply::monitorSensors()
1127{
1128 monitorPeakInputPowerSensor();
1129}
1130
1131void PowerSupply::monitorPeakInputPowerSensor()
1132{
1133 if (!peakInputPowerSensor)
1134 {
1135 return;
1136 }
1137
1138 constexpr size_t recordSize = 5;
1139 std::vector<uint8_t> data;
1140
1141 // Get the peak input power with input history command.
1142 // New data only shows up every 30s, but just try to read it every 1s
1143 // anyway so we always have the most up to date value.
1144 try
1145 {
1146 data = pmbusIntf->readBinary(INPUT_HISTORY,
1147 pmbus::Type::HwmonDeviceDebug, recordSize);
1148 }
1149 catch (const ReadFailure& e)
1150 {
1151 peakInputPowerSensor->value(std::numeric_limits<double>::quiet_NaN());
1152 peakInputPowerSensor->functional(false);
1153 throw;
1154 }
1155
1156 if (data.size() != recordSize)
1157 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001158 lg2::debug(
1159 "Input history command returned {DATA_SIZE} bytes instead of 5",
1160 "DATA_SIZE", data.size());
Matt Spinler592bd272023-08-30 11:00:01 -05001161 peakInputPowerSensor->value(std::numeric_limits<double>::quiet_NaN());
1162 peakInputPowerSensor->functional(false);
1163 return;
1164 }
1165
1166 // The format is SSAAAAPPPP:
1167 // SS = packet sequence number
1168 // AAAA = average power (linear format, little endian)
1169 // PPPP = peak power (linear format, little endian)
1170 auto peak = static_cast<uint16_t>(data[4]) << 8 | data[3];
1171 auto peakPower = linearToInteger(peak);
1172
1173 peakInputPowerSensor->value(peakPower);
1174 peakInputPowerSensor->functional(true);
1175 peakInputPowerSensor->available(true);
1176}
1177
Adriana Kobylak4175ffb2021-08-02 14:51:05 +00001178void PowerSupply::getInputVoltage(double& actualInputVoltage,
1179 int& inputVoltage) const
1180{
1181 using namespace phosphor::pmbus;
1182
1183 actualInputVoltage = in_input::VIN_VOLTAGE_0;
1184 inputVoltage = in_input::VIN_VOLTAGE_0;
1185
1186 if (present)
1187 {
1188 try
1189 {
1190 // Read input voltage in millivolts
1191 auto inputVoltageStr = pmbusIntf->readString(READ_VIN, Type::Hwmon);
1192
1193 // Convert to volts
1194 actualInputVoltage = std::stod(inputVoltageStr) / 1000;
1195
1196 // Calculate the voltage based on voltage thresholds
1197 if (actualInputVoltage < in_input::VIN_VOLTAGE_MIN)
1198 {
1199 inputVoltage = in_input::VIN_VOLTAGE_0;
1200 }
1201 else if (actualInputVoltage < in_input::VIN_VOLTAGE_110_THRESHOLD)
1202 {
1203 inputVoltage = in_input::VIN_VOLTAGE_110;
1204 }
1205 else
1206 {
1207 inputVoltage = in_input::VIN_VOLTAGE_220;
1208 }
1209 }
1210 catch (const std::exception& e)
1211 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001212 lg2::error("{SHORT_NAME} READ_VIN read error: {ERROR}",
1213 "SHORT_NAME", shortName, "ERROR", e);
Adriana Kobylak4175ffb2021-08-02 14:51:05 +00001214 }
1215 }
1216}
1217
Matt Spinler0975eaf2022-02-14 15:38:30 -06001218void PowerSupply::checkAvailability()
1219{
1220 bool origAvailability = available;
George Liu9464c422023-02-27 14:30:27 +08001221 bool faulted = isPowerOn() && (hasPSKillFault() || hasIoutOCFault());
1222 available = present && !hasInputFault() && !hasVINUVFault() && !faulted;
Matt Spinler0975eaf2022-02-14 15:38:30 -06001223
1224 if (origAvailability != available)
1225 {
1226 auto invpath = inventoryPath.substr(strlen(INVENTORY_OBJ_PATH));
1227 phosphor::power::psu::setAvailable(bus, invpath, available);
Matt Spinlerca1e9ea2022-02-18 14:03:08 -06001228
1229 // Check if the health rollup needs to change based on the
1230 // new availability value.
1231 phosphor::power::psu::handleChassisHealthRollup(bus, inventoryPath,
1232 !available);
Matt Spinler0975eaf2022-02-14 15:38:30 -06001233 }
1234}
1235
Matt Spinlera068f422023-03-10 13:06:49 -06001236void PowerSupply::setInputVoltageRating()
1237{
1238 if (!present)
1239 {
Matt Spinler1aaf9f82023-03-22 09:52:22 -05001240 if (inputVoltageRatingIface)
1241 {
1242 inputVoltageRatingIface->value(0);
1243 inputVoltageRatingIface.reset();
1244 }
Matt Spinlera068f422023-03-10 13:06:49 -06001245 return;
1246 }
1247
1248 double inputVoltageValue{};
1249 int inputVoltageRating{};
1250 getInputVoltage(inputVoltageValue, inputVoltageRating);
1251
1252 if (!inputVoltageRatingIface)
1253 {
Shawn McCarney768d2262024-07-09 15:02:59 -05001254 auto path = std::format(
Matt Spinlera068f422023-03-10 13:06:49 -06001255 "/xyz/openbmc_project/sensors/voltage/ps{}_input_voltage_rating",
1256 shortName.back());
1257
1258 inputVoltageRatingIface = std::make_unique<SensorObject>(
1259 bus, path.c_str(), SensorObject::action::defer_emit);
1260
1261 // Leave other properties at their defaults
1262 inputVoltageRatingIface->unit(SensorInterface::Unit::Volts, true);
1263 inputVoltageRatingIface->value(static_cast<double>(inputVoltageRating),
1264 true);
1265
1266 inputVoltageRatingIface->emit_object_added();
1267 }
1268 else
1269 {
1270 inputVoltageRatingIface->value(static_cast<double>(inputVoltageRating));
1271 }
1272}
1273
faisaladed7a02023-05-10 14:59:01 -05001274void PowerSupply::getPsuVpdFromDbus(const std::string& keyword,
1275 std::string& vpdStr)
1276{
1277 try
1278 {
1279 std::vector<uint8_t> value;
1280 vpdStr.clear();
1281 util::getProperty(VINI_IFACE, keyword, inventoryPath,
1282 INVENTORY_MGR_IFACE, bus, value);
1283 for (char c : value)
1284 {
1285 vpdStr += c;
1286 }
1287 }
1288 catch (const sdbusplus::exception_t& e)
1289 {
Anwaar Hadib64228d2025-05-30 23:55:26 +00001290 lg2::error("Failed getProperty error: {ERROR}", "ERROR", e);
faisaladed7a02023-05-10 14:59:01 -05001291 }
1292}
Matt Spinler592bd272023-08-30 11:00:01 -05001293
1294double PowerSupply::linearToInteger(uint16_t data)
1295{
1296 // The exponent is the first 5 bits, followed by 11 bits of mantissa.
1297 int8_t exponent = (data & 0xF800) >> 11;
1298 int16_t mantissa = (data & 0x07FF);
1299
1300 // If exponent's MSB on, then it's negative.
1301 // Convert from two's complement.
1302 if (exponent & 0x10)
1303 {
1304 exponent = (~exponent) & 0x1F;
1305 exponent = (exponent + 1) * -1;
1306 }
1307
1308 // If mantissa's MSB on, then it's negative.
1309 // Convert from two's complement.
1310 if (mantissa & 0x400)
1311 {
1312 mantissa = (~mantissa) & 0x07FF;
1313 mantissa = (mantissa + 1) * -1;
1314 }
1315
1316 auto value = static_cast<double>(mantissa) * pow(2, exponent);
1317 return value;
1318}
1319
1320std::vector<AssociationTuple> PowerSupply::getSensorAssociations()
1321{
1322 std::vector<AssociationTuple> associations;
1323
1324 associations.emplace_back("inventory", "sensors", inventoryPath);
1325
1326 auto chassis = getChassis(bus, inventoryPath);
1327 associations.emplace_back("chassis", "all_sensors", std::move(chassis));
1328
1329 return associations;
1330}
1331
Brandon Wyman3f1242f2020-01-28 13:11:25 -06001332} // namespace phosphor::power::psu